Exemple #1
0
    def __init__(
        self,
        parent,
        default_name,
        title="Attach Table",
        message="Settings for attaching table to global namespace",
        ID=-1,
        size=wx.DefaultSize,
        pos=wx.DefaultPosition,
        style=wx.DEFAULT_DIALOG_STYLE,
        useMetal=False,
    ):
        # Instead of calling wx.Dialog.__init__ we precreate the dialog
        # so we can set an extra style that must be set before
        # creation, and then we create the GUI object using the Create
        # method.
        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        pre.Create(parent, ID, title, pos, size, style)

        # This next step is the most important, it turns this Python
        # object into the real wrapper of the dialog (instead of pre)
        # as far as the wxPython extension is concerned.
        self.PostCreate(pre)

        # This extra style can be set after the UI object has been created.
        if 'wxMac' in wx.PlatformInfo and useMetal:
            self.SetExtraStyle(wx.DIALOG_EX_METAL)

        # Now continue with the normal construction of the dialog
        # contents
        sizer = wx.BoxSizer(wx.VERTICAL)

        label = wx.StaticText(self, -1, message)
        sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        ## CONTROLS #####   #####   #####   #####   #####   #####

        rb = self.dt_ctrl = wx.RadioBox(self, -1, "dtype", wx.DefaultPosition,
                                        wx.DefaultSize, self.dtypes_s, 2,
                                        wx.RA_SPECIFY_COLS)
        sizer.Add(rb, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        # asdict
        cb = self.asdict_ctrl = wx.CheckBox(self, -1, "As Dictionary")
        cb.SetHelpText("Instead of exporting the table, export {key:list} dict " + \
                       "with first row/coumn providing keys")
        sizer.Add(cb, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, cb)

        # asdict BOX
        sbox = wx.StaticBox(self, -1, "Dict Properties")
        bsizer = wx.StaticBoxSizer(sbox, wx.VERTICAL)
        rb = self.keyloc_ctrl = wx.RadioBox(self, -1, "Key Location",
                                            wx.DefaultPosition, wx.DefaultSize,
                                            ['Col 0', 'Row 0'], 2,
                                            wx.RA_SPECIFY_COLS)
        bsizer.Add(rb, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        rb = self.kdt_ctrl = wx.RadioBox(self, -1, "Key dtype",
                                         wx.DefaultPosition, wx.DefaultSize,
                                         self.dtypes_s, 2, wx.RA_SPECIFY_COLS)
        bsizer.Add(rb, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        sizer.Add(bsizer, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL,
                  5)  # 1, wx.EXPAND|wx.ALL, 25)

        # name
        if default_name:
            hlp = "The name in global namespace which the table will " + \
                  "be assigned"
            box = wx.BoxSizer(wx.HORIZONTAL)

            label = wx.StaticText(self, -1, "Name:")
            label.SetHelpText(hlp)
            box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

            text = self.name_ctrl = wx.TextCtrl(self,
                                                -1,
                                                default_name,
                                                size=(120, -1))
            text.SetHelpText(hlp)
            box.Add(text, 1, wx.ALIGN_CENTRE | wx.ALL, 5)

            sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        else:
            self.name_ctrl = False

        # bottom
        line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL)
        sizer.Add(line, 0,
                  wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP, 5)

        btnsizer = wx.StdDialogButtonSizer()

        #        if wx.Platform != "__WXMSW__":
        #            btn = wx.ContextHelpButton(self)
        #            btnsizer.AddButton(btn)

        btn = wx.Button(self, wx.ID_OK)
        btn.SetHelpText("Export the table to the shell")
        btn.SetDefault()
        btnsizer.AddButton(btn)

        btn = wx.Button(self, wx.ID_CANCEL)
        btn.SetHelpText("Return to the table view without exporting the table")
        btnsizer.AddButton(btn)
        btnsizer.Realize()

        sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        self.SetSizer(sizer)
        sizer.Fit(self)
Exemple #2
0
    def __init__(self,
                 mainControl,
                 ID,
                 title="Print",
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 exportTo=None):
        d = wx.PreDialog()
        self.PostCreate(d)

        self.mainControl = mainControl
        self.printer = self.mainControl.printer

        #         self.plainTextFontDesc = self.printer.plainTextFontDesc

        res = wx.xrc.XmlResource.Get()
        res.LoadOnDialog(self, self.mainControl, "PrintMainDialog")

        self.ctrls = XrcControls(self)

        self.ctrls.chSelectedSet.SetSelection(self.printer.selectionSet)

        #         # If Webkit available allow to use it for HTML print
        #         if WKHtmlWindow:
        #             self.ctrls.chExportTo.Append(_(u'HTML (Webkit)'))
        #
        #         if exportTo >= 0:
        #             self.ctrls.chExportTo.SetSelection(exportTo)
        #
        #         self.ctrls.tfWikiPageSeparator.SetValue(
        #                 self.mainControl.configuration.get("main",
        #                 "print_plaintext_wpseparator"))

        self.ctrls.btnPrint.SetId(wx.ID_OK)
        self.ctrls.btnCancel.SetId(wx.ID_CANCEL)

        self.mainControl.saveAllDocPages()
        self.mainControl.getWikiData().commit()

        self.supportedPrintTypes = set()

        self.emptyPanel = None

        printList = []  # List of tuples (<print object>, <print tag>,
        # <readable description>, <additional options panel>)

        addOptSizer = LayerSizer()

        for obtp in PluginManager.getSupportedPrintTypes(
                self.mainControl, self.ctrls.additOptions).values():
            panel = obtp[3]
            if panel is None:
                if self.emptyPanel is None:
                    # Necessary to avoid a crash
                    self.emptyPanel = wx.Panel(self.ctrls.additOptions)

                panel = self.emptyPanel
            else:
                pass

            # Add Tuple (Print object, print type tag,
            #     print type description, additional options panel)
            printList.append((obtp[0], obtp[1], obtp[2], panel))
            self.supportedPrintTypes.add(obtp[1])
            addOptSizer.Add(panel)

        mainControl.getCollator().sortByItem(printList, 2)

        self.ctrls.additOptions.SetSizer(addOptSizer)
        self.ctrls.additOptions.SetMinSize(addOptSizer.GetMinSize())

        self.ctrls.additOptions.Fit()
        self.Fit()

        self.printList = printList

        for e in self.printList:
            e[3].Show(False)
            e[3].Enable(False)
            self.ctrls.chExportTo.Append(e[2])

        if exportTo is None:
            exportTo = self.mainControl.getConfig().get(
                "main", "print_lastDialogTag", "")

        selection = 0

        for i, e in enumerate(self.printList):
            if exportTo == e[1]:
                selection = i
                break

        self.ctrls.chExportTo.SetSelection(selection)
        self._refreshForPtype()

        # Fixes focus bug under Linux
        self.SetFocus()

        wx.EVT_CHOICE(self, GUI_ID.chExportTo, self.OnExportTo)
        wx.EVT_CHOICE(self, GUI_ID.chSelectedSet, self.OnChSelectedSet)

        wx.EVT_BUTTON(self, GUI_ID.btnPreview, self.OnPreview)
        wx.EVT_BUTTON(self, GUI_ID.btnPageSetup, self.OnPageSetup)
        #         wx.EVT_BUTTON(self, GUI_ID.btnChoosePlainTextFont,
        #                 self.OnChoosePlainTextFont)
        wx.EVT_BUTTON(self, wx.ID_OK, self.OnPrint)
Exemple #3
0
    def __init__(
            self,
            option_parser,  #The OptionParser object
            parent=None,
            ID=0,
            title='Program Options',
            pos=wx.DefaultPosition,
            size=wx.DefaultSize,
            style=wx.DEFAULT_DIALOG_STYLE,
            name='OptparseDialog',
            values=None,
            args=False):

        self.option_parser = option_parser
        if values == None:
            values = option_parser.get_defaults()

        provider = wx.SimpleHelpProvider()
        wx.HelpProvider_Set(provider)

        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        pre.Create(parent, ID, title, pos, size, style)

        self.PostCreate(pre)

        sizer = wx.BoxSizer(wx.VERTICAL)

        sizer2 = wx.BoxSizer(wx.HORIZONTAL)
        top_label_text = '%s %s' % (option_parser.get_prog_name(),
                                    option_parser.get_version())
        label = wx.StaticText(self, -1, top_label_text)
        sizer2.Add(label, 0, wx.GROW | wx.ALIGN_LEFT | wx.ALL, 5)
        if wx.Platform != "__WXMSW__":
            sizer2.AddStretchSpacer(-1)
            btn = wx.ContextHelpButton(self)
            sizer2.Add(btn, 0, wx.ALIGN_RIGHT | wx.ALL)
        sizer.Add(sizer2, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL)
        sizer.Add(
            line, 0,
            wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP | wx.LEFT,
            5)

        nb = wx.Notebook(self, wx.ID_ANY)

        self.option_controls = {}
        self.option_controls.update(
            self.set_panel(nb, option_parser.option_list, values, 'Options'))
        for g in option_parser.option_groups:
            self.option_controls.update(
                self.set_panel(nb, g.option_list, values, g.title))
        if args:
            self.args_ctrl = self.set_args_panel(nb, values, 'Arguments')
        else:
            self.args_ctrl = None

        sizer.Add(
            nb, 0,
            wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP | wx.LEFT,
            5)

        line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL)
        sizer.Add(
            line, 0,
            wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP | wx.LEFT,
            5)

        btnsizer = wx.BoxSizer(wx.HORIZONTAL)

        btn = wx.Button(self, wx.ID_CANCEL)
        # btn.SetHelpText("The OK button completes the dialog")
        btnsizer.Add(btn, 0, wx.ALL, 5)

        btnsizer.AddSpacer((100, -1))
        btn = wx.Button(self, wx.ID_CLEAR, label="Reset")
        btn.Bind(wx.EVT_BUTTON, self.closeDialog)
        btnsizer.Add(btn, 0, wx.ALL, 5)

        btnsizer.AddSpacer((100, -1))
        btn = wx.Button(self, wx.ID_OK)
        btn.SetDefault()
        # btn.SetHelpText("The Cancel button cancels the dialog.")
        btnsizer.Add(btn, 0, wx.ALL, 5)

        sizer.Add(btnsizer, 0, wx.ALIGN_CENTER,
                  wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        self.SetSizer(sizer)
        sizer.Fit(self)
    def __init__(self,
                 parent,
                 ID,
                 nbChannels=10,
                 title="",
                 text="",
                 size=wx.DefaultSize,
                 pos=wx.DefaultPosition,
                 style=wx.DEFAULT_DIALOG_STYLE,
                 useMetal=False,
                 limits_scale=(0.01, 10),
                 limits_offset=(-100, 100)):

        # Instead of calling wx.Dialog.__init__ we precreate the dialog
        # so we can set an extra style that must be set before
        # creation, and then we create the GUI object using the Create
        # method.

        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        pre.Create(parent, ID, title, pos, size, style)

        # This next step is the most important, it turns this Python
        # object into the real wrapper of the dialog (instead of pre)
        # as far as the wxPython extension is concerned.
        self.PostCreate(pre)

        # This extra style can be set after the UI object has been created.
        if 'wxMac' in wx.PlatformInfo and useMetal:
            self.SetExtraStyle(wx.DIALOG_EX_METAL)

        # Now continue with the normal construction of the dialog
        self.nbChannels = nbChannels

        # contents
        sizer = wx.BoxSizer(wx.VERTICAL)

        label = wx.StaticText(self, -1, text)
        label.SetHelpText("help text")
        sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        # box 1 cmin
        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, "first channel:")
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        self.cmin = wx.Slider(
            self, -1, 1, 1, self.nbChannels, (30, 60), (400, -1),
            wx.SL_HORIZONTAL | wx.SL_AUTOTICKS | wx.SL_LABELS)
        self.cmin.SetTickFreq(5, 1)

        box.Add(self.cmin, 1, wx.ALIGN_CENTRE | wx.ALL, 5)
        sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        self.cmin.Bind(wx.EVT_SCROLL_CHANGED, self.OnChangedCmin)

        # box 2 cmax
        box = wx.BoxSizer(wx.HORIZONTAL)
        label = wx.StaticText(self, -1, "last channel :")
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        self.cmax = wx.Slider(
            self, -1, self.nbChannels, 1, self.nbChannels, (30, 60), (400, -1),
            wx.SL_HORIZONTAL | wx.SL_AUTOTICKS | wx.SL_LABELS)
        box.Add(self.cmax, 1, wx.ALIGN_CENTRE | wx.ALL, 5)
        self.cmin.SetTickFreq(5, 1)
        sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        self.cmax.Bind(wx.EVT_SCROLL_CHANGED, self.OnChangedCmax)

        # box 3 thinning factor
        box = wx.BoxSizer(wx.HORIZONTAL)
        label = wx.StaticText(self, -1, "thinning factor:")
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        self.thinning_factor = wx.Slider(
            self, -1, 1, 1, 30, (30, 60), (400, -1),
            wx.SL_HORIZONTAL | wx.SL_AUTOTICKS | wx.SL_LABELS)
        box.Add(self.thinning_factor, 1, wx.ALIGN_CENTRE | wx.ALL, 5)
        sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL)
        sizer.Add(line, 0,
                  wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP, 5)

        # buttons
        btnsizer = wx.StdDialogButtonSizer()

        btn = wx.Button(self, wx.ID_OK)

        btn.SetDefault()
        btnsizer.AddButton(btn)
        btn = wx.Button(self, wx.ID_CANCEL)
        btnsizer.AddButton(btn)
        btnsizer.Realize()

        sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        self.SetSizer(sizer)
        sizer.Fit(self)
        self.Show()
	def __init__(self, parent):
        # Instead of calling wx.Dialog.__init__ we precreate the dialog
        # so we can set an extra style that must be set before
        # creation, and then we create the GUI object using the Create
        # method.
		pre = wx.PreDialog()
		pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
		pre.Create(parent, -1, mtexts.txts['SunTransits'], pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_DIALOG_STYLE)

        # This next step is the most important, it turns this Python
        # object into the real wrapper of the dialog (instead of pre)
        # as far as the wxPython extension is concerned.
		self.PostCreate(pre)

		#main vertical sizer
		mvsizer = wx.BoxSizer(wx.VERTICAL)
		#main horizontal sizer
		mhsizer = wx.BoxSizer(wx.HORIZONTAL)

		#Target
		self.starget =wx.StaticBox(self, label='')
		targetsizer = wx.StaticBoxSizer(self.starget, wx.VERTICAL)
		self.ascrb = wx.RadioButton(self, -1, mtexts.txts['Ascendant'], style=wx.RB_GROUP)
		targetsizer.Add(self.ascrb, 0, wx.ALIGN_LEFT|wx.ALL, 2)
		self.mcrb = wx.RadioButton(self, -1, mtexts.txts['MediumCoeli'])
		targetsizer.Add(self.mcrb, 0, wx.ALIGN_LEFT|wx.ALL, 2)
		self.sunrb = wx.RadioButton(self, -1, mtexts.txts['Sun'])
		targetsizer.Add(self.sunrb, 0, wx.ALIGN_LEFT|wx.ALL, 2)
		self.moonrb = wx.RadioButton(self, -1, mtexts.txts['Moon'])
		targetsizer.Add(self.moonrb, 0, wx.ALIGN_LEFT|wx.ALL, 2)
		self.mercuryrb = wx.RadioButton(self, -1, mtexts.txts['Mercury'])
		targetsizer.Add(self.mercuryrb, 0, wx.ALIGN_LEFT|wx.ALL, 2)
		self.venusrb = wx.RadioButton(self, -1, mtexts.txts['Venus'])
		targetsizer.Add(self.venusrb, 0, wx.ALIGN_LEFT|wx.ALL, 2)
		self.marsrb = wx.RadioButton(self, -1, mtexts.txts['Mars'])
		targetsizer.Add(self.marsrb, 0, wx.ALIGN_LEFT|wx.ALL, 2)
		self.jupiterrb = wx.RadioButton(self, -1, mtexts.txts['Jupiter'])
		targetsizer.Add(self.jupiterrb, 0, wx.ALIGN_LEFT|wx.ALL, 2)
		self.saturnrb = wx.RadioButton(self, -1, mtexts.txts['Saturn'])
		targetsizer.Add(self.saturnrb, 0, wx.ALIGN_LEFT|wx.ALL, 2)
		self.uranusrb = wx.RadioButton(self, -1, mtexts.txts['Uranus'])
		targetsizer.Add(self.uranusrb, 0, wx.ALIGN_LEFT|wx.ALL, 2)
		self.neptunerb = wx.RadioButton(self, -1, mtexts.txts['Neptune'])
		targetsizer.Add(self.neptunerb, 0, wx.ALIGN_LEFT|wx.ALL, 2)
		self.plutorb = wx.RadioButton(self, -1, mtexts.txts['Pluto'])
		targetsizer.Add(self.plutorb, 0, wx.ALIGN_LEFT|wx.ALL, 2)

		mhsizer.Add(targetsizer, 0, wx.ALIGN_LEFT|wx.LEFT, 0)

		#Time
		rnge = 3000
		checker = rangechecker.RangeChecker()
		if checker.isExtended():
			rnge = 5000
		self.stime =wx.StaticBox(self, label='')
		timesizer = wx.StaticBoxSizer(self.stime, wx.VERTICAL)
		label = wx.StaticText(self, -1, mtexts.txts['StartingDate'])
		vsubsizer = wx.BoxSizer(wx.VERTICAL)
		vsubsizer.Add(label, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.LEFT, 0)
		fgsizer = wx.FlexGridSizer(2, 3)
		label = wx.StaticText(self, -1, mtexts.txts['Year']+':')
		vsizer = wx.BoxSizer(wx.VERTICAL)
		vsizer.Add(label, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.LEFT, 0)
		self.year = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, rnge), size=(50,-1))
		vsizer.Add(self.year, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.LEFT, 0)
		if checker.isExtended():
			self.year.SetHelpText(mtexts.txts['HelpYear'])
		else:
			self.year.SetHelpText(mtexts.txts['HelpYear2'])
		self.year.SetMaxLength(4)
		fgsizer.Add(vsizer, 0, wx.ALIGN_LEFT|wx.ALL, 5)

		vsizer = wx.BoxSizer(wx.VERTICAL)
		label = wx.StaticText(self, -1, mtexts.txts['Month']+':')
		vsizer.Add(label, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.LEFT, 0)
		self.month = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(1, 12), size=(50,-1))
		self.month.SetHelpText(mtexts.txts['HelpMonth'])
		self.month.SetMaxLength(2)
		vsizer.Add(self.month, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.LEFT, 0)
		fgsizer.Add(vsizer, 0, wx.ALIGN_LEFT|wx.ALL, 5)

		vsizer = wx.BoxSizer(wx.VERTICAL)
		label = wx.StaticText(self, -1, mtexts.txts['Day']+':')
		vsizer.Add(label, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.LEFT, 0)
		self.day = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(1, 31), size=(50,-1))
		self.day.SetHelpText(mtexts.txts['HelpDay'])
		self.day.SetMaxLength(2)
		vsizer.Add(self.day, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.LEFT, 0)
		fgsizer.Add(vsizer, 0, wx.ALIGN_LEFT|wx.ALL, 5)

		vsubsizer.Add(fgsizer, 0, wx.ALIGN_CENTER_HORIZONTAL)
		timesizer.Add(vsubsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)

		mhsizer.Add(timesizer, 0, wx.GROW|wx.ALIGN_LEFT|wx.LEFT, 5)
		mvsizer.Add(mhsizer, 0, wx.ALIGN_LEFT|wx.LEFT|wx.RIGHT, 5)

		btnsizer = wx.StdDialogButtonSizer()

		if wx.Platform != '__WXMSW__':
			btn = wx.ContextHelpButton(self)
			btnsizer.AddButton(btn)
        
		btnOk = wx.Button(self, wx.ID_OK, mtexts.txts['Ok'])
		btnsizer.AddButton(btnOk)
		btnOk.SetHelpText(mtexts.txts['HelpOk'])
		btnOk.SetDefault()

		btn = wx.Button(self, wx.ID_CANCEL, mtexts.txts['Cancel'])
		btnsizer.AddButton(btn)
		btn.SetHelpText(mtexts.txts['HelpCancel'])

		btnsizer.Realize()

		mvsizer.Add(btnsizer, 0, wx.GROW|wx.ALL, 10)
		self.SetSizer(mvsizer)
		mvsizer.Fit(self)

		btnOk.SetFocus()
