test_string_dialog.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import customtkinter
  2. customtkinter.set_appearance_mode("dark")
  3. customtkinter.set_default_color_theme("blue")
  4. customtkinter.set_window_scaling(0.8)
  5. customtkinter.set_widget_scaling(0.8)
  6. app = customtkinter.CTk()
  7. app.geometry("400x300")
  8. app.title("CTkDialog Test")
  9. def change_mode():
  10. if c1.get() == 0:
  11. customtkinter.set_appearance_mode("light")
  12. else:
  13. customtkinter.set_appearance_mode("dark")
  14. def button_1_click_event():
  15. dialog = customtkinter.CTkInputDialog(text="Type in a number:", title="Test")
  16. print("Number:", dialog.get_input())
  17. def button_2_click_event():
  18. dialog = customtkinter.CTkInputDialog(text="long text "*100, title="Test")
  19. print("Number:", dialog.get_input())
  20. button_1 = customtkinter.CTkButton(app, text="Open Dialog", command=button_1_click_event)
  21. button_1.pack(pady=20)
  22. button_2 = customtkinter.CTkButton(app, text="Open Dialog", command=button_2_click_event)
  23. button_2.pack(pady=20)
  24. c1 = customtkinter.CTkCheckBox(app, text="dark mode", command=change_mode)
  25. c1.pack(pady=20)
  26. app.mainloop()