== Introduction == How to create a simple text-input using a dialog. == Special Concerns == Have in mind * I program python for about 2 days * I use wxWindow for bout 2 hours * I think the documentation in wxWindow to be terrible overcomplicated So, This is in no way easily reusable in a project, use just to understand the wxWindow's Dialogs usage. == Code Sample == {{{ #!python import wx class MyApp(wx.App): def OnInit(self): # Args below are: parent, question, dialog title, default answer dlg = wx.TextEntryDialog(None,'What is your favorite programming language?','Eh??', 'Python') # This function returns the button pressed to close the dialog ret = dlg.ShowModal() # Let's check if user clicked OK or pressed ENTER if ret == wx.ID_OK: print('You entered: %s\n' % dlg.GetValue()) else: print('You don\'t know') # The dialog is not in the screen anymore, but it's still in memory #for you to access it's values. remove it from there. dlg.Destroy() return True # Always use zero here. otherwise, you will have an error window that will last only nano seconds # on the screen. dumb. # (Only if the error is in the startup code before MainLoop is called. --RobinDunn) app = MyApp(redirect = 0) app.MainLoop() }}} == Simple "Select directory" dialog == {{{ #!python import wx class MyApp(wx.App): def OnInit(self): # Args below are: parent, question, dialog title, default answer dd = wx.DirDialog(None, "Select directory to open", "~/", 0, (10, 10), wx.Size(400, 300)) # This function returns the button pressed to close the dialog ret = dd.ShowModal() # Let's check if user clicked OK or pressed ENTER if ret == wx.ID_OK: print('You selected: %s\n' % dd.GetPath()) else: print('You clicked cancel') # The dialog is not in the screen anymore, but it's still in memory #for you to access it's values. remove it from there. dd.Destroy() return True # Always use zero here. otherwise, you will have an error window that will last only nano seconds # on the screen. dumb. # (Only if the error is in the startup code before MainLoop is called. --RobinDunn) app = MyApp(redirect = 0) app.MainLoop() }}} === Comments === Later, more examples with other kinds of Dialogs