= How to create a spin control (Phoenix) =
'''Keywords :''' Spin control.

 <<TableOfContents>>

--------
= Introduction : =
This widget lets you increment and decrement a value.

It has two up and down arrow buttons for this purpose.

User can enter a value into a box or increment/decrement it by these two arrows.

'''{{{wx.SpinCtrl styles :}}}'''

 * wx.SP_ARROW_KEYS
 * wx.SP_WRAP

||||<style="text-align:center;">'''{{{wx.SpinCtrl methods}}}''' ||
||<#d0d0d0>{{{integer GetValue()}}} ||<#d0d0d0>get the current value ||
||{{{SetValue(integer value)}}} ||set the current value ||
||<#d0d0d0>{{{SetValueString(string value)}}} ||<#d0d0d0>something ||
||{{{SetRange(integer min, integer max)}}} ||set the min and max values ||
||<#d0d0d0>{{{integer GetMin()}}} ||<#d0d0d0>get the minimum value ||
||{{{integer GetMax()}}} ||get the maximum value ||


(info by '''ZetCode / Jan Bodnar''').

--------
= Demonstrating : =
__'''''Tested''' py3.x, wx4.x and Win10. ''__

Are you ready to use some samples ? ;)

Test, modify, correct, complete, improve and share your discoveries ! (!)

--------
== Sample one ==
{{attachment:img_sample_one.png}}

sample_one.py is a dialog-based script.

Our main class inherits from wx.Dialog instead of wx.Frame.

The main difference is that we cannot resize the window and we call Destroy() method instead of Close(), when we quit the application.

sample_one script converts Fahrenheit temperature to Celsius.

This example is very popular and can be found in most programming primer books.

{{{#!python
# sample_one.py

"""

Author : Jan Bodnar
Website : zetcode.com

"""

import wx

# class MyDialog
# class MyApp

#---------------------------------------------------------------------------

class MyDialog(wx.Dialog):
    def __init__(self, parent, id, title):
        wx.Dialog.__init__(self, parent, id, title,
                           wx.DefaultPosition, wx.Size(350, 350))

        self.SetIcon(wx.Icon('./icons/icon_wxWidgets.ico', wx.BITMAP_TYPE_ICO))

        #------------

        # wx.Font(pointSize, family, style, weight, underline, faceName)
        font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
        font.SetWeight(wx.BOLD)

        #------------

        self.convert = wx.StaticText(self, -1,
                                     '  Convert Fahrenheit temperature to Celsius  ',
                                     (20, 20), (-1, -1), wx.ALIGN_CENTER)
        self.convert.SetFont(font)
        self.convert.SetForegroundColour('White')
        self.convert.SetBackgroundColour('Red')


        self.Fahrenheit = wx.StaticText(self, -1, 'Fahrenheit : ', (20, 80))
        self.Fahrenheit.SetFont(font)

        self.celsius = wx.StaticText(self, -1, 'Celsius : ', (20, 150))
        self.celsius.SetFont(font)

        self.result =  wx.StaticText(self, -1, '...............', (150, 150))
        self.result.SetForegroundColour('Blue')

        self.sc = wx.SpinCtrl(self, -1, '', (150, 75), (60, -1))
        self.sc.SetRange(-459, 1000)
        self.sc.SetValue(0)

        compute_btn = wx.Button(self, 1, 'Co&mpute', (70, 250))
        compute_btn.SetFocus()

        clear_btn = wx.Button(self, 2, '&Close', (185, 250))

        #------------

        self.Bind(wx.EVT_BUTTON, self.OnCompute, id=1)
        self.Bind(wx.EVT_BUTTON, self.OnClose, id=2)
        self.Bind(wx.EVT_CLOSE, self.OnClose)

    #-----------------------------------------------------------------------

    def OnCompute(self, event):
        fahr = self.sc.GetValue()
        cels = round((fahr-32)*5/9.0, 2)
        self.result.SetLabel(str(cels))


    def OnClose(self, event):
        self.Destroy()

#---------------------------------------------------------------------------

class MyApp(wx.App):
    def OnInit(self):
        dlg = MyDialog(None, -1, 'wx.SpinCtrl')
        dlg.Centre()
        dlg.Show(True)

        return True

#---------------------------------------------------------------------------

app = MyApp(0)
app.MainLoop()
}}}
--------
= Download source =
[[attachment:source.zip]]

--------
= Additional Information =
'''Link :'''

- - - - -

https://wiki.wxpython.org/TitleIndex

https://docs.wxpython.org/

--------
= Thanks to =
Jan Bodnar (sample_one.py coding), the wxPython community...

--------
= About this page =
Date(d/m/y)     Person (bot)    Comments :

28/12/20 - Ecco (Created page for wxPython Phoenix).

--------
= Comments =
- blah, blah, blah....