Skip to content

Commit 70a4182

Browse files
committed
Merge branch 'compatibility'
* Add compatibility with Tk < 8.6.0 (requires PIL.ImageTk) * Add desktop icon in shortcuts
2 parents 4dd7b94 + a89e5b6 commit 70a4182

7 files changed

Lines changed: 27 additions & 15 deletions

File tree

changelog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ Copyright 2017 Juliette Monsel <j_4321@protonmail.com>
66
Changelog
77
---------
88

9+
- tkfilebrowser 2.2.5
10+
* Add compatibility with Tk < 8.6.0 (requires PIL.ImageTk)
11+
* Add desktop icon in shortcuts
12+
913
- tkfilebrowser 2.2.4
1014
* Fix bug in desktop folder identification
1115

tkfilebrowser/constants.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,13 @@
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")
70+
IM_DESKTOP = os.path.join(PATH, "images", "desktop.png")
6571
IM_FOLDER = os.path.join(PATH, "images", "dossier.png")
6672
IM_FOLDER_LINK = os.path.join(PATH, "images", "dossier_link.png")
6773
IM_NEW = os.path.join(PATH, "images", "new_folder.png")
@@ -73,7 +79,10 @@
7379

7480

7581
# --- translation
76-
LANG = locale.getdefaultlocale()[0]
82+
try:
83+
LANG = locale.getdefaultlocale()[0]
84+
except ValueError:
85+
LANG = 'en'
7786

7887
EN = {}
7988
FR = {"B": "octets", "MB": "Mo", "kB": "ko", "GB": "Go", "TB": "To",

tkfilebrowser/filebrowser.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,16 @@ 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_desktop = cst.PhotoImage(file=cst.IM_DESKTOP, master=self)
172+
self.im_file_link = cst.PhotoImage(file=cst.IM_FILE_LINK, master=self)
173+
self.im_folder_link = cst.PhotoImage(file=cst.IM_FOLDER_LINK, master=self)
174+
self.im_new = cst.PhotoImage(file=cst.IM_NEW, master=self)
175+
self.im_drive = cst.PhotoImage(file=cst.IM_DRIVE, master=self)
176+
self.im_home = cst.PhotoImage(file=cst.IM_HOME, master=self)
177+
self.im_recent = cst.PhotoImage(file=cst.IM_RECENT, master=self)
178+
self.im_recent_24 = cst.PhotoImage(file=cst.IM_RECENT_24, master=self)
178179

179180
# --- filetypes
180181
self.filetype = tk.StringVar(self)
@@ -310,7 +311,7 @@ def __init__(self, parent, initialdir="", initialfile="", mode="openfile",
310311
# but OSError in python2
311312
desktop = join(home, 'Desktop')
312313
if exists(desktop):
313-
self.left_tree.insert("", "end", iid=desktop, image=self.im_folder,
314+
self.left_tree.insert("", "end", iid=desktop, image=self.im_desktop,
314315
text=split(desktop)[-1])
315316
wrapper.add_tooltip(desktop, desktop)
316317

tkfilebrowser/images/desktop.png

707 Bytes
Loading

tkfilebrowser/images/drive.png

75 Bytes
Loading

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)