コード例 #1
0
    def __init__(self, parent, excelLink=None):
        img_filename = os.path.join(Utils.getImageFolder(),
                                    '20100718-Excel_icon.png')
        img = wx.Bitmap(img_filename) if img_filename and os.path.exists(
            img_filename) else wx.NullBitmap

        self.wizard = adv.Wizard()
        self.wizard.SetExtraStyle(adv.WIZARD_EX_HELPBUTTON)
        self.wizard.Create(parent, wx.ID_ANY, 'Import Start List', img)
        self.wizard.Bind(adv.EVT_WIZARD_PAGE_CHANGING, self.onPageChanging)

        self.fileNamePage = FileNamePage(self.wizard)
        self.sheetNamePage = SheetNamePage(self.wizard)
        self.headerNamesPage = HeaderNamesPage(self.wizard)
        self.summaryPage = SummaryPage(self.wizard)

        adv.WizardPageSimple.Chain(self.fileNamePage, self.sheetNamePage)
        adv.WizardPageSimple.Chain(self.sheetNamePage, self.headerNamesPage)
        adv.WizardPageSimple.Chain(self.headerNamesPage, self.summaryPage)

        self.excelLink = excelLink
        if excelLink:
            if excelLink.fileName:
                self.fileNamePage.setFileName(excelLink.fileName)
            if excelLink.sheetName:
                self.sheetNamePage.setExpectedSheetName(excelLink.sheetName)
            if excelLink.fieldCol:
                self.headerNamesPage.setExpectedFieldCol(excelLink.fieldCol)

        self.wizard.GetPageAreaSizer().Add(self.fileNamePage)
        self.wizard.SetPageSize(wx.Size(500, 200))
        self.wizard.FitToPage(self.fileNamePage)
コード例 #2
0
	def __init__( self, parent, excelLink = None ):
		img_filename = os.path.join( Utils.getImageFolder(), '20100718-Excel_icon.png' )
		img = wx.Bitmap(img_filename) if img_filename and os.path.exists(img_filename) else wx.NullBitmap
		
		self.wizard = adv.Wizard()
		self.wizard.SetExtraStyle( adv.WIZARD_EX_HELPBUTTON )
		self.wizard.Create( parent, wx.ID_ANY, _('Define Excel Link'), img )
		self.wizard.Bind( adv.EVT_WIZARD_PAGE_CHANGING, self.onPageChanging )
		self.wizard.Bind( adv.EVT_WIZARD_HELP,
			lambda evt: HelpSearch.showHelp('Menu-DataMgmt.html#link-to-external-excel-data') )
		
		self.fileNamePage = FileNamePage( self.wizard )
		self.sheetNamePage = SheetNamePage( self.wizard )
		self.headerNamesPage = HeaderNamesPage( self.wizard )
		self.summaryPage = SummaryPage( self.wizard )
		
		adv.WizardPageSimple.Chain( self.fileNamePage, self.sheetNamePage )
		adv.WizardPageSimple.Chain( self.sheetNamePage, self.headerNamesPage )
		adv.WizardPageSimple.Chain( self.headerNamesPage, self.summaryPage )
		
		self.excelLink = excelLink
		if excelLink:
			if excelLink.fileName:
				self.fileNamePage.setFileName( excelLink.fileName )
			if excelLink.sheetName:
				self.sheetNamePage.setExpectedSheetName( excelLink.sheetName )
			if excelLink.fieldCol:
				self.headerNamesPage.setExpectedFieldCol( excelLink.fieldCol )

		self.wizard.GetPageAreaSizer().Add( self.fileNamePage )
		self.wizard.SetPageSize( wx.Size(800,560) )
		self.wizard.FitToPage( self.fileNamePage )
