[wxpython-users] Re-sizing wx.StaticText in a wx.Dialog
Frank Aune
Frank.Aune at broadpark.no
Wed Apr 30 16:21:06 PDT 2008
Example code:
---
class PluginDialog(wx.Dialog):
DESC = 'Foobar'*30
def __init__(self, parent, foo):
self.parent = parent
# Pre-create dialog and create object into real wrapper of the dialog
pre = wx.PreDialog()
pre.Create(self.parent, -1, title='Test', pos=wx.DefaultPosition,
style=wx.DEFAULT_DIALOG_STYLE)
self.PostCreate(pre)
# Now continue with the normal construction of the dialog
sizer = wx.BoxSizer(wx.VERTICAL)
# Top Spacer
sizer.AddSpacer((0,20))
# Title
label = wx.StaticText(self, -1, 'Test')
label.SetFont(wx.Font(24, wx.SWISS, wx.NORMAL, wx.BOLD))
sizer.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 10)
# Static line
line = wx.StaticLine(self, -1, style=wx.LI_HORIZONTAL)
sizer.Add(line, 0, wx.EXPAND|wx.ALL)
# Description
box = wx.BoxSizer(wx.HORIZONTAL)
description = wx.StaticText(self, -1, self.DESC, size=(1,-1))
description.SetFont(wx.Font(14, wx.SWISS, wx.NORMAL, wx.BOLD))
box.Add(description, 1, wx.ALIGN_CENTRE|wx.EXPAND)
sizer.Add(box, 0, wx.EXPAND|wx.ALL, 5)
# Button
box = wx.BoxSizer(wx.HORIZONTAL)
btn = wx.Button(self, wx.ID_OK, style=wx.ALIGN_RIGHT)
box.Add(btn, 0, wx.EXPAND|wx.ALL)
sizer.Add(box, 0, wx.EXPAND|wx.ALL, 5)
self.SetSizerAndFit(sizer)
---
If DESC can be of *any* length, how do I get the statictext to fit it on
screen without making the dialog grow horizontal (or bump the OK button
downwards outside the frame, which has happened occationally).
Thanks.
More information about the wxpython-users
mailing list