Attachment 'mybox.py'
Download 1 import wx
2 from wx.lib import stattext as WX
3 # http://trac.wxwidgets.org/ticket/9859
4
5 class mybox(wx.Panel):
6
7 def __init__(self, parent, id=wx.ID_ANY, label=wx.EmptyString, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.TAB_TRAVERSAL|wx.NO_BORDER, name=''):
8 wx.Panel.__init__(self, parent, id, pos=pos, size=size, style=style, name=name)
9
10 y = self.GetBackgroundColour()
11 z = self.GetBackgroundColour()
12 r,g,b,a = y.Get(True)
13 xr = r ^ 255
14 xg = g ^ 255
15 xb = b ^ 255
16 y.Set(xr, xg, xb, a)
17 self.SetBackgroundColour(y)
18 self.vbox = wx.BoxSizer(wx.VERTICAL)
19
20 self.inside = wx.Panel(self, -1)
21 self.txt = label
22 self.label = WX.GenStaticText(self,wx.ID_ANY, label)
23 self.label.SetForegroundColour(z)
24 self.label.SetBackgroundColour(y)
25 self.vbox.Add(self.label,0,wx.EXPAND | wx.Bottom, 2)
26 junk, self.px = self.label.GetSize()
27 self.vbox.Add(self.inside, 1, wx.EXPAND | wx.BOTTOM | wx.LEFT | wx.RIGHT, self.px)
28 self.SetSizer(self.vbox)
29 self.SetAutoLayout(True)
30
31
32 def GetInside(self):
33 return self.inside
34
35
36 class MyForm(wx.Frame):
37
38 def __init__(self, inpanel=False):
39 wx.Frame.__init__(self, None, wx.ID_ANY, "StaticBox replacement Demo")
40 if inpanel:
41 panel = wx.Panel(self, wx.ID_ANY)
42 abox = mybox(panel, -1, "mybox")
43 else:
44 abox = mybox(self, -1, "mybox")
45 box = abox.GetInside()
46 boxsizer = wx.BoxSizer(wx.VERTICAL)
47 box.SetSizer(boxsizer)
48 box.SetAutoLayout(True)
49
50 txt = wx.StaticText(box, wx.ID_ANY, "Show the tooltip")
51 tt=wx.ToolTip("ToolTip")
52 txt.SetToolTip(tt)
53 boxsizer.Add(txt ,1, wx.EXPAND)
54
55
56 sizer = wx.FlexGridSizer(cols=1)
57 sizer.Add(abox, 1, wx.EXPAND | wx.ALL)
58 if inpanel:
59 panel.SetSizer(sizer)
60 panel.SetAutoLayout(True)
61
62 # Run the program
63 if __name__ == "__main__":
64 app = wx.PySimpleApp()
65 frame = MyForm(True).Show()
66 app.MainLoop()
67
68 app2 = wx.PySimpleApp()
69 frame = MyForm(False).Show()
70 app2.MainLoop()
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.