Python Forum
[WxPython] SpinCtrl. Pop-up warning - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: [WxPython] SpinCtrl. Pop-up warning (/thread-12733.html)



SpinCtrl. Pop-up warning - ioprst - Sep-10-2018

There is an object wx.SpinCtrl:
self.m_spinCtrl_width = wx.SpinCtrl(self.panel, -1, self.width, style=wx.SP_ARROW_KEYS | wx.TE_PROCESS_ENTER, max=max_)
This object has such a feature that if the parameter min> = 0 (in the code is not specified, only max is specified), then when you try to enter something different from the number in the widget, a warning flashes:

[Image: search?newwindow=1&rlz=1C1GIGM_enRU772RU...tbPtNpI2M:]

Can I somehow generate this warning myself? For example, I need the value of the object "m_spinCtrl_width" to be less than 0, but then the object allows to enter both letters (and any other characters) in the widget, I would like to track that if the user entered a number, then issue a warning.

Sorry for my English.


RE: SpinCtrl. Pop-up warning - Larz60+ - Sep-10-2018

This is untested code, but it doesn't work, it's very close

# Set max to your max
self.max = 10 # put in __init__

self.m_spinCtrl_width = wx.SpinCtrl(self.panel, -1, self.width, 
    style=wx.SP_ARROW_KEYS | wx.TE_PROCESS_ENTER, max=self.max

self.text.Bind(wx.EVT_SPINCTRL, self.SpinEvt)
self.m_spinCtrl_width.Bind(wx.EVT_SPINCTRL, self.SpinEvt)

def SpinEvt(self, event):
        if self.m_spinCtrl_width.GetValue() > self.max:
               self.m_spinCtrl_width.SetValue(self.max)
               wx.MessageDialog(self,"My Message Category","My Message").ShowModal()



RE: SpinCtrl. Pop-up warning - ioprst - Sep-11-2018

Thanks for the answer. Such an idea was already there. I would not want to force the user to click "OK" every time. Therefore, I seek a solution with a warning.


RE: SpinCtrl. Pop-up warning - ioprst - Sep-11-2018

I think the answer to the question: wx.adv.RichToolTip.