Skip to content

Commit

Permalink
V0.48.0 Added Buttons to Address Bar
Browse files Browse the repository at this point in the history
  • Loading branch information
domhnallmorr committed Jan 28, 2023
1 parent 1283672 commit 452a567
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pip install PyPDF2


## Preview
![alt text](https://imgur.com/oHL8iFM.png)
![alt text](https://imgur.com/hPORcAR.png)

![alt text](https://imgur.com/ZLl4JGj.png)

Expand Down
41 changes: 40 additions & 1 deletion src/custom_widgets/address_bar.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,58 @@
import os

import tkinter as tk
from tkinter import *
from tkinter import ttk
from tkinter.ttk import *
from ttkbootstrap.constants import *

class AddressBarEntry(ttk.Entry):
def __init__(self, branch_tab):
super(AddressBarEntry, self).__init__(branch_tab)
self.branch_tab = branch_tab
self.bind('<Return>', self.enter_event)

self.buttons = []
self.bind("<FocusIn>", self.on_focusin)
self.bind("<FocusOut>", self.on_focusout)

def update_bar(self, text):
self.delete(0, END) #deletes the current value
self.insert(0, text) #inserts new value assigned by 2nd parameter

# Add buttons to address bar
for btn in self.buttons:
btn.grid_forget()

folders = text.split(os.sep)
self.buttons = []
for idx, folder in enumerate(folders):
if idx == 0:
path = folder + os.sep

else:
path = os.path.join(path, folder)

btn = Button(self, text=folder, bootstyle="secondary",)
btn.grid(row=0, column=idx)
btn.bind("<Button-1>", lambda event=None, path=path: self.button_clicked(event, path))
btn.bindtags((btn, btn.winfo_class(), self, self.winfo_class(), "all"))
self.buttons.append(btn)


def enter_event(self, event):
# -------------- CALL THE CONTROLLER METHOD TO UPDATE THE BRANCH TAB BASED ON DIRECTORY IN THE ADDRESS BAR -------------
self.branch_tab.view.controller.update_branch_tab(self.branch_tab.branch_id, self.get().rstrip().lstrip())
# self.update_bar()

def button_clicked(self, event, path):
self.branch_tab.view.controller.update_branch_tab(self.branch_tab.branch_id, path)


def on_focusin(self, event):
for btn in self.buttons:
btn.grid_remove()

def on_focusout(self, event):
for btn in self.buttons:
btn.grid()

2 changes: 1 addition & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, parent, *args, **kwargs):
self.controller = controller.Controller(root, parent, self)

# ----------------- VERSION -----------------------
self.version = "0.47.3"
self.version = "0.48.0"

# ----------------- WEEK NUMBER -----------------------
year, week_num, day_of_week = datetime.date.today().isocalendar()
Expand Down

0 comments on commit 452a567

Please sign in to comment.