Exemple #6
0
    def __init__(
            self,
            option_parser, #The OptionParser object
            parent = None,
            ID = 0,
            title = 'Optparse Dialog',
            pos=wx.DefaultPosition,
            size=wx.DefaultSize,
            style=wx.DEFAULT_DIALOG_STYLE,
            name = 'OptparseDialog',
        ):

        provider = wx.SimpleHelpProvider()
        wx.HelpProvider_Set(provider)

        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        pre.Create(parent, ID, title, pos, size, style)

        self.PostCreate(pre)

        sizer = wx.BoxSizer(wx.VERTICAL)

        self.option_controls = {}

        top_label_text = '%s %s' % ( option_parser.get_prog_name(),
                                     option_parser.get_version() )
        label = wx.StaticText(self, -1, top_label_text)
        sizer.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        self.browse_option_map = {}

        # Add controls for all the options
        for option in option_parser.option_list:
            if option.dest is None:
                continue

            if option.help is None:
                option.help = u''

            box = wx.BoxSizer(wx.HORIZONTAL)
            if 'store' == option.action:
                label = wx.StaticText(self, -1, option.dest )
                label.SetHelpText( option.help )
                box.Add( label, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )

                if 'choice' == option.type:
                    if optparse.NO_DEFAULT == option.default:
                        option.default = option.choices[0]
                    ctrl = wx.ComboBox(
                        self, -1, choices = option.choices,
                        value = option.default,
                        style = wx.CB_DROPDOWN | wx.CB_READONLY | wx.CB_SORT
                    )
                else:
                    if 'MULTILINE' in option.help:
                        ctrl = wx.TextCtrl( self, -1, "", size=(300,100), style = wx.TE_MULTILINE|wx.TE_PROCESS_ENTER )
                    else:
                        ctrl = wx.TextCtrl( self, -1, "", size=(300,-1) )

                    if ( option.default != optparse.NO_DEFAULT ) and \
                       ( option.default is not None ):
                        ctrl.Value = unicode( option.default )

                box.Add( ctrl, 1, wx.ALIGN_CENTRE|wx.ALL, 5 )

                if option.type in ['file', 'directory']:
                    browse = wx.Button(self, label='...')
                    browse.SetHelpText( 'Click to open %s browser' % (option.type) )
                    self.browse_option_map[browse.GetId()] = option, ctrl
                    wx.EVT_BUTTON(self, browse.GetId(), self.OnSelectPath)
                    box.Add( browse, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )

            elif option.action in ( 'store_true', 'store_false' ):
                ctrl = wx.CheckBox( self, -1, option.dest, size = ( 300, -1 ) )
                box.Add( ctrl, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
            else:
                raise NotImplementedError ( 'Unknown option action: %s' % repr( option.action ) )

            ctrl.SetHelpText( option.help )
            sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)

            self.option_controls[ option ] = ctrl

        # Add a text control for entering args
        box = wx.BoxSizer( wx.HORIZONTAL )
        label = wx.StaticText(self, -1, 'args' )
        label.SetHelpText( 'This is the place to enter the args' )

        self.args_ctrl = wx.TextCtrl( self, -1, '', size = ( -1, 100 ),
                            style=wx.TE_MULTILINE | wx.TE_PROCESS_ENTER )
        self.args_ctrl.SetHelpText(
'''Args can either be separated by a space or a newline
Args the contain spaces must be entered like so: "arg with sapce"
'''
        )
        box.Add( label, 0, wx.ALIGN_CENTRE | wx.ALL, 5 )
        box.Add( self.args_ctrl, 1, wx.ALIGN_CENTRE | wx.ALL, 5 )

        sizer.Add( box , 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5)

        line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL)
        sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5)

        btnsizer = wx.StdDialogButtonSizer()

        if wx.Platform != "__WXMSW__":
            btn = wx.ContextHelpButton(self)
            btnsizer.AddButton(btn)

        btn = wx.Button(self, wx.ID_OK)
        btn.SetHelpText("The OK button completes the dialog")
        btn.SetDefault()
        btnsizer.AddButton(btn)

        btn = wx.Button(self, wx.ID_CANCEL)
        btn.SetHelpText("The Cancel button cancels the dialog. (Cool, huh?)")
        btnsizer.AddButton(btn)
        btnsizer.Realize()

        sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)

        self.SetSizer(sizer)
        sizer.Fit(self)
    def __init__(
            self, parent, ID, title, size=wx.DefaultSize, pos=wx.DefaultPosition, 
            style=wx.DEFAULT_DIALOG_STYLE
            ):

        
        self.frame = parent
        self.app = parent.app
        self.document = self.app.document
        self.sheet = self.app.document.sheet
        
        self.choices = self.document.logs.keys()
        
        #Set the values that will store the result of the dialog
        self.logid = self.choices[0]
        self.choice = 0 #0-all, 1- from-to, 2-list
        self.slice = slice(0, sys.maxint) # the result if self.choice is 1
        self.list = [] #A list of numbers, used if self.choice is 2
        
        #Create the dialog
        pre = wx.PreDialog()
        pre.Create(parent, ID, title, pos, size, style)
        self.PostCreate(pre)

        sizer = wx.BoxSizer(wx.VERTICAL)

        box = wx.BoxSizer(wx.HORIZONTAL)
        label = wx.StaticText(self, -1, "Choose log:")
        box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
        def from_logch(val):
            print '--------->',val
            self.logid = val
        self.logch = wx.Choice(self, -1, choices = self.choices, validator =\
                               MyValidator(getvalue = wx.Choice.GetStringSelection,\
                                           fromfunc = from_logch))
        self.logch.Select(0)
        box.Add(self.logch, 1, wx.ALIGN_CENTRE|wx.ALL, 5)
        sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
        
        box = wx.BoxSizer(wx.HORIZONTAL)

        def RbValidator(num):
            """A validator for the radio buttons"""
            def from_rb(val):
                if val is not None:
                    self.choice = val

            return MyValidator(getvalue = lambda wnd: ifelse(wx.RadioButton.GetValue(wnd),num, None),
                               fromfunc = from_rb)
        
        self.rbAll = wx.RadioButton(self, -1, "All", style = wx.RB_GROUP, validator=RbValidator(0))
        box.Add(self.rbAll, 1, wx.ALL|wx.ALIGN_CENTER,5)
        sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL,0)
        
        box = wx.BoxSizer(wx.HORIZONTAL)
        def from_FromTo(b):
            def f(val):
                if b:
                    self.slice = slice(default(lambda:int(val),0), self.slice.stop)
                else:
                    self.slice = slice(self.slice.start, default(lambda:int(val), sys.maxint))
            return f
        
        self.rbFrom = wx.RadioButton(self, -1, "From:", validator=RbValidator(1))
        box.Add(self.rbFrom,0,wx.ALL,5)
        self.txFrom = wx.TextCtrl(self, -1, '0', validator =\
                                  TextValidator(FILTER_NUMERIC, fromfunc = from_FromTo(True)))
        self.txFrom.Disable()
        box.Add(self.txFrom,1,wx.ALL,5)
        self.lbTo = wx.StaticText(self, -1, 'To:')
        self.lbTo.Disable()
        box.Add(self.lbTo,0,wx.ALL,5)
        self.txTo = wx.TextCtrl(self, -1, 'TODO', validator =\
                                TextValidator(FILTER_NUMERIC, fromfunc=from_FromTo(False)))
        self.txTo.Disable()
        box.Add(self.txTo, 1,wx.ALL,5)
        sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL,0)
        
        box = wx.BoxSizer(wx.HORIZONTAL)

        def from_List(val):
            self.list = [int(x) for x in val.split(',') if x != '']
        
        self.rbList = wx.RadioButton(self, -1, "List:", validator = RbValidator(2))
        box.Add(self.rbList, 0, wx.ALL,5)
        self.txList = wx.TextCtrl(self, -1, '', validator =\
            TextValidator(filter = lambda v:v==',' or FILTER_NUMERIC(v),\
                          fromfunc = from_List))

        self.txList.Disable()
        box.Add(self.txList, 1, wx.ALL, 5)
        sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL,0)

        line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL)
        sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5)

        btnsizer = wx.StdDialogButtonSizer()
        btn = wx.Button(self, wx.ID_OK)
        btn.SetDefault()
        btnsizer.AddButton(btn)
        btn = wx.Button(self, wx.ID_CANCEL)
        btnsizer.AddButton(btn)
        btnsizer.Realize()

        sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)

        self.SetSizer(sizer)
        sizer.Fit(self)
        
        
        #Now set up the events
        self.rbAll.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton)
        self.rbFrom.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton)
        self.rbList.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton)
