1 """GNUmed - Richard Terry style GUI elements
2
3 TODO:
4 - implement user defined rgb colours
5 - implement flashing text on the rest of the panel!
6 - add font size/style as option
7
8 copyright: author
9 dependencies: wxPython (>= version 2.3.1)
10 """
11
12
13 __version__ = "$Revision: 1.6 $"
14 __author__ = 'Dr. Richard Terry'
15 __license__ = 'GPL v2 or later (details at http://www.gnu.org)'
16
17 import wx
18
19
21 """Bottom left hand pane alert panel.
22
23 This panel consists constructs a simple heading to be used at the bottom
24 of the screen, in the form of capitalised word on user defined foreground
25 and background colours. The heading is left justified curently. The
26 default colours are black text on intermediate grey so as to not make it
27 too intrusive. The alert text will appear in flashing red text
28 """
29
30
32 wx.Panel.__init__(self, parent, id, wx.DefaultPosition, wx.DefaultSize, 0 )
33 self.SetBackgroundColour(wx.Colour(222,222,222))
34 sizer = wx.BoxSizer(wx.HORIZONTAL)
35
36
37
38
39
40
41 captionpanel = wx.Panel(self,-1,size = (400,10))
42 captionpanel.SetBackgroundColour(wx.Colour(197,194,197))
43 caption = wx.StaticText(captionpanel,-1, title,style = wx.ALIGN_CENTRE_VERTICAL)
44 caption.SetForegroundColour(wx.Colour(0,0,0))
45
46 caption.SetFont(wx.Font(10,wx.SWISS,wx.NORMAL, wx.BOLD,False,''))
47 sizer.Add(captionpanel,1,wx.EXPAND|wx.ALL,2)
48 sizer.Add(0,9,6)
49 self.SetSizer(sizer)
50 sizer.Fit(self)
51 self.SetAutoLayout(True)
52
53
58 self.caption.SetForegroundColour(wx.Colour(fg_red,fg_blue,fg_green))
59 return
60
61
63 """This panel consists of one or more headings on a horizontal panel and is
64
65 used to divide/head sections of the screenel There are user defined foreground
66 and background colours. The captions are centred in the available space. The
67 default colours are purple panel with white bold text
68 words (sounds yuk doesn't it - but I like it and it works well!!!!!
69 """
70
71
73 wx.Panel.__init__(self, parent, id, wx.DefaultPosition, wx.DefaultSize, 0)
74 sizer = wx.BoxSizer(wx.HORIZONTAL)
75 self.SetBackgroundColour(wx.Colour(197,194,255))
76
77 caption = wx.StaticText(self,-1, title,style = wx.ALIGN_CENTRE)
78 caption.SetForegroundColour(wx.WHITE)
79
80 caption.SetFont(wx.Font(13,wx.SWISS,wx.NORMAL, wx.BOLD,False,''))
81 sizer.Add(caption,1,wx.EXPAND)
82 self.SetSizer(sizer)
83 sizer.Fit(self)
84 self.SetAutoLayout(True)
85
86
89
91 self.caption.SetForegroundColour(wx.Colour(fg_red,fg_blue,fg_green))
92 return
93
94
96 """This panel consists constructs a simple heading to be used at the top
97
98 of a panel, in the form of capitalised word on user defined foreground
99 and background colours. The heading is left justified curently. The
100 default colours are purple panel, orange label with yellow capitalised
101 words (sounds yuk doesn't it - but I like it and it works well!!!!!
102 """
103 - def __init__ (self, parent, id, text, bgC = wx.Colour (197,194,255), hdrC = wx.Colour (255, 129, 131), txtC = wx.Colour (255, 255, 0)):
104 self.text = text
105 self.bgC = bgC
106 self.hdrC = hdrC
107 self.txtC = txtC
108 wx.Panel.__init__(self, parent, id)
109 wx.EVT_PAINT (self, self.OnPaint)
110 wx.EVT_SIZE (self, self.OnSize)
111 self.w = 0
112 self.h = 0
113
115 self.redraw (wxPaintDC (self))
116
119
121 dc.SetBrush (wx.Brush (self.bgC, wx.SOLID))
122 dc.SetPen (wx.TRANSPARENT_PEN)
123 dc.DrawRectangle (0, 0, self.w, self.h)
124 dc.SetTextBackground (self.hdrC)
125 dc.SetFont (wx.Font (12, wx.SWISS, wx.NORMAL, wx.BOLD))
126 dc.SetTextForeground (self.txtC)
127 txtw, txth = dc.GetTextExtent (self.text)
128 bufx = txtw / 10
129 if bufx + txtw > self.w:
130 bufx = 0
131 bufy = (self.h - txth)/2
132 if bufy < 0:
133 bufy = 0
134 dc.SetBrush (wx.Brush (self.hdrC, wx.SOLID))
135 dc.DrawRectangle (bufx, bufy, txtw, txth)
136 dc.DrawText (self.text, bufx, bufy)
137
139 self.bgC = bgC
140 self.redraw (wx.ClientDC (self))
141
143 self.hdrC = hdrC
144 self.redraw (wx.ClientDC (self))
145
146
147 if __name__ == "__main__":
148 app = wxPyWidgetTester(size = (50, 20))
149 app.SetWidget(cAlertCaption, -1," Alerts ")
150 app.MainLoop()
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179