Пример #1
0
    def __init__(self, parent, log):
        self.log = log
        scroll.ScrolledPanel.__init__(self, parent, -1)
        self.sizer = wx.BoxSizer(wx.VERTICAL)

        label = wx.StaticText(
            self, -1, """\
All these controls have been created by passing a single parameter, the autoformat code,
and use the factory class masked.Ctrl with its default controlType.
The masked package contains an internal dictionary of types and formats (autoformats).
Many of these already do complicated validation; To see some examples, try
29 Feb 2002 vs. 2004 for the date formats, or email address validation.
""")

        label.SetForegroundColour("Blue")
        self.sizer.Add(label, 0, wx.ALIGN_LEFT | wx.ALL, 5)

        description = wx.StaticText(self, -1, "Description")
        autofmt = wx.StaticText(self, -1, "AutoFormat Code")
        ctrl = wx.StaticText(self, -1, "Masked Ctrl")

        description.SetFont(
            wx.Font(9, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL,
                    wx.FONTWEIGHT_BOLD))
        autofmt.SetFont(
            wx.Font(9, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL,
                    wx.FONTWEIGHT_BOLD))
        ctrl.SetFont(
            wx.Font(9, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL,
                    wx.FONTWEIGHT_BOLD))

        grid = wx.FlexGridSizer(cols=3, vgap=10, hgap=5)
        grid.Add(description, 0, wx.ALIGN_LEFT)
        grid.Add(autofmt, 0, wx.ALIGN_LEFT)
        grid.Add(ctrl, 0, wx.ALIGN_LEFT)

        for autoformat, desc in masked.autoformats:
            grid.Add(wx.StaticText(self, -1, desc), 0, wx.ALIGN_LEFT)
            grid.Add(wx.StaticText(self, -1, autoformat), 0, wx.ALIGN_LEFT)
            grid.Add(
                masked.Ctrl(self,
                            -1,
                            "",
                            autoformat=autoformat,
                            demo=True,
                            name=autoformat), 0, wx.ALIGN_LEFT)

        self.sizer.Add(grid, 0, wx.ALIGN_LEFT | wx.ALL, border=5)
        self.SetSizer(self.sizer)
        self.SetAutoLayout(1)
        self.SetupScrolling()
Пример #2
0
    def __init__(self, parent, curSelected=(0, 1)):
        iTradeSizedDialog.__init__(self,
                                   parent,
                                   -1,
                                   message('converter_title'),
                                   size=(420, 420),
                                   style=wx.DEFAULT_DIALOG_STYLE
                                   | wx.RESIZE_BORDER)

        # container
        container = self.GetContentsPane()
        container.SetSizerType("vertical")

        # resizable pane
        pane = sc.SizedPanel(container, -1)
        pane.SetSizerType("form")
        pane.SetSizerProps(expand=True)

        # Row 1 : Org Currency Value
        self.wxOrgVal = masked.Ctrl(pane,
                                    integerWidth=9,
                                    fractionWidth=2,
                                    controlType=masked.controlTypes.NUMBER,
                                    allowNegative=False,
                                    groupDigits=True,
                                    groupChar=getGroupChar(),
                                    decimalChar=getDecimalChar(),
                                    selectOnEntry=True)
        self.wxOrgVal.SetValue(1)
        masked.EVT_NUM(self, self.wxOrgVal.GetId(), self.OnValueChange)

        self.wxOrgCur = wx.ComboBox(pane,
                                    -1,
                                    "",
                                    size=wx.Size(80, -1),
                                    style=wx.CB_DROPDOWN | wx.CB_READONLY)

        list = list_of_currencies()
        (curFrom, curTo) = curSelected

        for c in list:
            self.wxOrgCur.Append(c, c)

        self.wxOrgCur.SetSelection(curFrom)
        self.m_orgcur = list[curFrom]
        wx.EVT_COMBOBOX(self, self.wxOrgCur.GetId(), self.OnOrgCurrency)

        # Row 2 : Dest Currency Value
        self.wxDestVal = wx.StaticText(pane,
                                       -1,
                                       "",
                                       size=(100, -1),
                                       style=wx.ALIGN_RIGHT
                                       | wx.ST_NO_AUTORESIZE)
        self.wxDestVal.SetLabel('')
        self.wxDestVal.SetSizerProps(valign='center')
        self.wxDestCur = wx.ComboBox(pane,
                                     -1,
                                     "",
                                     size=wx.Size(80, -1),
                                     style=wx.CB_DROPDOWN | wx.CB_READONLY)

        for c in list:
            self.wxDestCur.Append(c, c)

        self.wxDestCur.SetSelection(curTo)
        self.m_destcur = list[curTo]
        wx.EVT_COMBOBOX(self, self.wxDestCur.GetId(), self.OnDestCurrency)

        # Last Row : OK and Cancel
        btnpane = sc.SizedPanel(container, -1)
        btnpane.SetSizerType("horizontal")
        btnpane.SetSizerProps(expand=True)

        # context help
        if wx.Platform != "__WXMSW__":
            btn = wx.ContextHelpButton(self)

        # CLOSE
        btn = wx.Button(btnpane, wx.ID_CANCEL, message('close'))
        btn.SetHelpText(message('close_desc'))

        # a little trick to make sure that you can't resize the dialog to
        # less screen space than the controls need
        self.Fit()
        self.SetMinSize(self.GetSize())

        EVT_UPDATE_CONVERT(self, self.OnUpdateConvert)

        # convert now
        self.convertValue()
    def ImpSetCriteria(self):
        global colList

        self.impcb = wx.CheckBox(self.panelB,
                                 -1,
                                 label="Age Limit",
                                 pos=(40, 130))
        self.min0 = masked.Ctrl(self.panelB,
                                pos=(240, 125),
                                size=(500, -1),
                                controlType=masked.controlTypes.NUMBER)
        self.min0.Enable(False)
        self.impdpc = wx.GenericDatePickerCtrl(
            self.panelB,
            size=(120, -1),
            pos=(420, 125),
            style=wx.TAB_TRAVERSAL | wx.DP_DROPDOWN | wx.DP_SHOWCENTURY
            | wx.DP_ALLOWNONE)
        self.impdpc.Enable(False)
        self.impcb.Disable()
        #self.Bind(wx.EVT_DATE_CHANGED, self.ImpOnDateChanged, self.impdpc)

        self.impcb1 = wx.CheckBox(self.panelB,
                                  -1,
                                  label="Aggregate (College)",
                                  pos=(40, 170))
        self.min1 = masked.Ctrl(self.panelB,
                                fractionWidth=2,
                                pos=(240, 165),
                                size=(50, -1),
                                controlType=masked.controlTypes.NUMBER)
        self.min1.Enable(False)
        #self.toLabel = wx.StaticText(self.panelB, -1, "To", pos=(380, 170)).SetFont(fontim)
        self.max1 = masked.Ctrl(self.panelB,
                                fractionWidth=2,
                                pos=(420, 165),
                                size=(50, -1),
                                controlType=masked.controlTypes.NUMBER)
        self.max1.Enable(False)
        self.impcb1.Disable()

        self.impcb2 = wx.CheckBox(self.panelB,
                                  -1,
                                  label="10th %",
                                  pos=(40, 210))
        self.min2 = masked.Ctrl(self.panelB,
                                fractionWidth=2,
                                pos=(240, 205),
                                controlType=masked.controlTypes.NUMBER)
        self.min2.Enable(False)
        #self.toLabel = wx.StaticText(self.panelB, -1, "To", pos=(380, 210)).SetFont(fontim)
        self.max2 = masked.Ctrl(self.panelB,
                                fractionWidth=2,
                                pos=(420, 205),
                                controlType=masked.controlTypes.NUMBER)
        self.max2.Enable(False)
        self.impcb2.Disable()

        self.impcb3 = wx.CheckBox(self.panelB,
                                  -1,
                                  label="12th %",
                                  pos=(40, 250))
        self.min3 = masked.Ctrl(self.panelB,
                                fractionWidth=2,
                                pos=(240, 245),
                                controlType=masked.controlTypes.NUMBER)
        self.min3.Enable(False)
        #self.toLabel = wx.StaticText(self.panelB, -1, "To", pos=(380, 250)).SetFont(fontim)
        self.max3 = masked.Ctrl(self.panelB,
                                fractionWidth=2,
                                pos=(420, 245),
                                controlType=masked.controlTypes.NUMBER)
        self.max3.Enable(False)
        self.impcb3.Disable()

        self.impcb4 = wx.CheckBox(self.panelB,
                                  -1,
                                  label="Top Rankers upto",
                                  pos=(40, 290))
        self.min4 = masked.Ctrl(self.panelB,
                                pos=(240, 285),
                                controlType=masked.controlTypes.NUMBER)
        self.min4.Enable(False)
        #self.toLabel = wx.StaticText(self.panelB, -1, "To", pos=(380, 290)).SetFont(fontim)
        #self.max4 = masked.Ctrl(self.panelB, fractionWidth=2, pos =(420, 285), controlType=masked.controlTypes.NUMBER )
        #self.max4.Enable(False)
        self.impcb4.Disable()

        self.Bind(wx.EVT_CHECKBOX, self.ImpOnDateCheckBox, self.impcb)
        self.Bind(wx.EVT_CHECKBOX, self.ImpOnCheckBox1, self.impcb1)
        self.Bind(wx.EVT_CHECKBOX, self.ImpOnCheckBox2, self.impcb2)
        self.Bind(wx.EVT_CHECKBOX, self.ImpOnCheckBox3, self.impcb3)
        self.Bind(wx.EVT_CHECKBOX, self.ImpOnCheckBox4, self.impcb4)

        if 'DOB' in colList:
            self.impcb.Enable()
        if 'TOTAL' in colList:
            self.impcb1.Enable()
            self.impcb4.Enable()
        if '10th' in colList:
            self.impcb2.Enable()
        if '12th' in colList:
            self.impcb3.Enable()
