test_filedialog.py 1.6 KB

12345678910111213141516171819202122232425262728293031
  1. import tkinter.messagebox
  2. import customtkinter
  3. customtkinter.set_appearance_mode("dark")
  4. class App(customtkinter.CTk):
  5. def __init__(self, *args, **kwargs):
  6. super().__init__(*args, **kwargs)
  7. self.title("test filedialog")
  8. self.button_1 = customtkinter.CTkButton(master=self, text="askopenfile", command=lambda: print(customtkinter.filedialog.askopenfile()))
  9. self.button_1.pack(pady=10)
  10. self.button_2 = customtkinter.CTkButton(master=self, text="askopenfiles", command=lambda: print(customtkinter.filedialog.askopenfiles()))
  11. self.button_2.pack(pady=10)
  12. self.button_3 = customtkinter.CTkButton(master=self, text="askdirectory", command=lambda: print(customtkinter.filedialog.askdirectory()))
  13. self.button_3.pack(pady=10)
  14. self.button_4 = customtkinter.CTkButton(master=self, text="asksaveasfile", command=lambda: print(customtkinter.filedialog.asksaveasfile()))
  15. self.button_4.pack(pady=10)
  16. self.button_5 = customtkinter.CTkButton(master=self, text="askopenfilename", command=lambda: print(customtkinter.filedialog.askopenfilename()))
  17. self.button_5.pack(pady=10)
  18. self.button_6 = customtkinter.CTkButton(master=self, text="askopenfilenames", command=lambda: print(customtkinter.filedialog.askopenfilenames()))
  19. self.button_6.pack(pady=10)
  20. self.button_7 = customtkinter.CTkButton(master=self, text="asksaveasfilename", command=lambda: print(customtkinter.filedialog.asksaveasfilename()))
  21. self.button_7.pack(pady=10)
  22. if __name__ == "__main__":
  23. app = App()
  24. app.mainloop()