fix: resolve C2/I4 review findings
- C2: remove duplicate EVT_SIZE binding (on_status_bar_resize); merge gauge repositioning into the single on_resize handler - I4: position gauge correctly on first show by updating rect inside pulse_gauge._do() when start=True, so no resize event is required Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -930,7 +930,6 @@ class SharePointApp(wx.Frame):
|
||||
# Add a Gauge to the status bar
|
||||
self.gauge = wx.Gauge(self.status_bar, range=100, size=(140, 18), style=wx.GA_HORIZONTAL | wx.GA_SMOOTH)
|
||||
self.gauge.Hide()
|
||||
self.Bind(wx.EVT_SIZE, self.on_status_bar_resize)
|
||||
|
||||
panel.SetSizer(vbox)
|
||||
self.Bind(wx.EVT_SIZE, self.on_resize)
|
||||
@@ -1361,6 +1360,9 @@ class SharePointApp(wx.Frame):
|
||||
if start:
|
||||
self.gauge.Show()
|
||||
self.gauge.Pulse()
|
||||
rect = self.status_bar.GetFieldRect(1)
|
||||
self.gauge.SetPosition((rect.x + 5, rect.y + 2))
|
||||
self.gauge.SetSize((rect.width - 10, rect.height - 4))
|
||||
else:
|
||||
self.gauge.Hide()
|
||||
self.gauge.SetValue(0)
|
||||
@@ -1542,21 +1544,19 @@ class SharePointApp(wx.Frame):
|
||||
def on_resize(self, event):
|
||||
width = self.GetSize().width
|
||||
threshold = 1100
|
||||
|
||||
|
||||
if width < threshold and not self.compact_mode:
|
||||
self.compact_mode = True
|
||||
self._update_button_labels(full=False)
|
||||
elif width >= threshold and self.compact_mode:
|
||||
self.compact_mode = False
|
||||
self._update_button_labels(full=True)
|
||||
|
||||
event.Skip()
|
||||
|
||||
def on_status_bar_resize(self, event):
|
||||
if hasattr(self, 'gauge') and self.gauge:
|
||||
rect = self.status_bar.GetFieldRect(1)
|
||||
self.gauge.SetPosition((rect.x + 5, rect.y + 2))
|
||||
self.gauge.SetSize((rect.width - 10, rect.height - 4))
|
||||
|
||||
event.Skip()
|
||||
|
||||
def _update_button_labels(self, full=True):
|
||||
|
||||
Reference in New Issue
Block a user