Exemple #8
0
 def __init__(self, parent):
     pre = wx.PreDialog()
     self.res = xrc.XmlResource('XRC/dlgPreferences.xrc')
     self.res.LoadOnDialog(pre, parent, 'dlgPreferences')
     self.PostCreate(pre)
     self.Bind(wx.EVT_INIT_DIALOG, self.OnCreate)
Exemple #9
0
    def __init__(self, parent_, Prj_=None, Default_=None):
        """
        Конструктор.
        @param parent_: Родительское окно.
        @param Prj_: Объект проекта.
        @param Default_: Список паспортов по умолчанию.
        """
        try:
            _title = u'Определение паспортов объектов'

            pre = wx.PreDialog()
            pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
            pre.Create(parent_,
                       -1,
                       title=_title,
                       pos=wx.DefaultPosition,
                       size=wx.Size(800, 400))

            # This next step is the most important, it turns this Python
            # object into the real wrapper of the dialog (instead of pre)
            # as far as the wxPython extension is concerned.
            self.PostCreate(pre)

            icon_img = ic_bmp.getSysImg('imgEdtPassport')
            if icon_img:
                icon = wx.IconFromBitmap(icon_img)
                self.SetIcon(icon)

            self._boxsizer = wx.BoxSizer(wx.VERTICAL)

            self._button_boxsizer = wx.BoxSizer(wx.HORIZONTAL)

            # Кнопка -OK-
            id_ = wx.NewId()
            self._ok_button = wx.Button(self, id_, u'OK', size=wx.Size(-1, -1))
            self.Bind(wx.EVT_BUTTON, self.OnOK, id=id_)
            # Кнопка -Отмена-
            id_ = wx.NewId()
            self._cancel_button = wx.Button(self,
                                            id_,
                                            u'Отмена',
                                            size=wx.Size(-1, -1))
            self.Bind(wx.EVT_BUTTON, self.OnCancel, id=id_)

            self._button_boxsizer.Add(self._cancel_button, 0,
                                      wx.ALIGN_CENTRE | wx.ALL, 10)
            self._button_boxsizer.Add(self._ok_button, 0,
                                      wx.ALIGN_CENTRE | wx.ALL, 10)

            self._psp_list_panel = icPassportListPanel(self, Prj_)
            # Если надо то установить редатируемый список паспортов
            if Default_:
                self._psp_list_panel.SetPassportList(Default_)

            self._boxsizer.Add(self._psp_list_panel, 1, wx.EXPAND | wx.GROW, 0)
            self._boxsizer.Add(self._button_boxsizer, 0, wx.ALIGN_RIGHT, 10)

            self.SetSizer(self._boxsizer)
            self.SetAutoLayout(True)
        except:
            log.fatal(
                u'Ошибка создания объекта диалогового окна выбора списка паспортов объектов'
            )
Exemple #10
0
    def __init__(self,
                 parent=None,
                 ID=-1,
                 title="InVesalius 3",
                 size=wx.DefaultSize,
                 pos=wx.DefaultPosition,
                 style=wx.DEFAULT_DIALOG_STYLE,
                 useMetal=False):
        import constants as const
        import data.mask as mask
        import project as prj

        # Instead of calling wx.Dialog.__init__ we precreate the dialog
        # so we can set an extra style that must be set before
        # creation, and then we create the GUI object using the Create
        # method.
        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        pre.Create(parent, ID, title, pos, (500,300), style)

        # This next step is the most important, it turns this Python
        # object into the real wrapper of the dialog (instead of pre)
        # as far as the wxPython extension is concerned.
        self.PostCreate(pre)

        self.CenterOnScreen()

        # This extra style can be set after the UI object has been created.
        if 'wxMac' in wx.PlatformInfo and useMetal:
            self.SetExtraStyle(wx.DIALOG_EX_METAL)

        self.CenterOnScreen()

        # LINE 1: Surface name

        label_mask = wx.StaticText(self, -1, _("New mask name:"))

        default_name =  const.MASK_NAME_PATTERN %(mask.Mask.general_index+2)
        text = wx.TextCtrl(self, -1, "", size=(80,-1))
        text.SetHelpText(_("Name the mask to be created"))
        text.SetValue(default_name)
        self.text = text

        # LINE 2: Threshold of reference

        # Informative label
        label_thresh = wx.StaticText(self, -1, _("Threshold preset:"))

        # Retrieve existing masks
        project = prj.Project()
        thresh_list = project.threshold_modes.keys()
        thresh_list.sort()
        default_index = thresh_list.index(_("Bone"))
        self.thresh_list = thresh_list

        # Mask selection combo
        combo_thresh = wx.ComboBox(self, -1, "", choices= self.thresh_list,
                                 style=wx.CB_DROPDOWN|wx.CB_READONLY)
        combo_thresh.SetSelection(default_index)
        if sys.platform != 'win32':
            combo_thresh.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
        self.combo_thresh = combo_thresh

        # LINE 3: Gradient
        bound_min, bound_max = project.threshold_range
        thresh_min, thresh_max = project.threshold_modes[_("Bone")]
        original_colour = random.choice(const.MASK_COLOUR)
        self.colour = original_colour
        colour = [255*i for i in original_colour] 
        colour.append(100)
        gradient = grad.GradientSlider(self, -1, int(bound_min),
                                        int(bound_max),
                                        int(thresh_min), int(thresh_max),
                                        colour)
        self.gradient = gradient

        # OVERVIEW
        # Sizer that joins content above
        flag_link = wx.EXPAND|wx.GROW|wx.ALL
        flag_button = wx.ALL | wx.EXPAND| wx.GROW

        fixed_sizer = wx.FlexGridSizer(rows=2, cols=2, hgap=10, vgap=10)
        fixed_sizer.AddGrowableCol(0, 1)
        fixed_sizer.AddMany([ (label_mask, 1, flag_link, 5),
                              (text, 1, flag_button, 2),
                              (label_thresh, 1, flag_link, 5),
                              (combo_thresh, 0, flag_button, 1)])#,
                              #(label_quality, 1, flag_link, 5),
                              #(combo_quality, 0, flag_button, 1)])

        # LINE 6: Buttons

        btn_ok = wx.Button(self, wx.ID_OK)
        btn_ok.SetDefault()
        btn_cancel = wx.Button(self, wx.ID_CANCEL)

        btnsizer = wx.StdDialogButtonSizer()
        btnsizer.AddButton(btn_ok)
        btnsizer.AddButton(btn_cancel)
        btnsizer.Realize()

        # OVERVIEW
        # Merge all sizers and checkboxes
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(fixed_sizer, 0, wx.ALL|wx.GROW|wx.EXPAND, 15)
        sizer.Add(gradient, 1, wx.BOTTOM|wx.RIGHT|wx.LEFT|wx.EXPAND|wx.GROW, 20)
        sizer.Add(btnsizer, 0, wx.ALIGN_RIGHT|wx.BOTTOM, 10)

        self.SetSizer(sizer)
        sizer.Fit(self)

        self.Bind(grad.EVT_THRESHOLD_CHANGED, self.OnSlideChanged, self.gradient)
        self.combo_thresh.Bind(wx.EVT_COMBOBOX, self.OnComboThresh)
Exemple #11
0
    def __init__(self, parent=None, ID=-1, title="InVesalius 3", size=wx.DefaultSize,
            pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE,
            useMetal=False):
        import constants as const
        import data.surface as surface
        import project as prj

        # Instead of calling wx.Dialog.__init__ we precreate the dialog
        # so we can set an extra style that must be set before
        # creation, and then we create the GUI object using the Create
        # method.
        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        pre.Create(parent, ID, title, pos, (500,300), style)

        # This next step is the most important, it turns this Python
        # object into the real wrapper of the dialog (instead of pre)
        # as far as the wxPython extension is concerned.
        self.PostCreate(pre)

        self.CenterOnScreen()

        # This extra style can be set after the UI object has been created.
        if 'wxMac' in wx.PlatformInfo and useMetal:
            self.SetExtraStyle(wx.DIALOG_EX_METAL)

        self.CenterOnScreen()

        # LINE 1: Surface name

        label_surface = wx.StaticText(self, -1, _("New surface name:"))

        default_name =  const.SURFACE_NAME_PATTERN %(surface.Surface.general_index+2)
        text = wx.TextCtrl(self, -1, "", size=(80,-1))
        text.SetHelpText(_("Name the surface to be created"))
        text.SetValue(default_name)
        self.text = text

        # LINE 2: Mask of reference

        # Informative label
        label_mask = wx.StaticText(self, -1, _("Mask of reference:"))

        # Retrieve existing masks
        project = prj.Project()
        index_list = project.mask_dict.keys()
        index_list.sort()
        self.mask_list = [project.mask_dict[index].name for index in index_list]


        # Mask selection combo
        combo_mask = wx.ComboBox(self, -1, "", choices= self.mask_list,
                                     style=wx.CB_DROPDOWN|wx.CB_READONLY)
        combo_mask.SetSelection(len(self.mask_list)-1)
        if sys.platform != 'win32':
            combo_mask.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
        self.combo_mask = combo_mask

        # LINE 3: Surface quality
        label_quality = wx.StaticText(self, -1, _("Surface quality:"))

        choices =  const.SURFACE_QUALITY_LIST
        style = wx.CB_DROPDOWN|wx.CB_READONLY
        combo_quality = wx.ComboBox(self, -1, "",
                                    choices= choices,
                                    style=style)
        combo_quality.SetSelection(3)
        if sys.platform != 'win32':
            combo_quality.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
        self.combo_quality = combo_quality


        # OVERVIEW
        # Sizer that joins content above
        flag_link = wx.EXPAND|wx.GROW|wx.ALL
        flag_button = wx.ALL | wx.EXPAND| wx.GROW

        fixed_sizer = wx.FlexGridSizer(rows=2, cols=2, hgap=10, vgap=0)
        fixed_sizer.AddGrowableCol(0, 1)
        fixed_sizer.AddMany([ (label_surface, 1, flag_link, 5),
                              (text, 1, flag_button, 2),
                              (label_mask, 1, flag_link, 5),
                              (combo_mask, 0, flag_button, 1),
                              (label_quality, 1, flag_link, 5),
                              (combo_quality, 0, flag_button, 1)])


        # LINES 4 and 5: Checkboxes
        check_box_holes = wx.CheckBox(self, -1, _("Fill holes"))
        check_box_holes.SetValue(True)
        self.check_box_holes = check_box_holes
        check_box_largest = wx.CheckBox(self, -1, _("Keep largest region"))
        self.check_box_largest = check_box_largest

        # LINE 6: Buttons

        btn_ok = wx.Button(self, wx.ID_OK)
        btn_ok.SetDefault()
        btn_cancel = wx.Button(self, wx.ID_CANCEL)

        btnsizer = wx.StdDialogButtonSizer()
        btnsizer.AddButton(btn_ok)
        btnsizer.AddButton(btn_cancel)
        btnsizer.Realize()

        # OVERVIEW
        # Merge all sizers and checkboxes
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(fixed_sizer, 0, wx.TOP|wx.RIGHT|wx.LEFT|wx.GROW|wx.EXPAND, 20)
        sizer.Add(check_box_holes, 0, wx.RIGHT|wx.LEFT, 30)
        sizer.Add(check_box_largest, 0, wx.RIGHT|wx.LEFT, 30)
        sizer.Add(btnsizer, 0, wx.ALIGN_RIGHT|wx.ALL, 10)

        self.SetSizer(sizer)
        sizer.Fit(self)
    def __init__(
        self,
        parent,
        ID,
        title,
        size=wx.DefaultSize,
        pos=wx.DefaultPosition,
        style=wx.DEFAULT_DIALOG_STYLE,
    ):

        # Instead of calling wx.Dialog.__init__ we precreate the dialog
        # so we can set an extra style that must be set before
        # creation, and then we create the GUI object using the Create
        # method.
        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        pre.Create(parent, ID, title, pos, size, style)

        # This next step is the most important, it turns this Python
        # object into the real wrapper of the dialog (instead of pre)
        # as far as the wxPython extension is concerned.
        self.PostCreate(pre)

        # Now continue with the normal construction of the dialog
        # contents
        sizer = wx.BoxSizer(wx.VERTICAL)

        label = wx.StaticText(self, -1, u"Aliyun.com OSS 连接信息")
        sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, "Access_id:")
        label.SetHelpText("access_id like 'nf2vweubkp3wczejft46s5q4'")
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        self.access_id = text = wx.TextCtrl(self, -1, "", size=(180, -1))
        text.SetHelpText("access_id like 'nf2vweubkp3wczejft46s5q4'")
        box.Add(text, 1, wx.ALIGN_CENTRE | wx.ALL, 5)

        sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, "Access_key:")
        label.SetHelpText(
            "secret_access_key like '24Z0v2ac9a2bZTMHdS2w2HbcNvI='")
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        self.access_key = text = wx.TextCtrl(self, -1, "", size=(180, -1))
        text.SetHelpText(label.GetHelpText())
        box.Add(text, 1, wx.ALIGN_CENTRE | wx.ALL, 5)

        sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, "Default Host:")
        label.SetHelpText("Default host is storage.aliyun.com")
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        self.host = text = wx.TextCtrl(self, -1, "", size=(180, -1))
        text.SetHelpText(label.GetHelpText())
        text.SetValue("storage.aliyun.com")
        box.Add(text, 1, wx.ALIGN_CENTRE | wx.ALL, 5)

        sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        self.chk_save = wx.CheckBox(self, -1, u"保存验证信息 -- (简单加密保存为本地文件)")
        self.chk_save.SetValue(True)

        sizer.Add(self.chk_save, 0, wx.GROW | wx.LEFT, 10)

        line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL)
        sizer.Add(line, 0,
                  wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP, 5)

        btnsizer = wx.StdDialogButtonSizer()

        if wx.Platform != "__WXMSW__":
            btn = wx.ContextHelpButton(self)
            btnsizer.AddButton(btn)

        btn = wx.Button(self, wx.ID_OK, u' 确 定 ')
        btn.SetHelpText("The OK button completes the dialog")
        btn.SetDefault()
        btnsizer.AddButton(btn)

        btn = wx.Button(self, wx.ID_CANCEL, u' 取 消 ')
        btn.SetHelpText("The Cancel button cancels the dialog. (Cool, huh?)")
        btnsizer.AddButton(btn)
        btnsizer.Realize()

        sizer.Add(
            btnsizer, 0,
            wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTRE_HORIZONTAL | wx.ALL, 5)

        self.SetSizer(sizer)
        sizer.Fit(self)
        self.Center()
