minor changes for pypi

This commit is contained in:
Tom Schimansky
2021-05-08 12:03:43 +02:00
parent 9958da72c6
commit 0c8e06b150
18 changed files with 50 additions and 1 deletions

0
examples/__init__.py Normal file
View File

158
examples/complex_example.py Normal file
View File

@ -0,0 +1,158 @@
import tkinter
import tkinter.messagebox
import customtkinter
customtkinter.set_appearance_mode("System") # Other: "Light", "Dark"
class App(tkinter.Tk):
APP_NAME = "CustomTkinter complex example"
WIDTH = 700
HEIGHT = 500
def __init__(self, *args, **kwargs):
customtkinter.enable_macos_darkmode()
tkinter.Tk.__init__(self, *args, **kwargs)
self.title(App.APP_NAME)
self.geometry(str(App.WIDTH) + "x" + str(App.HEIGHT))
self.minsize(App.WIDTH, App.HEIGHT)
self.protocol("WM_DELETE_WINDOW", self.on_closing)
self.bind("<Command-q>", self.on_closing)
self.bind("<Command-w>", self.on_closing)
self.createcommand('tk::mac::Quit', self.on_closing)
# ============ create two CTkFrames ============
self.frame_left = customtkinter.CTkFrame(master=self,
width=200,
height=App.HEIGHT-40,
corner_radius=10)
self.frame_left.place(relx=0.32, rely=0.5, anchor=tkinter.E)
self.frame_right = customtkinter.CTkFrame(master=self,
width=420,
height=App.HEIGHT-40,
corner_radius=10)
self.frame_right.place(relx=0.365, rely=0.5, anchor=tkinter.W)
# ============ frame_left ============
self.button_1 = customtkinter.CTkButton(master=self.frame_left,
text="CTkButton",
command=self.button_event,
border_width=0,
corner_radius=8)
self.button_1.place(relx=0.5, y=50, anchor=tkinter.CENTER)
self.button_2 = customtkinter.CTkButton(master=self.frame_left,
text="CTkButton",
command=self.button_event,
border_width=0,
corner_radius=8)
self.button_2.place(relx=0.5, y=100, anchor=tkinter.CENTER)
self.button_3 = customtkinter.CTkButton(master=self.frame_left,
text="CTkButton",
command=self.button_event,
border_width=0,
corner_radius=8)
self.button_3.place(relx=0.5, y=150, anchor=tkinter.CENTER)
# ============ frame_right ============
self.frame_info = customtkinter.CTkFrame(master=self.frame_right,
width=380,
height=200,
corner_radius=10)
self.frame_info.place(relx=0.5, y=20, anchor=tkinter.N)
# ============ frame_right -> frame_info ============
self.label_info_1 = customtkinter.CTkLabel(master=self.frame_info,
text="CTkLabel: Lorem ipsum dolor sit,\n" +
"amet consetetur sadipscing elitr,\n" +
"sed diam nonumy eirmod tempor\n" +
"invidunt ut labore",
width=250,
height=100,
corner_radius=8,
fg_color=("white", "gray38"), # <- custom tuple-color
justify=tkinter.LEFT)
self.label_info_1.place(relx=0.5, rely=0.15, anchor=tkinter.N)
self.progressbar = customtkinter.CTkProgressBar(master=self.frame_info,
width=250,
height=15,
border_width=0)
self.progressbar.place(relx=0.5, rely=0.85, anchor=tkinter.S)
# ============ frame_right <- ============
self.slider_1 = customtkinter.CTkSlider(master=self.frame_right,
width=160,
height=16,
border_width=5.5,
command=self.progressbar.set)
self.slider_1.place(x=20, rely=0.6, anchor=tkinter.W)
self.slider_1.set(0.3)
self.slider_2 = customtkinter.CTkSlider(master=self.frame_right,
width=160,
height=16,
border_width=5.5,
command=self.progressbar.set)
self.slider_2.place(x=20, rely=0.7, anchor=tkinter.W)
self.slider_2.set(0.7)
self.label_info_2 = customtkinter.CTkLabel(master=self.frame_right,
text="CTkLabel: Lorem ipsum",
width=180,
height=20,
justify=tkinter.CENTER)
self.label_info_2.place(x=310, rely=0.6, anchor=tkinter.CENTER)
self.button_4 = customtkinter.CTkButton(master=self.frame_right,
height=25,
text="CTkButton",
command=self.button_event,
border_width=0,
corner_radius=8)
self.button_4.place(x=310, rely=0.7, anchor=tkinter.CENTER)
self.entry = customtkinter.CTkEntry(master=self.frame_right,
width=120,
height=25,
corner_radius=10)
self.entry.place(relx=0.33, rely=0.92, anchor=tkinter.CENTER)
self.entry.insert(0, "CTkEntry")
self.button_5 = customtkinter.CTkButton(master=self.frame_right,
height=25,
text="CTkButton",
command=self.button_event,
border_width=0,
corner_radius=8)
self.button_5.place(relx=0.66, rely=0.92, anchor=tkinter.CENTER)
self.progressbar.set(0.65)
def button_event(self):
print("Button pressed")
def on_closing(self, event=0):
customtkinter.disable_macos_darkmode()
self.destroy()
def start(self):
self.mainloop()
if __name__ == "__main__":
app = App()
app.start()

