def __init__(self,file_name,zip_file,app_name,licence_txt,readme_txt): Wizard.__init__(self, None, -1, 'Install app') self.Bind(wx.adv.EVT_WIZARD_PAGE_CHANGING, self.on_wiz_page_changing) self.zip_file = zip_file self.app_name = app_name page1 = TitledPage(self, 1, _('Program description')) self.page1 = page1 page2 = TitledPage(self, 2, _('License')) page3 = TitledPage(self, 3, _('Run')) r_txt = wx.TextCtrl(page1, -1, size=wx.Size(600, 300), style=wx.TE_MULTILINE | wx.TE_READONLY) r_txt.SetValue(readme_txt) page1.sizer.Add(r_txt) self.FitToPage(page1) l_txt = wx.TextCtrl(page2, -1, licence_txt, size=wx.Size(600, 300), style=wx.TE_MULTILINE | wx.TE_READONLY) page2.sizer.Add(l_txt) page2.sizer.AddSpacer(5) self.licence = wx.CheckBox(page2, -1, _('Accept')) page2.sizer.Add(self.licence) page3.sizer.Add(wx.StaticText(page3, -1, _('Run the installed program or cancel'))) WizardPageSimple.Chain(page1, page2) WizardPageSimple.Chain(page2, page3) self.GetPageAreaSizer().Add(page1)
def __init__(self, file_name): Wizard.__init__(self, None, -1, "Install app") self.Bind(wx.adv.EVT_WIZARD_PAGE_CHANGING, self.on_wiz_page_changing) self.ptig = Ptig(file_name) page1 = TitledPage(self, 1, _("Program description")) self.page1 = page1 page2 = TitledPage(self, 2, _("License")) page3 = TitledPage(self, 3, _("Run")) r_txt = wx.TextCtrl(page1, -1, size=wx.Size(600, 300), style=wx.TE_MULTILINE | wx.TE_READONLY) r_txt.SetValue(self.ptig.get_readme()) page1.sizer.Add(r_txt) self.FitToPage(page1) l_txt = wx.TextCtrl( page2, -1, self.ptig.get_license(), size=wx.Size(600, 300), style=wx.TE_MULTILINE | wx.TE_READONLY, ) page2.sizer.Add(l_txt) page2.sizer.AddSpacer(5) self.licence = wx.CheckBox(page2, -1, _("Accept")) page2.sizer.Add(self.licence) page3.sizer.Add( wx.StaticText(page3, -1, _("Run the installed program or cancel"))) WizardPageSimple.Chain(page1, page2) WizardPageSimple.Chain(page2, page3) self.GetPageAreaSizer().Add(page1)
def __init__(self, *args, **kw): Wizard.__init__(self, *args, **kw) self.m_wiz_gnerate_keys = xrc.XRCCTRL(self, 'm_wiz_gnerate_keys') self.Bind(wx.EVT_BUTTON, self.generate_keys, id=xrc.XRCID('m_generate_keys')) self.Bind(wx.EVT_BUTTON, self.select_all, id=xrc.XRCID('m_select_all')) self.m_public_key = xrc.XRCCTRL(self, 'm_public_key')
def __init__(self, title, img_filePath=""): # img could be replaced by a py string of bytes if img_filePath and os.path.exists(img_filePath): img = wx.Bitmap(img_filePath) else: img = wx.NullBitmap Wizard.__init__(self, None, -1, title, img) self.pages = [] # Lets catch the events self.Bind(xwx.EVT_WIZARD_PAGE_CHANGED, self.OnWizardPageChanged) self.Bind(xwx.EVT_WIZARD_PAGE_CHANGING, self.OnWizardPageChanging) self.Bind(xwx.EVT_WIZARD_CANCEL, self.OnWizardCancel) self.Bind(xwx.EVT_WIZARD_FINISHED, self.OnWizardFinished)
def __init__(self): """Constructor""" Wizard.__init__(self, None, title="Disable Next") self.SetPageSize((500, 350)) mypage1 = self.create_page1() forward_btn = self.FindWindowById(wx.ID_FORWARD) forward_btn.Disable() self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.onUpdate, self.timer) self.timer.Start(1) self.RunWizard(mypage1)
def main(): """""" wizard = Wizard(None, -1, "Simple Wizard") page1 = TitledPage(wizard, "Page 1") page2 = TitledPage(wizard, "Page 2") page3 = TitledPage(wizard, "Page 3") page4 = TitledPage(wizard, "Page 4") WizardPageSimple.Chain(page1, page2) WizardPageSimple.Chain(page2, page3) WizardPageSimple.Chain(page3, page4) wizard.FitToPage(page1) wizard.RunWizard(page1) wizard.Destroy()
def createWizard(self): self.wizard = Wizard(None, -1, "Create new connection") self.wizard.Bind(wx.adv.EVT_WIZARD_PAGE_CHANGED, self.onPageChange) self.wizard.Bind(wx.adv.EVT_WIZARD_PAGE_CHANGING, self.onPageChanging) self.wizard.Bind(wx.adv.EVT_WIZARD_CANCEL, self.onCancel) self.wizard.Bind(wx.adv.EVT_WIZARD_FINISHED, self.onFinished) page1 = SelectDatabaseNamePage(self.wizard, "Select new connection type") page2 = ConncectionSettings(self.wizard, "Connection settings") self.page1 = page1 # self.pages.append(page1) # self.pages.append(page2) # page3 = TitledPage(wizard, "Page 3") # page4 = TitledPage(wizard, "Page 4") # page1.sizer.Add(wx.StaticText(page1, -1, "Testing the wizard")) # page4.sizer.Add(wx.StaticText(page4, -1, "This is the last page.")) # WizardPageSimple.Chain(page1, page2) # WizardPageSimple_Chain(page2, page3) # WizardPageSimple_Chain(page3, page4) self.wizard.FitToPage(page1) # Set the initial order of the pages page1.SetNext(page2) page2.SetPrev(page1) self.wizard.GetPageAreaSizer().Add(page1) if self.wizard.RunWizard(page1): logger.debug("Success") selectedItem = page1.tree.GetSelection() logger.debug(page1.tree.GetItemText(selectedItem)) logger.debug("%s, %s", page2.connectionNameTextCtrl.GetValue(), page2.dbb.GetValue()) # databasefile = page2.markFile.GetValue() connectionName = page2.connectionNameTextCtrl.GetValue() databaseFileName = connectionName.replace(" ", "_") + ".sqlite" databasefile = os.path.join(page2.dbb.GetValue(), databaseFileName) self.createNewDatabase(connectionName=connectionName, databaseAbsolutePath=databasefile) self.GetTopLevelParent()._mgr.GetPane( "databaseNaviagor").window.tree.initialize() else: wx.MessageBox("Create new connection was cancelled", "Create new connection")
def main(): """""" wizard = Wizard(None, -1, "Dynamic Wizard", images.WizTest1.GetBitmap()) page1 = TitledPage(wizard, "Page 1") page2 = TitledPage(wizard, "Page 2") page3 = TitledPage(wizard, "Page 3") page4 = UseAltBitmapPage(wizard, "Page 4") page5 = TitledPage(wizard, "Page 5") wizard.FitToPage(page1) page5.sizer.Add(wx.StaticText(page5, -1, "\nThis is the last page.")) # Set the initial order of the pages page1.SetNext(page2) page2.SetPrev(page1) page2.SetNext(page3) page3.SetPrev(page2) page3.SetNext(page4) page4.SetPrev(page3) page4.SetNext(page5) page5.SetPrev(page4) wizard.GetPageAreaSizer().Add(page1) wizard.RunWizard(page1) wizard.Destroy()
def __init__(self, title, parent, img_filename = ""): """ Constructor """ if img_filename and os.path.exists(img_filename): img = wx.Bitmap(img_filename) else: img = wx.NullBitmap wizmod.__init__(self, parent, wx.ID_ANY, title, img) self.SetPageSize((400,300)) # pages list self.pages = [] #flag self.canceled_flag = False self.overwrite_flag = True # Lets catch the events self.Bind(wizmod.EVT_WIZARD_PAGE_CHANGED, self.on_page_changed) self.Bind(wizmod.EVT_WIZARD_PAGE_CHANGING, self.on_page_changing) self.Bind(wizmod.EVT_WIZARD_CANCEL, self.on_cancel) self.Bind(wizmod.EVT_WIZARD_FINISHED, self.on_finished) self.Bind(wx.EVT_CLOSE, self.on_close)
def __init__(self, title, parent, img_filename=""): """ Constructor """ if img_filename and os.path.exists(img_filename): img = wx.Bitmap(img_filename) else: img = wx.NullBitmap wizmod.__init__(self, parent, wx.NewIdRef(), title, img) self.SetPageSize((400, 300)) # pages list self.pages = [] #flag self.canceled_flag = False self.overwrite_flag = True # Lets catch the events self.Bind(wizmod.EVT_WIZARD_PAGE_CHANGED, self.on_page_changed) self.Bind(wizmod.EVT_WIZARD_PAGE_CHANGING, self.on_page_changing) self.Bind(wizmod.EVT_WIZARD_CANCEL, self.on_cancel) self.Bind(wizmod.EVT_WIZARD_FINISHED, self.on_finished) self.Bind(wx.EVT_CLOSE, self.on_close)
def __init__(self, parent): Wizard.__init__(self, parent, -1, "Mirror Wizard") #self.Bind(Wizard.EVT_WIZARD_FINISHED, self.OnWizardFinished) self.Ok = False
class CreateNewConncetionWixard(wx.Panel): def __init__(self, parent=None, *args, **kw): wx.Panel.__init__(self, parent, id=-1) self.wizard = None self.pages = [] def createWizard(self): self.wizard = Wizard(None, -1, "Create new connection") self.wizard.Bind(wx.adv.EVT_WIZARD_PAGE_CHANGED, self.onPageChange) self.wizard.Bind(wx.adv.EVT_WIZARD_PAGE_CHANGING, self.onPageChanging) self.wizard.Bind(wx.adv.EVT_WIZARD_CANCEL, self.onCancel) self.wizard.Bind(wx.adv.EVT_WIZARD_FINISHED, self.onFinished) page1 = SelectDatabaseNamePage(self.wizard, "Select new connection type") page2 = ConncectionSettings(self.wizard, "Connection settings") self.page1 = page1 # self.pages.append(page1) # self.pages.append(page2) # page3 = TitledPage(wizard, "Page 3") # page4 = TitledPage(wizard, "Page 4") # page1.sizer.Add(wx.StaticText(page1, -1, "Testing the wizard")) # page4.sizer.Add(wx.StaticText(page4, -1, "This is the last page.")) # WizardPageSimple.Chain(page1, page2) # WizardPageSimple_Chain(page2, page3) # WizardPageSimple_Chain(page3, page4) self.wizard.FitToPage(page1) # Set the initial order of the pages page1.SetNext(page2) page2.SetPrev(page1) self.wizard.GetPageAreaSizer().Add(page1) if self.wizard.RunWizard(page1): logger.debug("Success") selectedItem = page1.tree.GetSelection() logger.debug(page1.tree.GetItemText(selectedItem)) logger.debug("%s, %s", page2.connectionNameTextCtrl.GetValue(), page2.dbb.GetValue()) # databasefile = page2.markFile.GetValue() connectionName = page2.connectionNameTextCtrl.GetValue() databaseFileName = connectionName.replace(" ", "_") + ".sqlite" databasefile = os.path.join(page2.dbb.GetValue(), databaseFileName) self.createNewDatabase(connectionName=connectionName, databaseAbsolutePath=databasefile) self.GetTopLevelParent()._mgr.GetPane( "databaseNaviagor").window.tree.initialize() else: wx.MessageBox("Create new connection was cancelled", "Create new connection") def createNewDatabase(self, databaseAbsolutePath=None, connectionName=None): try: manageSqliteDatabase = ManageSqliteDatabase( databaseAbsolutePath=databaseAbsolutePath, connectionName=connectionName) manageSqliteDatabase.createTable() sqlExecuter = SQLExecuter() sqlTypeObjectList = sqlExecuter.getSqlObjects() if len(sqlTypeObjectList) == 0: sqlExecuter.createOpalTables() sqlExecuter.addNewConnectionRow(databaseAbsolutePath, connectionName) except OperationalError as err: logger.error(err, exc_info=True) def onPageChange(self, event): '''Executed after the page has changed.''' logger.debug('onPageChange') if event.GetDirection(): dir = "forward" else: dir = "backward" page = event.GetPage() logger.debug("OnWizPageChanged: %s, %s\n" % (dir, page.__class__)) def onPageChanging(self, event): '''Executed before the page changes, so we might veto it.''' logger.debug('onPageChanging') if event.GetDirection(): dir = "forward" else: dir = "backward" page = event.GetPage() logger.debug("OnWizPageChanging: %s, %s\n" % (dir, page.__class__)) def onCancel(self, event): '''Cancel button has been pressed. Clean up and exit without continuing.''' logger.debug('onCancel') page = event.GetPage() logger.debug("on_cancel: %s\n", page.__class__) self.wizard.Destroy() # # Prevent cancelling of the wizard. # if page in self.pages: # # wx.MessageDialog("Cancelling on the first page has been prevented.", "Sorry") # # event.Veto() # dlg = wx.MessageDialog(page, # "Do you really want to close ?", # "Confirm Exit", wx.YES_NO |wx.ICON_QUESTION) # result = dlg.ShowModal() # if result == wx.ID_YES: # logger.debug( "Yes pressed") # self.wizard.Destroy() # else: # logger.debug( "No pressed") # dlg.Destroy() def onFinished(self, event): logger.debug('onFinished') wx.GetApp().ExitMainLoop()
#!/usr/bin/env python #-Imports---------------------------------------------------------------------- #--wxPython Imports. import wx if 'phoenix' in wx.version(): from wx.adv import Wizard, WizardPageSimple else: # Classic from wx.wizard import Wizard, WizardPageSimple if __name__ == '__main__': app = wx.App(False) mywiz = Wizard(None, -1, 'My Wizard') mywiz.pages = [] for i in range(3): page = WizardPageSimple(mywiz) st = wx.StaticText(page, -1, 'Wizard Page %d' % (i + 1)) if mywiz.pages: previous_page = mywiz.pages[-1] page.SetPrev(previous_page) previous_page.SetNext(page) mywiz.pages.append(page) mywiz.RunWizard(mywiz.pages[0]) mywiz.Destroy() app.MainLoop()