def Draw(self, evt): """When the page is drawn, it may need to update its fields if the selected database has changed.""" if not evt.GetDirection(): btn = self.parent.FindWindowById(wx.ID_FORWARD) if btn: btn.Enable() if len(self.Parent.CHOOSEDB.dblist.GetStringSelection()) == 0 and evt.Direction: evt.Veto() else: if self.sel != self.Parent.CHOOSEDB.dblist.GetStringSelection(): self.sel = self.Parent.CHOOSEDB.dblist.GetStringSelection() self.engine = Engine() for db in self.Parent.engine_list: if db.name == self.sel: self.engine = db self.fields.Clear(True) self.fields = wx.BoxSizer(wx.VERTICAL) if self.engine.instructions: self.fields.Add(StaticText( self, -1, '\n' + self.engine.instructions + '\n\n')) self.fieldset = dict() self.option = dict() saved_opts = get_saved_connection(self.engine.name) for opt in self.engine.required_opts: if opt[0] in saved_opts.keys(): default = saved_opts[opt[0]] else: default = opt[2] self.fieldset[opt[0]] = wx.BoxSizer(wx.HORIZONTAL) label = StaticText(self, -1, opt[0] + ": ", size=wx.Size(90, 35)) style = wx.TE_PASSWORD if opt[0] == "password" else 0 txt = TextCtrl(self, -1, str(default), size=wx.Size(200, -1), style=style) self.option[opt[0]] = txt self.fieldset[opt[0]].AddMany([label, self.option[opt[0]]]) if opt[0] == "file": file_opt = opt def open_file_dialog(evt): filter = "" if file_opt[3]: filter = file_opt[3] + "|" filter += "All files (*.*)|*.*" dialog = wx.FileDialog(None, style=wx.OPEN, wildcard=filter) if dialog.ShowModal() == wx.ID_OK: self.option[file_opt[0]].SetValue( dialog.GetPath()) self.browse = wx.Button(self, -1, "Choose...") self.fieldset[file_opt[0]].Add(self.browse) self.browse.Bind(wx.EVT_BUTTON, open_file_dialog) self.fieldset[opt[0]].Layout() self.fields.Add(self.fieldset[opt[0]]) self.sizer.Add(self.fields) self.sizer.Layout()
def __init__(self, lists): wx.App.__init__(self, redirect=False) mfs = wx.MemoryFSHandler() wx.FileSystem_AddHandler(mfs) mfs.AddFile("globe.png", icon.GetImage(), wx.BITMAP_TYPE_PNG) mfs.AddFile("cycle.png", cycle.GetImage(), wx.BITMAP_TYPE_PNG) mfs.AddFile("download.png", download.GetImage(), wx.BITMAP_TYPE_PNG) mfs.AddFile("downloaded.png", downloaded.GetImage(), wx.BITMAP_TYPE_PNG) mfs.AddFile("error.png", error.GetImage(), wx.BITMAP_TYPE_PNG) mfs.AddFile("warning.png", warning.GetImage(), wx.BITMAP_TYPE_PNG) mfs.AddFile("logo.png", logo.GetImage(), wx.BITMAP_TYPE_PNG) default_connection = get_default_connection() if default_connection: parameters = get_saved_connection(default_connection) parameters["engine"] = default_connection engine = choose_engine(parameters) else: wizard = ConnectWizard(lists, ENGINE_LIST) success = wizard.RunWizard(wizard.pages[0]) if not success: wizard.Destroy() return engine = wizard.CONNECTION.engine options = wizard.CONNECTION.option opts = dict() for key in options.keys(): opts[key] = options[key].GetValue() engine.opts = opts wizard.Destroy() try: engine.get_connection() except: pass self.frame = Frame( None, -1, "EcoData Retriever version %s" % VERSION, lists, engine) self.frame.Show()
def __init__(self, lists): wx.App.__init__(self, redirect=False) mfs = wx.MemoryFSHandler() wx.FileSystem_AddHandler(mfs) mfs.AddFile("globe.png", icon.GetImage(), wx.BITMAP_TYPE_PNG) mfs.AddFile("cycle.png", cycle.GetImage(), wx.BITMAP_TYPE_PNG) mfs.AddFile("download.png", download.GetImage(), wx.BITMAP_TYPE_PNG) mfs.AddFile("downloaded.png", downloaded.GetImage(), wx.BITMAP_TYPE_PNG) mfs.AddFile("error.png", error.GetImage(), wx.BITMAP_TYPE_PNG) mfs.AddFile("warning.png", warning.GetImage(), wx.BITMAP_TYPE_PNG) mfs.AddFile("logo.png", logo.GetImage(), wx.BITMAP_TYPE_PNG) default_connection = get_default_connection() if default_connection: parameters = get_saved_connection(default_connection) parameters["engine"] = default_connection engine = choose_engine(parameters) else: wizard = ConnectWizard(lists, ENGINE_LIST) success = wizard.RunWizard(wizard.pages[0]) if not success: wizard.Destroy() return engine = wizard.CONNECTION.engine options = wizard.CONNECTION.option opts = dict() for key in options.keys(): opts[key] = options[key].GetValue() engine.opts = opts wizard.Destroy() try: engine.get_connection() except: pass self.frame = Frame(None, -1, "EcoData Retriever version %s" % VERSION, lists, engine) self.frame.Show()