This repository was archived by the owner on Feb 10, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgui.py
More file actions
93 lines (65 loc) · 2.48 KB
/
gui.py
File metadata and controls
93 lines (65 loc) · 2.48 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
82
83
84
85
86
87
88
89
90
91
92
93
import liquidctl
import tkinter as tk
from tkinter import ttk
import sv_ttk
from c_picker import open_picker
def set_color(dev, channel, color):
color = color.lstrip("#")
rgb = tuple(int(color[i:i+2], 16) for i in (0, 2, 4))
dev.set_color(channel, "fixed", [rgb])
dev = None
root = tk.Tk()
root.geometry("650x450")
root.title("NZXT-CAMux")
sv_ttk.set_theme("dark")
dev_select = ttk.LabelFrame(root, text="Select Device", padding=12)
dev_select.pack(padx=20, pady=20)
ttk.Label(dev_select, text="If the device is already correct you still need to reselect it in order to work correclty.").pack()
dev_inf = ttk.LabelFrame(root, text="Device Information", padding=12)
dev_inf.pack(padx=20, pady=20)
dev_ops = ttk.LabelFrame(root, text="Device Operations", padding=12)
dev_ops.pack(padx=20, pady=20)
dev_list = list(liquidctl.find_liquidctl_devices())
# -- DEVICE INFORMATION -- #
desc_var = tk.StringVar(value="")
desc_label = ttk.Label(dev_inf, textvariable=desc_var)
desc_label.pack()
col_var = tk.StringVar(value="")
col_label = ttk.Label(dev_inf, textvariable=col_var)
col_label.pack()
speed_var = tk.StringVar(value="")
speed_label = ttk.Label(dev_inf, textvariable=speed_var)
speed_label.pack()
## -- END -- #
# -- DEVICE OPERATIONS -- #
col_op_var = tk.StringVar(value="")
col_op = ttk.Button(root, textvariable=col_op_var, command=lambda: open_picker(env=root, device=dev, color_callback=set_color))
col_op.pack(padx=20, pady=20)
## -- END -- #
def set_sel_dev(sel):
global dev
dev = sel
dev.connect()
dev.initialize()
desc_var.set(f"Device Description: {sel.description}")
col_var.set(f"Color Channels: {sel._color_channels}")
speed_var.set(f"Speed Channels: {sel._speed_channels}")
col_op_var.set("Set Color")
var = tk.StringVar(value=dev_list[0])
opt = ttk.OptionMenu(dev_select, var, dev_list[0], *dev_list, command=set_sel_dev)
opt.pack(padx=20, pady=20)
root.mainloop()
# for index, device in enumerate(dev_list):
# print(f" - IND: {index}: {device.description}")
# sel_dev = int(input(f"Select device by index [0-{len(dev_list) - 1}]: "))
# dev = dev_list[sel_dev]
# dev.connect()
# dev_c = dev.initialize()
# col_channels = dev._color_channels
# print("\nFound color channels:")
# for index, channel in enumerate(col_channels):
# print(f" - IND: {index}: {channel}")
# sel_chn = int(input(f"Select channel by index [0-{len(col_channels) - 1}]: "))
# print("\n")
# chn = list(col_channels)[sel_chn]
# dev.set_color(chn, "fixed", [(255, 0, 0)])