feat: replace static path label with interactive breadcrumb navigation panel
This commit is contained in:
@@ -100,10 +100,12 @@ class SharePointApp(wx.Frame):
|
||||
nav_panel.SetSizer(nav_hbox)
|
||||
vbox.Add(nav_panel, 0, wx.EXPAND | wx.ALL, 5)
|
||||
|
||||
# 2. PATH LABEL
|
||||
self.path_label = wx.StaticText(panel, label="📍 SharePoint")
|
||||
self.path_label.SetFont(wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
|
||||
vbox.Add(self.path_label, 0, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)
|
||||
# 2. PATH BREADCRUMBS (Adresselinje-stil)
|
||||
self.path_panel = wx.Panel(panel, style=wx.BORDER_SIMPLE)
|
||||
self.path_panel.SetBackgroundColour(wx.WHITE)
|
||||
self.path_sizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
self.path_panel.SetSizer(self.path_sizer)
|
||||
vbox.Add(self.path_panel, 0, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)
|
||||
|
||||
# 3. SPLITTER FOR TREE AND LIST
|
||||
self.splitter = wx.SplitterWindow(panel, style=wx.SP_LIVE_UPDATE | wx.SP_3DSASH)
|
||||
@@ -154,8 +156,41 @@ class SharePointApp(wx.Frame):
|
||||
self.update_path_display()
|
||||
|
||||
def update_path_display(self):
|
||||
path_str = " > ".join(self.current_path)
|
||||
wx.CallAfter(self.path_label.SetLabel, f"📍 {path_str}")
|
||||
self.path_sizer.Clear(True)
|
||||
|
||||
# Find alle noder fra rod til nuværende selektion
|
||||
nodes = []
|
||||
curr = self.tree_ctrl.GetSelection()
|
||||
|
||||
while curr.IsOk() and curr != self.tree_root:
|
||||
nodes.insert(0, curr)
|
||||
curr = self.tree_ctrl.GetItemParent(curr)
|
||||
|
||||
# Start ikon/label
|
||||
self._add_path_segment("📍 SharePoint", "ROOT")
|
||||
|
||||
for node in nodes:
|
||||
arrow = wx.StaticText(self.path_panel, label=" > ")
|
||||
arrow.SetForegroundColour(wx.Colour(150, 150, 150))
|
||||
self.path_sizer.Add(arrow, 0, wx.ALIGN_CENTER_VERTICAL)
|
||||
|
||||
name = self.tree_ctrl.GetItemText(node)
|
||||
self._add_path_segment(name, node)
|
||||
|
||||
self.path_panel.Layout()
|
||||
self.path_panel.Refresh()
|
||||
|
||||
def _add_path_segment(self, label, node):
|
||||
btn = wx.Button(self.path_panel, label=label, style=wx.BU_EXACTFIT | wx.BORDER_NONE)
|
||||
btn.SetBackgroundColour(wx.WHITE)
|
||||
btn.SetFont(wx.Font(9, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
|
||||
|
||||
if node == "ROOT":
|
||||
btn.Bind(wx.EVT_BUTTON, self.load_sites)
|
||||
elif node:
|
||||
btn.Bind(wx.EVT_BUTTON, lambda e: self.tree_ctrl.SelectItem(node))
|
||||
|
||||
self.path_sizer.Add(btn, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 2)
|
||||
|
||||
def login(self, event):
|
||||
self.set_status("Logger ind...")
|
||||
|
||||
Reference in New Issue
Block a user