示例#1
0
 def __init__(self, parent):
     super(SetPhoneWizard, self).__init__(parent, -1,
                                          'Phone Setting Wizard')
     self._data = {}
     commport_page = CommPortPage(self)
     phonemodel_page = PhoneModelPage(self)
     summary_page = SummaryPage(self)
     wiz.WizardPageSimple_Chain(phonemodel_page, commport_page)
     wiz.WizardPageSimple_Chain(commport_page, summary_page)
     self.first_page = phonemodel_page
     self.GetPageAreaSizer().Add(phonemodel_page, 1, wx.EXPAND | wx.ALL, 5)
     wiz.EVT_WIZARD_PAGE_CHANGING(self, self.GetId(), self.OnPageChanging)
     wiz.EVT_WIZARD_PAGE_CHANGED(self, self.GetId(), self.OnPageChanged)
示例#2
0
    def __init__(self, filename, *args, **kwargs):
        kwargs['style'] = wx.RESIZE_BORDER | wx.DEFAULT_DIALOG_STYLE
        super(CSVImportWizard, self).__init__(*args, **kwargs)

        self.optionsPage = CSVImportOptionsPage(filename, self)
        self.mappingPage = CSVImportMappingPage(self)
        self.optionsPage.SetNext(self.mappingPage)
        self.mappingPage.SetPrev(self.optionsPage)

        self.SetPageSize((600, -1))  # I know this is obsolete but it's the only one that works...

        wiz.EVT_WIZARD_PAGE_CHANGING(self, wx.ID_ANY, self.OnPageChanging)
        wiz.EVT_WIZARD_PAGE_CHANGED(self, wx.ID_ANY, self.OnPageChanged)
示例#3
0
 def __init__(self, parent):
     super(NewDBWizard, self).__init__(parent, -1,
                                       'New BitPim Storage Wizard')
     self.data = {}
     namepage = NamePage(self)
     pathpage = PathPage(self)
     optionspage = OptionsPage(self)
     summarypage = SummaryPage(self)
     wiz.WizardPageSimple_Chain(namepage, pathpage)
     wiz.WizardPageSimple_Chain(pathpage, optionspage)
     wiz.WizardPageSimple_Chain(optionspage, summarypage)
     self.firstpage = namepage
     self.GetPageAreaSizer().Add(namepage, 1, wx.EXPAND | wx.ALL, 5)
     wiz.EVT_WIZARD_PAGE_CHANGING(self, self.GetId(), self.OnPageChanging)
     wiz.EVT_WIZARD_PAGE_CHANGED(self, self.GetId(), self.OnPageChanged)
示例#4
0
    def __init__(self, parent, id=-1, title='Calendar Import Wizard'):
        super(ImportCalendarWizard, self).__init__(parent, id, title)
        self._data = {}
        _import_type_page = ImportTypePage(self)
        _import_source_page = ImportSourcePage(self)
        _import_data_all = ImportDataAll(self)
        _import_option = ImportOptionPage(self)

        wiz.WizardPageSimple_Chain(_import_type_page, _import_source_page)
        wiz.WizardPageSimple_Chain(_import_source_page, _import_data_all)
        wiz.WizardPageSimple_Chain(_import_data_all, _import_option)
        self.first_page = _import_type_page
        self.GetPageAreaSizer().Add(self.first_page, 1, wx.EXPAND | wx.ALL, 5)
        wiz.EVT_WIZARD_PAGE_CHANGING(self, self.GetId(), self.OnPageChanging)
        wiz.EVT_WIZARD_PAGE_CHANGED(self, self.GetId(), self.OnPageChanged)
