Python Forum

Full Version: make StaticText limit Number
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have an issue with StaticText, and I do not know how to make it accept only the following data = '0123456789.' . Of course, when you type any letter, the letter is automatically deleted. Can you help me please

#add frame and other
panel = wx.Panel(self)
lci = wx.StaticText(panel, label='Ci', pos=wx.Point(280, 128),size=wx.Size(19, 23), style=0)
lci.SetFont(wx.Font(14, wx.SWISS, wx.NORMAL, wx.BOLD,False, 'Tekton Pro Ext'))
inslci = wx.TextCtrl(panel, pos=wx.Point(312, 128), size=wx.Size(120, 24),style=0, value='...')
inslci.SetForegroundColour(wx.Colour(64, 128, 128))
how would it be possible to add a wx.adv.RichToolTip. I still do not have it very clear, could you explain?
You can use NumCtrl from wx.lib.masked.
example
import wx
from wx.lib.masked import NumCtrl

class Form:
    def __init__(self, *args, **kwargs):
        self.frame = wx.Frame(*args, **kwargs)
        self.panel = wx.Panel(self.frame)
        self.numctrl = NumCtrl(self.panel)

if __name__ == '__main__':
    app = wx.App()
    hform = Form(None, title='Number Control')
    hform.frame.Show()
    app.MainLoop()
(Nov-26-2017, 08:38 PM)Windspar Wrote: [ -> ]You can use NumCtrl from wx.lib.masked.
example
import wx
from wx.lib.masked import NumCtrl

class Form:
    def __init__(self, *args, **kwargs):
        self.frame = wx.Frame(*args, **kwargs)
        self.panel = wx.Panel(self.frame)
        self.numctrl = NumCtrl(self.panel)

if __name__ == '__main__':
    app = wx.App()
    hform = Form(None, title='Number Control')
    hform.frame.Show()
    app.MainLoop()
Okay, just if I want to place decimal numbers, how would I do?
wxpython Numctrl
fractionWidth tell how many decimal places you want
(Nov-26-2017, 10:42 PM)Windspar Wrote: [ -> ]wxpython Numctrl
fractionWidth tell how many decimal places you want

exelent, thank you very much