mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
removed CTkFiledialog, add filedialog
This commit is contained in:
@ -1,60 +1,31 @@
|
||||
import tkinter
|
||||
import tkinter.messagebox
|
||||
import customtkinter
|
||||
|
||||
customtkinter.set_appearance_mode("dark")
|
||||
|
||||
|
||||
class App(customtkinter.CTk):
|
||||
|
||||
customtkinter.set_appearance_mode("dark")
|
||||
APP_NAME = "Bulk Barcode Generator"
|
||||
WIDTH = 600
|
||||
HEIGHT = 450
|
||||
|
||||
MAIN_COLOR = "#5ea886"
|
||||
MAIN_COLOR_DARK = "#2D5862"
|
||||
MAIN_HOVER = "#05f4b7"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.title(App.APP_NAME)
|
||||
self.geometry(str(App.WIDTH) + "x" + str(App.HEIGHT))
|
||||
self.minsize(App.WIDTH, App.HEIGHT)
|
||||
self.title("test filedialog")
|
||||
|
||||
self.protocol("WM_DELETE_WINDOW", self.on_closing)
|
||||
|
||||
self.frame_left = customtkinter.CTkFrame(master=self,
|
||||
width=220,
|
||||
height=App.HEIGHT-40,
|
||||
corner_radius=5)
|
||||
self.frame_left.place(relx=0.38, rely=0.5, anchor=tkinter.E)
|
||||
|
||||
self.frame_right = customtkinter.CTkFrame(master=self,
|
||||
width=350,
|
||||
height=App.HEIGHT-40,
|
||||
corner_radius=5)
|
||||
self.frame_right.place(relx=0.40, rely=0.5, anchor=tkinter.W)
|
||||
|
||||
self.button_output = customtkinter.CTkButton(master=self.frame_right, border_color=App.MAIN_COLOR,
|
||||
fg_color=None, hover_color=App.MAIN_HOVER,
|
||||
height=28, text="Output Folder", command=self.button_outputFunc,
|
||||
border_width=3, corner_radius=10, font=('Calibri',12))
|
||||
self.button_output.place(relx=0.05, rely=0.06, anchor=tkinter.NW)
|
||||
self.entry_output = customtkinter.CTkEntry(master=self.frame_right, width=320, height=38, corner_radius=5)
|
||||
self.entry_output.place(relx=0.05, rely=0.18, anchor=tkinter.NW)
|
||||
|
||||
def button_outputFunc(self):
|
||||
self.entry_output.delete(0, 'end')
|
||||
filename = customtkinter.filedialog.askdirectory()
|
||||
self.entry_output.insert(0, str(filename))
|
||||
|
||||
def on_closing(self, event=0):
|
||||
self.destroy()
|
||||
|
||||
def start(self):
|
||||
self.mainloop()
|
||||
self.button_1 = customtkinter.CTkButton(master=self, text="askopenfile", command=lambda: print(customtkinter.filedialog.askopenfile()))
|
||||
self.button_1.pack(pady=10)
|
||||
self.button_2 = customtkinter.CTkButton(master=self, text="askopenfiles", command=lambda: print(customtkinter.filedialog.askopenfiles()))
|
||||
self.button_2.pack(pady=10)
|
||||
self.button_3 = customtkinter.CTkButton(master=self, text="askdirectory", command=lambda: print(customtkinter.filedialog.askdirectory()))
|
||||
self.button_3.pack(pady=10)
|
||||
self.button_4 = customtkinter.CTkButton(master=self, text="asksaveasfile", command=lambda: print(customtkinter.filedialog.asksaveasfile()))
|
||||
self.button_4.pack(pady=10)
|
||||
self.button_5 = customtkinter.CTkButton(master=self, text="askopenfilename", command=lambda: print(customtkinter.filedialog.askopenfilename()))
|
||||
self.button_5.pack(pady=10)
|
||||
self.button_6 = customtkinter.CTkButton(master=self, text="askopenfilenames", command=lambda: print(customtkinter.filedialog.askopenfilenames()))
|
||||
self.button_6.pack(pady=10)
|
||||
self.button_7 = customtkinter.CTkButton(master=self, text="asksaveasfilename", command=lambda: print(customtkinter.filedialog.asksaveasfilename()))
|
||||
self.button_7.pack(pady=10)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = App()
|
||||
app.start()
|
||||
app.mainloop()
|
||||
|
Reference in New Issue
Block a user