列表選擇框:wxSingleChoiceDialog
阿新 • • 發佈:2018-06-10
ren TE select nbsp 字符串 .text __name__ 綁定 對話框
wxSingleChoiceDialog(wxWindow* parent, const wxString& message, const wxString& caption, int n, const wxString* choices, void** clientData = NULL, long style = wxCHOICEDLG_STYLE, const wxPoint& pos = wxDefaultPosition)
支持的方法如下:
- wxSingleChoiceDialog::GetSelection 返回選項的index
- wxSingleChoiceDialog::GetSelectionClientData 返回與選項綁定的clientdata內容
- wxSingleChoiceDialog::GetStringSelection 返回選擇的字符串內容
- wxSingleChoiceDialog::SetSelection 設置選項
- wxSingleChoiceDialog::ShowModal
#!/usr/bin/env python # -*- coding: utf-8 -*- ‘‘‘ Function:常用對話框實例 Input:NONE Output: NONE author: socrates blog:http://www.cnblogs.com/dyx1024/ date:2012-07-07 ‘‘‘ import wx class MyFrame(wx.Frame): def __init__(self, parent, id): wx.Frame.__init__(self, parent, id, u‘測試面板Panel‘, size = (600, 300)) #創建面板 panel = wx.Panel(self) #在Panel上添加Button button = wx.Button(panel, label = u‘關閉‘, pos = (150, 60), size = (100, 60)) #綁定單擊事件 self.Bind(wx.EVT_BUTTON, self.OnCloseMe, button) # #消息對話框 # def OnCloseMe(self, event): # dlg = wx.MessageDialog(None, u"消息對話框測試", u"標題信息", wx.YES_NO | wx.ICON_QUESTION) # if dlg.ShowModal() == wx.ID_YES: # self.Close(True) # dlg.Destroy() # # #文本輸入對話框 # def OnCloseMe(self, event): # dlg = wx.TextEntryDialog(None, u"請在下面文本框中輸入內容:", u"文本輸入框標題", u"默認內容") # if dlg.ShowModal() == wx.ID_OK: # message = dlg.GetValue() #獲取文本框中輸入的值 # dlg_tip = wx.MessageDialog(None, message, u"標題信息", wx.OK | wx.ICON_INFORMATION) # if dlg_tip.ShowModal() == wx.ID_OK: # self.Close(True) # dlg_tip.Destroy() # dlg.Destroy() #列表選擇對話框 def OnCloseMe(self, event): dlg = wx.SingleChoiceDialog(None, u"請選擇你喜歡的水果:", u"列表選擇框標題", [u"蘋果", u"西瓜", u"草莓"]) if dlg.ShowModal() == wx.ID_OK: message = dlg.GetStringSelection() #獲取選擇的內容 dlg_tip = wx.MessageDialog(None, message, u"標題信息", wx.OK | wx.ICON_INFORMATION) if dlg_tip.ShowModal() == wx.ID_OK: self.Close(True) dlg_tip.Destroy() dlg.Destroy() if __name__ == ‘__main__‘: app = wx.PySimpleApp() frame = MyFrame(parent = None, id = -1) frame.Show() app.MainLoop()
列表選擇框:wxSingleChoiceDialog