How to create a static box (Phoenix)

Keywords : Static box.


Introduction :

This is a kind of a decorator widget.

It is used to logically group various widgets.

Note that this widget must be created before the widgets that it contains, and that those widgets should be siblings, not children, of the static box.

(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

img_sample_one.png

   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, id, title, size=(270, 260))
  20 
  21         self.SetIcon(wx.Icon('./icons/icon_wxWidgets.ico', wx.BITMAP_TYPE_ICO))
  22 
  23         #------------
  24 
  25         wx.StaticBox(self, -1, 'Personal info :', (5, 5), size=(240, 170))
  26         wx.CheckBox(self, -1 ,'Male', (15, 30))
  27         wx.CheckBox(self, -1 ,'Married', (15, 55))
  28         wx.StaticText(self, -1, 'Age', (15, 95))
  29         wx.SpinCtrl(self, -1, '1', (50, 90), (60, -1), min=1, max=120)
  30         wx.Button(self, 1, '&Ok', (90, 185), (60, -1))
  31 
  32         #------------
  33 
  34         self.Bind(wx.EVT_BUTTON, self.OnClose, id=1)
  35 
  36         #------------
  37 
  38         self.Centre()
  39 
  40         #------------
  41 
  42         self.ShowModal()
  43         self.Destroy()
  44 
  45     #-----------------------------------------------------------------------
  46 
  47     def OnClose(self, event):
  48         self.Close()
  49 
  50 #---------------------------------------------------------------------------
  51 
  52 class MyApp(wx.App):
  53      def OnInit(self):
  54          frame = MyDialog(None, -1, 'wx.StaticBox')
  55          frame.Show(True)
  56 
  57          return True
  58 
  59 #---------------------------------------------------------------------------
  60 
  61 app = MyApp(0)
  62 app.MainLoop()


Download source

source.zip


Additional Information

Link :

- - - - -

https://wiki.wxpython.org/TitleIndex

https://docs.wxpython.org/


Thanks to

Jan Bodnar (sample_one.py coding), the wxPython community...


About this page

Date(d/m/y) Person (bot) Comments :

30/12/20 - Ecco (Created page for wxPython Phoenix).


Comments

- blah, blah, blah....

How to create a static box (Phoenix) (last edited 2020-12-31 15:53:41 by Ecco)

NOTE: To edit pages in this wiki you must be a member of the TrustedEditorsGroup.