Skip to content

Commit 0b910bc

Browse files
committed
Slightly change example in main
1 parent 363b0d2 commit 0b910bc

4 files changed

Lines changed: 22 additions & 25 deletions

File tree

tkfilebrowser/__main__.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@
3838

3939
def c_open_file_old():
4040
rep = filedialog.askopenfilenames(parent=root, initialdir='/', initialfile='tmp',
41-
filetypes=[("PNG", "*.png"), ("JPEG", "*.jpg"), ("All files", "*")])
41+
filetypes=[("PNG", "*.png"),
42+
("JPEG", "*.jpg"),
43+
("All files", "*")])
4244
print(rep)
4345

4446

@@ -48,15 +50,19 @@ def c_open_dir_old():
4850

4951

5052
def c_save_old():
51-
rep = filedialog.asksaveasfilename(parent=root, defaultextension=".png", initialdir='/tmp', initialfile='image.png',
52-
filetypes=[("PNG", "*.png"), ("JPEG", "*.jpg"), ("All files", "*")])
53+
rep = filedialog.asksaveasfilename(parent=root, defaultextension=".png",
54+
initialdir='/tmp', initialfile='image.png',
55+
filetypes=[("PNG", "*.png"),
56+
("JPEG", "*.jpg"),
57+
("Text files", "*.txt"),
58+
("All files", "*")])
5359
print(rep)
5460

5561

5662
def c_open_file():
5763
rep = askopenfilenames(parent=root, initialdir='/', initialfile='tmp',
58-
# filetypes=[("Pictures", "*.png|*.jpg|*.JPG"), ("All files", "*")])
59-
filetypes=[("archive", "*.tar.*"), ("archive gzip", "*.tar.gz"), ("All files", "*")])
64+
filetypes=[("Pictures", "*.png|*.jpg|*.JPG"),
65+
("All files", "*")])
6066
print(rep)
6167

6268

@@ -68,9 +74,7 @@ def c_open_dir():
6874
def c_save():
6975
rep = asksaveasfilename(parent=root, defaultext=".png", initialdir='/tmp', initialfile='image.png',
7076
filetypes=[("Pictures", "*.png|*.jpg|*.JPG"),
71-
("PNG", "*.png"),
72-
("archive", "*.tar.*"),
73-
("archive gzip", "*.tar.gz"),
77+
("Text files", "*.txt"),
7478
("All files", "*")])
7579
print(rep)
7680

tkfilebrowser/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
"""
33
tkfilebrowser - Alternative to filedialog for Tkinter
4-
Copyright 2017 Juliette Monsel <j_4321@protonmail.com>
4+
Copyright 2017-2018 Juliette Monsel <j_4321@protonmail.com>
55
66
tkfilebrowser is free software: you can redistribute it and/or modify
77
it under the terms of the GNU General Public License as published by

tkfilebrowser/filebrowser.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
"""
33
tkfilebrowser - Alternative to filedialog for Tkinter
4-
Copyright 2017 Juliette Monsel <j_4321@protonmail.com>
4+
Copyright 2017-2018 Juliette Monsel <j_4321@protonmail.com>
55
66
tkfilebrowser is free software: you can redistribute it and/or modify
77
it under the terms of the GNU General Public License as published by
@@ -141,8 +141,6 @@ def __init__(self, parent, initialdir="", initialfile="", mode="openfile",
141141
default='white')
142142
fg = style.lookup('TLabel', 'foreground', default='black')
143143
active_bg = style.lookup('TButton', 'background', ('active',))
144-
# active_fg = style.lookup('TButton', 'foreground', ('active',))
145-
# disabled_fg = style.lookup('TButton', 'foreground', ('disabled',))
146144
sel_bg = style.lookup('Treeview', 'background', ('selected',))
147145
sel_fg = style.lookup('Treeview', 'foreground', ('selected',))
148146
self.option_add('*TCombobox*Listbox.selectBackground', sel_bg)
@@ -277,13 +275,13 @@ def __init__(self, parent, initialdir="", initialfile="", mode="openfile",
277275
scroll_left.grid(row=0, column=1, sticky="ns")
278276
self.left_tree.configure(yscrollcommand=scroll_left.set)
279277

280-
# --- list devices and bookmarked locations
281-
# recent
278+
# list devices and bookmarked locations
279+
# -------- recent
282280
self.left_tree.insert("", "end", iid="recent", text=_("Recent"),
283281
image=self.im_recent)
284282
wrapper.add_tooltip("recent", _("Recently used"))
285283

286-
# devices
284+
# -------- devices
287285
devices = psutil.disk_partitions()
288286

289287
for d in devices:
@@ -296,13 +294,13 @@ def __init__(self, parent, initialdir="", initialfile="", mode="openfile",
296294
image=self.im_drive)
297295
wrapper.add_tooltip(m, m)
298296

299-
# home
297+
# -------- home
300298
home = expanduser("~")
301299
self.left_tree.insert("", "end", iid=home, image=self.im_home,
302300
text=split(home)[-1])
303301
wrapper.add_tooltip(home, home)
304302

305-
# desktop
303+
# -------- desktop
306304
try:
307305
desktop = check_output(['xdg-users-dir', 'DESKTOP']).decode().strip()
308306
except Exception:
@@ -314,7 +312,7 @@ def __init__(self, parent, initialdir="", initialfile="", mode="openfile",
314312
text=split(desktop)[-1])
315313
wrapper.add_tooltip(desktop, desktop)
316314

317-
# bookmarks
315+
# -------- bookmarks
318316
path_bm = join(home, ".config", "gtk-3.0", "bookmarks")
319317
path_bm2 = join(home, ".gtk-bookmarks") # old location
320318
if exists(path_bm):

tkfilebrowser/functions.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
"""
33
tkfilebrowser - Alternative to filedialog for Tkinter
4-
Copyright 2017 Juliette Monsel <j_4321@protonmail.com>
4+
Copyright 2017-2018 Juliette Monsel <j_4321@protonmail.com>
55
66
tkfilebrowser is free software: you can redistribute it and/or modify
77
it under the terms of the GNU General Public License as published by
@@ -17,11 +17,6 @@
1717
along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
1919
20-
The icons are modified versions of icons from the elementary project
21-
(the xfce fork to be precise https://github.com/shimmerproject/elementary-xfce)
22-
Copyright 2007-2013 elementary LLC.
23-
24-
2520
Functions
2621
"""
2722

@@ -127,7 +122,7 @@ def asksaveasfilename(parent=None, title=_("Save As"), **kwargs):
127122
Options:
128123
* initialdir: initial folder whose content is displayed
129124
* initialfile: initial selected item (just the name, not the full path)
130-
* defaultext (save mode only): extension added to filename if none is given
125+
* defaultext: extension added to filename if none is given
131126
* filetypes: [('name', '*.ext1|*.ext2|..'), ...]
132127
show only files of given filetype ("*" for all files)
133128
* okbuttontext: text displayed on the validate button, if None, the

0 commit comments

Comments
 (0)