-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path16.0 conectar_GUI.py
More file actions
81 lines (59 loc) · 2.02 KB
/
16.0 conectar_GUI.py
File metadata and controls
81 lines (59 loc) · 2.02 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Excercise to connect
# The 2 buttons
# The radiobutton
# The checkbutton
# The spinbox
# and the combobox to the corresponding function:
# To do this, use: 'command = function_name' <-- NO PARENTHESIS in the function!
# For the combobox you need a BIND.
import tkinter as tk
from tkinter import ttk
window = tk.Tk()
window.title("Connecting GUI")
window.geometry('220x300')
window.resizable(0,0)
window.wm_iconbitmap('images/human.ico')
def button1():
print("You pushed button 1")
print('\a')
def button2():
print("yeaaaayy... this is button 2!")
print("This is fun!")
def radio_black():
print("You selected BLACK")
def radio_white():
print("You selected WHITE")
def checkbutton_ok():
print("You changed the option in the Checkbutton.")
def spin_changed():
print("Now you are changing the spinbox!")
def combo_changed(event):
print("You selected an option in the Combobox")
# 2 Buttons
btn1 = ttk.Button(window, text = "Button 1", command = button1)
btn1.pack(pady = 20)
btn2 = ttk.Button(window, text = "Now Button 2")
btn2.pack(pady = 10)
# 1 Radiobutton
radio_var1 = tk.StringVar()
radio_opt = ttk.Radiobutton(window, text = "Black?", value = radio_var1)
radio_opt.pack()
radio_var2 = tk.StringVar()
radio_opt = ttk.Radiobutton(window, text = "Or White", value = radio_var2)
radio_opt.pack()
# 1 Checkbutton
check_var = tk.IntVar()
check_opt = ttk.Checkbutton(window, text = "Tick me!", variable = check_var)
check_opt.pack(pady = 20)
# 1 Spinbox
spinbox1 = ttk.Spinbox(window, width = 15)
spinbox1["values"] = ("Spinbox", 2, 3, "Also letters", 4, 5, "More letters", "Cool, ha?")
spinbox1.pack()
# Combobox
combo_var = tk.StringVar()
combo = ttk.Combobox(window, width = 20)
combo['values'] = ("Select:", "Another one", "Yet another", "You get the idea, right?")
combo.current(0)
combo.pack(pady = 20)
#combo.bind("<<ComboboxSelected>>", ## Funtion_Here!! No parenthesis ##)
window.mainloop()