Home > other >  Use the wxpython layout problems
Use the wxpython layout problems

Time:10-12

When using wxpython write GUI development, want to achieve a simple clock in page, use Choice controls, after using BoxSizer, without all display relevant code is as follows:

The import wx
The class Clock_In (wx. Frame) :
Def __init__ (self, parent, title) :
Super (Clock_In, self) __init__ (the parent, the title=title, size=(450300),
Style=wx. MINIMIZE | wx. SYSTEM_MENU | wx. CLOSE_BOX | wx. The CAPTION)

The self. The InitUI ()
Self Center ()
List1=[" very poor ", "poor", "general", "good", "very good"]


Def InitUI (self) :
The panel=wx. A panel (self)
List1=[' poor ', 'poor', 'usually', 'good', 'good']
Self. SetBackgroundColour (" white ")
Box=wx. BoxSizer (wx. VERTICAL)

# condition
Box1=wx. BoxSizer (wx. HORIZONTAL)
STR=wx. StaticText (panel, label=u "health", size=(50100))
Box1. Add (STR, border=10)
The self. The listbox1=wx. Choice (panel, size=(150100), the choices=list1)
Self. Bind (wx. EVT_CHOICE, self onPlay (), the self. The listbox1)
Box1. Add (self. Listbox1, flag=wx. EXPAND, border=15)

# mood condition
Box2=wx. BoxSizer (wx. HORIZONTAL)
Str2=wx. StaticText (panel, label=u "mood status", size=(50100))
Box2. Add (str2, border=10)
Self. Listbox2=wx. Choice (panel, size=(150100), the choices=list1)
Self. Bind (wx. EVT_CHOICE, self onPlay (), the self. The listbox1)

Box2. Add (self. Listbox2, flag=wx. EXPAND, border=15)

Box. The Add (Box1)
Box. The Add (Box2)

The self. The SetSizer (Box)

Def onPlay (self) :
Pass

Def the main () :

=wx app. The app ()
The ex=Clock_In (None, title=u 'clock page)
Ex. The Show ()
App. MainLoop ()

If __name__=="__main__ ':
The main ()

After running the code page is shown below:




For a great god
  • Related