removed CTkFiledialog, add filedialog

This commit is contained in:
TomSchimansky 2022-11-12 14:01:54 +01:00
parent e269091ffe
commit 2f27611f3e
4 changed files with 22 additions and 50 deletions

View File

@ -4,9 +4,9 @@ import os
import sys import sys
from tkinter import Variable, StringVar, IntVar, DoubleVar, BooleanVar from tkinter import Variable, StringVar, IntVar, DoubleVar, BooleanVar
from tkinter.constants import * from tkinter.constants import *
import tkinter.filedialog as CTkFiledialog import tkinter.filedialog as filedialog
_ = Variable, StringVar, IntVar, DoubleVar, BooleanVar, CENTER, CTkFiledialog # prevent IDE from removing unused imports _ = Variable, StringVar, IntVar, DoubleVar, BooleanVar, CENTER, filedialog # prevent IDE from removing unused imports
# import manager classes # import manager classes
from .windows.widgets.appearance_mode.appearance_mode_tracker import AppearanceModeTracker from .windows.widgets.appearance_mode.appearance_mode_tracker import AppearanceModeTracker

View File

@ -1,3 +1,4 @@
import tkinter
from typing import Union, Tuple, Dict, List, Callable, Optional from typing import Union, Tuple, Dict, List, Callable, Optional
from .theme.theme_manager import ThemeManager from .theme.theme_manager import ThemeManager
@ -208,6 +209,7 @@ class CTkTabview(CTkBaseClass):
fill=self._apply_appearance_mode(self._border_color), fill=self._apply_appearance_mode(self._border_color),
outline=self._apply_appearance_mode(self._border_color)) outline=self._apply_appearance_mode(self._border_color))
self._canvas.configure(bg=self._apply_appearance_mode(self._bg_color)) self._canvas.configure(bg=self._apply_appearance_mode(self._bg_color))
tkinter.Frame.configure(self, bg=self._apply_appearance_mode(self._bg_color)) # configure bg color of tkinter.Frame, cuase canvas does not fill frame
def configure(self, require_redraw=False, **kwargs): def configure(self, require_redraw=False, **kwargs):
if "corner_radius" in kwargs: if "corner_radius" in kwargs:

View File

@ -155,7 +155,6 @@ class ScalingTracker:
for window in cls.window_widgets_dict: for window in cls.window_widgets_dict:
if window.winfo_exists() and not window.state() == "iconic": if window.winfo_exists() and not window.state() == "iconic":
current_dpi_scaling_value = cls.get_window_dpi_scaling(window) current_dpi_scaling_value = cls.get_window_dpi_scaling(window)
print("current dpi:", current_dpi_scaling_value)
if current_dpi_scaling_value != cls.window_dpi_scaling_dict[window]: if current_dpi_scaling_value != cls.window_dpi_scaling_dict[window]:
cls.window_dpi_scaling_dict[window] = current_dpi_scaling_value cls.window_dpi_scaling_dict[window] = current_dpi_scaling_value

View File

@ -1,60 +1,31 @@
import tkinter
import tkinter.messagebox import tkinter.messagebox
import customtkinter import customtkinter
customtkinter.set_appearance_mode("dark")
class App(customtkinter.CTk): 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): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.title(App.APP_NAME) self.title("test filedialog")
self.geometry(str(App.WIDTH) + "x" + str(App.HEIGHT))
self.minsize(App.WIDTH, App.HEIGHT)
self.protocol("WM_DELETE_WINDOW", self.on_closing) self.button_1 = customtkinter.CTkButton(master=self, text="askopenfile", command=lambda: print(customtkinter.filedialog.askopenfile()))
self.button_1.pack(pady=10)
self.frame_left = customtkinter.CTkFrame(master=self, self.button_2 = customtkinter.CTkButton(master=self, text="askopenfiles", command=lambda: print(customtkinter.filedialog.askopenfiles()))
width=220, self.button_2.pack(pady=10)
height=App.HEIGHT-40, self.button_3 = customtkinter.CTkButton(master=self, text="askdirectory", command=lambda: print(customtkinter.filedialog.askdirectory()))
corner_radius=5) self.button_3.pack(pady=10)
self.frame_left.place(relx=0.38, rely=0.5, anchor=tkinter.E) self.button_4 = customtkinter.CTkButton(master=self, text="asksaveasfile", command=lambda: print(customtkinter.filedialog.asksaveasfile()))
self.button_4.pack(pady=10)
self.frame_right = customtkinter.CTkFrame(master=self, self.button_5 = customtkinter.CTkButton(master=self, text="askopenfilename", command=lambda: print(customtkinter.filedialog.askopenfilename()))
width=350, self.button_5.pack(pady=10)
height=App.HEIGHT-40, self.button_6 = customtkinter.CTkButton(master=self, text="askopenfilenames", command=lambda: print(customtkinter.filedialog.askopenfilenames()))
corner_radius=5) self.button_6.pack(pady=10)
self.frame_right.place(relx=0.40, rely=0.5, anchor=tkinter.W) self.button_7 = customtkinter.CTkButton(master=self, text="asksaveasfilename", command=lambda: print(customtkinter.filedialog.asksaveasfilename()))
self.button_7.pack(pady=10)
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()
if __name__ == "__main__": if __name__ == "__main__":
app = App() app = App()
app.start() app.mainloop()