的东西在这里就是我打开一推出首选项窗口为GooeyPi:我PyInstaller GUI前端。这可以很容易地适应有一个密码对话框或框架。我分成两个功能:检查用户是否有设置偏好,并打开偏好窗口。这允许他们稍后改变偏好。我使用ShowModal来防止用户在设置之前使用该应用程序。
class GooeyPi(wx.Frame):
def __init__(self, *args, **kwargs):
super(GooeyPi, self).__init__(*args, **kwargs)
self.InitUI()
self.SetSize((460,350))
self.SetTitle('GooeyPi - PyInstaller GUI')
self.Show()
self.CheckFirstRun() # Checks for first run here.
.....
def CheckFirstRun(self):
config = controller.getConfig()
if config['pyidir'] == '':
...
self.OnPreferences(None)
....
def OnPreferences(self, e):
prefdlg = pref.Preferences(None, title='Edit Preferneces')
prefdlg.ShowModal()
prefdlg.Destroy()
和pref.Preferences是definied在一个单独的模块:
class Preferences(wx.Dialog):
def __init__(self, *args, **kw):
super(Preferences, self).__init__(*args, **kw)
self.InitUI()
self.SetSize((380,290))
self.SetTitle("Preferences")
def InitUI(self):
you_get_the_idea...