-
Book Overview & Buying
-
Table Of Contents
Python GUI Programming Cookbook, Second Edition - Second Edition
By :
In this recipe, we will use a Spinbox widget, and we will also bind the Enter key on the keyboard to one of our widgets.
We will use our tabbed GUI and add a Spinbox widget above the ScrolledText control. This simply requires us to increment the ScrolledText row value by one and to insert our new Spinbox control in the row above the Entry widget.
First, we add the Spinbox control. Place the following code above the ScrolledText widget:
# Adding a Spinbox widget
spin = Spinbox(mighty, from_=0, to=10)
spin.grid(column=0, row=2)This will modify our GUI as follows:
GUI_spinbox.py

Next, we will reduce the size of the Spinbox widget:
spin = Spinbox(mighty, from_=0, to=10, width=5)
Running the preceding code results in the following GUI:
GUI_spinbox_small.py

Next, we add another property to customize our widget further; bd is a short-hand notation for the borderwidth property:
spin = Spinbox(mighty, from_=0, to=10, width=5 , bd=8)
Running...