Python Forum
[WxPython] make StaticText limit Number
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[WxPython] make StaticText limit Number
#1
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?
Reply
#2
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()
99 percent of computer problems exists between chair and keyboard.
Reply
#3
(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?
Reply
#4
wxpython Numctrl
fractionWidth tell how many decimal places you want
99 percent of computer problems exists between chair and keyboard.
Reply
#5
(Nov-26-2017, 10:42 PM)Windspar Wrote: wxpython Numctrl
fractionWidth tell how many decimal places you want

exelent, thank you very much
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Update exist plot while change upper limit or lower limit SamLiu 1 949 Feb-05-2023, 10:09 AM
Last Post: SamLiu
  [WxPython] Append string to StaticText giu88 1 2,481 Aug-14-2018, 03:03 PM
Last Post: Windspar

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020