mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
removed .config(), added kwargs managing and filtering, added kwargs exceptions, fixed cursor color for combobox
This commit is contained in:
@ -13,6 +13,8 @@ class App(customtkinter.CTk):
|
||||
|
||||
self.title("CustomTkinter complex_example.py")
|
||||
self.geometry(f"{920}x{500}")
|
||||
self.minsize(700, 400)
|
||||
self.maxsize(1200, 700)
|
||||
self.protocol("WM_DELETE_WINDOW", self.on_closing) # call .on_closing() when app gets closed
|
||||
|
||||
# configure grid layout (4x4)
|
||||
@ -126,7 +128,7 @@ class App(customtkinter.CTk):
|
||||
self.progressbar_1.start()
|
||||
|
||||
def open_input_dialog(self):
|
||||
dialog = customtkinter.CTkInputDialog(master=None, text="Type in a number:", title="CTkInputDialog")
|
||||
dialog = customtkinter.CTkInputDialog(master=self, text="Type in a number:", title="CTkInputDialog")
|
||||
print("CTkInputDialog:", dialog.get_input())
|
||||
|
||||
def change_appearance_mode(self, new_appearance_mode: str):
|
||||
@ -139,10 +141,8 @@ class App(customtkinter.CTk):
|
||||
|
||||
def sidebar_button_callback(self):
|
||||
print("sidebar_button click")
|
||||
|
||||
self.entry.delete(0, tkinter.END)
|
||||
|
||||
|
||||
def on_closing(self, event=0):
|
||||
self.destroy()
|
||||
|
||||
|
@ -76,14 +76,14 @@ class TestCTk():
|
||||
def test_configure(self):
|
||||
print(" -> test_configure: ", end="")
|
||||
self.root_ctk.configure(bg="white")
|
||||
assert self.root_ctk.fg_color == "white"
|
||||
assert self.root_ctk.cget("fg_color") == "white"
|
||||
|
||||
self.root_ctk.configure(background="red")
|
||||
assert self.root_ctk.fg_color == "red"
|
||||
assert self.root_ctk.cget("fg_color") == "red"
|
||||
assert self.root_ctk.cget("bg") == "red"
|
||||
|
||||
self.root_ctk.config(fg_color=("green", "#FFFFFF"))
|
||||
assert self.root_ctk.fg_color == ("green", "#FFFFFF")
|
||||
assert self.root_ctk.cget("fg_color") == ("green", "#FFFFFF")
|
||||
print("successful")
|
||||
|
||||
def test_appearance_mode(self):
|
||||
|
55
test/unit_tests/test_ctk_entry.py
Normal file
55
test/unit_tests/test_ctk_entry.py
Normal file
@ -0,0 +1,55 @@
|
||||
import customtkinter
|
||||
import time
|
||||
|
||||
app = customtkinter.CTk()
|
||||
|
||||
entry_1 = customtkinter.CTkEntry(app, width=100, height=25)
|
||||
entry_1.pack(padx=20, pady=20)
|
||||
entry_2 = customtkinter.CTkEntry(app, width=100, height=25)
|
||||
entry_2.pack(padx=20, pady=20)
|
||||
|
||||
txt_var = customtkinter.StringVar(value="test")
|
||||
|
||||
entry_1.configure(width=300,
|
||||
height=35,
|
||||
corner_radius=1000,
|
||||
border_width=4,
|
||||
bg_color="green",
|
||||
fg_color=("red", "yellow"),
|
||||
border_color="blue",
|
||||
text_color=("brown", "green"),
|
||||
placeholder_text_color="blue",
|
||||
textvariable=txt_var,
|
||||
placeholder_text="new_placholder",
|
||||
font=("Times New Roman", -8, "bold"),
|
||||
state="normal",
|
||||
insertborderwidth=5,
|
||||
insertwidth=10,
|
||||
justify="right",
|
||||
show="+")
|
||||
|
||||
assert entry_1.cget("width") == 300
|
||||
assert entry_1.cget("height") == 35
|
||||
assert entry_1.cget("corner_radius") == 1000
|
||||
assert entry_1.cget("border_width") == 4
|
||||
assert entry_1.cget("bg_color") == "green"
|
||||
assert entry_1.cget("fg_color") == ("red", "yellow")
|
||||
assert entry_1.cget("border_color") == "blue"
|
||||
assert entry_1.cget("text_color") == ("brown", "green")
|
||||
assert entry_1.cget("placeholder_text_color") == "blue"
|
||||
assert entry_1.cget("textvariable") == txt_var
|
||||
assert entry_1.cget("placeholder_text") == "new_placholder"
|
||||
assert entry_1.cget("font") == ("Times New Roman", -8, "bold")
|
||||
assert entry_1.cget("state") == "normal"
|
||||
assert entry_1.cget("insertborderwidth") == 5
|
||||
assert entry_1.cget("insertwidth") == 10
|
||||
assert entry_1.cget("justify") == "right"
|
||||
# assert entry_1.cget("show") == "+" # somehow does not work, maybe a tkinter bug?
|
||||
|
||||
def test_textvariable():
|
||||
txt_var.set("test_2")
|
||||
print(entry_1.get())
|
||||
assert entry_1.get() == "test_2"
|
||||
|
||||
app.after(500, test_textvariable)
|
||||
app.mainloop()
|
Reference in New Issue
Block a user