-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5a94cad
Showing
21 changed files
with
568 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
V0.01.0 | ||
tidy frames | ||
come up with name | ||
titlebar | ||
add about menu | ||
V0.01.1 | ||
handle permission error | ||
|
||
V0.02 | ||
quick access | ||
add/delete top level node | ||
add/delete links | ||
scrollbar | ||
V0.03 | ||
scrollbar for tree | ||
auto hide | ||
V0.04 | ||
get size and date modified data | ||
V0.05 | ||
Collapse all button for quick access | ||
V0.06 | ||
Expand file types and icons | ||
V0.07 | ||
back/forward navigation | ||
V0.08 | ||
rename files | ||
V0.09 | ||
handle hidden files |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import tkinter as tk | ||
from tkinter import * | ||
from tkinter import ttk | ||
from tkinter.ttk import * | ||
|
||
def about(mainapp): | ||
|
||
win = tk.Toplevel() | ||
win.wm_title("About Tk Path Finder") | ||
|
||
l = tk.Label(win, width = 20, text=f"Tk Path Finder Version {mainapp.version}") | ||
l.grid(row=0, column=1, columnspan = 3) | ||
|
||
l2 = tk.Label(win, text=f"Icons From https://icons8.com") | ||
l2.grid(row=1, column=0, columnspan = 5) | ||
|
||
l3 = tk.Label(win, text = ''' | ||
Tk Path Finder makes no promise of warranty, satisfaction, performance, or | ||
anything else. Understand that your use of this tool is completely | ||
at your own risk.''') | ||
l3.grid(row=2, column=0, columnspan = 5) | ||
|
||
b = ttk.Button(win, text="Okay", command=win.destroy) | ||
b.grid(row=3, column=2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import tkinter as tk | ||
from tkinter import * | ||
from tkinter import ttk | ||
from tkinter.ttk import * | ||
|
||
class AddressBarEntry(ttk.Entry): | ||
def __init__(self, mainapp, branch_tab): | ||
super(AddressBarEntry, self).__init__(branch_tab) | ||
self.branch_tab = branch_tab | ||
self.bind('<Return>', self.enter_event) | ||
|
||
def update_bar(self): | ||
self.delete(0, END) #deletes the current value | ||
self.insert(0, self.branch_tab.explorer.current_directory) #inserts new value assigned by 2nd parameter | ||
|
||
def enter_event(self, event): | ||
self.branch_tab.explorer.address_bar_updateed(self.get()) | ||
self.branch_tab.update_tab() | ||
self.update_bar() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import os | ||
import subprocess | ||
import tkinter as tk | ||
from tkinter import * | ||
from tkinter import ttk | ||
from tkinter.ttk import * | ||
|
||
import address_bar | ||
import explorer_backend | ||
import treeview_functions | ||
|
||
class BranchTab(ttk.Frame): | ||
def __init__(self, root_tab, mainapp, id, text, width): | ||
super(BranchTab, self).__init__(mainapp.notebook) #check if this convention is right | ||
self.mainapp = mainapp | ||
self.id = id | ||
self.root_tab = root_tab | ||
self.text = text | ||
self.width = width | ||
|
||
# GRID | ||
self.tree_colspan = 16 | ||
self.grid_columnconfigure(self.tree_colspan-1, weight=1) | ||
self.grid_rowconfigure(1, weight=1) | ||
|
||
self.explorer = explorer_backend.FileExplorerBackend(self.mainapp) | ||
self.setup_adress_bar() | ||
self.setup_buttons() | ||
self.setup_treeview() | ||
self.address_bar_entry.update_bar() | ||
self.update_treeview() | ||
|
||
def update_tab(self): | ||
self.address_bar_entry.update_bar() | ||
self.update_treeview() | ||
self.root_tab.notebook.tab(self, text=os.path.basename(self.explorer.current_directory)) | ||
|
||
def setup_buttons(self): | ||
#Up a level | ||
ttk.Button(self, text=u'\u2191', command=self.up_one_level, style='primary.TButton').grid(row=0, column=0) | ||
|
||
def setup_adress_bar(self): | ||
self.address_bar_entry = address_bar.AddressBarEntry(self.mainapp, self) | ||
#self.address_bar_entry.pack(expand=True, fill=X) | ||
self.address_bar_entry.grid(row=0, column=1, columnspan=self.tree_colspan-1, sticky='NSEW', pady=self.mainapp.default_pady) | ||
|
||
def setup_treeview(self): | ||
column_names = ['Filename', 'Date Modified', 'Type', 'Size'] | ||
column_widths = [400, 100, 300, 100] | ||
height = 20 | ||
|
||
self.treeview = treeview_functions.create_treeview(self, column_names, column_widths, height) | ||
#self.treeview.pack(expand=True, fill=BOTH) | ||
self.treeview.grid(row=1, column=0, columnspan=16, sticky='NSEW', pady=self.mainapp.default_pady) | ||
self.treeview.bind("<Double-1>", self.OnDoubleClick) | ||
self.treeview.bind("<Button-3>", self.OnRightClick) | ||
|
||
def update_treeview(self): | ||
directory_data = self.explorer.list_directory() | ||
treeview_functions.write_data_to_treeview(self.mainapp, self.treeview, 'replace', directory_data) | ||
|
||
def OnDoubleClick(self, event): | ||
current_selection = treeview_functions.get_current_selection(self.treeview) | ||
if current_selection[1][2] == 'Folder': | ||
directory = current_selection[1][0] | ||
self.explorer.double_clicked_on_directory(directory) | ||
self.update_tab() | ||
else: | ||
self.explorer.double_clicked_on_file(current_selection[1][0]) | ||
|
||
|
||
def OnRightClick(self, event): | ||
iid = self.treeview.identify_row(event.y) | ||
if iid: | ||
self.treeview.selection_set(iid) | ||
popup_menu = tk.Menu(event.widget, tearoff=0) | ||
popup_menu.add_command(label="Open in Text Editor", command=self.open_in_text_editor) | ||
#popup_menu.add_command(label="Delete Root Tab", command=lambda tab=clicked_tab: event.widget.mainapp.delete_root_tab(tab)) | ||
|
||
try: | ||
popup_menu.tk_popup(event.x_root, event.y_root, 0) | ||
finally: | ||
popup_menu.grab_release() | ||
|
||
|
||
def up_one_level(self): | ||
self.explorer.up_one_level() | ||
self.update_tab() | ||
|
||
def open_in_text_editor(self): | ||
current_selection = treeview_functions.get_current_selection(self.treeview) | ||
if current_selection[1][2] != 'Folder': | ||
subprocess.call([r"C:\Program Files (x86)\Notepad++\notepad++.exe", fr"{self.explorer.current_directory}\\{current_selection[1][0]}"]) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import os | ||
import subprocess | ||
|
||
class FileExplorerBackend: | ||
def __init__(self, mainapp): | ||
self.current_directory = self.get_default_directory() | ||
#self.previous_directories = [] | ||
|
||
def get_default_directory(self): | ||
return os.getcwd() | ||
|
||
def list_directory(self): | ||
# Handle Directories | ||
directory_data = [] | ||
files_dirs = os.listdir(self.current_directory) | ||
directories = [o for o in files_dirs if os.path.isdir(os.path.join(self.current_directory,o))] | ||
for d in directories: | ||
directory_data.append([d, '-', 'Folder', '']) | ||
|
||
# Handle Files | ||
file_data = [] | ||
files = [o for o in files_dirs if not os.path.isdir(os.path.join(self.current_directory,o))] | ||
for f in files: | ||
file_data.append([f, '-', 'File', '']) | ||
|
||
return directory_data + file_data | ||
|
||
def get_file_type(self, filename): | ||
filename, file_extension = os.path.splitext(filename) | ||
print(file_extension) | ||
file_type = 'file' | ||
|
||
return file_type | ||
|
||
def setup_file_type_dict(self): | ||
self.known_file_types = {'.exe': 'application'} | ||
|
||
def double_clicked_on_directory(self, directory): | ||
#self.previous_directories.append(self.current_directory) | ||
self.current_directory = os.path.join(self.current_directory, directory) | ||
|
||
def double_clicked_on_file(self, file): | ||
os.startfile(os.path.join(self.current_directory, file)) | ||
print(os.path.join(self.current_directory, file)) | ||
#subprocess.run(['open', os.path.join(self.current_directory, file)], check=True) | ||
|
||
|
||
def address_bar_updateed(self, directory): | ||
print('bar updated') | ||
print(directory) | ||
if os.path.isdir(directory): | ||
self.current_directory = directory | ||
print('dsd') | ||
|
||
def up_one_level(self): | ||
self.current_directory = os.path.dirname(self.current_directory) | ||
|
||
def update_explorer(self): | ||
pass |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import tkinter as tk | ||
from tkinter import * | ||
from tkinter import ttk | ||
from tkinter.ttk import * | ||
|
||
from ttkbootstrap import Style | ||
|
||
import about_screen | ||
import root_tab | ||
import tkexplorer_icons | ||
|
||
class MainApplication(ttk.Frame): | ||
def __init__(self, parent, *args, **kwargs): | ||
ttk.Frame.__init__(self, parent, *args, **kwargs) | ||
self.parent = parent | ||
self.root_tabs = {} | ||
self.id = 0 | ||
self.setup_variables() | ||
|
||
# Styles | ||
self.style = Style('darkly') | ||
self.default_pady = 10 | ||
tkexplorer_icons.setup_icons(self) | ||
|
||
self.setup_menu() | ||
|
||
self.setup_main_frames() | ||
self.setup_notebook() | ||
self.setup_tabs() | ||
|
||
def setup_variables(self): | ||
self.version = '0.01.0' | ||
self.parent.title(f"Tk Path Finder V{self.version}") | ||
|
||
def setup_menu(self): | ||
menu = tk.Menu(self.master) | ||
self.master.config(menu=menu) | ||
|
||
# ________ ABOUT ________ | ||
about_menu = tk.Menu(menu, tearoff = 0) | ||
menu.add_cascade(label='About',menu=about_menu) | ||
about_menu.add_command(label = 'About Tk Path Finder', command = lambda self=self: about_screen.about(self)) | ||
|
||
def setup_notebook(self): | ||
self.notebook = ttk.Notebook(self.container) | ||
self.notebook.pack(expand=True, fill=BOTH, side=LEFT) | ||
self.notebook.bind('<Button-3>', root_tab.right_click) | ||
self.notebook.mainapp = self | ||
|
||
def setup_tabs(self): | ||
if self.root_tabs == {}: | ||
tab = self.create_root_tab() | ||
self.root_tabs = {0: tab} | ||
|
||
def create_root_tab(self): | ||
tab = root_tab.RootTab(self, self.id, self.id, 40) | ||
self.notebook.add(tab, text=f'{str(self.id).ljust(20)}') | ||
|
||
self.id += 1 | ||
|
||
return tab | ||
|
||
def delete_root_tab(self, tab): | ||
if len(self.notebook.tabs()) > 1: | ||
self.notebook.forget(tab) | ||
|
||
def delete_branch_tab(self, tab): | ||
if len(tab.root_tab.notebook.tabs()) > 1: | ||
tab.root_tab.notebook.forget(tab) | ||
|
||
def setup_main_frames(self): | ||
#self.top_frame = Frame(self.parent) # for toolbar and address bar | ||
#self.top_frame.grid(row=0,column=0, sticky="n") | ||
|
||
self.rootpane = ttk.PanedWindow(self.parent, orient=tk.HORIZONTAL) | ||
self.rootpane.pack(expand=True, fill=BOTH, side=LEFT) | ||
#self.rootpane.grid(row=1,column=0, columnspan=4,sticky="nsew") | ||
|
||
self.sidebar_frame = ttk.Frame() | ||
self.sidebar_frame.grid_rowconfigure(1, weight=1) | ||
self.sidebar_frame.grid_columnconfigure(19, weight=1) | ||
self.rootpane.add(self.sidebar_frame) | ||
|
||
self.container = tk.Frame(self.rootpane, bg='pink') | ||
self.container.pack(expand=True, fill=BOTH, side=LEFT) | ||
#self.container.grid_columnconfigure(0, weight=1) | ||
|
||
self.rootpane.add(self.container,)#stretch="always") | ||
|
||
ttk.Label(self.sidebar_frame, text='Quick Access').pack() | ||
#ttk.Button(self.container, text='Add Root', command=self.create_root_tab).pack() | ||
if __name__ == "__main__": | ||
root = tk.Tk() | ||
root.resizable(width=tk.TRUE, height=tk.TRUE) | ||
#MainApplication(root).pack(side="top", fill="both", expand=True) | ||
MA = MainApplication(root) | ||
#MA.pack(expand=True, fill=BOTH, side=LEFT) | ||
#MA.grid(row=1, columnspan=4, sticky='nsew') | ||
# root.bind('<Control-s>', lambda event, MA=MA: fm.save(event, MA)) | ||
# root.bind('<Control-Shift-KeyPress-S>', lambda event, MA=MA: fm.save_as(event, MA)) | ||
# root.bind('<Control-z>', MA.states.undo) | ||
# root.bind('<Control-y>', MA.states.redo) | ||
|
||
#root.geometry('{}x{}'.format(MA.screen_width, MA.screen_height)) | ||
root.state('zoomed') #mamimise window | ||
root.mainloop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from tkinter.ttk import Notebook | ||
|
||
class Autoresized_Notebook(Notebook): | ||
def __init__(self, master=None, **kw): | ||
|
||
Notebook.__init__(self, master, **kw) | ||
self.bind("<<NotebookTabChanged>>", self._on_tab_changed) | ||
|
||
def _on_tab_changed(self,event): | ||
event.widget.update_idletasks() | ||
|
||
tab = event.widget.nametowidget(event.widget.select()) | ||
event.widget.configure(height=tab.winfo_reqheight()) | ||
|
||
if __name__== "__main__": | ||
from tkinter import Frame, Tk | ||
root = Tk() | ||
|
||
notebook = Autoresized_Notebook(root) | ||
notebook.add(Frame(notebook, width=400, height=200, name="a"),text="TAB 1") | ||
notebook.add(Frame(notebook, width=400, height=300, name="b"),text="TAB 2") | ||
notebook.add(Frame(notebook, width=400, height=100, name="c"),text="TAB 3") | ||
|
||
notebook.pack() | ||
|
||
root.mainloop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import tkinter as tk | ||
from tkinter import * | ||
from tkinter import ttk | ||
from tkinter.ttk import * | ||
|
||
class RenameWindow: | ||
def __init__(self, lopa, mainapp, master, side, row_data): | ||
top=self.top=Toplevel(master) | ||
top.grab_set() |
Oops, something went wrong.