Opened 9 years ago

Closed 13 months ago

#10514 closed enhancement (outdated)

DirBrowseButton does not support passing labelWidth argument

Reported by: leovitch Owned by:
Priority: normal Milestone:
Component: wxPython Version:
Keywords: Cc:
Blocked By: Blocking:
Patch: no


DirBrowseButton in is a subclass of FileBrowseButton in the same file, but it doesn't support passing all of the superclass' keyword arguments in. Unfortunately, some of these arguments, such as labelWidth, take effect immediately, so there's no direct way to cope with this in client code. It looks like this is a result of the labelWidth parameter getting added to FileBrowseButton and not retrofitted to DirBrowseButton. There's no logical problem in using this with DirBrowseButton, but you are prevented from actually using it.

How to reproduce: try to create a DirBrowseButton and set the labelWidth parameter (the labelWidth parameter of FileBrowseButton allows every label in a column of these controls to be the same width). You will get a TypeError because of the mismatch.

How to fix: this particular parameter could simply be added to the code in DirBrowseButton.init, but for the future it would probably be better to make that method use *args and kwargs instead. Here is the code I'm currently using to patch around the problem; this could be directly incorporated to DirBrowseButton to fix the problem.

from wx.lib.filebrowsebutton import DirBrowseButton as DirBrowseButtonBase
from wx.lib.filebrowsebutton import FileBrowseButton

class DirBrowseButton(DirBrowseButtonBase):
    ownArgs = {
        'dialogClass': wx.DirDialog,
        'newDirectory': False,
    def __init__(self, *args, **kwargs):
        for (ownAttr,ownValue) in self.ownArgs.iteritems():
            if ownAttr in kwargs:
                ownValue = kwargs[ownAttr]
                del kwargs[ownAttr]
        FileBrowseButton.__init__(self, *args, **kwargs)

I guess strictly speaking this is an 'enhancement' although really it's just an incomplete implementation of labelWidth.

Change History (1)

comment:1 Changed 13 months ago by robind

  • Resolution set to outdated
  • Status changed from new to closed

Closing old Phoenix tickets...

If this is still an issue in wxPython 4.0.0a1 then please open a new issue (or PR) at the wxPython-Phoenix project page on Github:

Note: See TracTickets for help on using tickets.