Making your own dialog
Even though wxPython provides a large number of dialog options that can be used for most standard actions that any general application may need to perform, there will almost certainly come a time when you need to make your own custom dialog. There are many actions that can be better customized for a given application through their own dialogs. For example, wxPython provides PasswordEntryDialog
, but this dialog only has one field for a password; if your application requires a login dialog, this likely won't meet your needs. So, in this recipe, we will take a look at how to create custom dialogs by making a user login dialog.
How to do it…
For this recipe, perform the following steps:
First, let's begin by defining the dialog subclass and its major parts using the following code:
class LoginDialog(wx.Dialog): def __init__(self, parent, title="Login"): super(LoginDialog, self).__init__(parent, title=title) self._user = wx.TextCtrl(self) self._pass...