Exemple #13
0
 def __init__(self):
     pre = wx.PreDialog()
     self.PostCreate(pre)
     pub.subscribe(self.patient_data_updated, "patient.loaded")
     pub.sendMessage("patient.request", {})
Exemple #14
0
    def __init__(self, parent):
        # Instead of calling wx.Dialog.__init__ we precreate the dialog
        # so we can set an extra style that must be set before
        # creation, and then we create the GUI object using the Create
        # method.
        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        pre.Create(parent,
                   -1,
                   mtexts.txts['SecondaryDirs'],
                   pos=wx.DefaultPosition,
                   size=wx.DefaultSize,
                   style=wx.DEFAULT_DIALOG_STYLE)

        # This next step is the most important, it turns this Python
        # object into the real wrapper of the dialog (instead of pre)
        # as far as the wxPython extension is concerned.
        self.PostCreate(pre)

        #main vertical sizer
        mvsizer = wx.BoxSizer(wx.VERTICAL)
        #main horizontal sizer
        mhsizer = wx.BoxSizer(wx.HORIZONTAL)

        #Age
        sage = wx.StaticBox(self, label=mtexts.txts['Age'])
        agesizer = wx.StaticBoxSizer(sage, wx.VERTICAL)
        self.age = wx.TextCtrl(self,
                               -1,
                               '',
                               validator=intvalidator.IntValidator(0, 100),
                               size=(40, -1))
        agesizer.Add(self.age, 0, wx.ALIGN_CENTER | wx.ALL, 5)
        self.age.SetMaxLength(2)

        mhsizer.Add(agesizer, 1, wx.GROW | wx.ALIGN_LEFT | wx.LEFT, 0)

        #Direction
        sdir = wx.StaticBox(self, label='')
        dirsizer = wx.StaticBoxSizer(sdir, wx.VERTICAL)
        vsizer = wx.BoxSizer(wx.VERTICAL)
        self.directrb = wx.RadioButton(self,
                                       -1,
                                       mtexts.txts['Direct'],
                                       style=wx.RB_GROUP)
        vsizer.Add(self.directrb, 0, wx.ALIGN_LEFT | wx.TOP, 2)
        self.converserb = wx.RadioButton(self, -1, mtexts.txts['Converse'])
        vsizer.Add(self.converserb, 0, wx.ALIGN_LEFT | wx.TOP, 2)

        dirsizer.Add(vsizer, 0, wx.ALIGN_LEFT | wx.ALL, 5)

        mhsizer.Add(dirsizer, 1, wx.GROW | wx.ALIGN_LEFT | wx.LEFT, 5)
        mvsizer.Add(mhsizer, 1,
                    wx.GROW | wx.ALIGN_CENTER | wx.TOP | wx.LEFT | wx.RIGHT, 5)

        #Time
        stime = wx.StaticBox(self, label='')
        timesizer = wx.StaticBoxSizer(stime, wx.VERTICAL)
        vsizer = wx.BoxSizer(wx.VERTICAL)
        self.solartimerb = wx.RadioButton(self,
                                          -1,
                                          mtexts.txts['ApparentSolarTime'],
                                          style=wx.RB_GROUP)
        vsizer.Add(self.solartimerb, 0, wx.ALIGN_LEFT | wx.TOP, 2)
        self.meantimerb = wx.RadioButton(self, -1, mtexts.txts['MeanTime'])
        vsizer.Add(self.meantimerb, 0, wx.ALIGN_LEFT | wx.TOP, 2)
        timesizer.Add(vsizer, 0, wx.ALIGN_LEFT | wx.ALL, 5)

        mvsizer.Add(timesizer, 0,
                    wx.GROW | wx.ALIGN_CENTER | wx.LEFT | wx.RIGHT | wx.BOTTOM,
                    5)

        btnsizer = wx.StdDialogButtonSizer()

        if wx.Platform != '__WXMSW__':
            btn = wx.ContextHelpButton(self)
            btnsizer.AddButton(btn)

        btnOk = wx.Button(self, wx.ID_OK, mtexts.txts['Ok'])
        btnsizer.AddButton(btnOk)
        btnOk.SetHelpText(mtexts.txts['HelpOk'])
        btnOk.SetDefault()

        self.Bind(wx.EVT_BUTTON, self.onOK, id=wx.ID_OK)

        btn = wx.Button(self, wx.ID_CANCEL, mtexts.txts['Cancel'])
        btnsizer.AddButton(btn)
        btn.SetHelpText(mtexts.txts['HelpCancel'])

        btnsizer.Realize()

        mvsizer.Add(btnsizer, 0, wx.GROW | wx.ALL, 10)
        self.SetSizer(mvsizer)
        mvsizer.Fit(self)

        btnOk.SetFocus()
