In this video we’ll learn how to use Object Oriented Programming with CustomTkinter and Python.
Class Based Programming, as opposed to the Functional Based Programming we usually do, is something a lot of people are interested in.
In this video I’ll show you how to use Class Based Object Oriented Programming with CustomTkinter and Tkinter in general.
Python Code: ctk_object_oriented.py
(Github Code)
from tkinter import * import customtkinter # Set the theme and color options customtkinter.set_appearance_mode("dark") # Modes: system (default), light, dark customtkinter.set_default_color_theme("dark-blue") # Themes: blue (default), dark-blue, green class App(customtkinter.CTk): def __init__(self): super().__init__() #root = customtkinter.CTk() self.title('Tkinter.com - Object Oriented CustomTkinter') self.iconbitmap('images/codemy.ico') self.geometry('700x450') # Text Box self.my_text = customtkinter.CTkTextbox(self, width=600, height=300) self.my_text.pack(pady=20) self.my_button = customtkinter.CTkButton(self, text="Clear Box", command=self.clear) self.my_button.pack(pady=20) def clear(self): self.my_text.delete('0.0', END) # Define app and Create our app's mainloop app = App() app.mainloop()
Add comment