From 16fca9d7d2f2062247ee6a767a0c1a79a22bb6de Mon Sep 17 00:00:00 2001 From: Martin Tranberg Date: Mon, 30 Mar 2026 19:25:10 +0200 Subject: [PATCH] feat: replace static path label with interactive breadcrumb navigation panel --- sharepoint_browser.py | 47 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/sharepoint_browser.py b/sharepoint_browser.py index bcea58d..67b229f 100644 --- a/sharepoint_browser.py +++ b/sharepoint_browser.py @@ -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...")