Пример #4
0
    def __init__( self, parent, log ):

        wx.Panel.__init__( self, parent, -1 )
        self.log = log
        panel = wx.Panel( self, -1 )

        header = wx.StaticText(panel, -1, """\
This shows the various options for masked.NumCtrl.
The controls at the top reconfigure the resulting control at the bottom.
""")
        header.SetForegroundColour( "Blue" )

        intlabel = wx.StaticText( panel, -1, "Integer width:" )
        self.integerwidth = masked.NumCtrl(
                                panel, value=10, integerWidth=2, allowNegative=False
                                )

        fraclabel = wx.StaticText( panel, -1, "Fraction width:" )
        self.fractionwidth = masked.NumCtrl(
                                panel, value=0, integerWidth=2, allowNegative=False
                                )

        groupcharlabel = wx.StaticText( panel,-1, "Grouping char:" )
        self.groupchar = masked.TextCtrl(
                                panel, -1, value=',', mask='&', excludeChars = '-()',
                                formatcodes='F', emptyInvalid=True, validRequired=True
                                )

        decimalcharlabel = wx.StaticText( panel,-1, "Decimal char:" )
        self.decimalchar = masked.TextCtrl(
                                panel, -1, value='.', mask='&', excludeChars = '-()',
                                formatcodes='F', emptyInvalid=True, validRequired=True
                                )

        self.set_min = wx.CheckBox( panel, -1, "Set minimum value:" )
        # Create this masked.NumCtrl using factory, to show how:
        self.min = masked.Ctrl( panel, integerWidth=5, fractionWidth=2, controlType=masked.controlTypes.NUMBER )
        self.min.Enable( False )

        self.set_max = wx.CheckBox( panel, -1, "Set maximum value:" )
        self.max = masked.NumCtrl( panel, integerWidth=5, fractionWidth=2 )
        self.max.Enable( False )


        self.limit_target = wx.CheckBox( panel, -1, "Limit control" )
        self.allow_none = wx.CheckBox( panel, -1, "Allow empty control" )
        self.group_digits = wx.CheckBox( panel, -1, "Group digits" )
        self.group_digits.SetValue( True )
        self.allow_negative = wx.CheckBox( panel, -1, "Allow negative values" )
        self.allow_negative.SetValue( True )
        self.use_parens = wx.CheckBox( panel, -1, "Use parentheses" )
        self.select_on_entry = wx.CheckBox( panel, -1, "Select on entry" )
        self.select_on_entry.SetValue( True )

        label = wx.StaticText( panel, -1, "Resulting numeric control:" )
        font = label.GetFont()
        font.SetWeight(wx.BOLD)
        label.SetFont(font)

        self.target_ctl = masked.NumCtrl( panel, -1, name="target control" )

        label_numselect = wx.StaticText( panel, -1, """\
Programmatically set the above
value entry ctrl:""")
        self.numselect = wx.ComboBox(panel, -1, choices = [ '0', '111', '222.22', '-3', '54321.666666666', '-1353.978',
                                                     '1234567', '-1234567', '123456789', '-123456789.1',
                                                     '1234567890.', '-9876543210.9' ])

        grid1 = wx.FlexGridSizer( 0, 4, 0, 0 )
        grid1.Add( intlabel, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
        grid1.Add( self.integerwidth, 0, wx.ALIGN_LEFT|wx.ALL, 5 )

        grid1.Add( groupcharlabel, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
        grid1.Add( self.groupchar, 0, wx.ALIGN_LEFT|wx.ALL, 5 )

        grid1.Add( fraclabel, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
        grid1.Add( self.fractionwidth, 0, wx.ALIGN_LEFT|wx.ALL, 5 )

        grid1.Add( decimalcharlabel, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
        grid1.Add( self.decimalchar, 0, wx.ALIGN_LEFT|wx.ALL, 5 )

        grid1.Add( self.set_min, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
        grid1.Add( self.min, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
        grid1.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5)
        grid1.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5)

        grid1.Add( self.set_max, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
        grid1.Add( self.max, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
        grid1.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5)
        grid1.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5)


        grid1.Add( self.limit_target, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
        grid1.Add( self.allow_none, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
        hbox1 = wx.BoxSizer( wx.HORIZONTAL )
        hbox1.Add( (17,5), 0, wx.ALIGN_LEFT|wx.ALL, 5)
        hbox1.Add( self.group_digits, 0, wx.ALIGN_LEFT|wx.LEFT, 5 )
        grid1.Add( hbox1, 0, wx.ALIGN_LEFT|wx.ALL, 5)
        grid1.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5)

        grid1.Add( self.allow_negative, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
        grid1.Add( self.use_parens, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
        hbox2 = wx.BoxSizer( wx.HORIZONTAL )
        hbox2.Add( (17,5), 0, wx.ALIGN_LEFT|wx.ALL, 5)
        hbox2.Add( self.select_on_entry, 0, wx.ALIGN_LEFT|wx.LEFT, 5 )
        grid1.Add( hbox2, 0, wx.ALIGN_LEFT|wx.ALL, 5)
        grid1.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5)


        grid2 = wx.FlexGridSizer( 0, 2, 0, 0 )
        grid2.Add( label, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
        grid2.Add( self.target_ctl, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
        grid2.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5)
        grid2.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5)
        grid2.Add( label_numselect, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
        grid2.Add( self.numselect, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
        grid2.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5)
        grid2.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5)
        grid2.AddGrowableCol(1)

        self.outer_box = wx.BoxSizer( wx.VERTICAL )
        self.outer_box.Add(header, 0, wx.ALIGN_LEFT|wx.TOP|wx.LEFT, 20)
        self.outer_box.Add( grid1, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.BOTTOM|wx.RIGHT, 20 )
        self.outer_box.Add( grid2, 0, wx.ALIGN_LEFT|wx.ALL, 20 )
        self.grid2 = grid2

        panel.SetAutoLayout( True )
        panel.SetSizer( self.outer_box )
        self.outer_box.Fit( panel )
        panel.Move( (50,10) )
        self.panel = panel

        self.Bind(masked.EVT_NUM, self.OnSetIntWidth, self.integerwidth )
        self.Bind(masked.EVT_NUM, self.OnSetFractionWidth, self.fractionwidth )
        self.Bind(wx.EVT_TEXT, self.OnSetGroupChar, self.groupchar )
        self.Bind(wx.EVT_TEXT, self.OnSetDecimalChar, self.decimalchar )

        self.Bind(wx.EVT_CHECKBOX, self.OnSetMin, self.set_min )
        self.Bind(wx.EVT_CHECKBOX, self.OnSetMax, self.set_max )
        self.Bind(masked.EVT_NUM, self.SetTargetMinMax, self.min )
        self.Bind(masked.EVT_NUM, self.SetTargetMinMax, self.max )

        self.Bind(wx.EVT_CHECKBOX, self.SetTargetMinMax, self.limit_target )
        self.Bind(wx.EVT_CHECKBOX, self.OnSetAllowNone, self.allow_none )
        self.Bind(wx.EVT_CHECKBOX, self.OnSetGroupDigits, self.group_digits )
        self.Bind(wx.EVT_CHECKBOX, self.OnSetAllowNegative, self.allow_negative )
        self.Bind(wx.EVT_CHECKBOX, self.OnSetUseParens, self.use_parens )
        self.Bind(wx.EVT_CHECKBOX, self.OnSetSelectOnEntry, self.select_on_entry )

        self.Bind(masked.EVT_NUM, self.OnTargetChange, self.target_ctl )
        self.Bind(wx.EVT_COMBOBOX, self.OnNumberSelect, self.numselect )
Пример #5
0
    def __init__(self,
                 parent,
                 id,
                 caption="",
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=0):

        wx.Control.__init__(self, parent, id, pos, size, style=wx.NO_BORDER)
        cmix.TextCtrlMixin.__init__(self)

        self.colors['normalBackground'] = wx.TheColourDatabase.Find('white')

        self.maskedCtrl = None
        self._cal = None

        if self._time:
            fmt = "EUDATE24HRTIMEDDMMYYYY.HHMM"
        else:
            fmt = "EUDATEDDMMYYYY."

        p = wx.Panel(self, -1)
        self.maskedCtrl = masked.Ctrl(
            p,
            -1,
            autoformat=fmt,
            emptyBackgroundColour=self.colors['normalBackground'],
            validBackgroundColour=self.colors['normalBackground'],
            invalidBackgroundColour=self.colors['invalidBackground'],
            foregroundColour=self.colors['normalForeground'],
            signedForegroundColour=self.colors['normalForeground'])
        self.maskedCtrl._fixSelection = lambda *x: None
        if wx.Platform == '__WXGTK__':
            maskedCtrl = self.maskedCtrl

            def _OnKeyDown(event):
                if event.GetKeyCode() == wx.WXK_RETURN:
                    event.Skip()
                else:
                    masked.TextCtrl._OnKeyDown(self, event)

            maskedCtrl._OnKeyDown = _OnKeyDown

            def _OnChar(event):
                if event.GetKeyCode() == wx.WXK_RETURN:
                    event.Skip()
                else:
                    start, stop = maskedCtrl.GetSelection()
                    if start == 0 and stop == len(maskedCtrl.GetValue(
                    )) and 48 <= event.GetKeyCode() <= 57:
                        maskedCtrl.SetValue('')
                        maskedCtrl.SetSelection(0, 0)
                        maskedCtrl.SetInsertionPoint(0)
                    masked.TextCtrl._OnChar(self, event)

            maskedCtrl._OnChar = _OnChar

            def _OnReturn(event):
                event.Skip()
                return True

            maskedCtrl._OnReturn = maskedCtrl._keyhandlers[13] = _OnReturn

#        if wx.Platform == '__WXGTK__':
#            if wx.WXK_RETURN in self.maskedCtrl._nav:
#                _nav = self.maskedCtrl._nav
#                _nav.pop(_nav.index(wx.WXK_RETURN))

        if wx.WXK_RETURN in self.maskedCtrl._nav:
            _nav = self.maskedCtrl._nav
            _nav.pop(_nav.index(wx.WXK_RETURN))

        self.SetFont(self.maskedCtrl.GetFont())
        dw, dh = self.maskedCtrl.GetSize()
        sz = wx.FlexGridSizer(0, 2, 0, 0)
        sz.Add(self.maskedCtrl, 0, wx.ALIGN_LEFT)
        self.buttonCalendar = wx.Button(p, -1, "...", size=(dh, dh))
        sz.Add(self.buttonCalendar, 0, wx.ALIGN_CENTER)
        p.SetSizer(sz)
        #self.SetSizer(sz)
        sz.SetSizeHints(self)
        p.Fit()
        self.Bind(wx.EVT_BUTTON, self.OnCalendarCall, self.buttonCalendar)
        self.Bind(wx.EVT_TEXT, self.OnTextChanged, self.maskedCtrl)

        #quando DateCtrl riceve il focus, lo passa al TextCtrl interno
        self.Bind(wx.EVT_SET_FOCUS, self.OnFocusGain)
        self.maskedCtrl.Bind(wx.EVT_KEY_DOWN, self.OnChar)
        self.maskedCtrl.Bind(wx.EVT_CHAR, self.OnCharX)
        if wx.Platform == '__WXGTK__':
            self.maskedCtrl.Bind(wx.EVT_PAINT, self.OnPaint)
        for obj in (self.maskedCtrl, self.buttonCalendar):
            obj.Bind(wx.EVT_SET_FOCUS, self.OnFocusGain)
            obj.Bind(wx.EVT_KILL_FOCUS, self.OnFocusLost)
Пример #6
0
    def __init__(self, parent, quote, bAdd=True):
        # context help
        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        if bAdd:
            title = message('stops_add_caption') % quote.name()
        else:
            title = message('stops_edit_caption') % quote.name()
        pre.Create(parent, -1, title, size=(420, 420))
        self.PostCreate(pre)

        # init
        self.m_add = bAdd
        self.m_quote = quote
        self.m_parent = parent

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

        # current quote
        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, quote.name())
        box.Add(label, 0, wx.ALIGN_LEFT | wx.ALL, 5)

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

        label = wx.StaticText(self, -1, quote.sv_close(bDispCurrency=True))
        box.Add(label, 0, wx.ALIGN_LEFT | wx.ALL, 5)

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

        # Thresholds
        if quote.nv_number() == 0:
            msgb = message('stops_noshares_loss')
            msgh = message('stops_noshares_win')
        else:
            msgb = message('stops_shares_loss')
            msgh = message('stops_shares_win')

            box = wx.BoxSizer(wx.HORIZONTAL)

            label = wx.StaticText(
                self, -1,
                message('stops_portfolio') %
                (quote.nv_number(), quote.sv_pr(bDispCurrency=True)))
            box.Add(label, 0, wx.ALIGN_LEFT | wx.ALL, 5)

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

        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, msgb)
        box.Add(label, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT | wx.ALL, 5)

        self.wxLoss = masked.Ctrl(self,
                                  integerWidth=6,
                                  fractionWidth=2,
                                  controlType=masked.controlTypes.NUMBER,
                                  allowNegative=False,
                                  groupChar=getGroupChar(),
                                  decimalChar=getDecimalChar())
        box.Add(self.wxLoss, 0,
                wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT | wx.ALL, 5)
        if quote.hasStops(): self.wxLoss.SetValue(quote.nv_stoploss())

        label = wx.StaticText(self, -1, quote.currency_symbol())
        box.Add(label, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT | wx.ALL, 5)

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

        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, msgh)
        box.Add(label, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT | wx.ALL, 5)

        self.wxWin = masked.Ctrl(self,
                                 integerWidth=6,
                                 fractionWidth=2,
                                 controlType=masked.controlTypes.NUMBER,
                                 allowNegative=False,
                                 groupChar=getGroupChar(),
                                 decimalChar=getDecimalChar())
        box.Add(self.wxWin, 0,
                wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT | wx.ALL, 5)
        if quote.hasStops(): self.wxWin.SetValue(quote.nv_stopwin())

        label = wx.StaticText(self, -1, quote.currency_symbol())
        box.Add(label, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT | wx.ALL, 5)

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

        # Commands (OK / CANCEL / Help)
        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
        if bAdd:
            msg = message('stops_add')
            msgdesc = message('stops_add_desc')
        else:
            msg = message('stops_edit')
            msgdesc = message('stops_edit_desc')

        btn = wx.Button(self, wx.ID_OK, msg)
        btn.SetDefault()
        btn.SetHelpText(msgdesc)
        box.Add(btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        wx.EVT_BUTTON(self, wx.ID_OK, self.OnValid)

        # 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)
Пример #7
0
    def __init__(self, parent, server, auth, timeout):
        iTradeSizedDialog.__init__(self,parent,-1,message('connection_title'),size=(420, 420),style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)

        if server!="":
            ip,self.m_port = server.split(':')
            a,b,c,d = ip.split('.')
            self.m_ip = '%3i.%3i.%3i.%3i' % (int(a),int(b),int(c),int(d))
            self.m_port = int(self.m_port)
        else:
            self.m_ip = "   .   .   .   "
            self.m_port = 0
        if auth!="":
            self.m_user,self.m_pwd = auth.split(':')
        else:
            self.m_user = ""
            self.m_pwd = ""
        self.m_timeout = timeout

        # container
        container = self.GetContentsPane()
        container.SetSizerType("vertical")

        # resizable pane
        pane = sc.SizedPanel(container, -1)
        pane.SetSizerType("form")
        pane.SetSizerProps(expand=True)

        # Row 1 : server / proxy="172.30.0.3:8080"
        label = wx.StaticText(pane, -1, message('proxy_server_ip'))
        label.SetSizerProps(valign='center')
        self.wxIPCtrl = masked.Ctrl(pane, -1, controlType = masked.controlTypes.IPADDR, size=(120,-1))
        self.wxIPCtrl.SetValue(self.m_ip)

        label = wx.StaticText(pane, -1, message('proxy_server_port'))
        label.SetSizerProps(valign='center')
        self.wxPortCtrl = masked.Ctrl(pane, integerWidth=4, fractionWidth=0, controlType=masked.controlTypes.NUMBER, allowNegative = False, groupDigits = False,size=(80,-1), selectOnEntry=True)
        self.wxPortCtrl.SetValue(self.m_port)

        # Row2 : auth = "user:password"
        label = wx.StaticText(pane, -1, message('proxy_auth_user'))
        label.SetSizerProps(valign='center')
        self.wxUserCtrl = wx.TextCtrl(pane, -1, self.m_user, size=(120,-1))
        #self.wxUserCtrl.SetSizerProps(expand=True)

        label = wx.StaticText(pane, -1, message('proxy_auth_pwd'))
        label.SetSizerProps(valign='center')
        self.wxPwdCtrl = wx.TextCtrl(pane, -1, self.m_pwd, size=(120,-1))
        #self.wxPwdCtrl.SetSizerProps(expand=True)

        # Row3 : timeout
        label = wx.StaticText(pane, -1, message('connection_timeout'))
        label.SetSizerProps(valign='center')
        self.wxTimeoutCtrl = masked.Ctrl(pane, integerWidth=3, fractionWidth=0, controlType=masked.controlTypes.NUMBER, allowNegative = False, groupDigits = False,size=(80,-1), selectOnEntry=True)
        self.wxTimeoutCtrl.SetValue(self.m_timeout)
        #self.wxTimeoutCtrl.SetSizerProps(expand=False)

        # Last Row : OK and Cancel
        btnpane = sc.SizedPanel(container, -1)
        btnpane.SetSizerType("horizontal")
        btnpane.SetSizerProps(expand=True)

        # context help
        if wx.Platform != "__WXMSW__":
            btn = wx.ContextHelpButton(btnpane)

        # OK
        btn = wx.Button(btnpane, wx.ID_OK, message('valid'))
        btn.SetDefault()
        btn.SetHelpText(message('valid_desc'))
        wx.EVT_BUTTON(self, wx.ID_OK, self.OnValid)

        # CANCEL
        btn = wx.Button(btnpane, wx.ID_CANCEL, message('cancel'))
        btn.SetHelpText(message('cancel_desc'))

        # a little trick to make sure that you can't resize the dialog to
        # less screen space than the controls need
        self.Fit()
        self.SetMinSize(self.GetSize())
Пример #8
0
    def __init__(self, parent, log):
        self.log = log
        scroll.ScrolledPanel.__init__(self, parent, -1)
        self.sizer = wx.BoxSizer(wx.VERTICAL)

        labelMaskedCombos = wx.StaticText(
            self, -1, """\
These are some examples of masked.ComboBox:""")
        labelMaskedCombos.SetForegroundColour("Blue")

        label_statecode = wx.StaticText(
            self, -1, """\
A state selector; only
"legal" values can be
entered:""")
        statecode = masked.ComboBox(self,
                                    -1,
                                    masked.states[0],
                                    choices=masked.states,
                                    autoformat="USSTATE")

        label_statename = wx.StaticText(
            self, -1, """\
A state name selector,
with auto-select:""")

        # Create this one using factory function:
        statename = masked.Ctrl(self,
                                -1,
                                masked.state_names[0],
                                controlType=masked.controlTypes.COMBO,
                                choices=masked.state_names,
                                autoformat="USSTATENAME",
                                autoSelect=True)
        statename.SetCtrlParameters(formatcodes='F!V_')

        numerators = [str(i) for i in range(1, 4)]
        denominators = [
            string.ljust(str(i), 2) for i in [2, 3, 4, 5, 8, 16, 32, 64]
        ]
        fieldsDict = {
            0: masked.Field(choices=numerators, choiceRequired=False),
            1: masked.Field(choices=denominators, choiceRequired=True)
        }
        choices = []
        for n in numerators:
            for d in denominators:
                if n != d:
                    choices.append('%s/%s' % (n, d))

        label_fraction = wx.StaticText(
            self, -1, """\
A masked ComboBox for fraction selection.
Choices for each side of the fraction can
be selected with PageUp/Down:""")

        fraction = masked.Ctrl(self,
                               -1,
                               "",
                               controlType=masked.controlTypes.COMBO,
                               choices=choices,
                               choiceRequired=True,
                               mask="#/##",
                               formatcodes="F_",
                               validRegex="^\d\/\d\d?",
                               fields=fieldsDict)

        label_code = wx.StaticText(
            self, -1, """\
A masked ComboBox to validate
text from a list of numeric codes:""")

        choices = ["91", "136", "305", "4579"]
        code = masked.ComboBox(self,
                               -1,
                               choices[0],
                               choices=choices,
                               choiceRequired=True,
                               formatcodes="F_r",
                               mask="####")

        label_selector = wx.StaticText(
            self, -1, """\
Programmatically set
choice sets:""")
        self.list_selector = wx.ComboBox(self,
                                         -1,
                                         '',
                                         choices=['list1', 'list2', 'list3'])
        self.dynamicbox = masked.Ctrl(
            self,
            -1,
            '    ',
            controlType=masked.controlTypes.COMBO,
            mask='XXXX',
            formatcodes='F_',
            # these are to give dropdown some initial height,
            # as base control apparently only sets that size
            # during initial construction <sigh>:
            choices=['', '1', '2', '3', '4', '5'])

        self.dynamicbox.Clear(
        )  # get rid of initial choices used to size the dropdown

        labelIpAddrs = wx.StaticText(
            self, -1, """\
Here are some examples of IpAddrCtrl, a control derived from masked.TextCtrl:"""
        )
        labelIpAddrs.SetForegroundColour("Blue")

        label_ipaddr1 = wx.StaticText(self, -1, "An empty control:")
        ipaddr1 = masked.IpAddrCtrl(self, -1, style=wx.TE_PROCESS_TAB)

        label_ipaddr2 = wx.StaticText(self, -1, "A restricted mask:")
        ipaddr2 = masked.IpAddrCtrl(self, -1, mask=" 10.  1.109.###")

        label_ipaddr3 = wx.StaticText(
            self, -1, """\
A control with restricted legal values:
10. (1|2) . (129..255) . (0..255)""")
        ipaddr3 = masked.Ctrl(self,
                              -1,
                              controlType=masked.controlTypes.IPADDR,
                              mask=" 10.  #.###.###")
        ipaddr3.SetFieldParameters(
            0, validRegex="1|2",
            validRequired=False)  # requires entry to match or not allowed

        # This allows any value in penultimate field, but colors anything outside of the range invalid:
        ipaddr3.SetFieldParameters(1,
                                   validRange=(129, 255),
                                   validRequired=False)

        labelNumerics = wx.StaticText(
            self, -1, """\
Here are some useful configurations of a masked.TextCtrl for integer and floating point input that still treat
the control as a text control.  (For a true numeric control, check out the masked.NumCtrl class!)"""
        )
        labelNumerics.SetForegroundColour("Blue")

        label_intctrl1 = wx.StaticText(
            self, -1, """\
An integer entry control with
shifting insert enabled:""")
        self.intctrl1 = masked.TextCtrl(self,
                                        -1,
                                        name='intctrl',
                                        mask="#{9}",
                                        formatcodes='_-,F>')
        label_intctrl2 = wx.StaticText(
            self, -1, """\
     Right-insert integer entry:""")
        self.intctrl2 = masked.TextCtrl(self,
                                        -1,
                                        name='intctrl',
                                        mask="#{9}",
                                        formatcodes='_-,Fr')

        label_floatctrl = wx.StaticText(
            self, -1, """\
A floating point entry control
with right-insert for ordinal:""")
        self.floatctrl = masked.TextCtrl(self,
                                         -1,
                                         name='floatctrl',
                                         mask="#{9}.#{2}",
                                         formatcodes="F,_-R",
                                         useParensForNegatives=False)
        self.floatctrl.SetFieldParameters(
            0, formatcodes='r<', validRequired=True
        )  # right-insert, require explicit cursor movement to change fields
        self.floatctrl.SetFieldParameters(
            1, defaultValue='00')  # don't allow blank fraction

        label_numselect = wx.StaticText(
            self, -1, """\
<= Programmatically set the value
     of the float entry ctrl:""")
        numselect = wx.ComboBox(self,
                                -1,
                                choices=[
                                    '', '111', '222.22', '-3',
                                    '54321.666666666', '-1353.978', '1234567',
                                    '-1234567', '123456789', '-123456789.1',
                                    '1234567890.', '-1234567890.1'
                                ])

        parens_check = wx.CheckBox(
            self, -1, "Use () to indicate negatives in above controls")

        gridCombos = wx.FlexGridSizer(cols=4, vgap=10, hgap=10)
        gridCombos.Add(label_statecode, 0, wx.ALIGN_LEFT)
        gridCombos.Add(statecode, 0, wx.ALIGN_LEFT)
        gridCombos.Add(label_fraction, 0, wx.ALIGN_LEFT)
        gridCombos.Add(fraction, 0, wx.ALIGN_LEFT)
        gridCombos.Add(label_statename, 0, wx.ALIGN_LEFT)
        gridCombos.Add(statename, 0, wx.ALIGN_LEFT)
        gridCombos.Add(label_code, 0, wx.ALIGN_LEFT)
        gridCombos.Add(code, 0, wx.ALIGN_LEFT)
        gridCombos.Add(label_selector, 0, wx.ALIGN_LEFT)
        hbox = wx.BoxSizer(wx.HORIZONTAL)
        hbox.Add(self.list_selector, 0, wx.ALIGN_LEFT)
        hbox.Add(wx.StaticText(self, -1, ' => '), 0, wx.ALIGN_LEFT)
        hbox.Add(self.dynamicbox, 0, wx.ALIGN_LEFT)
        gridCombos.Add(hbox, 0, wx.ALIGN_LEFT)

        gridIpAddrs = wx.FlexGridSizer(cols=4, vgap=10, hgap=15)
        gridIpAddrs.Add(label_ipaddr1, 0, wx.ALIGN_LEFT)
        gridIpAddrs.Add(ipaddr1, 0, wx.ALIGN_LEFT)
        gridIpAddrs.Add(label_ipaddr2, 0, wx.ALIGN_LEFT)
        gridIpAddrs.Add(ipaddr2, 0, wx.ALIGN_LEFT)
        gridIpAddrs.Add(label_ipaddr3, 0, wx.ALIGN_LEFT)
        gridIpAddrs.Add(ipaddr3, 0, wx.ALIGN_LEFT)

        gridNumerics = wx.FlexGridSizer(cols=4, vgap=10, hgap=10)
        gridNumerics.Add(label_intctrl1, 0, wx.ALIGN_LEFT)
        gridNumerics.Add(self.intctrl1, 0, wx.ALIGN_LEFT)
        gridNumerics.Add(label_intctrl2, 0, wx.ALIGN_RIGHT)
        gridNumerics.Add(self.intctrl2, 0, wx.ALIGN_LEFT)
        gridNumerics.Add(label_floatctrl, 0, wx.ALIGN_LEFT)
        gridNumerics.Add(self.floatctrl, 0, wx.ALIGN_LEFT)
        gridNumerics.Add(label_numselect, 0, wx.ALIGN_RIGHT)
        gridNumerics.Add(numselect, 0, wx.ALIGN_LEFT)

        self.sizer.Add(labelMaskedCombos, 0, wx.ALIGN_LEFT | wx.ALL, 5)
        self.sizer.Add(gridCombos, 0, wx.ALIGN_LEFT | wx.ALL, border=5)
        self.sizer.Add(wx.StaticLine(self, -1),
                       0,
                       wx.EXPAND | wx.TOP | wx.BOTTOM,
                       border=8)
        self.sizer.Add(labelIpAddrs, 0, wx.ALIGN_LEFT | wx.ALL, 5)
        self.sizer.Add(gridIpAddrs, 0, wx.ALIGN_LEFT | wx.ALL, border=5)
        self.sizer.Add(wx.StaticLine(self, -1),
                       0,
                       wx.EXPAND | wx.TOP | wx.BOTTOM,
                       border=8)
        self.sizer.Add(labelNumerics, 0, wx.ALIGN_LEFT | wx.ALL, 5)
        self.sizer.Add(gridNumerics, 0, wx.ALIGN_LEFT | wx.ALL, border=5)
        self.sizer.Add(parens_check, 0, wx.ALIGN_LEFT | wx.ALL, 5)

        self.SetSizer(self.sizer)
        self.SetAutoLayout(1)
        self.SetupScrolling()

        self.Bind(wx.EVT_COMBOBOX, self.OnComboSelection, id=fraction.GetId())
        self.Bind(wx.EVT_COMBOBOX, self.OnComboSelection, id=code.GetId())
        self.Bind(wx.EVT_COMBOBOX, self.OnComboSelection, id=statecode.GetId())
        self.Bind(wx.EVT_COMBOBOX, self.OnComboSelection, id=statename.GetId())
        self.Bind(wx.EVT_TEXT, self.OnTextChange, id=code.GetId())
        self.Bind(wx.EVT_TEXT, self.OnTextChange, id=statecode.GetId())
        self.Bind(wx.EVT_TEXT, self.OnTextChange, id=statename.GetId())
        self.Bind(wx.EVT_COMBOBOX,
                  self.OnListSelection,
                  id=self.list_selector.GetId())

        self.Bind(wx.EVT_TEXT, self.OnTextChange, id=self.intctrl1.GetId())
        self.Bind(wx.EVT_TEXT, self.OnTextChange, id=self.intctrl2.GetId())
        self.Bind(wx.EVT_TEXT, self.OnTextChange, id=self.floatctrl.GetId())
        self.Bind(wx.EVT_COMBOBOX, self.OnNumberSelect, id=numselect.GetId())
        self.Bind(wx.EVT_CHECKBOX, self.OnParensCheck, id=parens_check.GetId())

        self.Bind(wx.EVT_TEXT, self.OnIpAddrChange, id=ipaddr1.GetId())
        self.Bind(wx.EVT_TEXT, self.OnIpAddrChange, id=ipaddr2.GetId())
        self.Bind(wx.EVT_TEXT, self.OnIpAddrChange, id=ipaddr3.GetId())
Пример #9
0
    def load(self):
        checklist = []

        box_image_title = wx.StaticBox(self, -1, "图片")
        box_image = wx.StaticBoxSizer(box_image_title, wx.VERTICAL)
        grid_image = wx.FlexGridSizer(cols=3)
        self.image_ctrls = list()
        for item in self.query_items.keys():
            if self.query_items[item]['field'] not in ['id', 'path']:
                if self.query_items[item]['field'] == 'date':
                    self.ctr_date_from = PopupControl.PopControl(self,
                                                                 1,
                                                                 checklist,
                                                                 self,
                                                                 -1,
                                                                 pos=(30, 30))
                    self.ctr_date_to = PopupControl.PopControl(self,
                                                               1,
                                                               checklist,
                                                               self,
                                                               -1,
                                                               pos=(30, 30))
                    st = wx.StaticText(self, -1, ' ≤ 采集日期 ≤ ')
                    self.image_ctrls.append(
                        (self.ctr_date_from, st, self.ctr_date_to))

                    self.ctr_time_from = masked.Ctrl(
                        self,
                        -1,
                        "",
                        autoformat='24HRTIMEHHMMSS',
                        demo=True,
                        name='24HRTIME')
                    self.ctr_time_from.SetValue('00:00:00')
                    self.ctr_time_to = masked.Ctrl(self,
                                                   -1,
                                                   "",
                                                   autoformat='24HRTIMEHHMMSS',
                                                   demo=True,
                                                   name='24HRTIME')
                    self.ctr_time_to.SetValue('23:59:59')
                    st = wx.StaticText(self, -1, ' ≤ 采集时间 ≤ ')
                    self.image_ctrls.append(
                        (self.ctr_time_from, st, self.ctr_time_to))

                elif self.query_items[item]['field'] in [
                        'speed', 'scale', 'width', 'height'
                ]:  # 范围
                    ctrl1 = wx.TextCtrl(self, -1, "", size=(120, -1))
                    setattr(
                        self, 'ctr' + '_' + self.query_items[item]['field'] +
                        '_from', ctrl1)
                    st = wx.StaticText(self, -1, ' ≤ ' + item + ' ≤ ')
                    ctrl2 = wx.TextCtrl(self, -1, "", size=(120, -1))
                    setattr(
                        self,
                        'ctr' + '_' + self.query_items[item]['field'] + '_to',
                        ctrl2)
                    self.image_ctrls.append((ctrl1, st, ctrl2))

                elif self.query_items[item]['field'] in [
                        'quality', 'line', 'side', 'site', 'weather', 'set',
                        'state'
                ]:
                    st = wx.StaticText(self, -1, item)
                    _sql = 'SELECT dmp.image.%s FROM dmp.image group by dmp.image.%s' % (
                        self.query_items[item]['field'],
                        self.query_items[item]['field'])
                    _data = Util.execute_sql(_sql)
                    _list = [str(x[0]) for x in _data]
                    ctrl = PopupControl.PopControl(self,
                                                   2,
                                                   _list,
                                                   self,
                                                   -1,
                                                   pos=(30, 30))
                    setattr(
                        self, 'ctr' + '_' + self.query_items[item]['field'] +
                        '_select', ctrl)
                    self.image_ctrls.append((st, None, ctrl))

                elif self.query_items[item]['field'] in ['code']:
                    dct = dict()
                    _sql = 'SELECT distinct %s FROM dmp.image group by %s' % (
                        self.query_items[item]['field'],
                        self.query_items[item]['field'])
                    _data = Util.execute_sql(_sql)
                    _list = [str(x[0]) for x in _data]
                    for c in _list:
                        _kind = ''
                        _type = ''
                        if 'X' * 20 == c:
                            continue
                        if c[0] == 'J':
                            _kind = c[1:4]
                        elif c[0] == 'K':
                            _type = c[1:4]
                            _kind = c[4:6]
                        elif c[0] == 'D':
                            _type = 'D'
                        elif c[0] == 'T' or c[0] == 'Q':
                            _type = c[1]
                            _kind = c[2:7]
                        else:
                            pass
                        if c[0] not in dct.keys():
                            dct[c[0]] = dict()

                        if _type not in dct[c[0]].keys():
                            dct[c[0]][_type] = list()

                        dct[c[0]][_type].append(_kind)
                    _types = [
                        x for x in [list(dct[k1].keys()) for k1 in dct.keys()]
                        if x != ['']
                    ]
                    lt = list()
                    for t in _types:
                        lt.extend(t)
                    _kinds = [
                        x
                        for x in [list(dct[k1].values()) for k1 in dct.keys()]
                        if x != ['']
                    ]
                    lk = list()
                    for k in _kinds:
                        for kk in k:
                            lk.extend(kk)
                    lk = list(set(lk))
                    st = wx.StaticText(self, -1, '车属性')
                    ctrl = PopupControl.PopControl(self,
                                                   2,
                                                   list(dct.keys()),
                                                   self,
                                                   -1,
                                                   pos=(30, 30))
                    setattr(
                        self, 'ctr' + '_' + self.query_items[item]['field'] +
                        '_property', ctrl)
                    self.image_ctrls.append((st, None, ctrl))

                    st = wx.StaticText(self, -1, '车种')
                    ctrl = PopupControl.PopControl(self,
                                                   2,
                                                   lt,
                                                   self,
                                                   -1,
                                                   pos=(30, 30))
                    setattr(
                        self, 'ctr' + '_' + self.query_items[item]['field'] +
                        '_type', ctrl)
                    self.image_ctrls.append((st, None, ctrl))

                    st = wx.StaticText(self, -1, '车型')
                    ctrl = PopupControl.PopControl(self,
                                                   2,
                                                   lk,
                                                   self,
                                                   -1,
                                                   pos=(30, 30))
                    setattr(
                        self, 'ctr' + '_' + self.query_items[item]['field'] +
                        '_kind', ctrl)
                    self.image_ctrls.append((st, None, ctrl))
                else:
                    checklist.append(item)
        if len(checklist) > 0:
            st = wx.StaticText(self, -1, '其他')
            ctrl = PopupControl.PopControl(self,
                                           2,
                                           checklist,
                                           self,
                                           -1,
                                           pos=(30, 30))
            setattr(self, 'ctr_other', ctrl)
            self.image_ctrls.append((st, None, ctrl))

        for item1, item2, item3 in self.image_ctrls:
            grid_image.Add(item1, 0,
                           wx.ALIGN_CENTRE | wx.LEFT | wx.RIGHT | wx.TOP, 5)
            if item2 is None:
                grid_image.Add(wx.StaticText(self, -1, ''), 0,
                               wx.ALIGN_CENTRE | wx.LEFT | wx.RIGHT | wx.TOP,
                               5)
            else:
                grid_image.Add(item2, 0,
                               wx.ALIGN_CENTRE | wx.LEFT | wx.RIGHT | wx.TOP,
                               5)
            grid_image.Add(item3, 0,
                           wx.ALIGN_CENTRE | wx.LEFT | wx.RIGHT | wx.TOP, 5)

        box_image.Add(grid_image, 0, wx.LEFT | wx.ALL, 5)
        self.ALL_SIZER.Add(box_image, 0, wx.LEFT | wx.ALL, 5)

        box_label_title = wx.StaticBox(self, -1, "标签")
        box_label = wx.StaticBoxSizer(box_label_title, wx.VERTICAL)
        grid_label = wx.FlexGridSizer(cols=3)
        self.label_ctrls = []
        st = wx.StaticText(self, -1, '标签类型')
        ctrl = PopupControl.PopControl(self,
                                       2,
                                       Util.label_type,
                                       self,
                                       -1,
                                       pos=(30, 30))
        # ctrl.SetValue(Util.label_type[0])
        setattr(self, 'ctr_label_type', ctrl)
        self.label_ctrls.append((st, None, ctrl))

        if not self.is_nagetive:
            st = wx.StaticText(self, -1, '包含检测项')
        else:
            st = wx.StaticText(self, -1, '不包含检测项')
        ctrl = PopupControl.PopControl(self,
                                       2,
                                       list(Util.label_object.values()),
                                       self,
                                       -1,
                                       pos=(30, 30))
        setattr(self, 'ctr_label_object', ctrl)
        self.label_ctrls.append((st, None, ctrl))

        st = wx.StaticText(self, -1, '报警类型')
        ctrl = PopupControl.PopControl(self,
                                       2,
                                       Util.alarm_type,
                                       self,
                                       -1,
                                       pos=(30, 30))
        setattr(self, 'ctr_alarm_type', ctrl)
        self.label_ctrls.append((st, None, ctrl))

        if self.is_nagetive:
            st = wx.StaticText(self, -1, '测试集比例')
            ctrl = wx.TextCtrl(self, -1)
            setattr(self, 'ctr_testset_input', ctrl)
            self.label_ctrls.append((st, None, ctrl))

            st = wx.StaticText(self, -1, '训练集比例')
            ctrl = wx.TextCtrl(self, -1)
            setattr(self, 'ctr_trainset_input', ctrl)
            self.label_ctrls.append((st, None, ctrl))

            st = wx.StaticText(self, -1, '样本数量')
            ctrl = wx.TextCtrl(self, -1)
            setattr(self, 'ctr_samples_input', ctrl)
            self.label_ctrls.append((st, None, ctrl))

        for item1, item2, item3 in self.label_ctrls:
            grid_label.Add(item1, 0,
                           wx.ALIGN_CENTRE | wx.LEFT | wx.RIGHT | wx.TOP, 5)
            if item2 is None:
                grid_label.Add(wx.StaticText(self, -1, ''), 0,
                               wx.ALIGN_CENTRE | wx.LEFT | wx.RIGHT | wx.TOP,
                               5)
            else:
                grid_label.Add(item2, 0,
                               wx.ALIGN_CENTRE | wx.LEFT | wx.RIGHT | wx.TOP,
                               5)
            grid_label.Add(item3, 0,
                           wx.ALIGN_CENTRE | wx.LEFT | wx.RIGHT | wx.TOP, 5)

        box_label.Add(grid_label, 0, wx.LEFT | wx.ALL, 5)
        self.ALL_SIZER.Add(box_label, 0, wx.LEFT | wx.ALL, 5)
        if not self.is_nagetive:
            _line_sizer = wx.BoxSizer(wx.HORIZONTAL)
            self.btn_query = wx.Button(self, -1, '检索')
            self.btn_query.Bind(wx.EVT_BUTTON, self.on_query_click)
            # self.btn_clear = wx.Button(self, -1, '清空')
            # self.btn_clear.Bind(wx.EVT_BUTTON, self.on_clear_click)
            _line_sizer.Add(self.btn_query, 0, wx.ALIGN_CENTRE, 5)
            # _line_sizer.Add(self.btn_clear, 0, wx.ALIGN_CENTRE, 5)
            self.ALL_SIZER.Add(_line_sizer, 0, wx.ALIGN_CENTRE, 5)
        else:
            self.btn_query = wx.Button(self, -1, '确定')
            self.btn_query.Bind(wx.EVT_BUTTON, self.on_query_click)
            self.ALL_SIZER.Add(self.btn_query, 1, wx.ALIGN_CENTRE | wx.ALL, 5)
        self.SetSizer(self.ALL_SIZER)
        self.SetupScrolling()
Пример #10
0
    def _init_ctrls(self, prnt):
        wx.Panel.__init__(self,
                          id=wxID_WXPANEL1,
                          name='',
                          parent=prnt,
                          pos=wx.Point(304, 219),
                          size=wx.Size(337, 300),
                          style=wx.TAB_TRAVERSAL)
        self.SetClientSize(wx.Size(337, 300))

        proj = self.project

        sizer = wx.BoxSizer(wx.VERTICAL)

        import wx.lib.filebrowsebutton as filebrowse

        self.fbb = filebrowse.FileBrowseButton(self, -1, labelText=_("Icon"))
        self.fbb.SetValue(proj.icon)
        sizer.Add(self.fbb, 0, wx.GROW | wx.ALIGN_CENTRE | wx.ALL, 2)

        self.readme = filebrowse.FileBrowseButton(self,
                                                  -1,
                                                  labelText=_("Readme file"))
        self.readme.SetValue(proj.readme_path)
        sizer.Add(self.readme, 0, wx.GROW | wx.ALIGN_CENTRE | wx.ALL, 2)

        self.eula = filebrowse.FileBrowseButton(
            self, -1, labelText=_("End of user license agreement file"))
        self.eula.SetValue(proj.eula_path)
        sizer.Add(self.eula, 0, wx.GROW | wx.ALIGN_CENTRE | wx.ALL, 2)

        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, _("Optimization"))
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 2)

        self.optim = wx.ComboBox(self,
                                 -1,
                                 proj.optimization,
                                 choices=[_("Default"),
                                          _("Debug"),
                                          _("All")])
        box.Add(self.optim, 1, wx.ALIGN_CENTRE | wx.ALL, 2)
        sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 2)

        self.upx = wx.CheckBox(self, -1, _("Use upx"))
        self.upx.SetValue(proj.use_upx)
        sizer.Add(self.upx, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 0)

        self.not_one_file = wx.CheckBox(self, -1,
                                        _("Do not create an unique file"))
        self.not_one_file.SetValue(proj.no_single_file)
        sizer.Add(self.not_one_file, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 0)

        self.display_console = wx.CheckBox(self, -1, _("Display console"))
        self.display_console.SetValue(proj.use_console)
        sizer.Add(self.display_console, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL,
                  0)

        self.tcl_tk = wx.CheckBox(self, -1, _("Use Tcl/Tk"))
        self.tcl_tk.SetValue(proj.use_tk)
        sizer.Add(self.tcl_tk, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 0)

        box_label = wx.StaticBox(self, -1,
                                 _("Executable's informations (Windows only)"))
        buttonbox = wx.StaticBoxSizer(box_label, wx.VERTICAL)

        infosizer = wx.BoxSizer(wx.HORIZONTAL)
        label = wx.StaticText(self, -1, _("Product name"))
        infosizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 1)
        self.product_name = wx.TextCtrl(self, -1, proj.product_name)
        infosizer.Add(self.product_name, 1, wx.ALIGN_CENTRE | wx.ALL, 1)
        buttonbox.Add(infosizer, 0, wx.GROW | wx.ALIGN_CENTRE | wx.ALL, 1)

        infosizer = wx.BoxSizer(wx.HORIZONTAL)
        label = wx.StaticText(self, -1, _("Company"))
        infosizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 1)
        self.company = wx.TextCtrl(self, -1, proj.company_name)
        infosizer.Add(self.company, 1, wx.ALIGN_CENTRE | wx.ALL, 1)
        buttonbox.Add(infosizer, 0, wx.GROW | wx.ALIGN_CENTRE | wx.ALL, 1)

        infosizer = wx.BoxSizer(wx.HORIZONTAL)
        label = wx.StaticText(self, -1, _("Version"))
        infosizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 1)
        proj.product_version = 1.0
        self.version = masked.Ctrl(self,
                                   value=proj.product_version,
                                   integerWidth=2,
                                   fractionWidth=2,
                                   controlType=masked.controlTypes.NUMBER)
        infosizer.Add(self.version, 1, wx.ALIGN_CENTRE | wx.ALL, 1)
        buttonbox.Add(infosizer, 0, wx.GROW | wx.ALIGN_CENTRE | wx.ALL, 1)

        infosizer = wx.BoxSizer(wx.HORIZONTAL)
        label = wx.StaticText(self, -1, _("Description"))
        infosizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 1)
        self.description = wx.TextCtrl(self, -1, proj.description)
        infosizer.Add(self.description, 1, wx.ALIGN_CENTRE | wx.ALL, 1)
        buttonbox.Add(infosizer, 0, wx.GROW | wx.ALIGN_CENTRE | wx.ALL, 1)

        infosizer = wx.BoxSizer(wx.HORIZONTAL)
        label = wx.StaticText(self, -1, _("Copyrights"))
        infosizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 1)
        self.copyrights = wx.TextCtrl(self, -1, proj.copyrights)
        infosizer.Add(self.copyrights, 1, wx.ALIGN_CENTRE | wx.ALL, 1)
        buttonbox.Add(infosizer, 0, wx.GROW | wx.ALIGN_CENTRE | wx.ALL, 1)

        infosizer = wx.BoxSizer(wx.HORIZONTAL)
        label = wx.StaticText(self, -1, _("License"))
        infosizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 1)
        self.license = wx.TextCtrl(self, -1, proj.license)
        infosizer.Add(self.license, 1, wx.ALIGN_CENTRE | wx.ALL, 1)
        buttonbox.Add(infosizer, 0, wx.GROW | wx.ALIGN_CENTRE | wx.ALL, 1)

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

        self.SetSizer(sizer)
        sizer.Fit(self)
