-
Notifications
You must be signed in to change notification settings - Fork 0
/
window_info.py
41 lines (32 loc) · 1.41 KB
/
window_info.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
import tkinter as tk
from tkinter import *
from tkinter import ttk
class WindowInfo(Toplevel):
def __init__(self, bulbList, parent):
super().__init__(parent, bg='#D4AC3D')
DEFAULT_PROPS = ["power", "bright", "ct", "rgb", "hue", "sat", "color_mode", "flowing", "delayoff", "music_on",
"name", "active_mode", 'current_brightness']
tree = ttk.Treeview(self, column=[i for i in range(len(DEFAULT_PROPS))], show='headings')
# Dodaje zerowa koluimne wymaganą przez tkinter
tree.column(f"#0", anchor=tk.CENTER, width=0)
tree.heading(f"#0", text=f"")
# nagłówki kolumn
for i, j in enumerate(DEFAULT_PROPS):
tree.column(f"#{i + 1}", anchor=tk.CENTER, width=80)
tree.heading(f"#{i + 1}", text=f"{j}")
tree.grid(row=0, column=0, sticky='ns')
# add a scrollbar
scrollbar_vertical = ttk.Scrollbar(self, orient=tk.VERTICAL, command=tree.yview)
tree.configure(yscroll=scrollbar_vertical.set)
scrollbar_vertical.grid(row=0, column=1, sticky='ns')
# Dodawanie wierszy
for i in bulbList:
lista = list(i.get_properties(DEFAULT_PROPS).values())
print(lista)
tree.insert("", tk.END, values=lista)
if __name__ == '__main__':
import refresh
root = tk.Tk()
bulbs = refresh.bulb_list()
WindowInfo(bulbs, root)
root.mainloop()