コード例 #3
0
def nbwizard(parent):
    """Create a wx wizard with pages and run it.  Then use the collected information
    to populate the newboard_template and save it to the user's config directory.
    `parent` is the wx.Window that will own the wizard.
    """
    inputs = {}

    bmp = wx.Bitmap(get_pkg_path("res/wizard.png"), wx.BITMAP_TYPE_PNG)
    wizard = wxa.Wizard(parent, title="New Keyboard Definition", bitmap=bmp)

    page1 = IntroWizardPage(wizard, inputs)
    page2 = DescIdWizardPage(wizard, inputs)
    page3 = AvrWizardPage(wizard, inputs)
    page4 = MatrixWizardPage(wizard, inputs)
    page5 = LedWizardPage(wizard, inputs)
    page6 = KleWizardPage(wizard, inputs)
    page7 = OutroWizardPage(wizard, inputs)

    page1.Chain(page2).Chain(page3).Chain(page4).Chain(page5).Chain(
        page6).Chain(page7)

    wizard.FitToPage(page1)
    wizard.GetPageAreaSizer().Add(page1)

    wizard.Bind(wx.adv.EVT_WIZARD_BEFORE_PAGE_CHANGED, OnPageChange)

    if wizard.RunWizard(page1):
        try:
            parsed = kleparse.parse(inputs['path'])
            mapping = create_mapping(inputs, parsed)
            output_file = inputs['id'].lower() + '.py'
            output_path = os.path.join(get_user_boards_dir(), output_file)
            create_config(output_path, mapping)
        except Exception as err:
            wx.MessageBox(str(err),
                          caption="Error creating config",
                          style=wx.ICON_ERROR | wx.OK | wx.CENTRE,
                          parent=parent)
            return
        msg = (
            "Config file for '{0}' successfully created.  Edit the following file then "
            "restart EasyAVR.\n\n{1}").format(inputs['description'],
                                              output_path)
        wx.MessageBox(msg, caption="Success", parent=parent)
コード例 #4
0
    def __init__(self, parent, size=wx.DefaultSize):
        self.wizard = adv.Wizard(parent, wx.ID_ANY, _('Compute Speed'))
        self.wizard.Bind(adv.EVT_WIZARD_PAGE_CHANGING, self.onPageChanging)

        self.iPhoto1 = None
        self.iPhoto2 = None

        self.wheelEdgesPage = WheelEdgesPage(self.wizard)
        self.frontWheelEdgePage = FrontWheelEdgePage(self.wizard,
                                                     self.getSpeed)
        self.timePage = TimePage(self.wizard)

        adv.WizardPageSimple.Chain(self.wheelEdgesPage,
                                   self.frontWheelEdgePage)
        adv.WizardPageSimple.Chain(self.frontWheelEdgePage, self.timePage)

        self.wizard.SetPageSize(size)
        self.wizard.GetPageAreaSizer().Add(self.wheelEdgesPage)
        self.wizard.FitToPage(self.wheelEdgesPage)
コード例 #5
0
ファイル: converter.py プロジェクト: juce/GDBManager5
def RunConverterWizard(frame, bitmap):
    frame.dirs = {"KDB": "C:\\", "GDB": "C:\\"}

    # Create the wizard and the pages
    wizard = wiz.Wizard(frame, -1, "KDB-->GDB Converter", bitmap)
    page1 = TitledPage(wizard, "KDB --> GDB")
    page2 = PageChooseKDB(wizard, "Choose KDB folder", frame.dirs)
    page3 = PageChooseGDB(wizard, "Choose GDB location", frame.dirs)
    page4 = PageConfirm(wizard, "Confirm inputs", frame.dirs)
    page5 = TitledPage(wizard, "Conversion finished")
    frame.page1 = page1

    page1.sizer.Add(
        wx.StaticText(
            page1, -1, """
This wizard will create a new GDB from an existing KDB (the
older-format kits database used by Kitserver 5.0). The converter
will use English names for all teams, so if you want to change 
those, you can do it after the conversion is done.

NOTE: If you specify a destination folder where you already 
have an existing GDB, the converter will backup your current 
GDB, so nothing will be lost or overwritten. 
Press "Next" to continue."""))
    wizard.FitToPage(page1)
    page5.sizer.Add(
        wx.StaticText(
            page5, -1, """
KDB->GDB conversion completed successfully.
You can now use your new GDB with Kitserver 5.1.

Press "Finish" to exit the converter, and return
back to GDB Manager.
"""))

    # Use the convenience Chain function to connect the pages
    wiz.WizardPageSimple.Chain(page1, page2)
    wiz.WizardPageSimple.Chain(page2, page3)
    wiz.WizardPageSimple.Chain(page3, page4)
    wiz.WizardPageSimple.Chain(page4, page5)

    return wizard.RunWizard(page1)
