def DoTimeit(parent): import util from askpypathdlg import AskPythonPathDlg pypathdlg = AskPythonPathDlg(parent, \ wx.ID_ANY, \ 'Timeit wizard (step 1: setup python path)', \ cfg = util.GenCfgPath('option', 'timeitpath.cfg')) retcode = pypathdlg.ShowModal() if retcode != wx.ID_OK: return pypath = pypathdlg.GetPath() pypathdlg.Destroy() _ShowTimeitDlg(parent, pypath)
border = 5, \ flag = wx.LEFT | wx.ALIGN_CENTRE_VERTICAL) vbox.Add(hbox, \ border = 5, \ flag = wx.ALIGN_RIGHT) def GetPath(self): return self.path.GetValue() def OnPath(self, evt): dlg = wx.FileDialog(self, \ message = "Choose python directory:", defaultDir=os.getcwd(), wildcard="python executable file (*)|*|" \ "All files (*.*)|*.*", style=wx.OPEN | wx.CHANGE_DIR) if dlg.ShowModal() == wx.ID_OK: self.path.SetValue(dlg.GetPath()) def OnOK(self, evt): self.pathoption.SetPath(self.path.GetValue()) evt.Skip() if __name__ == "__main__": import util app = wx.PySimpleApp() print AskPythonPathDlg(None, cfg=util.GenCfgPath('option', 'timeit.cfg')).ShowModal() # app.MainLoop()
flag = wx.LEFT | wx.ALIGN_CENTRE_VERTICAL) vbox.Add(hbox, \ border = 5, \ flag = wx.ALIGN_RIGHT) def GetPath(self): return self.path.GetValue() def OnPath(self, evt): dlg = wx.FileDialog(self, \ message = "Choose python directory:", defaultDir=os.getcwd(), wildcard="python executable file (*)|*|" \ "All files (*.*)|*.*", style=wx.OPEN | wx.CHANGE_DIR) if dlg.ShowModal() == wx.ID_OK: self.path.SetValue(dlg.GetPath()) def OnOK(self, evt): self.pathoption.SetPath(self.path.GetValue()) evt.Skip() if __name__ == "__main__": import util app = wx.PySimpleApp() print( AskPythonPathDlg(None, cfg=util.GenCfgPath('option', 'timeit.cfg')).ShowModal()) # app.MainLoop()
class UIConfig(Singleton): import util cfg = util.GenCfgPath('option', 'ui.cfg') # print cfg # cfg = 'option/ui.cfg' def __init__(self): self.__init() self.modified = False def __init(self): self.file = self.opencfg(UIConfig.cfg) self.cfg = Parser() self.cfg.readfp(self.file) self.file.close() def __setdefault(self): f = open(self.fn, 'w') f.write(default_file) f.close() def opencfg(self, fn): self.fn = fn try: return open(fn, 'r') except IOError: self.__setdefault() return open(fn, 'r') def release(self): if self.modified: f = open(self.fn, 'w') self.cfg.write(f) f.close() def setDefault(self): self.__setdefault() self.__init() def getMaximized(self): return self.cfg.get(WINDOW, MAXIMIZE).lower() == 'true' @modified_decorator def setMaximized(self, value): self.cfg.set(WINDOW, MAXIMIZE, str(bool(value))) def getWindowSize(self): return list(map(int, str2list(self.cfg.get(WINDOW, SIZE)))) @modified_decorator def setWindowSize(self, value): self.cfg.set(WINDOW, SIZE, \ sep.join(map(str, value))) def getWindowPos(self): return list(map(int, str2list(self.cfg.get(WINDOW, POS)))) @modified_decorator def setWindowPos(self, value): self.cfg.set(WINDOW, POS, \ sep.join(map(str, value))) def getLeftSplitProp(self): return self.cfg.getfloat(SPLIT, LEFT_SPLIT) @modified_decorator def setLeftSplitProp(self, prop): self.cfg.set(SPLIT, LEFT_SPLIT, '%.2f' % prop) def getUpSplitProp(self): return self.cfg.getfloat(SPLIT, UP_SPLIT) @modified_decorator def setUpSplitProp(self, prop): self.cfg.set(SPLIT, UP_SPLIT, '%.2f' % prop) def getRightSplitProp(self): return self.cfg.getfloat(SPLIT, RIGHT_SPLIT) @modified_decorator def setRightSplitProp(self, prop): self.cfg.set(SPLIT, RIGHT_SPLIT, '%.2f' % prop) def getLastDir(self): return self.cfg.get(DIRCTRL, DIR) @modified_decorator def setLastDir(self, value): import sys self.cfg.set(DIRCTRL, DIR, value.encode(sys.getfilesystemencoding()))