Alex Couper <amcouper <at> gmail.com> writes:
I've managed to get wx.Button to have multi-line labels under linux and XP
simply by using \n in the label parameter:"self.button1 = wx.Button(parent=self,
id=wx.ID_ANY, label='Two\nLines', size=
wx.Size(104, 80))"Under XP, the above code produces a button with multilined
and centered text. Under linux, the text is not centered, and must be done
'manually' by prepending spaces to the appropriate line.
Alex Couper
I've found a way to center the text on a button on Linux. Below is the code.
Can someone tell me if this works on Windows?
ยทยทยท
#####################################################
#!/usr/bin/env python
import wx
class MYGUI(wx.App):
def OnInit(self):
self.frame = Frame(None, title = "My GUI")
self.frame.CenterOnScreen()
self.frame.Show()
self.SetTopWindow(self.frame)
return True
class Frame(wx.Frame):
def __init__(self, *args, **kwargs):
wx.Frame.__init__(self, *args, **kwargs)
panel = wx.Panel(self, -1)
buttonLabel = "Two\n".center(5) + "Lines".center(5)
button = wx.Button(parent = panel, id = wx.ID_ANY, label = buttonLabel,
size = (104, 80))
if __name__ == "__main__":
app = MYGUI()
app.MainLoop()