Пример #11
0
    def __init__(self, parent, portfolio, operation):
        iTradeSizedDialog.__init__(self,
                                   None,
                                   -1,
                                   message('portfolio_properties_%s' %
                                           operation),
                                   style=wx.DEFAULT_DIALOG_STYLE,
                                   size=(420, 420))

        if portfolio:
            self.m_filename = portfolio.filename()
            self.m_name = portfolio.name()
            self.m_accountref = portfolio.accountref()
            self.m_market = portfolio.market()
            self.m_currency = portfolio.currency()
            self.m_vat = portfolio.vat()
            self.m_term = portfolio.term()
            self.m_risk = portfolio.risk()
            self.m_indice = portfolio.indice()
        else:
            self.m_filename = 'noname'
            self.m_name = ''
            self.m_accountref = ''
            self.m_market = 'EURONEXT'
            self.m_currency = 'EUR'
            self.m_vat = 1.196
            self.m_term = 3
            self.m_risk = 5
            self.m_indice = getDefaultIndice(self.m_market)
        self.m_operation = operation

        # container
        container = self.GetContentsPane()
        container.SetSizerType("vertical")

        # resizable pane
        pane = sc.SizedPanel(container, -1)
        pane.SetSizerType("form")
        pane.SetSizerProps(expand=True)

        # row1 : filename
        label = wx.StaticText(pane, -1, message('portfolio_filename'))
        label.SetSizerProps(valign='center')
        self.wxFilenameCtrl = wx.TextCtrl(pane,
                                          -1,
                                          self.m_filename,
                                          size=(120, -1))
        self.wxFilenameCtrl.SetSizerProps(expand=True)

        # row2 : name
        label = wx.StaticText(pane, -1, message('portfolio_name'))
        label.SetSizerProps(valign='center')
        self.wxNameCtrl = wx.TextCtrl(pane, -1, self.m_name, size=(180, -1))
        self.wxNameCtrl.SetSizerProps(expand=True)

        # row3 : accountref
        label = wx.StaticText(pane, -1, message('portfolio_accountref'))
        label.SetSizerProps(valign='center')

        self.wxAccountRefCtrl = wx.TextCtrl(pane,
                                            -1,
                                            self.m_accountref,
                                            size=(80, -1))
        self.wxAccountRefCtrl.SetSizerProps(expand=True)

        # row4 : market
        label = wx.StaticText(pane, -1, message('portfolio_market'))
        label.SetSizerProps(valign='center')

        self.wxMarketCtrl = wx.ComboBox(pane,
                                        -1,
                                        "",
                                        size=wx.Size(160, -1),
                                        style=wx.CB_DROPDOWN | wx.CB_READONLY)
        wx.EVT_COMBOBOX(self, self.wxMarketCtrl.GetId(), self.OnMarket)

        count = 0
        for eachCtrl in list_of_markets():
            self.wxMarketCtrl.Append(eachCtrl, eachCtrl)
            if eachCtrl == self.m_market:
                idx = count
            count = count + 1

        self.wxMarketCtrl.SetSelection(idx)

        # row5 : main indice
        label = wx.StaticText(pane, -1, message('portfolio_indicator'))
        label.SetSizerProps(valign='center')

        self.wxIndicatorCtrl = wx.ComboBox(pane,
                                           -1,
                                           "",
                                           size=wx.Size(160, -1),
                                           style=wx.CB_DROPDOWN
                                           | wx.CB_READONLY)
        wx.EVT_COMBOBOX(self, self.wxIndicatorCtrl.GetId(), self.OnIndicator)

        count = 0
        for eachCtrl in quotes.list():
            if eachCtrl.list() == QLIST_INDICES:
                #self.wxIndicatorCtrl.Append(eachCtrl.name(),eachCtrl.isin())
                try:
                    self.wxIndicatorCtrl.Append(eachCtrl.name(),
                                                eachCtrl.isin())
                except:
                    print 'eachCtrl:', eachCtrl
                if eachCtrl.isin() == self.m_indice:
                    idx = count
                count = count + 1

        self.wxIndicatorCtrl.SetSelection(idx)

        # row6 : currency
        label = wx.StaticText(pane, -1, message('portfolio_currency'))
        label.SetSizerProps(valign='center')

        self.wxCurrencyCtrl = wx.ComboBox(pane,
                                          -1,
                                          "",
                                          size=wx.Size(80, -1),
                                          style=wx.CB_DROPDOWN
                                          | wx.CB_READONLY)
        wx.EVT_COMBOBOX(self, self.wxCurrencyCtrl.GetId(), self.OnCurrency)

        count = 0
        for eachCtrl in list_of_currencies():
            #print eachCtrl
            self.wxCurrencyCtrl.Append(eachCtrl, eachCtrl)
            if eachCtrl == self.m_currency:
                idx = count
            count = count + 1

        self.wxCurrencyCtrl.SetSelection(idx)

        # row7 : default vat
        label = wx.StaticText(pane, -1, message('portfolio_vat'))
        label.SetSizerProps(valign='center')

        self.wxVATCtrl = masked.Ctrl(pane,
                                     integerWidth=5,
                                     fractionWidth=3,
                                     controlType=masked.controlTypes.NUMBER,
                                     allowNegative=False,
                                     groupChar=getGroupChar(),
                                     decimalChar=getDecimalChar())
        self.wxVATCtrl.SetValue((self.m_vat - 1) * 100)

        # Row8 : trading style
        label = wx.StaticText(container, -1, message('prop_tradingstyle'))

        btnpane = sc.SizedPanel(container,
                                -1,
                                style=wx.RAISED_BORDER | wx.CAPTION
                                | wx.TAB_TRAVERSAL | wx.CLIP_CHILDREN
                                | wx.NO_FULL_REPAINT_ON_RESIZE)
        btnpane.SetSizerType("form")
        btnpane.SetSizerProps(expand=True)

        label = wx.StaticText(btnpane, -1, message('prop_term'))
        label.SetSizerProps(valign='center')

        self.wxTermCtrl = masked.Ctrl(btnpane,
                                      integerWidth=3,
                                      fractionWidth=0,
                                      controlType=masked.controlTypes.NUMBER,
                                      allowNegative=False,
                                      groupChar=getGroupChar(),
                                      decimalChar=getDecimalChar())
        self.wxTermCtrl.SetValue(self.m_term)

        label = wx.StaticText(btnpane, -1, message('prop_risk'))
        label.SetSizerProps(valign='center')

        self.wxRiskCtrl = masked.Ctrl(btnpane,
                                      integerWidth=3,
                                      fractionWidth=0,
                                      controlType=masked.controlTypes.NUMBER,
                                      allowNegative=False,
                                      groupChar=getGroupChar(),
                                      decimalChar=getDecimalChar())
        self.wxRiskCtrl.SetValue(self.m_risk)

        # row 9 : separator
        line = wx.StaticLine(container,
                             -1,
                             size=(20, -1),
                             style=wx.LI_HORIZONTAL)
        line.SetSizerProps(expand=True)

        # Last Row : OK and Cancel
        btnpane = sc.SizedPanel(container, -1)
        btnpane.SetSizerType("horizontal")
        btnpane.SetSizerProps(expand=True)

        if operation == 'create':
            msg = message('portfolio_properties_btncreate')
            msgdesc = message('portfolio_properties_btncreatedesc')
            fnt = self.OnValid
        elif operation == 'delete':
            msg = message('portfolio_properties_btndelete')
            msgdesc = message('portfolio_properties_btndeletedesc')
            fnt = self.OnValid
        elif operation == 'edit':
            msg = message('portfolio_properties_btnedit')
            msgdesc = message('portfolio_properties_btneditdesc')
            fnt = self.OnValid
        elif operation == 'rename':
            msg = message('portfolio_properties_btnrename')
            msgdesc = message('portfolio_properties_btnrenamedesc')
            fnt = self.OnValid
        else:
            msg = message('valid')
            msgdesc = message('valid_desc')
            fnt = self.OnValid

        # context help
        if wx.Platform != "__WXMSW__":
            btn = wx.ContextHelpButton(btnpane)

        # OK
        btn = wx.Button(btnpane, wx.ID_OK, msg)
        btn.SetDefault()
        btn.SetHelpText(msgdesc)
        wx.EVT_BUTTON(self, wx.ID_OK, fnt)

        # CANCEL
        btn = wx.Button(btnpane, wx.ID_CANCEL, message('cancel'))
        btn.SetHelpText(message('cancel_desc'))

        # enable some fields based on the operation
        if operation == 'edit':
            # edit: filename, market and currency can't be changed
            self.wxFilenameCtrl.Enable(False)
            self.wxMarketCtrl.Enable(False)
            self.wxCurrencyCtrl.Enable(False)
            #self.wxNameCtrl.SetFocus()
        elif operation == 'delete':
            # display only
            self.wxFilenameCtrl.Enable(False)
            self.wxNameCtrl.Enable(False)
            self.wxAccountRefCtrl.Enable(False)
            self.wxMarketCtrl.Enable(False)
            self.wxCurrencyCtrl.Enable(False)
            self.wxVATCtrl.Enable(False)
            self.wxTermCtrl.Enable(False)
            self.wxRiskCtrl.Enable(False)
            self.wxIndicatorCtrl.Enable(False)
            #self.btn.SetFocus()
        elif operation == 'rename':
            # filename only
            self.wxNameCtrl.Enable(False)
            self.wxAccountRefCtrl.Enable(False)
            self.wxMarketCtrl.Enable(False)
            self.wxCurrencyCtrl.Enable(False)
            self.wxVATCtrl.Enable(False)
            self.wxTermCtrl.Enable(False)
            self.wxRiskCtrl.Enable(False)
            self.wxIndicatorCtrl.Enable(False)
            #self.btn.SetFocus()
        else:
            # everything is editable
            pass

        # a little trick to make sure that you can't resize the dialog to
        # less screen space than the controls need
        self.Fit()
        self.SetMinSize(self.GetSize())
