Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inter-views navigation #18

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions yagat/frames/impl/base_list_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,18 @@ def __init__(self, column_name: str, editable: bool = False):

class BaseListView(tk.Frame, ABC):

def sheet_selected(self, event):
logging.info(event)
if event.eventname == 'select' and event.selected and event.selected.type_ == 'rows' and event.selected.box.from_r == event.selected.box.upto_r - 1:
logging.info('single row')
x = self.winfo_pointerx()
y = self.winfo_pointery()
abs_coord_x = self.winfo_pointerx() - self.winfo_vrootx()
abs_coord_y = self.winfo_pointery() - self.winfo_vrooty()
self.popup_menu.tk_popup(abs_coord_x, abs_coord_y, 0)
else:
logging.info('other')

def sheet_modified(self, event):
if event.eventname == 'edit_table':
row = event.selected.row
Expand All @@ -147,6 +159,9 @@ def sheet_modified(self, event):

def __init__(self, parent, context: AppContext, *args, **kwargs):
tk.Frame.__init__(self, parent, *args, **kwargs)
self.popup_menu = tk.Menu(self, tearoff=False)
self.popup_menu.add_command(label="To Bus View")
self.popup_menu.add_command(label="To Bus/Breaker View")
self.sheet = tks.Sheet(self, index_align='left')
self.sheet.enable_bindings('edit_cell', 'single_select',
'drag_select',
Expand All @@ -161,6 +176,7 @@ def __init__(self, parent, context: AppContext, *args, **kwargs):
'arrowkeys',
)
self.sheet.bind("<<SheetModified>>", self.sheet_modified)
self.sheet.bind("<<SheetSelect>>", self.sheet_selected)
self.context = context
self.context.add_selection_changed_listener(self.on_selection_changed)
self.context.add_tab_changed_listener(lambda _: self.on_selection_changed(self.context.selection))
Expand Down