Probably something very obvious, but I can't see how to do it.
Is there a way to keep the line feed formatting of text on buttons? They
seem to lose it when the colour is changed. (Python 2.2, wxP 2.4.1, win ME).
Ta,
Chris.
example:
from wxPython.wx import *
class ButtonApp(wxApp):
def OnInit(self):
frame = wxFrame(None, -1, "Button Test", size = (200, 100))
panel = wxPanel(frame, -1)
self.panel = panel
ID1 = wxNewId()
ID2 = wxNewId()
self.button1 = wxButton(panel, ID1, "View\nLabel\nChanges")
self.button2 = wxButton(panel, ID2, "This \nDoesn't \nWork")
EVT_BUTTON(self, ID1, self.ChangeBColour)
EVT_BUTTON(self, ID2, self.ChangeFColour)
self.button1.SetSize((70, 70))
self.button2.SetSize((70, 70))
sizer_1 = wxBoxSizer(wxHORIZONTAL)
sizer_1.Add(self.button1, 0,
wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0)
sizer_1.Add(self.button2, 0,
wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0)
panel.SetAutoLayout(1)
panel.SetSizer(sizer_1)
panel.Layout()
frame.Show(true)
self.SetTopWindow(frame)
return true
def ChangeBColour(self, event):
buttonID = event.GetId()
button = self.panel.FindWindowById(buttonID)
button.SetBackgroundColour(wxNamedColour('Red'))
def ChangeFColour(self, event):
buttonID = event.GetId()
button = self.panel.FindWindowById(buttonID)
button.SetForegroundColour(wxNamedColour('Blue'))
if __name__ == '__main__':
app = ButtonApp(0)
app.MainLoop()