这个 GUI 非常新,正在尝试构建 python-GUI。已经从 wx-form builder 设计了 GUI 结构并使用它。我刚刚创建了两个下拉菜单和两个按钮。当您选择两个下拉值并单击开始按钮时,
1) It should display what values are selected.
2) `Start` button should be freezed, till some activity completed.
3) `Start` button should be released when some activity is completed or when `Stop` button is clicked.
4) And also, Is it possible to select multiple values from drop-down ?
我不确定我尝试过的是否正确。Bur 将在下面发布代码,请指导我完成此操作。如果有任何好的文件,请帮助我。
测试.py
import wx
from wx import xrc
class MyApp(wx.App):
def OnInit(self):
self.res = xrc.XmlResource('test.xrc')
self.init_frame()
return True
def init_frame(self):
self.frame = self.res.LoadFrame(None, 'mainFrame')
#text = str(combobox1.currentText())
self.env = xrc.XRCCTRL(self.frame, 'list1')
self.service = xrc.XRCCTRL(self.frame, 'list2')
#self.panel = xrc.XRCCTRL(self.frame, 'panel')
#self.text1 = xrc.XRCCTRL(self.panel, 'text1')
#self.text2 = xrc.XRCCTRL(self.panel, 'text2')
self.frame.Bind(wx.EVT_BUTTON, self.OnSubmit, id=xrc.XRCID('Button1'))
self.frame.Show()
def OnSubmit(self,a):
wx.MessageBox('Your name is %s %s!' %
(self.env, self.service), 'Feedback')
#print self.env
#self.service = xrc.XRCCTRL(self.panel, 'serviceList')
#self.frame.Bind(wx.EVT_BUTTON, self.OnNewFrame, self.button)
self.frame.Show()
# self.collectLogButton.Bind( wx.EVT_BUTTON, self.solveFunc )
# self.stopButton.Bind( wx.EVT_BUTTON, self.clearFunc )
#def OnNewFrame(self, evt):
# self.frame2 = self.res.LoadFrame(None, 'nextFrame')
# self.frame2.Show()
if __name__ == '__main__':
app = MyApp(False)
app.MainLoop()
测试.xrc
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<resource xmlns="http://www.wxwindows.org/wxxrc" version="2.3.0.1">
<object class="wxFrame" name="mainFrame">
<style>wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL</style>
<size>500,300</size>
<title></title>
<centered>1</centered>
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<option>0</option>
<flag>wxEXPAND</flag>
<border>5</border>
<object class="wxBoxSizer">
<minsize>-1,80</minsize>
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<option>0</option>
<flag>wxEXPAND</flag>
<border>5</border>
<object class="wxBoxSizer">
<minsize>100,-1</minsize>
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<option>0</option>
<flag>wxALL</flag>
<border>5</border>
<object class="wxStaticBitmap" name="m_bitmap1">
<bitmap />
</object>
</object>
</object>
</object>
<object class="sizeritem">
<option>1</option>
<flag>wxEXPAND</flag>
<border>5</border>
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<option>0</option>
<flag>wxALL|wxALIGN_CENTER_HORIZONTAL</flag>
<border>5</border>
<object class="wxStaticText" name="titleText">
<font>
<size>30</size>
<family>default</family>
<style>normal</style>
<weight>normal</weight>
<underlined>0</underlined>
<face>Verdana Bold</face>
</font>
<label>TITLE</label>
<wrap>-1</wrap>
</object>
</object>
</object>
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxEXPAND</flag>
<border>5</border>
<object class="wxBoxSizer">
<minsize>100,-1</minsize>
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<option>1</option>
<flag>wxEXPAND</flag>
<border>5</border>
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<option>0</option>
<flag>wxALL</flag>
<border>5</border>
<object class="wxStaticBitmap" name="m_bitmap2">
<bitmap />
</object>
</object>
</object>
</object>
<object class="sizeritem">
<option>1</option>
<flag>wxEXPAND</flag>
<border>5</border>
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<option>0</option>
<flag>wxALL</flag>
<border>5</border>
<object class="wxStaticBitmap" name="m_bitmap3">
<bitmap />
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
<object class="sizeritem">
<option>1</option>
<flag>wxEXPAND</flag>
<border>5</border>
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<option>1</option>
<flag>wxALIGN_CENTER_HORIZONTAL</flag>
<border>5</border>
<object class="wxFlexGridSizer">
<rows>2</rows>
<cols>2</cols>
<vgap>0</vgap>
<hgap>0</hgap>
<growablecols></growablecols>
<growablerows></growablerows>
<object class="sizeritem">
<option>0</option>
<flag>wxALL</flag>
<border>5</border>
<object class="wxStaticText" name="envLabel">
<font>
<size>20</size>
<family>default</family>
<style>normal</style>
<weight>normal</weight>
<underlined>0</underlined>
<face>Calibri Bold</face>
</font>
<label>List1</label>
<wrap>-1</wrap>
</object>
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxALL</flag>
<border>5</border>
<object class="wxChoice" name="list1">
<selection>0</selection>
<content>
<item>val1</item>
<item>val2</item>
<item>val3</item>
</content>
</object>
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxALL</flag>
<border>5</border>
<object class="wxStaticText" name="serviceLabel">
<font>
<size>20</size>
<family>default</family>
<style>normal</style>
<weight>normal</weight>
<underlined>0</underlined>
<face>Calibri Bold</face>
</font>
<label>List2</label>
<wrap>-1</wrap>
</object>
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxALL</flag>
<border>5</border>
<object class="wxChoice" name="list2">
<selection>0</selection>
<content>
<item>val4</item>
<item>val5</item>
<item>val6</item>
</content>
</object>
</object>
</object>
</object>
<object class="sizeritem">
<option>1</option>
<flag>wxALIGN_CENTER_HORIZONTAL</flag>
<border>5</border>
<object class="wxBoxSizer">
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<option>0</option>
<flag>wxALL</flag>
<border>5</border>
<object class="wxButton" name="Button1">
<font>
<family>default</family>
<style>normal</style>
<weight>normal</weight>
<underlined>0</underlined>
<face>Cambria Bold</face>
</font>
<label>Start</label>
<default>0</default>
</object>
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxALL</flag>
<border>5</border>
<object class="wxButton" name="Button2">
<font>
<family>default</family>
<style>normal</style>
<weight>normal</weight>
<underlined>0</underlined>
<face>Calibri Bold</face>
</font>
<label>Stop</label>
<default>0</default>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</resource>