Python wx 模块,TE_RIGHT 实例源码

我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用wx.TE_RIGHT

项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def __init__(self, parent, name, init, stextwidth):
        def OnEdit(event):
            text = event.GetString()
            point = self.value.GetInsertionPoint()
            if (IsNumber(self.value.GetValue()) == False):
                self.value.SetBackgroundColour( "Pink" )
                self.value.SetForegroundColour( "Black" )
            else:
                self.value.SetBackgroundColour(wx.NullColour)
                self.value.SetForegroundColour(wx.NullColour)
                self.value.ChangeValue(text)
                self.value.SetInsertionPoint(point)
        fontpointsize=wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT).GetPointSize()
        self.font = wx.Font(fontpointsize, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
        wx.BoxSizer.__init__(self, wx.HORIZONTAL)
        dc = wx.ScreenDC()
        dc.SetFont(self.font)
        textw,texth = dc.GetTextExtent(name)
        if textw > stextwidth:
            labelw = textw
        else:
            labelw = stextwidth
        self.label = StaticTextNew(parent, -1, name, style =wx.ALIGN_RIGHT, size=(labelw,-1) )
        self.label.SetFont(self.font)
        self.Add( self.label, 0, wx.CENTER )
        self.value = TextCtrlNew(parent, value=str(init), style=wx.TE_PROCESS_ENTER)
        self.value.SetWindowStyle(wx.TE_RIGHT)
        self.value.SetFont(self.font)
        self.value.Bind(wx.EVT_TEXT, OnEdit)
        self.Add( self.value, 1, wx.CENTER|wx.EXPAND )
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def __init__(self, parent, rang, accury):
        wx.TextCtrl.__init__(self, parent, wx.TE_RIGHT)
        self.min, self.max = rang
        self.accury = accury
        wx.TextCtrl.Bind(self, wx.EVT_KEY_UP, self.ontext)

    #! TODO: what is this?
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def __init__(self, parent):
        wx.TextCtrl.__init__(self, parent, wx.TE_RIGHT)
        wx.TextCtrl.Bind(self, wx.EVT_KEY_UP, self.ontext)
        wx.TextCtrl.Bind(self, wx.EVT_LEFT_DOWN, self.oncolor)
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def __init__(self, parent, name, smax, smin, sinc, sinit, stextwidth, swidth):
        if abs(sinc) < 1.0:
            self.precision = "%."+str(str(sinc)[::-1].find('.'))+"f"
        else:
            self.precision = "%d"
        def OnSpin(pos):
            self.value.ChangeValue(self.precision%(sinc * pos + self.remainder))
        def OnEdit(event):
            text = event.GetString()
            point = self.value.GetInsertionPoint()
            if (IsNumber(self.value.GetValue()) == False):
                self.value.SetBackgroundColour( "Pink" )
                self.value.SetForegroundColour( "Black" )
            else:
                self.value.SetBackgroundColour(wx.NullColour)
                self.value.SetForegroundColour(wx.NullColour)
                self.value.ChangeValue(text)
                self.value.SetInsertionPoint(point)
                if ( text == '' or  text == '.'): self.spin.SetValue(smin/sinc);
                try:
                    self.spin.SetValue(int(float(text)/sinc))
                except:
                    pass
                event.Skip()
        fontpointsize=wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT).GetPointSize()
        self.font = wx.Font(fontpointsize, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
        dc = wx.ScreenDC()
        dc.SetFont(self.font)
        textw,texth = dc.GetTextExtent(name)
        if textw > stextwidth:
            labelw = textw
        else:
            labelw = stextwidth
        wx.BoxSizer.__init__(self, wx.HORIZONTAL)
        self.label = StaticTextNew(parent, -1, name, style=wx.ALIGN_RIGHT, size=(labelw,-1) )
        self.label.SetFont(self.font)
        self.Add( self.label, 0, wx.CENTER )
        self.value = TextCtrlNew(parent, value=str(sinit),size=(swidth, -1), style=wx.TE_PROCESS_ENTER)
        self.value.SetWindowStyle(wx.TE_RIGHT)
        self.value.SetFont(self.font)
        self.value.Bind(wx.EVT_TEXT, OnEdit)
        self.Add( self.value, 0, wx.CENTER )
        bw,bh = dc.GetTextExtent("0")
        spinw = int(1.5*bh)
        self.spin = SpinButtonNew(parent, size=(spinw,-1), spinfunc=OnSpin)
        self.spin.SetRange(int(smin/sinc), int(smax/sinc))
        self.spin.SetValue(int(sinit/sinc))
        self.remainder = smin%sinc
        self.Add( self.spin, 0, wx.CENTER )
        self.IsEnabled = True
        self.Layout()
        self.Show()