How To Create SpinControl in wxPython

In this wxPython article i want to show How To Create SpinControl in wxPython. wx.SpinCtrl combines wx.TextCtrl and wx.SpinButton in one control.

 

 

So This class supports the following styles:

  • wx.SP_ARROW_KEYS: The user can use arrow keys to change the value.
  • wx.SP_WRAP: The value wraps at the minimum and maximum.
  • wx.TE_PROCESS_ENTER: Indicates that the control should generate wxEVT_TEXT_ENTER events. Using this style will prevent the user from using the Enter key for dialog navigation (e.g. activating the default button in the dialog) under MSW.
  • wx.ALIGN_LEFT: Same as wx.TE_LEFT for wx.TextCtrl: the text is left aligned (this is the default).

 

 

 

 

Also you can check More GUI Development Tutorials in the below link.

1: PyQt5 GUI Development Tutorials

2: TKinter GUI Development Tutorials

3: Pyside2 GUI Development Tutorials 

4: Kivy GUI Development Tutorials

 

 

 

 

So this is the complete code for How To Create SpinControl in wxPython

 

 

 

 

So this class is MyFrame class that inherits from wx.Frame and it is a top level window that contains our panel.

 

 

 

 

After that we have MyPanel class that inherits from wx.Panel and it is the place that we create our widgets and layouts in this class. in this class we create our SpinControl with a StaticText.

 

 

 

 

These are for creating SpinControl also we set the range value for our SpinControl

 

 

 

This is our label or we can call it StaticText

 

 

 

In here we bind a method to our SpinControl

 

 

 

This is the event method for our SpinControl

 

 

So the last class is MyApp class that inherits from wx.App. the OnInit() method is where you will most often create frame subclass objects. and start our main loop.That’s it. Once the application’s main event loop processing takes over, control passes to wxPython. Unlike procedural programs, a wxPython GUI program primarily responds to the events taking place around it, mostly determined by a  human user clicking with a mouse and typing at the keyboard. When all the  frames in an application have been closed, the app.MainLoop() method will  return and the program will exit.

 

 

 

 

 

So run the code and this will be the result

How To Create SpinControl in wxPython
How To Create SpinControl in wxPython

 

 

 

 

 

Also you can watch the complete video for this article

Subscribe and Get Free Video Courses & Articles in your Email

 

Codeloop
Share via
Copy link
Powered by Social Snap
×