-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpinbox.py
More file actions
34 lines (26 loc) · 915 Bytes
/
Spinbox.py
File metadata and controls
34 lines (26 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import tkinter as tk
from tkinter import ttk
from tkinter import Spinbox
from tkinter import scrolledtext
win = tk.Tk()
win.title('Spin Box')
# Spinbox callback
def _spin():
value = spin.get()
print(value)
scr.insert(tk.INSERT, value + '\n')
# I find the argument name from_ unusual.
#spin = Spinbox(win, from_=0, to=10, width=5, bd=8, command=_spin)
# We can spicify values by using the values parameter
spin = Spinbox(win, values=(1,2,4,42,100), from_=0, to=10, width=5, bd=8, command=_spin)
spin.grid(column=0,row=2)
# adding a second spinbox widget
spin = Spinbox(win, values=(0,50,100), width=5, bd=8, command=_spin, relief=tk.RIDGE)
spin.grid(column=1, row=2)
# Using a scrolled text control
scrolW = 30
scrolH = 3
# adding a spinbox widget
scr = scrolledtext.ScrolledText(win, width=scrolW, height=scrolH, wrap=tk.WORD)
scr.grid(column=0, row=3, sticky='WE', columnspan=3)
win.mainloop()