View File

@ -0,0 +1,186 @@
import tkinter
import tkinter.messagebox
import customtkinter
import sys
# Set dark appearance mode:
customtkinter.set_appearance_mode("Dark") # Other: "Light", "System"
class App(tkinter.Tk):
APP_NAME = "CustomTkinter complex example"
WIDTH = 700
HEIGHT = 500
MAIN_COLOR = "#5EA880"
MAIN_COLOR_DARK = "#2D5862"
MAIN_HOVER = "#458577"
def __init__(self, *args, **kwargs):
customtkinter.enable_macos_darkmode()
tkinter.Tk.__init__(self, *args, **kwargs)
if "win" in sys.platform:
if customtkinter.get_appearance_mode() == "Dark":
self.configure(bg="gray20") # set window background to dark color
self.title(App.APP_NAME)
self.geometry(str(App.WIDTH) + "x" + str(App.HEIGHT))
self.minsize(App.WIDTH, App.HEIGHT)
self.protocol("WM_DELETE_WINDOW", self.on_closing)
self.bind("<Command-q>", self.on_closing)
self.bind("<Command-w>", self.on_closing)
self.createcommand('tk::mac::Quit', self.on_closing)
# ============ create two CTkFrames ============
self.frame_left = customtkinter.CTkFrame(master=self,
width=200,
height=App.HEIGHT-40,
corner_radius=0)
self.frame_left.place(relx=0.32, rely=0.5, anchor=tkinter.E)
self.frame_right = customtkinter.CTkFrame(master=self,
width=420,
height=App.HEIGHT-40,
corner_radius=0)
self.frame_right.place(relx=0.365, rely=0.5, anchor=tkinter.W)
# ============ frame_left ============
self.button_1 = customtkinter.CTkButton(master=self.frame_left,
border_color=App.MAIN_COLOR,
fg_color=None,
hover_color=App.MAIN_HOVER,
text="CTkButton",
command=self.button_event,
border_width=2,
corner_radius=0)
self.button_1.place(relx=0.5, y=50, anchor=tkinter.CENTER)
self.button_2 = customtkinter.CTkButton(master=self.frame_left,
border_color=App.MAIN_COLOR,
fg_color=None,
hover_color=App.MAIN_HOVER,
text="CTkButton",
command=self.button_event,
border_width=2,
corner_radius=0)
self.button_2.place(relx=0.5, y=100, anchor=tkinter.CENTER)
self.button_3 = customtkinter.CTkButton(master=self.frame_left,
border_color=App.MAIN_COLOR,
fg_color=None,
hover_color=App.MAIN_HOVER,
text="CTkButton",
command=self.button_event,
border_width=2,
corner_radius=0)
self.button_3.place(relx=0.5, y=150, anchor=tkinter.CENTER)
# ============ frame_right ============
self.frame_info = customtkinter.CTkFrame(master=self.frame_right,
width=380,
height=200,
corner_radius=0)
self.frame_info.place(relx=0.5, y=20, anchor=tkinter.N)
# ============ frame_right -> frame_info ============
self.label_info_1 = customtkinter.CTkLabel(master=self.frame_info,
text="CTkLabel: Lorem ipsum dolor sit,\n" +
"amet consetetur sadipscing elitr,\n" +
"sed diam nonumy eirmod tempor\n" +
"invidunt ut labore",
width=250,
height=100,
corner_radius=0,
fg_color=("white", "gray20"),
text_color=App.MAIN_COLOR,
justify=tkinter.LEFT)
self.label_info_1.place(relx=0.5, rely=0.15, anchor=tkinter.N)
self.progressbar = customtkinter.CTkProgressBar(master=self.frame_info,
progress_color=App.MAIN_COLOR,
width=250,
height=15,
border_width=0)
self.progressbar.place(relx=0.5, rely=0.85, anchor=tkinter.S)
self.progressbar.set(0.65)
# ============ frame_right <- ============
self.slider_1 = customtkinter.CTkSlider(master=self.frame_right,
button_color=App.MAIN_COLOR,
button_hover_color=App.MAIN_HOVER,
width=160,
height=16,
border_width=5.5,
command=self.progressbar.set)
self.slider_1.place(x=20, rely=0.6, anchor=tkinter.W)
self.slider_1.set(0.3)
self.slider_2 = customtkinter.CTkSlider(master=self.frame_right,
button_color=App.MAIN_COLOR,
button_hover_color=App.MAIN_HOVER,
width=160,
height=16,
border_width=5.5,
command=self.progressbar.set)
self.slider_2.place(x=20, rely=0.7, anchor=tkinter.W)
self.slider_2.set(0.7)
self.label_info_2 = customtkinter.CTkLabel(master=self.frame_right,
text="CTkLabel: Lorem ipsum",
width=180,
height=20,
justify=tkinter.CENTER)
self.label_info_2.place(x=310, rely=0.6, anchor=tkinter.CENTER)
self.button_4 = customtkinter.CTkButton(master=self.frame_right,
border_color=App.MAIN_COLOR,
fg_color=None,
hover_color=App.MAIN_HOVER,
height=28,
text="CTkButton",
command=self.button_event,
border_width=2,
corner_radius=0)
self.button_4.place(x=310, rely=0.7, anchor=tkinter.CENTER)
self.entry = customtkinter.CTkEntry(master=self.frame_right,
width=120,
height=28,
corner_radius=0)
self.entry.place(relx=0.33, rely=0.92, anchor=tkinter.CENTER)
self.entry.insert(0, "CTkEntry")
self.button_5 = customtkinter.CTkButton(master=self.frame_right,
border_color=App.MAIN_COLOR,
fg_color=None,
hover_color=App.MAIN_HOVER,
height=28,
text="CTkButton",
command=self.button_event,
border_width=2,
corner_radius=0)
self.button_5.place(relx=0.66, rely=0.92, anchor=tkinter.CENTER)
def button_event(self):
print("Button pressed")
def on_closing(self, event=0):
customtkinter.disable_macos_darkmode()
self.destroy()
def start(self):
self.mainloop()
if __name__ == "__main__":
app = App()
app.start()