示例#5
0
    def __init__(self, parent, entry,
                 id=-1, title='Calendar Import Preset Wizard'):
        super(ImportCalendarPresetWizard, self).__init__(parent, id, title)
        self._data=entry
        _import_name_page=PresetNamePage(self)
        _import_type_page=imp_cal_wizard.ImportTypePage(self)
        _import_source_page=imp_cal_wizard.ImportSourcePage(self)
        _import_filter_page=PresetFilterPage(self)
        _import_option=ImportOptionPage(self)

        wiz.WizardPageSimple_Chain(_import_name_page, _import_type_page)
        wiz.WizardPageSimple_Chain(_import_type_page, _import_source_page)
        wiz.WizardPageSimple_Chain(_import_source_page, _import_filter_page)
        wiz.WizardPageSimple_Chain(_import_filter_page, _import_option)
        self.first_page=_import_name_page
        self.GetPageAreaSizer().Add(self.first_page, 1, wx.EXPAND|wx.ALL, 5)
        wiz.EVT_WIZARD_PAGE_CHANGING(self, self.GetId(), self.OnPageChanging)
        wiz.EVT_WIZARD_PAGE_CHANGED(self, self.GetId(), self.OnPageChanged)
示例#6
0
        page = event.GetPage()
        try:
            page._changedToThisPage(event)
        except AttributeError:
            pass


if __name__ == '__main__':
    app = wx.PySimpleApp()

    id = wx.NewId()
    wizard = wiz.Wizard(None, id, "Summarize Sales For A Month")
    wizard.data = {}

    page1 = ChooseFolderPage(wizard)
    page2 = ReadyPage(wizard)
    page3 = FeedbackPage(wizard)

    page1.SetNext(page2)
    page2.SetPrev(page1)
    page2.SetNext(page3)

    wiz.EVT_WIZARD_PAGE_CHANGING(app, id, onPageChanging)
    wiz.EVT_WIZARD_PAGE_CHANGED(app, id, onPageChanged)

    wizard.FitToPage(page1)
    wizard.RunWizard(page1)
    wizard.Destroy()

    app.MainLoop()
示例#7
0
def ui_wizard(ui, parent):

    # Create the copy of the 'context' we will need while editing:
    context = ui.context
    ui._context = context
    new_context = {}
    for name, value in context.items():
        new_context[name] = value.clone_traits()
    ui.context = new_context

    # Now bind the context values to the 'info' object:
    ui.info.bind_context()

    # Create the Tkinter wizard window:
    ui.control = wizard = wz.Wizard(parent, -1, ui.view.title)

    # Create all of the wizard pages:
    pages = []
    editor_pages = []
    info = ui.info
    shadow_group = ui.view.content.get_shadow(ui)
    min_dx = min_dy = 0
    for group in shadow_group.get_content():
        page = UIWizardPage(wizard, editor_pages)
        pages.append(page)
        fill_panel_for_group(page, group, ui)

        # Size the page correctly, then calculate cumulative minimum size:
        sizer = page.GetSizer()
        sizer.Fit(page)
        size = sizer.CalcMin()
        min_dx = max(min_dx, size.GetWidth())
        min_dy = max(min_dy, size.GetHeight())

        # If necessary, create a GroupEditor and attach it to the right places:
        id = group.id
        if id or group.enabled_when:
            page.editor = editor = GroupEditor(control=page)
            if id:
                page.id = id
                editor_pages.append(page)
                info.bind(id, editor)
            if group.enabled_when:
                ui.add_enabled(group.enabled_when, editor)

    # Size the wizard correctly:
    wizard.SetPageSize(wx.Size(min_dx, min_dy))

    # Set up the wizard 'page changing' event handler:
    wz.EVT_WIZARD_PAGE_CHANGING(wizard, wizard.GetId(), page_changing)

    # Size the wizard and the individual pages appropriately:
    prev_page = pages[0]
    wizard.FitToPage(prev_page)

    # Link the pages together:
    for page in pages[1:]:
        page.SetPrev(prev_page)
        prev_page.SetNext(page)
        prev_page = page

    # Finalize the display of the wizard:
    try:
        ui.prepare_ui()
    except:
        ui.control.Destroy()
        ui.control.ui = None
        ui.control = None
        ui.result = False
        raise

    # Position the wizard on the display:
    ui.handler.position(ui.info)

    # Run the wizard:
    if wizard.RunWizard(pages[0]):
        # If successful, apply the modified context to the original context:
        original = ui._context
        for name, value in ui.context.items():
            original[name].copy_traits(value)
        ui.result = True
    else:
        ui.result = False

    # Clean up loose ends, like restoring the original context:
    ui.control.Destroy()
    ui.control = None
    ui.context = ui._context
    ui._context = {}
