simple_example.py 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import customtkinter
  2. import tkinterDnD
  3. customtkinter.set_ctk_parent_class(tkinterDnD.Tk)
  4. customtkinter.set_appearance_mode("dark") # Modes: "System" (standard), "Dark", "Light"
  5. customtkinter.set_default_color_theme("blue") # Themes: "blue" (standard), "green", "dark-blue"
  6. app = customtkinter.CTk()
  7. app.geometry("400x780")
  8. app.title("CustomTkinter simple_example.py")
  9. print(type(app), isinstance(app, tkinterDnD.Tk))
  10. def button_callback():
  11. print("Button click", combobox_1.get())
  12. def slider_callback(value):
  13. progressbar_1.set(value)
  14. frame_1 = customtkinter.CTkFrame(master=app)
  15. frame_1.pack(pady=20, padx=60, fill="both", expand=True)
  16. label_1 = customtkinter.CTkLabel(master=frame_1, justify=customtkinter.LEFT)
  17. label_1.pack(pady=10, padx=10)
  18. progressbar_1 = customtkinter.CTkProgressBar(master=frame_1)
  19. progressbar_1.pack(pady=10, padx=10)
  20. button_1 = customtkinter.CTkButton(master=frame_1, command=button_callback)
  21. button_1.pack(pady=10, padx=10)
  22. slider_1 = customtkinter.CTkSlider(master=frame_1, command=slider_callback, from_=0, to=1)
  23. slider_1.pack(pady=10, padx=10)
  24. slider_1.set(0.5)
  25. entry_1 = customtkinter.CTkEntry(master=frame_1, placeholder_text="CTkEntry")
  26. entry_1.pack(pady=10, padx=10)
  27. optionmenu_1 = customtkinter.CTkOptionMenu(frame_1, values=["Option 1", "Option 2", "Option 42 long long long..."])
  28. optionmenu_1.pack(pady=10, padx=10)
  29. optionmenu_1.set("CTkOptionMenu")
  30. combobox_1 = customtkinter.CTkComboBox(frame_1, values=["Option 1", "Option 2", "Option 42 long long long..."])
  31. combobox_1.pack(pady=10, padx=10)
  32. combobox_1.set("CTkComboBox")
  33. checkbox_1 = customtkinter.CTkCheckBox(master=frame_1)
  34. checkbox_1.pack(pady=10, padx=10)
  35. radiobutton_var = customtkinter.IntVar(value=1)
  36. radiobutton_1 = customtkinter.CTkRadioButton(master=frame_1, variable=radiobutton_var, value=1)
  37. radiobutton_1.pack(pady=10, padx=10)
  38. radiobutton_2 = customtkinter.CTkRadioButton(master=frame_1, variable=radiobutton_var, value=2)
  39. radiobutton_2.pack(pady=10, padx=10)
  40. switch_1 = customtkinter.CTkSwitch(master=frame_1)
  41. switch_1.pack(pady=10, padx=10)
  42. text_1 = customtkinter.CTkTextbox(master=frame_1, width=200, height=70)
  43. text_1.pack(pady=10, padx=10)
  44. text_1.insert("0.0", "CTkTextbox\n\n\n\n")
  45. segmented_button_1 = customtkinter.CTkSegmentedButton(master=frame_1, values=["CTkSegmentedButton", "Value 2"])
  46. segmented_button_1.pack(pady=10, padx=10)
  47. tabview_1 = customtkinter.CTkTabview(master=frame_1, width=300)
  48. tabview_1.pack(pady=10, padx=10)
  49. tabview_1.add("CTkTabview")
  50. tabview_1.add("Tab 2")
  51. app.mainloop()