View File

@ -0,0 +1,39 @@
import tkinter
import customtkinter # <- import the CustomTkinter module
customtkinter.enable_macos_darkmode()
customtkinter.set_appearance_mode("System") # Other: "Dark", "Light"
root_tk = tkinter.Tk() # create the Tk window like you normally do
root_tk.geometry("400x240")
root_tk.title("CustomTkinter Test")
def button_function():
print("button pressed")
def slider_function(value):
progressbar_1.set(value)
frame_1 = customtkinter.CTkFrame(master=root_tk, width=300, height=200, corner_radius=15)
frame_1.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
label_1 = customtkinter.CTkLabel(master=frame_1)
label_1.place(relx=0.5, rely=0.1, anchor=tkinter.CENTER)
progressbar_1 = customtkinter.CTkProgressBar(master=frame_1)
progressbar_1.place(relx=0.5, rely=0.25, anchor=tkinter.CENTER)
button_1 = customtkinter.CTkButton(master=frame_1, corner_radius=10, command=button_function)
button_1.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
slider_1 = customtkinter.CTkSlider(master=frame_1, command=slider_function)
slider_1.place(relx=0.5, rely=0.7, anchor=tkinter.CENTER)
entry_1 = customtkinter.CTkEntry(master=frame_1)
entry_1.place(relx=0.5, rely=0.85, anchor=tkinter.CENTER)
root_tk.mainloop()
customtkinter.disable_macos_darkmode()

View File

@ -0,0 +1,35 @@
import tkinter
import customtkinter # <- import the CustomTkinter module
from PIL import Image, ImageTk # <- import PIL for the images
customtkinter.enable_macos_darkmode()
customtkinter.set_appearance_mode("System") # Other: "Dark", "Light"
root_tk = tkinter.Tk() # create the Tk window like you normally do
root_tk.geometry("400x240")
root_tk.title("CustomTkinter Test")
def button_function():
print("button pressed")
# load images as PhotoImage
settings_image = ImageTk.PhotoImage(Image.open("test_images/settings.png").resize((40, 40)))
bell_image = ImageTk.PhotoImage(Image.open("test_images/bell.png").resize((40, 40)))
frame_1 = customtkinter.CTkFrame(master=root_tk, width=300, height=200, corner_radius=15)
frame_1.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
# button with settings-image
button_1 = customtkinter.CTkButton(master=frame_1, image=settings_image, width=60, height=60,
corner_radius=10, command=button_function)
button_1.place(relx=0.33, rely=0.5, anchor=tkinter.CENTER)
# button with bell-image
button_2 = customtkinter.CTkButton(master=frame_1, image=bell_image, width=60, height=60,
corner_radius=10, command=button_function)
button_2.place(relx=0.66, rely=0.5, anchor=tkinter.CENTER)
root_tk.mainloop()
customtkinter.disable_macos_darkmode()

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB