python - wxpython , passing boolean flag for background checking -
how can value button click frame?
btnyes = wx.button(panel, -1, "ok") self.bind(wx.evt_button, self.clickyes, btnyes) def clickyes(self, evt): print "clicked yes" self.close()
whenever user click yes , want value check in other module. confirmation flag. when user confirmed 1 item carrying on doing other items. confirmation flag using here below :
def my_methodabc(): matchlist = [] x, y in product(d1rows, d2rows): if userconfirmedfromwxpythonclickyesbutton(): matchlist.append(abc) return matchlist
use messagedialog. there lots of examples on web. here couple:
- http://wiki.wxpython.org/messageboxes
- http://www.blog.pythonlibrary.org/2010/06/26/the-dialogs-of-wxpython-part-1-of-2/
and here's simple example:
import wx ######################################################################## class mainframe(wx.frame): """""" #---------------------------------------------------------------------- def __init__(self): """constructor""" wx.frame.__init__(self, none, title="test") panel = wx.panel(self) btn = wx.button(panel, label="ask question") btn.bind(wx.evt_button, self.showmessagedlg) #---------------------------------------------------------------------- def showmessagedlg(self, event): """ show message """ msg = "do want continue?" title = "question!" style = wx.yes_no|wx.yes_default|wx.icon_question dlg = wx.messagedialog(parent=none, message=msg, caption=title, style=style) result = dlg.showmodal() if result == wx.id_yes: print "user pressed yes!" else: print "user pressed no!" dlg.destroy() if __name__ == "__main__": app = wx.app(false) frame = mainframe() frame.show() app.mainloop()
you want call match list method if user pressed yes button rather printing message stdout though.
Comments
Post a Comment