Пример #12
0
    def __init__(self, parent, title):
        # create frame
        frame = wx.Frame.__init__(self,
                                  parent,
                                  -1,
                                  title,
                                  size=(frame_size_x, frame_size_y))

        self.MazeClassic = 1

        # create status bar
        self.m_status = self.CreateStatusBar(1)

        sizer = wx.BoxSizer(wx.VERTICAL)

        bs = wx.BoxSizer(wx.HORIZONTAL)
        b = wx.Button(self, 1, "Init Classic")
        self.Bind(wx.EVT_BUTTON, self.OnInitClassic, b)
        bs.Add(b, 0, wx.ALIGN_LEFT)

        b = wx.Button(self, 2, "Init Half")
        self.Bind(wx.EVT_BUTTON, self.OnInitHalf, b)
        bs.Add(b, 0, wx.ALIGN_LEFT)

        b = wx.Button(self, 3, "Turn L90")
        self.Bind(wx.EVT_BUTTON, self.OnBtn3, b)
        bs.Add(b, 0, wx.ALIGN_LEFT)

        b = wx.Button(self, 4, "Turn R90")
        self.Bind(wx.EVT_BUTTON, self.OnBtn4, b)
        bs.Add(b, 0, wx.ALIGN_LEFT)

        b = wx.Button(self, 5, "None")
        self.Bind(wx.EVT_BUTTON, self.OnBtn5, b)
        bs.Add(b, 0, wx.ALIGN_LEFT)

        b = wx.Button(self, 6, "None")
        self.Bind(wx.EVT_BUTTON, self.OnBtn6, b)
        bs.Add(b, 0, wx.ALIGN_LEFT)

        sizer.Add(bs, 0, wx.ALIGN_TOP)

        bs = wx.BoxSizer(wx.HORIZONTAL)
        b = wx.Button(self, 20, "N->45")
        self.Bind(wx.EVT_BUTTON, self.OnBtn45, b)
        bs.Add(b, 0, wx.ALIGN_LEFT)

        b = wx.Button(self, 21, "N->90")
        self.Bind(wx.EVT_BUTTON, self.OnBtn90, b)
        bs.Add(b, 0, wx.ALIGN_LEFT)

        b = wx.Button(self, 22, "N->135")
        self.Bind(wx.EVT_BUTTON, self.OnBtn135, b)
        bs.Add(b, 0, wx.ALIGN_LEFT)

        b = wx.Button(self, 23, "N->180")
        self.Bind(wx.EVT_BUTTON, self.OnBtn180, b)
        bs.Add(b, 0, wx.ALIGN_LEFT)

        sizer.Add(bs, 0, wx.ALIGN_TOP)

        bs = wx.BoxSizer(wx.HORIZONTAL)
        b = wx.Button(self, 30, "D->45")
        self.Bind(wx.EVT_BUTTON, self.OnBtnDiagTo45, b)
        bs.Add(b, 0, wx.ALIGN_LEFT)

        b = wx.Button(self, 31, "D->90")
        self.Bind(wx.EVT_BUTTON, self.OnBtnDiagTo90, b)
        bs.Add(b, 0, wx.ALIGN_LEFT)

        b = wx.Button(self, 32, "D->135")
        self.Bind(wx.EVT_BUTTON, self.OnBtnDiagTo135, b)
        bs.Add(b, 0, wx.ALIGN_LEFT)

        sizer.Add(bs, 0, wx.ALIGN_TOP)

        bs = wx.BoxSizer(wx.HORIZONTAL)
        e = self.e1 = masked.Ctrl(self,
                                  integerWidth=1,
                                  fractionWidth=10,
                                  controlType=masked.controlTypes.NUMBER)
        bs.Add(e, 0, wx.ALIGN_LEFT)
        e = self.e2 = masked.Ctrl(self,
                                  integerWidth=1,
                                  fractionWidth=10,
                                  controlType=masked.controlTypes.NUMBER)
        bs.Add(e, 0, wx.ALIGN_LEFT)
        e = self.e3 = masked.Ctrl(self,
                                  integerWidth=1,
                                  fractionWidth=10,
                                  controlType=masked.controlTypes.NUMBER)
        bs.Add(e, 0, wx.ALIGN_LEFT)

        sizer.Add(bs, 0, wx.ALIGN_TOP)

        # Add the Canvas
        NC = NavCanvas.NavCanvas(self, Debug=0, BackgroundColor="Black")

        self.Canvas = NC.Canvas
        sizer.Add(NC, 1, wx.EXPAND)

        self.SetSizer(sizer)
