Skip to content

Commit

Permalink
Slightly change example in main
Browse files Browse the repository at this point in the history
  • Loading branch information
j4321 committed Aug 14, 2018
1 parent 363b0d2 commit 0b910bc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 25 deletions.
20 changes: 12 additions & 8 deletions tkfilebrowser/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@

def c_open_file_old():
rep = filedialog.askopenfilenames(parent=root, initialdir='/', initialfile='tmp',
filetypes=[("PNG", "*.png"), ("JPEG", "*.jpg"), ("All files", "*")])
filetypes=[("PNG", "*.png"),
("JPEG", "*.jpg"),
("All files", "*")])
print(rep)


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


def c_save_old():
rep = filedialog.asksaveasfilename(parent=root, defaultextension=".png", initialdir='/tmp', initialfile='image.png',
filetypes=[("PNG", "*.png"), ("JPEG", "*.jpg"), ("All files", "*")])
rep = filedialog.asksaveasfilename(parent=root, defaultextension=".png",
initialdir='/tmp', initialfile='image.png',
filetypes=[("PNG", "*.png"),
("JPEG", "*.jpg"),
("Text files", "*.txt"),
("All files", "*")])
print(rep)


def c_open_file():
rep = askopenfilenames(parent=root, initialdir='/', initialfile='tmp',
# filetypes=[("Pictures", "*.png|*.jpg|*.JPG"), ("All files", "*")])
filetypes=[("archive", "*.tar.*"), ("archive gzip", "*.tar.gz"), ("All files", "*")])
filetypes=[("Pictures", "*.png|*.jpg|*.JPG"),
("All files", "*")])
print(rep)


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

Expand Down
2 changes: 1 addition & 1 deletion tkfilebrowser/constants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""
tkfilebrowser - Alternative to filedialog for Tkinter
Copyright 2017 Juliette Monsel <[email protected]>
Copyright 2017-2018 Juliette Monsel <[email protected]>
tkfilebrowser is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
16 changes: 7 additions & 9 deletions tkfilebrowser/filebrowser.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""
tkfilebrowser - Alternative to filedialog for Tkinter
Copyright 2017 Juliette Monsel <[email protected]>
Copyright 2017-2018 Juliette Monsel <[email protected]>
tkfilebrowser is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -141,8 +141,6 @@ def __init__(self, parent, initialdir="", initialfile="", mode="openfile",
default='white')
fg = style.lookup('TLabel', 'foreground', default='black')
active_bg = style.lookup('TButton', 'background', ('active',))
# active_fg = style.lookup('TButton', 'foreground', ('active',))
# disabled_fg = style.lookup('TButton', 'foreground', ('disabled',))
sel_bg = style.lookup('Treeview', 'background', ('selected',))
sel_fg = style.lookup('Treeview', 'foreground', ('selected',))
self.option_add('*TCombobox*Listbox.selectBackground', sel_bg)
Expand Down Expand Up @@ -277,13 +275,13 @@ def __init__(self, parent, initialdir="", initialfile="", mode="openfile",
scroll_left.grid(row=0, column=1, sticky="ns")
self.left_tree.configure(yscrollcommand=scroll_left.set)

# --- list devices and bookmarked locations
# recent
# list devices and bookmarked locations
# -------- recent
self.left_tree.insert("", "end", iid="recent", text=_("Recent"),
image=self.im_recent)
wrapper.add_tooltip("recent", _("Recently used"))

# devices
# -------- devices
devices = psutil.disk_partitions()

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

# home
# -------- home
home = expanduser("~")
self.left_tree.insert("", "end", iid=home, image=self.im_home,
text=split(home)[-1])
wrapper.add_tooltip(home, home)

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

# bookmarks
# -------- bookmarks
path_bm = join(home, ".config", "gtk-3.0", "bookmarks")
path_bm2 = join(home, ".gtk-bookmarks") # old location
if exists(path_bm):
Expand Down
9 changes: 2 additions & 7 deletions tkfilebrowser/functions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""
tkfilebrowser - Alternative to filedialog for Tkinter
Copyright 2017 Juliette Monsel <[email protected]>
Copyright 2017-2018 Juliette Monsel <[email protected]>
tkfilebrowser is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -17,11 +17,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
The icons are modified versions of icons from the elementary project
(the xfce fork to be precise https://github.com/shimmerproject/elementary-xfce)
Copyright 2007-2013 elementary LLC.
Functions
"""

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

0 comments on commit 0b910bc

Please sign in to comment.