Patch #1540143 Add optional labelwidths to filebrowsebutton
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40680 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -42,7 +42,8 @@ class FileBrowseButton(wx.Panel):
|
|||||||
fileMask = "*.*",
|
fileMask = "*.*",
|
||||||
fileMode = wx.OPEN,
|
fileMode = wx.OPEN,
|
||||||
# callback for when value changes (optional)
|
# callback for when value changes (optional)
|
||||||
changeCallback= lambda x:x
|
changeCallback= lambda x:x,
|
||||||
|
labelWidth = 0
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
:param labelText: Text for label to left of text field
|
:param labelText: Text for label to left of text field
|
||||||
@@ -53,6 +54,7 @@ class FileBrowseButton(wx.Panel):
|
|||||||
:param fileMask: File mask (glob pattern, such as *.*) to use in file dialog
|
:param fileMask: File mask (glob pattern, such as *.*) to use in file dialog
|
||||||
:param fileMode: wx.OPEN or wx.SAVE, indicates type of file dialog to use
|
:param fileMode: wx.OPEN or wx.SAVE, indicates type of file dialog to use
|
||||||
:param changeCallback: Optional callback called for all changes in value of the control
|
:param changeCallback: Optional callback called for all changes in value of the control
|
||||||
|
:param labelWidth: Width of the label
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# store variables
|
# store variables
|
||||||
@@ -66,7 +68,7 @@ class FileBrowseButton(wx.Panel):
|
|||||||
self.fileMode = fileMode
|
self.fileMode = fileMode
|
||||||
self.changeCallback = changeCallback
|
self.changeCallback = changeCallback
|
||||||
self.callCallback = True
|
self.callCallback = True
|
||||||
|
self.labelWidth = labelWidth
|
||||||
|
|
||||||
# create the dialog
|
# create the dialog
|
||||||
self.createDialog(parent, id, pos, size, style )
|
self.createDialog(parent, id, pos, size, style )
|
||||||
@@ -117,6 +119,9 @@ class FileBrowseButton(wx.Panel):
|
|||||||
label = wx.StaticText(self, -1, self.labelText, style =wx.ALIGN_RIGHT )
|
label = wx.StaticText(self, -1, self.labelText, style =wx.ALIGN_RIGHT )
|
||||||
font = label.GetFont()
|
font = label.GetFont()
|
||||||
w, h, d, e = self.GetFullTextExtent(self.labelText, font)
|
w, h, d, e = self.GetFullTextExtent(self.labelText, font)
|
||||||
|
if self.labelWidth > 0:
|
||||||
|
label.SetSize((self.labelWidth+5, h))
|
||||||
|
else:
|
||||||
label.SetSize((w+5, h))
|
label.SetSize((w+5, h))
|
||||||
return label
|
return label
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user