Skip to content

Commit fa0fd28

Browse files
authored
Merge pull request #33 from yuqisun/master
update theme selector
2 parents ada7dd3 + cc233e3 commit fa0fd28

File tree

6 files changed

+104
-7
lines changed

6 files changed

+104
-7
lines changed

README.md

+2-6
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,9 @@ root@2cd33efd97b3 WORK_REPO# export DISPLAY=192.168.3.38:0.0 # change to your ow
5555
root@2cd33efd97b3 WORK_REPO# source venv/bin/activate
5656
(venv) root@2cd33efd97b3 WORK_REPO# cd /WORK_REPO/CGRA-Flow
5757

58+
# Startup theme mode selector UI
59+
(venv) root@2cd33efd97b3 CGRA-Flow# python startup.py
5860
# Three themes are available: dark, light, and classic
59-
# Start with default theme (dark mode)
60-
(venv) root@2cd33efd97b3 build# ./launchUI.bash
61-
# Start with light theme
62-
(venv) root@2cd33efd97b3 build# ./launchUI.bash light
63-
# Start with classic theme
64-
(venv) root@2cd33efd97b3 build# ./launchUI.bash classic
6561
```
6662

6763
Otherwise, if you don't need the GUI, development can be performed in the container with the environment well set up:

launchUI.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
if args.theme == 'light':
2929
customtkinter.set_appearance_mode("light") # Modes: system (default), light, dark
3030
customtkinter.set_default_color_theme("dark-blue") # Themes: blue (default), dark-blue, green
31-
CANVAS_BG_COLOR = "#DBDBDB"
31+
CANVAS_BG_COLOR = "#E5E5E5"
3232
CANVAS_LINE_COLOR = "black"
3333

3434
from VectorCGRA.cgra.translate.CGRATemplateRTL_test import *

startup.py

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import os
2+
import tkinter
3+
4+
import customtkinter
5+
from PIL import Image
6+
7+
customtkinter.set_appearance_mode("Dark")
8+
customtkinter.set_default_color_theme("dark-blue")
9+
10+
master = customtkinter.CTk()
11+
image_path = './theme/'
12+
theme_selector_dark_image = customtkinter.CTkImage(Image.open(os.path.join(image_path, "dark_theme.png")), size=(500, 410))
13+
theme_selector_light_image = customtkinter.CTkImage(Image.open(os.path.join(image_path, "light_theme.png")), size=(500, 410))
14+
theme_selector_classic_image = customtkinter.CTkImage(Image.open(os.path.join(image_path, "classic_theme.png")), size=(500, 410))
15+
16+
def launchUI(theme_radio_var):
17+
print(f'Get theme radio var: {theme_radio_var.get()}')
18+
if theme_radio_var.get() == 1:
19+
print('Activate light mode.')
20+
os.system("./launchUI.bash light &")
21+
elif theme_radio_var.get() == 2:
22+
print('Activate classic mode.')
23+
os.system("./launchUI.bash classic &")
24+
else:
25+
print('Activate dark mode.')
26+
os.system("./launchUI.bash &")
27+
master.destroy()
28+
29+
30+
def switchUI(theme_radio_var, radiobutton_frame, launch_button, theme_selector_image_label):
31+
theme_selector_image_label.forget()
32+
if theme_radio_var.get() == 1:
33+
print('light mode.')
34+
customtkinter.set_appearance_mode("light")
35+
customtkinter.set_default_color_theme("dark-blue")
36+
radiobutton_frame.configure(fg_color='#D9D9D9')
37+
launch_button.configure(fg_color='#3A7EBF')
38+
theme_selector_image_label = customtkinter.CTkLabel(main_frame, text="", image=theme_selector_light_image,
39+
compound="bottom", anchor="center")
40+
theme_selector_image_label.grid(row=1, column=0)
41+
elif theme_radio_var.get() == 2:
42+
print('classic mode.')
43+
customtkinter.set_appearance_mode("light")
44+
# customtkinter.set_default_color_theme("green")
45+
radiobutton_frame.configure(fg_color='#F0F0F0')
46+
launch_button.configure(fg_color='#808080')
47+
theme_selector_image_label = customtkinter.CTkLabel(main_frame, text="", image=theme_selector_classic_image,
48+
compound="bottom", anchor="center")
49+
theme_selector_image_label.grid(row=1, column=0)
50+
else:
51+
print('dark mode.')
52+
customtkinter.set_appearance_mode("dark")
53+
customtkinter.set_default_color_theme("dark-blue")
54+
radiobutton_frame.configure(fg_color='#292929')
55+
launch_button.configure(fg_color='#1F538D')
56+
theme_selector_image_label = customtkinter.CTkLabel(main_frame, text="", image=theme_selector_dark_image,
57+
compound="bottom", anchor="center")
58+
theme_selector_image_label.grid(row=1, column=0)
59+
60+
61+
# configure window
62+
master.title("Startup theme selector")
63+
master.geometry(f"{500}x{500}")
64+
master.resizable(False, False)
65+
66+
main_frame = customtkinter.CTkFrame(master)
67+
main_frame.grid(row=0, column=0, sticky="nsew")
68+
main_frame.grid_rowconfigure(0, weight=1)
69+
main_frame.grid_rowconfigure(1, weight=3)
70+
main_frame.grid_columnconfigure(0, weight=1)
71+
72+
radiobutton_frame = customtkinter.CTkFrame(main_frame)
73+
radiobutton_frame.grid(row=0, column=0, sticky="nsew")
74+
75+
radiobutton_frame.grid_rowconfigure(0, weight=1)
76+
radiobutton_frame.grid_rowconfigure(1, weight=2)
77+
radiobutton_frame.grid_columnconfigure(0, weight=1)
78+
radiobutton_frame.grid_columnconfigure(1, weight=1)
79+
radiobutton_frame.grid_columnconfigure(2, weight=1)
80+
81+
theme_radio_var = tkinter.IntVar(value=0)
82+
83+
main_frame_label = customtkinter.CTkLabel(radiobutton_frame, text='Please choose the theme mode: ', font=customtkinter.CTkFont(size=15, weight="bold"))
84+
main_frame_label.grid(row=0, column=0, columnspan=2, padx=(10, 5), pady=(10, 10), sticky="w")
85+
launch_button = customtkinter.CTkButton(master=radiobutton_frame, text='LaunchUI', command=lambda: launchUI(theme_radio_var))
86+
launch_button.grid(row=0, column=2, pady=(10, 10), sticky="w")
87+
88+
theme_selector_image_label = customtkinter.CTkLabel(main_frame, text="", image=theme_selector_dark_image, compound="bottom", anchor="center")
89+
theme_selector_image_label.grid(row=1, column=0)
90+
91+
# create radiobutton frame
92+
light_theme_button = customtkinter.CTkRadioButton(master=radiobutton_frame, text='Light', variable=theme_radio_var, value=1, command=lambda: switchUI(theme_radio_var, radiobutton_frame, launch_button, theme_selector_image_label))
93+
light_theme_button.grid(row=1, column=0, pady=(10, 10), padx=(10,0), sticky="w")
94+
dark_theme_button = customtkinter.CTkRadioButton(master=radiobutton_frame, text='Dark', variable=theme_radio_var, value=0, command=lambda: switchUI(theme_radio_var, radiobutton_frame, launch_button, theme_selector_image_label))
95+
dark_theme_button.grid(row=1, column=1, pady=(10, 10), padx=(10,0), sticky="w")
96+
classic_theme_button = customtkinter.CTkRadioButton(master=radiobutton_frame, text='Classic', variable=theme_radio_var, value=2, command=lambda: switchUI(theme_radio_var, radiobutton_frame, launch_button, theme_selector_image_label))
97+
classic_theme_button.grid(row=1, column=2, pady=(10, 10), padx=(10,0), sticky="w")
98+
99+
master.mainloop()
100+
101+

theme/classic_theme.png

20.2 KB
Loading

theme/dark_theme.png

18.7 KB
Loading

theme/light_theme.png

19.5 KB
Loading

0 commit comments

Comments
 (0)