Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #=======================================================================
- ########################################################################
- #=========================== Left Frame File ===========================
- import customtkinter as ctk
- class LeftFrame:
- def __init__(self, master, changeColorFunc = None):
- self.main_frame = ctk.CTkFrame(master)
- self.main_frame.pack()
- self.main_theme = ctk.get_appearance_mode()
- self.is_dark_mode = True
- self.changeColor = lambda theme : changeColorFunc(theme)
- self.dark_mode_toggle = ctk.CTkSwitch(self.main_frame, command=self.changeTheme)
- self.dark_mode_toggle.pack()
- def changeTheme(self):
- if self.is_dark_mode:
- self.main_theme = "Light"
- self.is_dark_mode = False
- ctk.set_appearance_mode(self.main_theme)
- self.changeColor(self.main_theme)
- else:
- self.main_theme = "Dark"
- self.is_dark_mode = True
- ctk.set_appearance_mode(self.main_theme)
- self.changeColor(self.main_theme)
- #========================================================================
- #########################################################################
- #=========================== Right Frame File ===========================
- import customtkinter as ctk
- from PIL import ImageTk, Image
- class RightFrame:
- def __init__(self, master = None):
- self.main_frame = ctk.CTkFrame(master)
- self.main_frame.pack()
- #============ Images for button ============
- self.github_logo_black = ImageTk.PhotoImage(Image.open(f"{self.PATH}/src/images/ui/github32_b.png"))
- self.github_logo_white = ImageTk.PhotoImage(Image.open(f"{self.PATH}/src/images/ui/github32_w.png")) # unused
- #=========== Button ============
- self.btn_github = ctk.CTkButton(self.main_frame,
- text="GitHub",
- image=self.github_logo_black,
- command=self.changeButtonColor)
- self.btn_github.pack()
- self.btn_github.configure(image=self.github_logo_black)
- def changeButtonColor(self, mode):
- if mode == "Dark":
- self.btn_github.configure(image=self.github_logo_white)
- elif mode == "Light":
- self.btn_github.configure(image=self.github_logo_black)
- #========================================================================
- #########################################################################
- #=========================== Main Window File ===========================
- import customtkinter as ctk
- from left_frame import LeftFrame
- from right_frame import RightFrame
- class App:
- def __init__(self):
- self.main = ctk.CTk()
- self.right = RightFrame(self.main)
- self.left = LeftFrame(self.main, changeColorFunc=self.right.changeButtonColor)
- self.main.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment