How to create a static line (Phoenix)
Keywords : Static line.
Introduction :
This widget displays a simple line on the window.
It can be horizontal or vertical.
wx.StaticLine styles :
- wx.LI_HORIZONTAL
- wx.LI_VERTICAL
wx.StaticLine methods |
|
bool IsVertical() |
check if the line is vertical |
integer GetDefaultSize() |
return the size of the line |
(info by ZetCode / Jan Bodnar).
Demonstrating :
Tested py3.x, wx4.x and Win10.
Are you ready to use some samples ?
Test, modify, correct, complete, improve and share your discoveries !
Sample one
sample_one.py script displays central european countries and their population.
The wx.StatLine makes it look more visually attractive.
1 # sample_one.py
2
3 """
4
5 Author : Jan Bodnar
6 Website : zetcode.com
7
8 """
9
10 import wx
11
12 # class MyDialog
13 # class MyApp
14
15 #---------------------------------------------------------------------------
16
17 class MyDialog(wx.Dialog):
18 def __init__ (self, parent, id, title):
19 wx.Dialog.__init__(self, parent, -1, title, size=(360, 390))
20
21 self.SetIcon(wx.Icon('./icons/icon_wxWidgets.ico', wx.BITMAP_TYPE_ICO))
22
23 #------------
24
25 font = wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD)
26 heading = wx.StaticText(self, -1, 'The Central Europe', (130, 15))
27 heading.SetFont(font)
28
29 wx.StaticLine(self, -1, (25, 50), (300,1))
30
31 wx.StaticText(self, -1, 'Slovakia', (25, 80), style=wx.ALIGN_RIGHT)
32 wx.StaticText(self, -1, 'Hungary', (25, 100), style=wx.ALIGN_RIGHT)
33 wx.StaticText(self, -1, 'Poland', (25, 120), style=wx.ALIGN_RIGHT)
34 wx.StaticText(self, -1, 'Czech Republic', (25, 140))
35 wx.StaticText(self, -1, 'Germany', (25, 160))
36 wx.StaticText(self, -1, 'Slovenia', (25, 180))
37 wx.StaticText(self, -1, 'Austria', (25, 200))
38 wx.StaticText(self, -1, 'Switzerland', (25, 220))
39
40 wx.StaticText(self, -1, '5 379 000', (250, 80))
41 wx.StaticText(self, -1, '10 084 000', (250, 100))
42 wx.StaticText(self, -1, '38 635 000', (250, 120))
43 wx.StaticText(self, -1, '10 240 000', (250, 140))
44 wx.StaticText(self, -1, '82 443 000', (250, 160))
45 wx.StaticText(self, -1, '2 001 000', (250, 180))
46 wx.StaticText(self, -1, '8 032 000', (250, 200))
47 wx.StaticText(self, -1, '7 288 000', (250, 220))
48
49 wx.StaticLine(self, -1, (25, 260), (300,1))
50
51 sum = wx.StaticText(self, -1, '164 102 000', (240, 280))
52 sum_font = sum.GetFont()
53 sum_font.SetWeight(wx.BOLD)
54 sum.SetFont(sum_font)
55
56 wx.Button(self, 1, '&Ok', (140, 310), (60, 30))
57
58 #------------
59
60 self.Bind(wx.EVT_BUTTON, self.OnOk, id=1)
61
62 #------------
63
64 self.Centre()
65
66 #-----------------------------------------------------------------------
67
68 def OnOk(self, event):
69 self.Close()
70
71 #---------------------------------------------------------------------------
72
73 class MyApp(wx.App):
74 def OnInit(self):
75 dia = MyDialog(None, -1, 'wx.StaticLine')
76 dia.ShowModal()
77 dia.Destroy()
78
79 return True
80
81 #---------------------------------------------------------------------------
82
83 app = MyApp()
84 app.MainLoop()
Download source
Additional Information
Link :
- - - - -
https://wiki.wxpython.org/TitleIndex
Thanks to
Jan Bodnar (sample_one.py coding), the wxPython community...
About this page
Date(d/m/y) Person (bot) Comments :
28/12/20 - Ecco (Created page for wxPython Phoenix).
Comments
- blah, blah, blah....