コード例 #6
0
    def __init__(self, parent, geoTrack=None, geoTrackFName=None):
        img_filename = os.path.join(Utils.getImageFolder(), 'gps.png')
        bitmap = wx.Bitmap(img_filename) if img_filename and os.path.exists(
            img_filename) else wx.NullBitmap

        self.parent = parent
        self.wizard = adv.Wizard()
        self.wizard.SetExtraStyle(adv.WIZARD_EX_HELPBUTTON)
        self.wizard.Create(parent,
                           title=_('Import GPX Course File'),
                           bitmap=bitmap)

        self.introPage = IntroPage(self.wizard, self)
        self.fileNamePage = FileNamePage(self.wizard)
        self.useTimesPage = UseTimesPage(self.wizard)
        self.summaryPage = SummaryPage(self.wizard)

        self.wizard.Bind(adv.EVT_WIZARD_PAGE_CHANGING, self.onPageChanging)
        self.wizard.Bind(adv.EVT_WIZARD_CANCEL, self.onCancel)
        self.wizard.Bind(
            adv.EVT_WIZARD_HELP, lambda evt: HelpSearch.showHelp(
                'Menu-DataMgmt.html#import-course-in-gpx-format'))

        adv.WizardPageSimple.Chain(self.introPage, self.fileNamePage)
        adv.WizardPageSimple.Chain(self.fileNamePage, self.useTimesPage)
        adv.WizardPageSimple.Chain(self.useTimesPage, self.summaryPage)

        self.wizard.SetPageSize(wx.Size(500, 200))
        self.wizard.GetPageAreaSizer().Add(self.introPage)

        self.geoTrack = geoTrack
        self.geoTrackOriginal = geoTrack
        self.geoTrackFName = geoTrackFName
        self.geoTrackFNameOriginal = geoTrackFName

        self.introPage.setInfo(geoTrack, geoTrackFName)
        if geoTrackFName:
            self.fileNamePage.setInfo(geoTrackFName)
コード例 #7
0
                    + self.Parent.outDB + '.' + self.Parent.outPerImage +
                    '", "' + self.Parent.outDB + '.' +
                    self.Parent.outPerObject + '", "' + self.Parent.outDB +
                    '.' + prefix + '_table_index")')
            except:
                print('Logging merge to CPA_Merged_Tables.merged failed.')

            dlg.Destroy()

            dlg = wx.MessageDialog(self, 'Tables merged successfully!',
                                   'Success!', wx.OK | wx.ICON_INFORMATION)
            dlg.ShowModal()


app = wx.PySimpleApp()
wizard = wiz.Wizard(None,
                    -1,
                    "Create Master Table",
                    style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
page1 = Page1(wizard)
page2 = Page2(wizard)
page3 = Page3(wizard)
page4 = Page4(wizard)
wiz.WizardPageSimple_Chain(page1, page2)
wiz.WizardPageSimple_Chain(page2, page3)
wiz.WizardPageSimple_Chain(page3, page4)
wizard.FitToPage(page1)
wizard.RunWizard(page1)
wizard.Destroy()
app.MainLoop()
コード例 #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:
    ui._context = context = ui.context
    new_context = {
        name: None if value is None else value.clone_traits()
        for name, value in context.items()
    }
    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:
    wizard.Bind(wz.EVT_WIZARD_PAGE_CHANGING, 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:
    wizard.Unbind(wz.EVT_WIZARD_PAGE_CHANGING, handler=page_changing)
    save_window(ui)
    ui.finish()
    ui.context = ui._context
    ui._context = {}