-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisplay.py
More file actions
36 lines (28 loc) · 1017 Bytes
/
Copy pathdisplay.py
File metadata and controls
36 lines (28 loc) · 1017 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
35
36
import tkinter as tk
import numpy as np
branches = np.array([[True, False], [False, False], [False, False]])
def create_rectangles():
rect_height = 100 # Height is 2x width
padding = 10 # Space between rectangles
for row in range(3):
for col in range(2):
x1 = col * (50 + padding) + padding
y1 = row * (rect_height + padding) + padding
x2 = x1 + 50
y2 = y1 + rect_height
if (branches[row][col] == True):
canvas.create_rectangle(x1, y1, x2, y2, fill="green", outline="black")
else:
canvas.create_rectangle(x1, y1, x2, y2, fill="red", outline="black")
# Create main window
root = tk.Tk()
root.title("Tkinter Rectangle Grid")
# Canvas size
canvas_width = 2 * (50 + 10) + 10
canvas_height = 3 * (100 + 10) + 10
canvas = tk.Canvas(root, width=canvas_width, height=canvas_height, bg="white")
canvas.pack()
# Draw rectangles
create_rectangles()
# Run the Tkinter event loop
root.mainloop()