-
Notifications
You must be signed in to change notification settings - Fork 0
/
sequencePopup.py
70 lines (60 loc) · 2.47 KB
/
sequencePopup.py
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
import tkinter as tk
from tkinter import simpledialog
MODES = [
("White", "white"),
("Red", "red"),
("Green", "green"),
("Blue", "blue"),
]
class MyDialog(tk.simpledialog.Dialog):
"""
Dialogue window to choose color of sequence rectangle
"""
def body(self, master):
self.parent = master
e1_var = tk.IntVar(value=2)
e2_var = tk.IntVar(value=2)
e3_var = tk.IntVar(value=200)
l1 = tk.Label(master, width=22, text="Rows (1-100)").pack()
self.e1 = tk.Entry(master, textvariable=e1_var)
self.e1.pack()
self.rows = 2
l2 = tk.Label(master, width=22, text="Columns (1-100)").pack()
self.e2 = tk.Entry(master, textvariable=e2_var)
self.e2.pack()
self.cols = 2
l3 = tk.Label(master, width=22, text="Time (ms)").pack()
self.e3 = tk.Entry(master, textvariable=e3_var)
self.e3.pack()
self.time = 100
l4 = tk.Label(master, width=22, text="Color").pack()
self.v = tk.StringVar(master, "white")
for text, mode in MODES:
b = tk.Radiobutton(master, text=text, variable=self.v, value=mode)
b.pack(anchor=tk.W, padx=40)
self.color = "white"
self.w = master.winfo_screenwidth() / self.cols
self.h = master.winfo_screenheight() / self.rows
self.mySubmitButton = tk.Button(master, text='Update Rectangle', command=self.update)
self.mySubmitButton.pack(pady=5)
self.canv = tk.Canvas(master, highlightthickness=0, height=self.h + 5, width=self.w + 5, bg="black")
self.canv.pack()
self.rect = self.canv.create_rectangle(5, 5, self.w, self.h, fill="white", tags="R")
self.cont = False
# Return values
def apply(self, *args):
self.color = self.v.get()
self.rows = self.e1.get()
self.cols = self.e2.get()
self.time = self.e3.get()
self.w = self.parent.winfo_screenwidth() / int(self.e2.get())
self.h = self.parent.winfo_screenheight() / int(self.e1.get())
self.cont = True
# Update rectangle in preview
def update(self):
self.w = self.parent.winfo_screenwidth() / int(self.e2.get())
self.h = self.parent.winfo_screenheight() / int(self.e1.get())
self.color = self.v.get()
self.canv.itemconfig(self.rect, fill=self.color)
self.canv.coords(self.rect, 5, 5, self.w, self.h)
print("x: ", 0, " y: ", 0, " w: ", self.w, " h:", self.h)