Пример #13
0
    def __init__(self, *a, **k):
        wx.Panel.__init__(self, *a, **k)

        # controlli ------------------------------------------------------------
        self.cognome = wx.TextCtrl(self, validator=CFValidator())
        self.nome = wx.TextCtrl(self, validator=CFValidator())
        self.sesso = wx.RadioBox(self, -1, choices=['M', 'F'])
        self.nascita = masked.Ctrl(self, autoformat='EUDATEDDMMYYYY.', 
                                   emptyInvalid=True)
        self.stato = wx.ComboBox(self, style=wx.CB_DROPDOWN|wx.CB_READONLY)
        self.provincia = wx.ComboBox(self, style=wx.CB_DROPDOWN|wx.CB_READONLY, 
                                     validator=CFValidator())
        self.comune = wx.ComboBox(self, style=wx.CB_DROPDOWN|wx.CB_READONLY, 
                                  validator=CFValidator())
        calcola = wx.Button(self, -1, 'CALCOLA CODICE')
        reset = wx.Button(self, -1, 'resetta')
        self.codice = wx.TextCtrl(self)
        copia = wx.Button(self, -1, 'copia')
        
        # setting --------------------------------------------------------------
        self.SetFont(wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, 
                             wx.FONTSTYLE_NORMAL))
        self.codice.SetFont(wx.Font(10, wx.FONTFAMILY_MODERN, 
                                    wx.FONTSTYLE_NORMAL, wx.FONTSTYLE_NORMAL))
        self.codice.SetEditable(False)
        calcola.SetDefault()
        self.stato.SetItems(['ITALIA'] + self._chiedi_al_db('lista_stati'))
        self.stato.SetValue('ITALIA')
        self.provincia.SetItems([''] + self._chiedi_al_db('lista_province'))
        self.provincia.SetValue('')
        
        # bindig ---------------------------------------------------------------
        for ctl, evt in ((calcola, self.su_calcola), (reset, self.su_reset), 
                         (copia, self.su_copia)):
            ctl.Bind(wx.EVT_BUTTON, evt)
        for ctl, evt in ((self.stato, self.su_stato), 
                         (self.provincia, self.su_provincia)):
            ctl.Bind(wx.EVT_COMBOBOX, evt)
        
        # layout ---------------------------------------------------------------
        g = wx.FlexGridSizer(7, 2, 5, 5)
        g.AddGrowableCol(1)
        for lab, ctl, flag in (
                ('cognome', self.cognome, wx.EXPAND), 
                ('nome', self.nome, wx.EXPAND), ('sesso', self.sesso, 0), 
                ('nato il', self.nascita, 0), ('stato', self.stato, wx.EXPAND), 
                ('provincia', self.provincia, wx.EXPAND),
                ('comune', self.comune, wx.EXPAND)):
            g.Add(wx.StaticText(self, -1, lab), 0, wx.ALIGN_CENTER_VERTICAL)
            g.Add(ctl, 0, flag)
        
        b1 = wx.BoxSizer()
        b1.Add(calcola, 2, wx.EXPAND|wx.ALL, 5)
        b1.Add(reset, 1, wx.EXPAND|wx.ALL, 5)
        
        b2 = wx.BoxSizer()
        b2.Add(self.codice, 2, wx.EXPAND|wx.ALL, 5)
        b2.Add(copia, 1, wx.EXPAND|wx.ALL, 5)
        
        s = wx.BoxSizer(wx.VERTICAL)
        s.Add(g, 0, wx.EXPAND|wx.ALL, 5)
        s.Add((5, 5))
        s.Add(b1, 0, wx.EXPAND)
        s.Add((5, 5))
        s.Add(b2, 0, wx.EXPAND)
        self.SetSizer(s)
        self.Fit()