示例#8
0
def ui_wizard(ui, parent):
    """ Creates a wizard-based wxPython user interface for a specified UI
    object.
    """
    # Create the copy of the 'context' we will need while editing:
    context = ui.context
    ui._context = context
    new_context = {}
    for name, value in context.items():
        if value is not None:
            new_context[name] = value.clone_traits()
        else:
            new_context[name] = None

    ui.context = new_context

    # Now bind the context values to the 'info' object:
    ui.info.bind_context()

    # Create the wxPython wizard window:
    title = ui.view.title
    if title == '':
        title = DefaultTitle
    ui.control = wizard = wz.Wizard(parent, -1, title)

    # Create all of the wizard pages:
    pages = []
    editor_pages = []
    info = ui.info
    shadow_group = ui.view.content.get_shadow(ui)
    min_dx = min_dy = 0
    # Create a dictionary mapping each contained group in shadow_group to
    # its id and enabled_when fields.
    group_fields_mapping = {}
    for group in shadow_group.get_content():
        # FIXME: When the group's id or enabled_when or visible_when is
        # set, the "fill_panel_for_group" will create a new Panel to hold the
        # contents of the group (instead of adding them to the page itself).
        # This leads to an incorrect sizing of the panel(not sure why
        # actually): example would be 'test_ui2.py' in
        # Traits/integrationtests/ui. In addition,
        # it leads to incorrect bindings (of the id) on the UIInfo object:
        # the id is bound to the GroupEditor created in "fill_panel.."
        # instead of the PageGroupEditor created here.
        # A simple solution is to clear out these fields before calling
        # "fill_panel_for_group", and then reset these traits.
        group_fields_mapping[group] = (group.id, group.enabled_when)
        (group.id, group.enabled_when) = ('', '')
        page = UIWizardPage(wizard, editor_pages)
        pages.append(page)
        fill_panel_for_group(page, group, ui)

        # Size the page correctly, then calculate cumulative minimum size:
        sizer = page.GetSizer()
        sizer.Fit(page)
        size = sizer.CalcMin()
        min_dx = max(min_dx, size.GetWidth())
        min_dy = max(min_dy, size.GetHeight())

        # If necessary, create a PageGroupEditor and attach it to the right
        # places:
        (group.id, group.enabled_when) = group_fields_mapping[group]
        if group.id or group.enabled_when:
            page.editor = editor = PageGroupEditor(control=page)
            if group.id:
                page.id = group.id
                editor_pages.append(page)
                info.bind(page.id, editor)
            if group.enabled_when:
                ui.add_enabled(group.enabled_when, editor)

    # Size the wizard correctly:
    wizard.SetPageSize(wx.Size(min_dx, min_dy))

    # Set up the wizard 'page changing' event handler:
    wz.EVT_WIZARD_PAGE_CHANGING(wizard, wizard.GetId(), page_changing)

    # Size the wizard and the individual pages appropriately:
    prev_page = pages[0]
    wizard.FitToPage(prev_page)

    # Link the pages together:
    for page in pages[1:]:
        page.SetPrev(prev_page)
        prev_page.SetNext(page)
        prev_page = page

    # Finalize the display of the wizard:
    try:
        ui.prepare_ui()
    except:
        ui.control.Destroy()
        ui.control.ui = None
        ui.control = None
        ui.result = False
        raise

    # Position the wizard on the display:
    ui.handler.position(ui.info)

    # Restore the user_preference items for the user interface:
    restore_window(ui)

    # Run the wizard:
    if wizard.RunWizard(pages[0]):
        # If successful, apply the modified context to the original context:
        original = ui._context
        for name, value in ui.context.items():
            if value is not None:
                original[name].copy_traits(value)
            else:
                original[name] = None
        ui.result = True
    else:
        ui.result = False

    # Clean up loose ends, like restoring the original context:
    save_window(ui)
    ui.finish()
    ui.context = ui._context
    ui._context = {}