If I change the font used by a button, its initial label appears in the
specified font.
If I change the button's label, its font then switches to some default font.
This happens both on HP-UX/Gtk & Linux/Gtk, but not on MS Windows.
Below is a simple example that demonstrates the problem. Clicking on the
checkbox, changes the button's label. On *nix/Gtk, the font also changes.
As I workaround, I can add the following statements to OnCheckbox():
self.button_1.SetFont(wx.NullFont)
self.button_1.SetFont(wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0,
""))
and the problem goes away (I have to set the NullFont first or it ignores
the real font change).
Is this a known bug and will it be fixed?
I'm Using wxPython-2.5.2.8
regards,
Richard Townsend
···
----------------------------------------------------------------------------
-
import wx
class MyFrame(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: MyFrame.__init__
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.checkbox_1 = wx.CheckBox(self, -1, "Hide")
self.button_1 = wx.Button(self, -1, "Show")
self.__set_properties()
self.__do_layout()
# end wxGlade
self.Bind(wx.EVT_CHECKBOX, self.OnCheckbox, self.checkbox_1)
def __set_properties(self):
# begin wxGlade: MyFrame.__set_properties
self.SetTitle("frame_1")
self.button_1.SetFont(wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.NORMAL,
0, ""))
# end wxGlade
def __do_layout(self):
# begin wxGlade: MyFrame.__do_layout
sizer_1 = wx.BoxSizer(wx.VERTICAL)
sizer_1.Add(self.checkbox_1, 0, wx.FIXED_MINSIZE, 0)
sizer_1.Add(self.button_1, 0, wx.TOP|wx.BOTTOM|wx.FIXED_MINSIZE, 8)
self.SetAutoLayout(True)
self.SetSizer(sizer_1)
sizer_1.Fit(self)
sizer_1.SetSizeHints(self)
self.Layout()
# end wxGlade
def OnCheckbox(self, event):
if event.GetInt():
label = "Hide"
else:
label = "Show"
self.button_1.SetLabel(label)
# end of class MyFrame
class MyApp(wx.App):
def OnInit(self):
wx.InitAllImageHandlers()
frame_1 = MyFrame(None, -1, "")
self.SetTopWindow(frame_1)
frame_1.Show()
return 1
# end of class MyApp
if __name__ == "__main__":
app = MyApp(0)
app.MainLoop()