Skip to content

Commit 1b7bfae

Browse files
committed
Add compatibility Tk 8.5 and fix recent files with space
1 parent 16b33e6 commit 1b7bfae

4 files changed

Lines changed: 16 additions & 13 deletions

File tree

tkfilebrowser/constants.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@
6161
RECENT_FILES = os.path.join(LOCAL_PATH, 'recent_files')
6262

6363
# --- images
64+
if tk.TkVersion < 8.6:
65+
from PIL.ImageTk import PhotoImage
66+
else:
67+
PhotoImage = tk.PhotoImage
68+
6469
IM_HOME = os.path.join(PATH, "images", "home.png")
6570
IM_FOLDER = os.path.join(PATH, "images", "dossier.png")
6671
IM_FOLDER_LINK = os.path.join(PATH, "images", "dossier_link.png")

tkfilebrowser/filebrowser.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,15 @@ def __init__(self, parent, initialdir="", initialfile="", mode="openfile",
166166
foreground='white')
167167

168168
# --- images
169-
self.im_file = tk.PhotoImage(file=cst.IM_FILE, master=self)
170-
self.im_folder = tk.PhotoImage(file=cst.IM_FOLDER, master=self)
171-
self.im_file_link = tk.PhotoImage(file=cst.IM_FILE_LINK, master=self)
172-
self.im_folder_link = tk.PhotoImage(file=cst.IM_FOLDER_LINK, master=self)
173-
self.im_new = tk.PhotoImage(file=cst.IM_NEW, master=self)
174-
self.im_drive = tk.PhotoImage(file=cst.IM_DRIVE, master=self)
175-
self.im_home = tk.PhotoImage(file=cst.IM_HOME, master=self)
176-
self.im_recent = tk.PhotoImage(file=cst.IM_RECENT, master=self)
177-
self.im_recent_24 = tk.PhotoImage(file=cst.IM_RECENT_24, master=self)
169+
self.im_file = cst.PhotoImage(file=cst.IM_FILE, master=self)
170+
self.im_folder = cst.PhotoImage(file=cst.IM_FOLDER, master=self)
171+
self.im_file_link = cst.PhotoImage(file=cst.IM_FILE_LINK, master=self)
172+
self.im_folder_link = cst.PhotoImage(file=cst.IM_FOLDER_LINK, master=self)
173+
self.im_new = cst.PhotoImage(file=cst.IM_NEW, master=self)
174+
self.im_drive = cst.PhotoImage(file=cst.IM_DRIVE, master=self)
175+
self.im_home = cst.PhotoImage(file=cst.IM_HOME, master=self)
176+
self.im_recent = cst.PhotoImage(file=cst.IM_RECENT, master=self)
177+
self.im_recent_24 = cst.PhotoImage(file=cst.IM_RECENT_24, master=self)
178178

179179
# --- filetypes
180180
self.filetype = tk.StringVar(self)

tkfilebrowser/recent_files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __init__(self, filename, nbmax=30):
4141
self._files = [] # most recent files first
4242
try:
4343
with open(filename) as file:
44-
self._files = file.read().split()
44+
self._files = file.read().splitlines()
4545
except Exception:
4646
pass
4747

tkfilebrowser/tooltip.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ def __init__(self, parent, **kwargs):
3333
3434
Options:
3535
* parent: parent window
36-
* image: PhotoImage/BitmapImage to display in the tooltip
3736
* text: text (str) to display in the tooltip
3837
* compound: relative orientation of the graphic relative to the text
3938
* alpha: opacity of the tooltip (0 for transparent, 1 for opaque),
@@ -49,8 +48,7 @@ def __init__(self, parent, **kwargs):
4948
bg = ttk.Style(self).lookup(style, 'background')
5049
self.configure(background=bg)
5150

52-
self.im = kwargs.get('image', None)
53-
self.label = ttk.Label(self, text=kwargs.get('text', ''), image=self.im,
51+
self.label = ttk.Label(self, text=kwargs.get('text', ''),
5452
style=style, compound=kwargs.get('compound', 'left'),
5553
padding=kwargs.get('padding', 4))
5654
self.label.pack()

0 commit comments

Comments
 (0)