Exemple #15
0
    def __init__(self, parent=None, id=-1, component={}, logType=0,
                 evalSpace=None, bCounter=False, progressDlg=None, *arg, **kwarg):
        """
        Конструктор для создания icDialog.
        @type parent: C{wxWindow}
        @param parent: Указатель на родительское окно.
        @type id: C{int}
        @param id: Идентификатор окна.
        @type component: C{dictionary}
        @param component: Словарь описания компонента.
        @type logType: C{int}
        @param logType: Тип лога (0 - консоль, 1- файл, 2- окно лога).
        @param evalSpace: Пространство имен, необходимых для вычисления внешних выражений.
        @type evalSpace: C{dictionary}
        """
        #   Атрибуты сайзера
        self.sizer = None
        self.bSizerAdd = False
        self.title = None

        util.icSpcDefStruct(SPC_IC_DIALOG, component)
        icWidget.__init__(self, parent, id, component, logType, evalSpace)

        self.title = self.getTitle()
        pos = component['position']
        self.size = component['size']
        fgr = component['foregroundColor']
        bgr = component['backgroundColor']
        self.style = style = component['style'] | wx.WANTS_CHARS
        self.on_close = component['onClose']
        self.set_focus = component['setFocus']
        self.kill_focus = component['killFocus']
        icon = component['icon']

        #   Флаг, указывающий, что необходимо сохранять изменяющиеся
        #   параметры окна (позицию и размеры).
        self.saveChangeProperty = True

        #   Читаем расположение и размеры диалога из файла настроек пользователя
        _pos = self.LoadUserProperty('position')
        _size = self.LoadUserProperty('size')

        if _pos:
            pos = _pos

        if pos[0] > 1000:
            pos[0] = -1
        if pos[1] > 1000:
            pos[1] = -1

        if _size:
            self.size = _size

        # Буфер результата работы с формой
        self.__result_buff = None

        # wx.Dialog.__init__(self, parent, id, self.title, pos, self.size, style = style, name = self.name)
        # Instead of calling wxDialog.__init__ we precreate the dialog
        # so we can set an extra style that must be set before
        # creation, and then we create the GUI dialog using the Create
        # method.

        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        pre.Create(parent, id, self.title, pos, self.size, style, self.name)

        # This next step is the most important, it turns this Python
        # object into the real wrapper of the dialog (instead of pre)
        # as far as the wxPython extension is concerned.
        self.this = pre.this

        if icon:
            icon_img = util.ic_eval(icon, evalSpace=self.evalSpace)
            if icon_img:
                icon = wx.IconFromBitmap(icon_img)
                self.SetIcon(icon)

        self.Show(False)
        #   Признак разрушения дочерних элементов
        self._bChildsDestroied = False

        if fgr is not None:
            self.SetForegroundColour(wx.Colour(fgr[0], fgr[1], fgr[2]))

        if bgr is not None:
            self.SetBackgroundColour(wx.Colour(bgr[0], bgr[1], bgr[2]))

        self.SetAutoLayout(True)

        self.Bind(wx.EVT_CLOSE, self.OnClose)
        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_SET_FOCUS, self.OnSetFocus)
        self.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus)
        self.BindICEvt()

        #   Создаем дочерние компоненты
        self.Freeze()
        self.childCreator(bCounter, progressDlg)
        self.Thaw()
        
        if component.get('show', '1') in ('True', 'true', 1):
            self.Show(True)

        if component.get('fit', None):
            self.Fit()
    def __init__(self, parent, username, password, connector):
        # context help
        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        pre.Create(parent,
                   -1,
                   message('login_title') + ' - ' + connector.name(),
                   size=(420, 420))
        self.PostCreate(pre)

        self.m_username = username
        self.m_password = password
        self.m_connector = connector

        wx.EVT_SIZE(self, self.OnSize)

        sizer = wx.BoxSizer(wx.VERTICAL)

        # info
        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, connector.desc())
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        sizer.AddSizer(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        # username
        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, message('login_username'))
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        self.wxUsernameCtrl = wx.TextCtrl(self,
                                          -1,
                                          self.m_username,
                                          size=(180, -1))
        box.Add(self.wxUsernameCtrl, 1, wx.ALIGN_CENTRE | wx.ALL, 5)

        sizer.AddSizer(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        # password
        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, message('login_password'))
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        self.wxPasswordCtrl = wx.TextCtrl(self,
                                          -1,
                                          self.m_password,
                                          size=(180, -1))
        box.Add(self.wxPasswordCtrl, 1, wx.ALIGN_CENTRE | wx.ALL, 5)

        sizer.AddSizer(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        # OK and Cancel
        box = wx.BoxSizer(wx.HORIZONTAL)

        # context help
        if wx.Platform != "__WXMSW__":
            btn = wx.ContextHelpButton(self)
            box.Add(btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        # OK
        btn = wx.Button(self, wx.ID_OK, message('login_set'))
        btn.SetDefault()
        btn.SetHelpText(message('login_setdesc'))
        box.Add(btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        wx.EVT_BUTTON(self, wx.ID_OK, self.OnValid)

        # TEST
        btn = wx.Button(self, wx.ID_REFRESH, message('login_test'))
        btn.SetHelpText(message('login_testdesc'))
        box.Add(btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        wx.EVT_BUTTON(self, wx.ID_REFRESH, self.OnTest)

        # CANCEL
        btn = wx.Button(self, wx.ID_CANCEL, message('cancel'))
        btn.SetHelpText(message('cancel_desc'))
        box.Add(btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        sizer.AddSizer(box, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        self.SetAutoLayout(True)
        self.SetSizerAndFit(sizer)
Exemple #17
0
    def __init__(self, parent, id, editor, sound):
        pre = wx.PreDialog()
        self.res = xrc.XmlResource(DIALOG_RESOURCE_FILE)
        self.res.LoadOnDialog(pre, parent, 'dlgSoundEdit')
        #self.res.LoadOnDialog(pre, parent, 'test')
        self.PostCreate(pre)
        
        self.sound = sound
        self.editor = editor
        self.animlist = []
        
        self.ok = False
        
        self.currentName = xrc.XRCCTRL(self, 'lblCurrentName')
        self.textNewName = xrc.XRCCTRL(self, 'txtNewName')
        self.chkLoop = xrc.XRCCTRL(self, 'chkLoop')
        self.spinPlayCount = xrc.XRCCTRL(self, 'spinPlayCount')
        self.slVolume = xrc.XRCCTRL(self, 'slVolume')
        self.txtVolume = xrc.XRCCTRL(self, 'txtVolume')
        self.slBalance = xrc.XRCCTRL(self, 'slBalance')
        self.btnPlay = xrc.XRCCTRL(self, 'btnPlay')
        self.btnStop = xrc.XRCCTRL(self, "btnStop")
        self.btnChangeName = xrc.XRCCTRL(self, 'btnChangeName')
        self.btnOk = xrc.XRCCTRL(self, 'btnOk')
        self.btnCancel = xrc.XRCCTRL(self, 'btnCancel')
        
        self.btnAddPlay = xrc.XRCCTRL(self, 'btnAddPlay')
        self.btnAddPlay.Bind(wx.EVT_BUTTON, self.onAdd)
        self.btnRemovePlay = xrc.XRCCTRL(self, 'btnRemovePlay')
        self.btnRemovePlay.Bind(wx.EVT_BUTTON, self.onRemove)
        self.chkBg = xrc.XRCCTRL(self, 'chkBg')
        self.chkBg.Bind(wx.EVT_CHECKBOX, self.setBg)
        
        self.actorList, self.actorName = self.editor.objectMgr.findObjectsByAssetRName("actor")
        
        self.dropActor = xrc.XRCCTRL(self, 'dropActor')
        self.dropActor.Bind(wx.EVT_COMBOBOX, self.getActorList)
        self.dropActor.SetItems(self.actorName)
        
        self.dropAnim = xrc.XRCCTRL(self, 'dropAnimation')
        self.dropAnim.Bind(wx.EVT_COMBOBOX, self.getAnimList)
        
        self.playwithlist = xrc.XRCCTRL(self, 'playwithlist')
        self.playwithlist.InsertColumn(0, "Actor")
        self.playwithlist.SetColumnWidth(0, 100)
        self.playwithlist.InsertColumn(1, "Animation")
        self.playwithlist.SetColumnWidth(1, 150)
        i=0
        if self.sound.anims != []:
            for n in self.sound.anims:
                pos = self.playwithlist.GetItemCount()
                self.playwithlist.InsertStringItem(pos, self.sound.actors[i])
                self.playwithlist.SetStringItem(pos, 1, n)
                self.animlist.append(n)
                i=i+1
                       
        
        self.currentName.SetLabel(self.sound.name)
        
        self.sliders = [self.slVolume]
        self.textValueBoxes = [ self.txtVolume]
        
        self.txtVolume.SetValue(str((self.sound.getVolume() * 100.0)))
        self.slVolume.SetValue(int(self.sound.getVolume() * 100.0))
 
        self.chkLoop.SetValue(self.sound.getLoop())
        self.spinPlayCount.SetValue(int(self.sound.getLoopCount()))
        
        
        self.origVolume = self.sound.getVolume()
        self.origName = self.currentName.GetLabel()
        self.origLoop = self.sound.getLoop()
        self.origLoopCount = self.sound.getLoopCount()
        
        self.chkLoop.Bind(wx.EVT_CHECKBOX, self.onLoop)
        self.spinPlayCount.Bind(wx.EVT_SPINCTRL, self.onLoopCount)
        self.spinPlayCount.Bind(wx.EVT_TEXT, self.onLoopCount)
        self.slVolume.Bind(wx.EVT_SLIDER, self.onSliderVolume )
        self.txtVolume.Bind(wx.EVT_TEXT_ENTER, self.onTextVolume)
        self.btnChangeName.Bind(wx.EVT_BUTTON, self.onChangeName)
        self.btnCancel.Bind(wx.EVT_BUTTON, self.onCancel)
        self.btnOk.Bind(wx.EVT_BUTTON, self.onOk)
        self.btnPlay.Bind(wx.EVT_BUTTON, self.onPlay)
        self.btnStop.Bind(wx.EVT_BUTTON, self.onStop)
        
        # Keep the editor from binding the keys
        base.le.ui.bindKeyEvents(False)
Exemple #18
0
 def __init__(self, parent):
     pre = wx.PreDialog()
     self.parent = parent
     parent._resources.LoadOnDialog(pre, parent, "dont_touch_d")
     self.PostCreate(pre)
     self.Fit()
Exemple #19
0
    def __init__(
            self, parent, ID, title, size=wx.DefaultSize, pos=wx.DefaultPosition, 
            style=wx.DEFAULT_DIALOG_STYLE):

        pre = wx.PreDialog()
        #pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        pre.Create(parent, ID, title, pos, size, style)
        self.PostCreate(pre)
        #生成修改面板
        #self = wx.Frame(parent=None,title=u'档案修改',size=(450,370))
        #生成GridBagSizer布局管理器
        modify_archives_gridBagSizer = wx.GridBagSizer(vgap=5,hgap=5)
        #生成文本标签
        modify_archives_menleiText = wx.StaticText(parent=self,label=u"门        类:",style=wx.ALIGN_CENTER_VERTICAL)
        #add_archives_jibieText = wx.StaticText(parent=self.add_archives_panel,label=u"级别:",style=wx.ALIGN_CENTER_HORIZONTAL)
        modify_archives_guidangText = wx.StaticText(parent=self,label=u"归        档:",style=wx.ALIGN_CENTER_VERTICAL)
        modify_archives_qixianText = wx.StaticText(parent=self,label=u"期        限:",style=wx.wx.ALIGN_CENTER_VERTICAL)
        modify_archives_anjuantimingText = wx.StaticText(parent=self,label=u"案卷题名:",style=wx.wx.ALIGN_CENTER_VERTICAL)
        modify_archives_danweiText = wx.StaticText(parent=self,label=u"单        位:",style=wx.wx.ALIGN_CENTER_VERTICAL)
        modify_archives_lijuanriqiText = wx.StaticText(parent=self,label=u"立卷日期:",style=wx.wx.ALIGN_CENTER_VERTICAL)
        modify_archives_weizhiText = wx.StaticText(parent=self,label=u"位        置:",style=wx.wx.ALIGN_CENTER_VERTICAL)
        modify_archives_mijiText = wx.StaticText(parent=self,label=u"密        级:",style=wx.wx.ALIGN_CENTER_VERTICAL)
        modify_archives_zerenrenText = wx.StaticText(parent=self,label=u"责  任  人:",style=wx.wx.ALIGN_CENTER_VERTICAL)
        modify_archives_quhaoText = wx.StaticText(parent=self,label=u"区        号:",style=wx.wx.ALIGN_CENTER_VERTICAL)
        modify_archives_guihaoText = wx.StaticText(parent=self,label=u"柜        号:",style=wx.wx.ALIGN_CENTER_VERTICAL)
        modify_archives_hehaoText = wx.StaticText(parent=self,label=u"盒        号:",style=wx.wx.ALIGN_CENTER_VERTICAL)
        modify_archives_juanhaoText = wx.StaticText(parent=self,label=u"卷        号:",style=wx.wx.ALIGN_CENTER_VERTICAL)
        modify_archives_hujianhaoText = wx.StaticText(parent=self,label=u"互  见  号:",style=wx.wx.ALIGN_CENTER_VERTICAL)
        modify_archives_kemuText = wx.StaticText(parent=self,label=u"科        目:",style=wx.wx.ALIGN_CENTER_VERTICAL)
        modify_archives_beizhuText = wx.StaticText(parent=self,label=u"备        注:",style=wx.wx.ALIGN_CENTER_VERTICAL)
        modify_archives_inputterText = wx.StaticText(parent=self,label=u"录  入  人:",style=wx.wx.ALIGN_CENTER_VERTICAL)
        modify_archives_font = wx.Font(pointSize=9,family=wx.ROMAN,style=wx.NORMAL,weight=wx.BOLD)
        modify_archives_menleiText.SetFont(modify_archives_font)
        #add_archives_jibieText.SetFont(modify_archives_font)
        modify_archives_guidangText.SetFont(modify_archives_font)
        modify_archives_qixianText.SetFont(modify_archives_font)
        modify_archives_anjuantimingText.SetFont(modify_archives_font)
        modify_archives_danweiText.SetFont(modify_archives_font)
        modify_archives_lijuanriqiText.SetFont(modify_archives_font)
        modify_archives_weizhiText.SetFont(modify_archives_font)
        modify_archives_mijiText.SetFont(modify_archives_font)
        modify_archives_zerenrenText.SetFont(modify_archives_font)
        modify_archives_quhaoText.SetFont(modify_archives_font)
        modify_archives_guihaoText.SetFont(modify_archives_font)
        modify_archives_hehaoText.SetFont(modify_archives_font)
        modify_archives_juanhaoText.SetFont(modify_archives_font)
        modify_archives_hujianhaoText.SetFont(modify_archives_font)
        modify_archives_kemuText.SetFont(modify_archives_font)
        modify_archives_beizhuText.SetFont(modify_archives_font)
        modify_archives_inputterText.SetFont(modify_archives_font)
        
        #将文本标签纳入add_archives_gridBagSizer布局管理器中
        modify_archives_gridBagSizer.Add(modify_archives_menleiText,pos=(0,0),flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.TOP,border=15)
        #add_archives_gridBagSizer.Add(modify_archives_jibieText,pos=(1,0),flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT)
        modify_archives_gridBagSizer.Add(modify_archives_guidangText,pos=(1,0),flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT)
        modify_archives_gridBagSizer.Add(modify_archives_anjuantimingText,pos=(2,0),flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT)
        modify_archives_gridBagSizer.Add(modify_archives_qixianText,pos=(3,0),flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT)
        modify_archives_gridBagSizer.Add(modify_archives_danweiText,pos=(4,0),flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT)
        modify_archives_gridBagSizer.Add(modify_archives_lijuanriqiText,pos=(5,0),flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT)
        modify_archives_gridBagSizer.Add(modify_archives_weizhiText,pos=(6,0),flag=wx.wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT)
        modify_archives_gridBagSizer.Add(modify_archives_mijiText,pos=(7,0),flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT)
        modify_archives_gridBagSizer.Add(modify_archives_zerenrenText,pos=(8,0),flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT)
        
        modify_archives_gridBagSizer.Add(modify_archives_quhaoText,pos=(0,2),flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.TOP,border=15)
        modify_archives_gridBagSizer.Add(modify_archives_guihaoText,pos=(1,2),flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT)
        modify_archives_gridBagSizer.Add(modify_archives_hehaoText,pos=(2,2),flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT)
        modify_archives_gridBagSizer.Add(modify_archives_juanhaoText,pos=(3,2),flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT)
        modify_archives_gridBagSizer.Add(modify_archives_hujianhaoText,pos=(4,2),flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT)
        modify_archives_gridBagSizer.Add(modify_archives_kemuText,pos=(5,2),flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT)
        modify_archives_gridBagSizer.Add(modify_archives_beizhuText,pos=(6,2),span=(2,1),flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT)
        modify_archives_gridBagSizer.Add(modify_archives_inputterText,pos=(8,2),flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT)
        
        ARCHIVES_SIZE = (120,25)
        #生成  门类  下拉选择框
        #根据不同门类选项存放不同归档信息的列表
        self.modify_menlei_archives_comboBox = wx.combo.OwnerDrawnComboBox(parent=self,id=-1,value=temp_list_frame[1],size=ARCHIVES_SIZE,choices=UtilData.MENLEI_List,style=wx.CB_READONLY)
        #设置下拉列表一次容纳10个元素
        self.modify_menlei_archives_comboBox.SetPopupMaxHeight(self.modify_menlei_archives_comboBox.GetCharHeight()*10)
        #为下拉选择框绑定事件,目的是根据选择不同的门类提供不同的归档列表值
        self.modify_menlei_archives_comboBox.Bind(wx.EVT_COMBOBOX, self.choiceGuiDangFrame)

        #生成  归档  下拉选择框
        self.modify_guidang_archives_comboBox = wx.combo.OwnerDrawnComboBox(parent=self,id=-1,value=temp_list_frame[2],size=ARCHIVES_SIZE,choices=UtilData.MENLEI_W_List,style=wx.CB_READONLY)
        #设置下拉列表一次容纳10个元素
        self.modify_guidang_archives_comboBox.SetPopupMaxHeight(self.modify_guidang_archives_comboBox.GetCharHeight()*10)
        
        #生成  期限  下拉选择框
        self.modify_qixian_archives_comboBox = wx.combo.OwnerDrawnComboBox(parent=self,id=-1,value=temp_list_frame[15],size=ARCHIVES_SIZE,choices=UtilData.QIXIAN_List,style=wx.CB_READONLY)
        #设置下拉列表一次容纳10个元素
        self.modify_qixian_archives_comboBox.SetPopupMaxHeight(self.modify_qixian_archives_comboBox.GetCharHeight()*10)
        
        #生成 案卷题名 输入框
        self.modify_anjuantiming_archives_ctrl = wx.TextCtrl(parent=self,value=temp_list_frame[4],size=ARCHIVES_SIZE)
        
        #生成  单位  下拉选择框
        self.modify_danwei_archives_comboBox = wx.combo.OwnerDrawnComboBox(parent=self,id=-1,value=temp_list_frame[3],size=ARCHIVES_SIZE,choices=UtilData.DANWEI_List,style=wx.CB_READONLY)
        #设置下拉列表一次容纳10个元素
        self.modify_danwei_archives_comboBox.SetPopupMaxHeight(self.modify_danwei_archives_comboBox.GetCharHeight()*10)
        ##为下拉选择框绑定事件
        #self.modify_danwei_archives_comboBox.Bind(wx.EVT_COMBOBOX, self.createChoicesForAnJuanHaoFrame)        
        
        #生成 立卷日期 下拉选择框
        self.modify_lijuanriqi_archives_pop = UtilData.DateControl(self, -1, pos = (30,30),size=ARCHIVES_SIZE)
        self.modify_lijuanriqi_archives_pop.SetValue(temp_list_frame[5])
        
        #生成 位置 下拉选择框
        self.modify_weizhi_archives_comboBox = wx.combo.OwnerDrawnComboBox(parent=self,id=-1,value=temp_list_frame[6],size=ARCHIVES_SIZE,choices=UtilData.WEIZHI_List,style=wx.CB_READONLY)
        #设置下拉列表一次容纳10个元素
        self.modify_weizhi_archives_comboBox.SetPopupMaxHeight(self.modify_weizhi_archives_comboBox.GetCharHeight()*10)
        #为下拉选择框绑定事件
        self.modify_weizhi_archives_comboBox.Bind(wx.EVT_COMBOBOX, self.choiceEvent)        
        
        #生成 密级 下拉选择框
        self.modify_miji_archives_comboBox = wx.combo.OwnerDrawnComboBox(parent=self,id=-1,value=temp_list_frame[7],size=ARCHIVES_SIZE,choices=UtilData.MIJI_List,style=wx.CB_READONLY)
        #设置下拉列表一次容纳10个元素
        self.modify_miji_archives_comboBox.SetPopupMaxHeight(self.modify_miji_archives_comboBox.GetCharHeight()*10)
        #为下拉选择框绑定事件
        self.modify_miji_archives_comboBox.Bind(wx.EVT_COMBOBOX, self.choiceEvent)    
        
        #生成 责任人 输入框
        self.modify_zerenren_archives_ctrl = wx.TextCtrl(parent=self,value=temp_list_frame[8],size=ARCHIVES_SIZE)        
        
        #生成  区号  下拉选择框
        self.modify_quhao_archives_comboBox = wx.combo.OwnerDrawnComboBox(parent=self,id=-1,value=temp_list_frame[9],size=ARCHIVES_SIZE,choices=UtilData.QUHAO_List,style=wx.CB_READONLY)
        #设置下拉列表一次容纳10个元素
        self.modify_quhao_archives_comboBox.SetPopupMaxHeight(self.modify_quhao_archives_comboBox.GetCharHeight()*10)
        #为下拉选择框绑定事件
        self.modify_quhao_archives_comboBox.Bind(wx.EVT_COMBOBOX, self.createChoicesForJuanHaoFrame)

        #生成  柜号  下拉选择框
        self.modify_guihao_archives_comboBox = wx.combo.OwnerDrawnComboBox(parent=self,id=-1,value=temp_list_frame[10],size=ARCHIVES_SIZE,choices=UtilData.GUIHAO_List,style=wx.CB_READONLY)
        #设置下拉列表一次容纳10个元素
        self.modify_guihao_archives_comboBox.SetPopupMaxHeight(self.modify_guihao_archives_comboBox.GetCharHeight()*10)
        #为下拉选择框绑定事件
        self.modify_guihao_archives_comboBox.Bind(wx.EVT_COMBOBOX, self.createChoicesForJuanHaoFrame)
        
        #生成  盒号  下拉选择框
        self.modify_hehao_archives_comboBox = wx.combo.OwnerDrawnComboBox(parent=self,id=-1,value=temp_list_frame[11],size=ARCHIVES_SIZE,choices=UtilData.HEHAO_List,style=wx.CB_READONLY)
        #设置下拉列表一次容纳10个元素
        self.modify_hehao_archives_comboBox.SetPopupMaxHeight(self.modify_hehao_archives_comboBox.GetCharHeight()*10)
        #为盒号选择框绑定事件(自动判断该盒号下的卷号是否唯一)
        self.modify_hehao_archives_comboBox.Bind(wx.EVT_COMBOBOX, self.createChoicesForJuanHaoFrame)
        
        #取得初始化时区号、卷号、盒号的值,设置卷号控件为None方便初始化数据库查询
        self.modify_initQuhao_archives_comboBox_value = self.modify_quhao_archives_comboBox.GetValue()
        self.modify_initGuihao_archives_comboBox_value = self.modify_guihao_archives_comboBox.GetValue()
        self.modify_initHehao_archives_comboBox_value = self.modify_hehao_archives_comboBox.GetValue()
        self.modify_juanhao_archives_comboBox = None
        #生成卷号初始化列表
        self.temp_ccfjhf = self.createChoicesForJuanHaoFrame(event='')
        self.temp_list =temp_list_frame[12].split() + self.temp_ccfjhf
        #生成  卷号  下拉选择框
        self.modify_juanhao_archives_comboBox = wx.combo.OwnerDrawnComboBox(parent=self,id=-1,value=temp_list_frame[12],size=ARCHIVES_SIZE,choices=self.temp_list,style=wx.CB_READONLY)
        #设置下拉列表一次容纳10个元素
        self.modify_juanhao_archives_comboBox.SetPopupMaxHeight(self.modify_juanhao_archives_comboBox.GetCharHeight()*10)

        ##取得初始化时单位的值,设置案卷号控件为None方便初始化数据库查询
        #self.modify_initDanwei_archives_comboBox_value = self.modify_danwei_archives_comboBox.GetValue()
        #self.modify_anjuanhao_archives_comboBox = None
        ##生成 案卷号 初始化列表
        #self.temp_accfjhf = self.createChoicesForAnJuanHaoFrame(event='')
        #self.temp_list_anjuanhao =temp_list_frame[4].split() + self.temp_accfjhf
        ##生成  案卷号  下拉选择框
        #self.modify_anjuanhao_archives_comboBox = wx.combo.OwnerDrawnComboBox(parent=self,id=-1,value=temp_list_frame[4],size=ARCHIVES_SIZE,choices=self.temp_list_anjuanhao,style=wx.CB_READONLY)
        ##设置下拉列表一次容纳10个元素
        #self.modify_anjuanhao_archives_comboBox.SetPopupMaxHeight(self.modify_anjuanhao_archives_comboBox.GetCharHeight()*10)       
       
        #生成 互见号 输入框
        self.modify_hujianhao_archives_ctrl = wx.TextCtrl(parent=self,value=temp_list_frame[13],size=ARCHIVES_SIZE)
        
        #生成 科目 下拉选择框
        self.modify_kemu_archives_comboBox = wx.combo.OwnerDrawnComboBox(parent=self,id=-1,value=temp_list_frame[14],size=ARCHIVES_SIZE,choices=UtilData.KEMU_List,style=wx.CB_READONLY)
        #设置下拉列表一次容纳10个元素
        self.modify_kemu_archives_comboBox.SetPopupMaxHeight(self.modify_kemu_archives_comboBox.GetCharHeight()*10)
        
        #生成 备注 输入框
        self.modify_beizhu_archives_ctrl = wx.TextCtrl(parent=self,value=temp_list_frame[16],size=ARCHIVES_SIZE)     
        
        #生成 录入人 输入框
        self.modify_inputter_archives_ctrl = wx.TextCtrl(parent=self,value=temp_list_frame[17],size=ARCHIVES_SIZE)        
        
        #生成 修改档案 按钮并进行绑定
        self.modify_newArchive_button = wx.Button(parent=self,label=u'修改档案')
        self.modify_newArchive_button.Bind(wx.EVT_BUTTON, self.modifyOldArchive)

        #将各选择与输入控件加入布局管理器
        modify_archives_gridBagSizer.Add(self.modify_menlei_archives_comboBox,pos=(0,1),flag=wx.ALIGN_LEFT|wx.TOP,border=15)
        modify_archives_gridBagSizer.Add(self.modify_guidang_archives_comboBox,pos=(1,1),flag=wx.ALIGN_LEFT)
        modify_archives_gridBagSizer.Add(self.modify_anjuantiming_archives_ctrl,pos=(2,1),flag=wx.ALIGN_LEFT)
        modify_archives_gridBagSizer.Add(self.modify_qixian_archives_comboBox,pos=(3,1),flag=wx.ALIGN_LEFT)
        modify_archives_gridBagSizer.Add(self.modify_danwei_archives_comboBox,pos=(4,1),flag=wx.ALIGN_LEFT)
        #此处放置 立卷日期 pos=(5,1)
        modify_archives_gridBagSizer.Add(self.modify_lijuanriqi_archives_pop,pos=(5,1),flag=wx.ALIGN_LEFT) 
        modify_archives_gridBagSizer.Add(self.modify_weizhi_archives_comboBox,pos=(6,1),flag=wx.ALIGN_LEFT)
        modify_archives_gridBagSizer.Add(self.modify_miji_archives_comboBox,pos=(7,1),flag=wx.ALIGN_LEFT)
        modify_archives_gridBagSizer.Add(self.modify_zerenren_archives_ctrl,pos=(8,1),flag=wx.ALIGN_LEFT)
        modify_archives_gridBagSizer.Add(self.modify_quhao_archives_comboBox,pos=(0,3),flag=wx.ALIGN_LEFT|wx.TOP,border=15)
        modify_archives_gridBagSizer.Add(self.modify_guihao_archives_comboBox,pos=(1,3),flag=wx.ALIGN_LEFT)
        modify_archives_gridBagSizer.Add(self.modify_hehao_archives_comboBox,pos=(2,3),flag=wx.ALIGN_LEFT)
        modify_archives_gridBagSizer.Add(self.modify_juanhao_archives_comboBox,pos=(3,3),flag=wx.ALIGN_LEFT)
        modify_archives_gridBagSizer.Add(self.modify_hujianhao_archives_ctrl,pos=(4,3),flag=wx.ALIGN_LEFT)
        modify_archives_gridBagSizer.Add(self.modify_kemu_archives_comboBox,pos=(5,3),flag=wx.ALIGN_LEFT)
        modify_archives_gridBagSizer.Add(self.modify_beizhu_archives_ctrl,pos=(6,3),span=(2,1),flag=wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL)
        modify_archives_gridBagSizer.Add(self.modify_inputter_archives_ctrl,pos=(8,3),flag=wx.ALIGN_LEFT)
        modify_archives_gridBagSizer.Add(self.modify_newArchive_button,pos=(9,0),span=(1,4),flag=wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_TOP,border=20)   
        #各列尽可能扩展
        modify_archives_gridBagSizer.AddGrowableCol(0)
        modify_archives_gridBagSizer.AddGrowableCol(3)
        self.SetSizer(modify_archives_gridBagSizer)
        self.Show()
        self.Center()
    def __init__(
        self,
        parent,
        ID=-1,
        title=u'创建存储空间',
        size=wx.DefaultSize,
        pos=wx.DefaultPosition,
        style=wx.DEFAULT_DIALOG_STYLE,
    ):

        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        pre.Create(parent, ID, title, pos, size, style)

        self.PostCreate(pre)

        sizer = wx.BoxSizer(wx.VERTICAL)

        label = wx.StaticText(
            self, -1, u"6-16个字符,包括小写字母、数字、下划线(_)和短横线(-),\n必须以小写字母或者数字开头,不含空格")
        sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        box = wx.BoxSizer(wx.HORIZONTAL)
        label = wx.StaticText(self, -1, "空间命名:")
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        self.bucket_name = text = wx.TextCtrl(self, -1, "", size=(180, -1))
        box.Add(text, 1, wx.ALIGN_CENTRE | wx.ALL, 5)

        sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, u" 权  限  :")
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        radio1 = self._private = wx.RadioButton(self,
                                                -1,
                                                u" 私有读写 ",
                                                style=wx.RB_GROUP)
        radio2 = self._public = wx.RadioButton(self, -1, u" 公有读 ")

        box.Add(radio1, 1, wx.ALIGN_CENTRE | wx.ALL, 5)
        box.Add(radio2, 1, wx.ALIGN_LEFT | wx.ALL, 5)

        sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL)
        sizer.Add(line, 0,
                  wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP, 5)

        btnsizer = wx.StdDialogButtonSizer()

        if wx.Platform != "__WXMSW__":
            btn = wx.ContextHelpButton(self)
            btnsizer.AddButton(btn)

        btn = wx.Button(self, wx.ID_OK, u' 确 定 ')
        btn.SetHelpText("The OK button completes the dialog")
        btn.SetDefault()
        btnsizer.AddButton(btn)

        btn = wx.Button(self, wx.ID_CANCEL, u' 取 消 ')
        btn.SetHelpText("The Cancel button cancels the dialog. (Cool, huh?)")
        btnsizer.AddButton(btn)
        btnsizer.Realize()

        sizer.Add(
            btnsizer, 0,
            wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTRE_HORIZONTAL | wx.ALL, 5)

        self.SetSizer(sizer)
        sizer.Fit(self)
        self.Center()
        self.Bind(wx.EVT_BUTTON, self.on_ok, id=wx.ID_OK)
    def __init__(self,
                 optParser,
                 title,
                 parent=None,
                 ID=0,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=wx.DEFAULT_DIALOG_STYLE | wx.THICK_FRAME):
        """Function for initialization"""

        modis_icon = wx.Icon('/home/lucadelu/github/pyModis/pyModis.ico',
                             wx.BITMAP_TYPE_ICO)
        #        self.SetIcon(modis_icon)
        provider = wx.SimpleHelpProvider()
        wx.HelpProvider_Set(provider)

        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        pre.Create(parent, ID, title, pos, size, style)

        self.PostCreate(pre)
        self.CenterOnScreen()
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.args_ctrl = []
        self.option_controls = {}

        #       IN THE TOP OF GUI THERE WAS THE NAME OF THE SCRIPT, BUT NOW IT IS IN
        #       THE TITLE

        #        top_label_text = '%s %s' % (optParser.get_prog_name(),
        #                                     optParser.get_version())
        #        label = wx.StaticText(self, -1, top_label_text)
        #        sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        # Add a text control for entering args

        arg = self._checkArg(optParser.get_prog_name())
        sizer.Add(arg, 0,
                  wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP, 5)

        self.browse_option_map = {}
        # Add controls for all the options
        for option in optParser.list_of_option:
            if option.dest is None:
                continue

            if option.help is None:
                option.help = u''

            if checkLabel(option) == 'Formats':
                continue

            box = wx.BoxSizer(wx.HORIZONTAL)
            if 'store' == option.action:
                label = wx.StaticText(self, -1, checkLabel(option))
                label.SetHelpText(
                    option.help.replace(' [default=%default]', ''))
                box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

                if 'choice' == option.type:
                    choices = list(set(option.choices))
                    if optparse.NO_DEFAULT == option.default:
                        option.default = choices[0]
                    ctrl = wx.ComboBox(self,
                                       -1,
                                       choices=choices,
                                       value=option.default,
                                       size=TEXTCTRL_SIZE,
                                       style=wx.CB_DROPDOWN | wx.CB_READONLY
                                       | wx.CB_SORT)
                elif option.type in ['file', 'output']:
                    if option.type == 'file':
                        fmode = wx.OPEN
                    elif option.type == 'output':
                        fmode = wx.SAVE
                    ctrl = filebrowse.FileBrowseButton(
                        self,
                        id=wx.ID_ANY,
                        fileMask='*',
                        labelText='',
                        dialogTitle='Choose output file',
                        buttonText='Browse',
                        startDirectory=os.getcwd(),
                        fileMode=fmode,
                        size=TEXTCTRL_SIZE)
                elif option.type == 'directory':
                    ctrl = filebrowse.DirBrowseButton(
                        self,
                        id=wx.ID_ANY,
                        labelText='',
                        dialogTitle='Choose output file',
                        buttonText='Browse',
                        startDirectory=os.getcwd(),
                        size=TEXTCTRL_SIZE)
                else:
                    if 'MULTILINE' in option.help:
                        ctrl = wx.TextCtrl(self,
                                           -1,
                                           "",
                                           size=(400, 100),
                                           style=wx.TE_MULTILINE
                                           | wx.TE_PROCESS_ENTER)
                    else:
                        ctrl = wx.TextCtrl(self, -1, "", size=TEXTCTRL_SIZE)

                    if (option.default != optparse.NO_DEFAULT) and \
                       (option.default is not None):
                        ctrl.Value = str(option.default)

                box.Add(ctrl, 1, wx.ALIGN_RIGHT | wx.ALL, 5)

            elif option.action in ('store_true', 'store_false'):
                ctrl = wx.CheckBox(self,
                                   -1,
                                   checkLabel(option),
                                   size=(300, -1))
                box.Add(ctrl, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
            elif option.action == 'group_name':
                label = wx.StaticText(self, -1, checkLabel(option))
                font = wx.Font(12, wx.DECORATIVE, wx.NORMAL, wx.BOLD)
                label.SetFont(font)
                box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
                ctrl = None
            else:
                raise NotImplementedError(
                    'Unknown option action: '
                    '{act}'.format(act=repr(option.action)))
            if ctrl:
                ctrl.SetHelpText(option.help.replace(' [default=%default]',
                                                     ''))
                self.option_controls[option] = ctrl
            sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL)
        sizer.Add(line, 0,
                  wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP, 5)

        btnsizer = wx.StdDialogButtonSizer()

        if wx.Platform != "__WXMSW__":
            btn = wx.ContextHelpButton(self)
            btnsizer.AddButton(btn)

        btn = wx.Button(self, wx.ID_OK)
        btn.SetHelpText("The OK button completes the dialog")
        btn.SetDefault()
        btnsizer.AddButton(btn)

        btn = wx.Button(self, wx.ID_CANCEL)
        btn.SetHelpText("The Cancel button cancels the dialog. (Cool, huh?)")
        btnsizer.AddButton(btn)
        btnsizer.Realize()

        sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        self.SetSizer(sizer)
        sizer.Fit(self)
Exemple #22
0
    def __init__(self, torrent, parent):

        self.torrent = torrent
        self.utility = torrent.utility

        title = self.utility.lang.get('choosedowndest')
        style = wx.DEFAULT_DIALOG_STYLE

        pre = wx.PreDialog()
        pre.Create(parent, -1, title, style=style)
        self.this = pre.this

        # May be called with a torrent
        # This dialog is used :
        # 1 - to change the destination (location and name) of an existing torrent (the dialog has an apply button) :
        # 2 - to choose a new destination for a new torrent because the destination is duplicate or badly named (no apply button in this case) :
        if self.torrent.files.isFile():
            indestloc = self.torrent.files.dest
        else:
            indestloc = self.torrent.files.getProcDest(pathonly=True,
                                                       checkexists=False)
        destloc = path.split(indestloc)[0]
        destname = path.split(indestloc)[1]
        self.currenttorname = self.torrent.getColumnText(COL_TITLE)
        self.torfilename = path.split(self.torrent.src)[1]
        self.newdest = ''

        outerbox = wx.BoxSizer(wx.VERTICAL)

        globalbox = wx.StaticBoxSizer(wx.StaticBox(self, -1, ''), wx.VERTICAL)

        downdestlocbox = wx.StaticBoxSizer(
            wx.StaticBox(self, -1, self.utility.lang.get('downdestloc')),
            wx.VERTICAL)
        downdestloc = wx.BoxSizer(wx.HORIZONTAL)
        self.downdestloctext = wx.TextCtrl(self, -1, destloc, wx.Point(-1, -1),
                                           wx.Size(400, -1))
        downdestloc.Add(self.downdestloctext, 1)
        downdestlocbtn = wx.Button(self,
                                   -1,
                                   self.utility.lang.get('browsebtn'),
                                   style=wx.BU_EXACTFIT)
        downdestloc.Add(downdestlocbtn, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT,
                        5)
        downdestlocbox.Add(downdestloc, 0, wx.EXPAND | wx.TOP, 0)

        if self.torrent.files.isFile():
            downdestnamehead = self.utility.lang.get('downfilename')
        else:
            downdestnamehead = self.utility.lang.get('downdirname')
        downdestnamebox = wx.StaticBoxSizer(
            wx.StaticBox(self, -1, downdestnamehead), wx.VERTICAL)
        downdestname = wx.BoxSizer(wx.HORIZONTAL)
        self.downdestnametext = wx.TextCtrl(self, -1, destname,
                                            wx.Point(-1, -1), wx.Size(400, -1))
        downdestname.Add(self.downdestnametext, 1)
        downdestnamebtn = wx.Button(self,
                                    -1,
                                    self.utility.lang.get('browsebtn'),
                                    style=wx.BU_EXACTFIT)
        downdestname.Add(downdestnamebtn, 0,
                         wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5)
        downdestnamebox.Add(downdestname, 0, wx.EXPAND | wx.TOP, 0)

        self.rentorwithdest = wx.CheckBox(
            self, -1, self.utility.lang.get('rentorwithdest'))
        if self.utility.config.Read('defrentorwithdest', "boolean"):
            self.rentorwithdest.SetValue(True)
        else:
            self.rentorwithdest.SetValue(False)
        downdestnamebox.Add(self.rentorwithdest, 0, wx.TOP, 3)

        globalbox.Add(downdestlocbox, 0, wx.TOP, 6)
        globalbox.Add(downdestnamebox, 0, wx.TOP | wx.EXPAND, 6)

        outerbox.Add(globalbox, 0, wx.TOP, -4)

        buttonbox = wx.BoxSizer(wx.HORIZONTAL)
        okbtn = wx.Button(self,
                          -1,
                          self.utility.lang.get('ok'),
                          style=wx.BU_EXACTFIT)
        cancelbtn = wx.Button(self,
                              -1,
                              self.utility.lang.get('cancel'),
                              style=wx.BU_EXACTFIT)
        applybtn = wx.Button(self,
                             -1,
                             self.utility.lang.get('apply'),
                             style=wx.BU_EXACTFIT)
        buttonbox.Add(applybtn, 0, wx.ALL, 5)
        buttonbox.Add(okbtn, 0, wx.ALL, 5)
        buttonbox.Add(cancelbtn, 0, wx.ALL, 5)

        outerbox.Add(buttonbox, 0, wx.ALIGN_CENTER)

        self.SetAutoLayout(True)
        self.SetSizer(outerbox)
        self.Fit()

        # Add events
        self.Bind(wx.EVT_BUTTON, self.onChangeLocation, downdestlocbtn)
        self.Bind(wx.EVT_BUTTON, self.onChangeName, downdestnamebtn)
        self.Bind(wx.EVT_BUTTON, self.onApply, applybtn)
        self.Bind(wx.EVT_BUTTON, self.onOK, okbtn)
        self.Bind(wx.EVT_BUTTON, self.onCancel, cancelbtn)
        self.Bind(wx.EVT_CLOSE, self.onCancel)
    def __init__(self,
                 parent,
                 ID,
                 nbChannels,
                 title="",
                 text="",
                 size=wx.DefaultSize,
                 pos=wx.DefaultPosition,
                 style=wx.DEFAULT_DIALOG_STYLE,
                 useMetal=False,
                 limits_scale=(0.01, 10),
                 limits_offset=(-100, 100)):
        # Instead of calling wx.Dialog.__init__ we precreate the dialog
        # so we can set an extra style that must be set before
        # creation, and then we create the GUI object using the Create
        # method.

        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        pre.Create(parent, ID, title, pos, size, style)

        # This next step is the most important, it turns this Python
        # object into the real wrapper of the dialog (instead of pre)
        # as far as the wxPython extension is concerned.
        self.PostCreate(pre)

        # This extra style can be set after the UI object has been created.
        if 'wxMac' in wx.PlatformInfo and useMetal:
            self.SetExtraStyle(wx.DIALOG_EX_METAL)

        # Now continue with the normal construction of the dialog

        self.nbChannels = nbChannels

        # contents
        sizer = wx.BoxSizer(wx.VERTICAL)

        label = wx.StaticText(self, -1, text)
        label.SetHelpText("help text")
        sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        self.cb = {}
        for c in range(1, self.nbChannels + 1):
            self.cb[c] = wx.CheckBox(self, -1, "channel {}".format(c))
            sizer.Add(self.cb[c], 0,
                      wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP,
                      5)

        line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL)
        sizer.Add(line, 0,
                  wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP, 5)

        # buttons
        btnsizer = wx.StdDialogButtonSizer()
        btn = wx.Button(self, wx.ID_OK)
        btn.SetDefault()
        btnsizer.AddButton(btn)
        btn = wx.Button(self, wx.ID_CANCEL)
        btnsizer.AddButton(btn)
        btnsizer.Realize()

        sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        self.SetSizer(sizer)
        sizer.Fit(self)
        self.Show()
    def __init__(
        self,
        parent,
        ID,
        title,
        text="",
        text2="",
        helptext="",
        minval=1,
        maxval=100,
        increment=None,
        defval=1,
        size=wx.DefaultSize,
        pos=wx.DefaultPosition,
        style=wx.DEFAULT_DIALOG_STYLE,
        useMetal=False,
    ):

        # Instead of calling wx.Dialog.__init__ we precreate the dialog
        # so we can set an extra style that must be set before
        # creation, and then we create the GUI object using the Create
        # method.
        if increment is None:
            increment = 10
        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        pre.Create(parent, ID, title, pos, size, style)

        # This next step is the most important, it turns this Python
        # object into the real wrapper of the dialog (instead of pre)
        # as far as the wxPython extension is concerned.
        self.PostCreate(pre)

        # This extra style can be set after the UI object has been created.
        if 'wxMac' in wx.PlatformInfo and useMetal:
            self.SetExtraStyle(wx.DIALOG_EX_METAL)

        # Now continue with the normal construction of the dialog
        # contents
        sizer = wx.BoxSizer(wx.VERTICAL)

        label = wx.StaticText(self, -1, text)
        label.SetHelpText(helptext)
        sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        # box 1 xmin
        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, text2)
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        self.channelFS = FS.FloatSpin(self,
                                      -1,
                                      min_val=minval,
                                      max_val=maxval,
                                      digits=0,
                                      value=defval,
                                      increment=increment,
                                      agwStyle=FS.FS_LEFT)
        box.Add(self.channelFS, 1, wx.ALIGN_CENTRE | wx.ALL, 5)
        sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        # buttons
        btnsizer = wx.StdDialogButtonSizer()

        btn = wx.Button(self, wx.ID_OK)

        btn.SetDefault()
        btnsizer.AddButton(btn)
        btn = wx.Button(self, wx.ID_CANCEL)
        btnsizer.AddButton(btn)
        btnsizer.Realize()

        sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        self.SetSizer(sizer)
        sizer.Fit(self)
        self.Show()
Exemple #25
0
    def __init__(self,
                 parent,
                 ID,
                 title,
                 size=wx.DefaultSize,
                 pos=wx.DefaultPosition,
                 style=wx.DEFAULT_DIALOG_STYLE):

        # Instead of calling wx.Dialog.__init__ we precreate the dialog
        # so we can set an extra style that must be set before
        # creation, and then we create the GUI dialog using the Create
        # method.
        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        pre.Create(parent, ID, title, pos, size, style)

        # This next step is the most important, it turns this Python
        # object into the real wrapper of the dialog (instead of pre)
        # as far as the wxPython extension is concerned.
        self.PostCreate(pre)

        # Now continue with the normal construction of the dialog
        # contents
        sizer = wx.BoxSizer(wx.VERTICAL)

        # Display type choice
        b = wx.StaticBox(self, -1, "Immersive display settings")
        box = wx.StaticBoxSizer(b, wx.HORIZONTAL)
        label = wx.StaticText(self, -1, "Display type: ")
        label.SetHelpText("The type of immersive display you are using")
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        temp_selection_string = self.getDefaultDisplay()
        self.display_choice = wx.ComboBox(self, -1, temp_selection_string,
                                          (90, 50), (180, -1),
                                          self.getAvailableDisplays(),
                                          wx.CB_READONLY)
        self.display_choice.SetHelpText("Here's some help text for field #1")
        self.display_choice.SetStringSelection(temp_selection_string)
        box.Add(self.display_choice, 1, wx.ALIGN_CENTRE | wx.ALL, 5)

        self.Bind(wx.EVT_COMBOBOX, self.onDisplayChoice, self.display_choice)

        sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        # Haptics device choice
        b = wx.StaticBox(self, -1, "Haptics device settings")
        static_box = wx.StaticBoxSizer(b, wx.VERTICAL)
        box = wx.BoxSizer(wx.HORIZONTAL)
        label = wx.StaticText(self, -1, "Haptics device:")
        label.SetHelpText("The haptics devices used in the display")
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        temp_selection_string = self.getDefaultDevice()
        self.device_choice = wx.ComboBox(
            self, -1, temp_selection_string, (90, 50), (180, -1),
            self.getDevicesForDisplay(self.display_choice.GetValue()),
            wx.CB_READONLY)
        self.device_choice.SetStringSelection(temp_selection_string)

        self.device_choice.SetHelpText("Here's some help text for field #1")
        box.Add(self.device_choice, 1, wx.ALIGN_CENTRE | wx.ALL, 5)

        stylus_box = wx.BoxSizer(wx.HORIZONTAL)
        label = wx.StaticText(self, -1, "Default stylus: ")
        label.SetHelpText("blah")
        stylus_box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        temp_selection_string = self.getDefaultStylus()
        self.stylus_choice = wx.ComboBox(self, -1, temp_selection_string,
                                         (90, 50), (180, -1),
                                         self.getCommonStylus(),
                                         wx.CB_READONLY)
        self.stylus_choice.SetStringSelection(temp_selection_string)
        self.Bind(wx.EVT_COMBOBOX, self.onStylusChoice, self.stylus_choice)
        self.stylus_choice.SetHelpText("Here's some help text for field #1")

        stylus_box.Add(self.stylus_choice, 1, wx.ALIGN_CENTRE | wx.ALL, 5)

        static_box.Add(box, 1, wx.ALIGN_LEFT | wx.ALL, 5)
        static_box.Add(stylus_box, 1, wx.ALIGN_LEFT | wx.ALL, 5)
        sizer.Add(static_box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL,
                  5)

        # Render settings
        b = wx.StaticBox(self, -1, "Graphical render settings")
        static_box = wx.StaticBoxSizer(b, wx.VERTICAL)
        box = wx.BoxSizer(wx.HORIZONTAL)
        label = wx.StaticText(self, -1, "Stereo mode:")
        label.SetHelpText("The mode in which to render the scene graphically")
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        temp_selection_string = self.getDefaultStereoMode()
        self.stereo_choice = wx.ComboBox(self, -1, temp_selection_string,
                                         (90, 50), (130, -1),
                                         stereo_mode_box_options,
                                         wx.CB_READONLY)
        self.stereo_choice.SetHelpText("Here's some help text for field #1")
        box.Add(self.stereo_choice, 1, wx.ALIGN_CENTRE | wx.ALL, 5)
        self.stereo_choice.SetStringSelection(temp_selection_string)

        check_boxes = wx.BoxSizer(wx.VERTICAL)
        self.mirrored_cb = wx.CheckBox(self, -1, "Mirrored in Y")
        self.mirrored_cb.SetValue(self.getDefaultMirrored())
        self.fullscreen_cb = wx.CheckBox(self, -1, "Fullscreen")
        self.fullscreen_cb.SetValue(self.getDefaultFullscreen())
        check_boxes.Add(self.mirrored_cb, 1, wx.ALIGN_LEFT | wx.ALL, 5)
        check_boxes.Add(self.fullscreen_cb, 1, wx.ALIGN_LEFT | wx.ALL, 5)
        box.Add(check_boxes, 1, wx.ALIGN_CENTRE | wx.ALL, 5)
        static_box.Add(box, 1, wx.ALIGN_CENTRE | wx.ALL, 5)

        viewpoint_box = wx.BoxSizer(wx.HORIZONTAL)
        label = wx.StaticText(self, -1, "Default Viewpoint: ")
        label.SetHelpText("blah")
        viewpoint_box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        self.browse_viewpoints = []

        if (cp.has_option("graphical", "viewpoint")):
            vp = cp.get("graphical", "viewpoint")
            if (not (self.isCommonViewpoint(vp))
                    and not (self.isDisplayViewpoint(
                        self.display_choice.GetValue(), vp))):
                self.browse_viewpoints.append(vp)
        temp_selection_string = self.getDefaultViewpoint()
        self.viewpoint_choice = wx.ComboBox(
            self, -1, temp_selection_string, (90, 50), (120, -1),
            self.getViewpointForDisplay(self.display_choice.GetValue()),
            wx.CB_READONLY)
        self.viewpoint_choice.SetStringSelection(temp_selection_string)
        self.Bind(wx.EVT_COMBOBOX, self.onViewpointChoice,
                  self.viewpoint_choice)
        self.viewpoint_choice.SetHelpText("Here's some help text for field #1")

        viewpoint_box.Add(self.viewpoint_choice, 1, wx.ALIGN_CENTRE | wx.ALL,
                          5)
        static_box.Add(viewpoint_box, 1, wx.ALIGN_LEFT | wx.ALL, 5)
        sizer.Add(static_box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL,
                  5)

        #        line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL)
        #        sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5)

        btnsizer = wx.StdDialogButtonSizer()

        if wx.Platform != "__WXMSW__":
            btn = wx.ContextHelpButton(self)
            btnsizer.AddButton(btn)

        btn = wx.Button(self, wx.ID_OK)
        btn.SetHelpText("The OK button completes the dialog")
        btn.SetDefault()
        btnsizer.AddButton(btn)

        btn = wx.Button(self, wx.ID_CANCEL)
        btn.SetHelpText("The Cancel button cnacels the dialog. (Cool, huh?)")
        btnsizer.AddButton(btn)

        btn = wx.Button(self, wx.ID_APPLY)
        btn.SetHelpText("The Cancel button cnacels the dialog. (Cool, huh?)")
        self.Bind(wx.EVT_BUTTON, self.onApply, btn)
        btnsizer.AddButton(btn)

        btnsizer.Realize()

        sizer.Add(btnsizer, 0, wx.ALIGN_RIGHT | wx.ALL, 5)

        self.SetSizer(sizer)
        sizer.Fit(self)
    def __init__(self, parent, options, pdfixstarssel, ephepath):  #, inittxt):
        # Instead of calling wx.Dialog.__init__ we precreate the dialog
        # so we can set an extra style that must be set before
        # creation, and then we create the GUI object using the Create
        # method.
        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        pre.Create(parent,
                   -1,
                   mtexts.txts['FixStars'],
                   pos=wx.DefaultPosition,
                   size=wx.DefaultSize,
                   style=wx.DEFAULT_DIALOG_STYLE)

        # This next step is the most important, it turns this Python
        # object into the real wrapper of the dialog (instead of pre)
        # as far as the wxPython extension is concerned.
        self.PostCreate(pre)

        #main vertical sizer
        mvsizer = wx.BoxSizer(wx.VERTICAL)

        self.sstars = wx.StaticBox(self, label='')
        starssizer = wx.StaticBoxSizer(self.sstars, wx.VERTICAL)

        ID_FixStars = wx.NewId()
        self.li = FixStarListCtrl(self, ephepath, ID_FixStars, size=(275, 280))
        starssizer.Add(self.li, 0, wx.ALIGN_CENTER | wx.ALL, 5)
        self.li.fill(options.fixstars, pdfixstarssel)

        hbtnsizer = wx.BoxSizer(wx.HORIZONTAL)
        ID_SelectAll = wx.NewId()
        btnSelectAll = wx.Button(self, ID_SelectAll, mtexts.txts['SelectAll'])
        hbtnsizer.Add(btnSelectAll, 0)

        ID_DeselectAll = wx.NewId()
        btnDeselectAll = wx.Button(self, ID_DeselectAll,
                                   mtexts.txts['DeselectAll'])
        hbtnsizer.Add(btnDeselectAll, 0)

        starssizer.Add(hbtnsizer, 0)
        mvsizer.Add(starssizer, 0, wx.LEFT | wx.RIGHT, 5)

        self.Bind(wx.EVT_BUTTON, self.OnSelectAll, id=ID_SelectAll)
        self.Bind(wx.EVT_BUTTON, self.OnDeselectAll, id=ID_DeselectAll)

        btnsizer = wx.StdDialogButtonSizer()

        if wx.Platform != '__WXMSW__':
            btn = wx.ContextHelpButton(self)
            btnsizer.AddButton(btn)

        btnOk = wx.Button(self, wx.ID_OK, mtexts.txts['Ok'])
        btnOk.SetHelpText(mtexts.txts['HelpOk'])
        btnOk.SetDefault()
        btnsizer.AddButton(btnOk)

        btn = wx.Button(self, wx.ID_CANCEL, mtexts.txts['Cancel'])
        btn.SetHelpText(mtexts.txts['HelpCancel'])
        btnsizer.AddButton(btn)

        btnsizer.Realize()

        mvsizer.Add(btnsizer, 0, wx.GROW | wx.ALL, 10)
        self.SetSizer(mvsizer)
        mvsizer.Fit(self)

        btnOk.SetFocus()
Exemple #27
0
 def __init__(self):
     pre = wx.PreDialog()
     self.PostCreate(pre)
Exemple #28
0
 def __init__(self):
     pre = wx.PreDialog()
     # the Create step is done by XRC.
     self.PostCreate(pre)
Exemple #29
0
    def __init__(self,
                 parent,
                 id,
                 title,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=wx.DEFAULT_DIALOG_STYLE):
        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        pre.Create(parent, id, title, pos, size, style)

        self.PostCreate(pre)

        sizer = wx.BoxSizer(wx.VERTICAL)

        box = wx.BoxSizer(wx.HORIZONTAL)
        label = wx.StaticText(self, -1, u'交易地址:', size=(80, -1))
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        self.t_td_front = wx.TextCtrl(self,
                                      -1,
                                      default_td_front,
                                      size=(200, -1))
        box.Add(self.t_td_front, 1, wx.ALIGN_CENTRE | wx.ALL, 5)
        sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        box = wx.BoxSizer(wx.HORIZONTAL)
        label = wx.StaticText(self, -1, u'行情地址:', size=(80, -1))
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        self.t_md_front = wx.TextCtrl(self,
                                      -1,
                                      default_md_front,
                                      size=(200, -1))
        box.Add(self.t_md_front, 1, wx.ALIGN_CENTRE | wx.ALL, 5)
        sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        box = wx.BoxSizer(wx.HORIZONTAL)
        label = wx.StaticText(self, -1, u'经纪公司:', size=(80, -1))
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        self.t_broker_id = wx.TextCtrl(self,
                                       -1,
                                       default_broker_id,
                                       size=(200, -1))
        box.Add(self.t_broker_id, 1, wx.ALIGN_CENTRE | wx.ALL, 5)
        sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        box = wx.BoxSizer(wx.HORIZONTAL)
        label = wx.StaticText(self, -1, u'用户名:', size=(80, -1))
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        self.t_user_id = wx.TextCtrl(self, -1, default_user_id, size=(200, -1))
        box.Add(self.t_user_id, 1, wx.ALIGN_CENTRE | wx.ALL, 5)
        sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        box = wx.BoxSizer(wx.HORIZONTAL)
        label = wx.StaticText(self, -1, u'密码:', size=(80, -1))
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        self.t_password = wx.TextCtrl(self,
                                      -1,
                                      default_password,
                                      size=(200, -1),
                                      style=wx.TE_PASSWORD)
        box.Add(self.t_password, 1, wx.ALIGN_CENTRE | wx.ALL, 5)
        sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        box = wx.BoxSizer(wx.HORIZONTAL)
        label = wx.StaticText(self, -1, u'合约:', size=(80, -1))
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        self.t_instrument_ids = wx.TextCtrl(self,
                                            -1,
                                            default_instrument_ids,
                                            size=(200, 80),
                                            style=wx.TE_MULTILINE
                                            | wx.TE_PROCESS_ENTER)
        box.Add(self.t_instrument_ids, 1, wx.ALIGN_CENTRE | wx.ALL, 5)
        sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL)
        sizer.Add(line, 0,
                  wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP, 5)

        box = wx.BoxSizer(wx.HORIZONTAL)

        self.b_save = btn = wx.Button(self, -1, U'保存')
        box.Add(btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        self.b_login = btn = wx.Button(self, -1, U'登录')
        btn.SetDefault()
        box.Add(btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        btn = wx.Button(self, wx.ID_CANCEL, u'取消')
        box.Add(btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        sizer.Add(box, 0, wx.ALIGN_CENTER_VERTICAL | wx.CENTER | wx.ALL, 5)

        self.message = tc = wx.TextCtrl(self,
                                        -1,
                                        '',
                                        size=(400, 100),
                                        style=wx.TE_MULTILINE
                                        | wx.TE_PROCESS_ENTER | wx.TE_READONLY)
        tc.SetInsertionPoint(0)
        box = wx.BoxSizer(wx.HORIZONTAL)
        box.Add(tc, 1, wx.EXPAND)

        sizer.Add(box, 0, wx.ALIGN_CENTER_VERTICAL | wx.CENTER | wx.ALL, 5)

        self.SetSizer(sizer)
        sizer.Fit(self)

        self.Bind(wx.EVT_BUTTON, self.on_login, self.b_login)
        self.Bind(wx.EVT_BUTTON, self.on_save, self.b_save)
Exemple #30
0
    def __init__(self, defaultAccounts):

        # Instead of calling wx.Dialog.__init__ we precreate the dialog
        # so we can set an extra style that must be set before
        # creation, and then we create the GUI dialog using the Create
        # method.
        pre = wx.PreDialog()
        pre.Create(None, -1, _(u"Login to a peer network"), wx.DefaultPosition,
                   wx.DefaultSize, wx.DEFAULT_DIALOG_STYLE)

        # This next step is the most important, it turns this Python
        # object into the real wrapper of the dialog (instead of pre)
        # as far as the wxPython extension is concerned.
        self.this = pre.this

        # Now continue with the normal construction of the dialog
        # contents

        sizer = wx.BoxSizer(wx.VERTICAL)
        grid = wx.GridSizer(5, 2)

        protocol = PROTOCOLS[0]
        for account in defaultAccounts:
            if account.protocol == protocol:
                self.userid = account.userid
                self.server = account.server
                self.password = account.password
                self.useSSL = account.useSSL
                break
        else:
            self.userid = ""
            self.server = ""
            self.password = ""
            self.useSSL = False

        # Userid (text control)....
        label = wx.StaticText(self, -1, _(u"Userid:"))
        grid.Add(label, 0, wx.ALIGN_LEFT | wx.ALL, 5)
        self.useridText = wx.TextCtrl(self, -1, self.userid,
                                      wx.DefaultPosition, [150, -1])
        grid.Add(self.useridText, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        # Password (text control):
        label = wx.StaticText(self, -1, _(u"Password:"******"Server:"))
        grid.Add(label, 0, wx.ALIGN_LEFT | wx.ALL, 5)
        self.serverText = wx.TextCtrl(self, -1, self.server,
                                      wx.DefaultPosition, [150, -1])
        grid.Add(self.serverText, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        # SSL (checkbox)....
        label = wx.StaticText(self, -1, _(u"Secure connection:"))
        grid.Add(label, 0, wx.ALIGN_LEFT | wx.ALL, 5)
        self.sslCheck = wx.CheckBox(self, -1, "SSL", wx.DefaultPosition,
                                    [150, -1])
        self.sslCheck.SetValue(self.useSSL)
        grid.Add(self.sslCheck, 0, wx.ALIGN_LEFT | wx.ALL, 5)

        # Protocol (choice)....
        label = wx.StaticText(self, -1, _(u"Over:"))
        grid.Add(label, 0, wx.ALIGN_LEFT | wx.ALL, 5)
        self.protocolsChoice = wx.Choice(self, -1, choices=PROTOCOL_NAMES)
        grid.Add(self.protocolsChoice, 1, wx.ALIGN_LEFT | wx.ALL, 5)
        self.protocolsChoice.SetSelection(0)

        sizer.Add(grid, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        sizer.Add(self.CreateStdDialogButtonSizer(wx.OK | wx.CANCEL), 0,
                  wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        self.SetSizer(sizer)
        self.SetAutoLayout(True)
        sizer.Fit(self)