[tor-commits] [nyx/master] Drop Panel's get_parent() method
atagar at torproject.org
atagar at torproject.org
Sun Mar 20 00:17:45 UTC 2016
commit 2cdee9afa60c8d72654a503a0975936b1e351add
Author: Damian Johnson <atagar at torproject.org>
Date: Wed Mar 16 10:22:34 2016 -0700
Drop Panel's get_parent() method
Only used in one spot, and a weird one at that. I want to get rid of this
attribute entirely but it's still used within the Panel itself.
---
nyx/panel/__init__.py | 7 -------
nyx/panel/header.py | 11 +++++------
2 files changed, 5 insertions(+), 13 deletions(-)
diff --git a/nyx/panel/__init__.py b/nyx/panel/__init__.py
index 287d756..176eea9 100644
--- a/nyx/panel/__init__.py
+++ b/nyx/panel/__init__.py
@@ -192,13 +192,6 @@ class Panel(object):
self.title_visible = is_visible
- def get_parent(self):
- """
- Provides the parent used to create subwindows.
- """
-
- return self.parent
-
def set_visible(self, is_visible):
"""
Toggles if the panel is visible or not.
diff --git a/nyx/panel/header.py b/nyx/panel/header.py
index 3ee0e84..51245ee 100644
--- a/nyx/panel/header.py
+++ b/nyx/panel/header.py
@@ -44,21 +44,19 @@ class HeaderPanel(nyx.panel.Panel, threading.Thread):
self._vals = get_sampling()
+ self._last_width = 100
self._pause_condition = threading.Condition()
self._halt = False # terminates thread if true
self._reported_inactive = False
tor_controller().add_status_listener(self.reset_listener)
- def is_wide(self, width = None):
+ def is_wide(self):
"""
True if we should show two columns of information, False otherwise.
"""
- if width is None:
- width = self.get_parent().getmaxyx()[1]
-
- return width >= MIN_DUAL_COL_WIDTH
+ return self._last_width >= MIN_DUAL_COL_WIDTH
def get_height(self):
"""
@@ -127,7 +125,8 @@ class HeaderPanel(nyx.panel.Panel, threading.Thread):
def draw(self, width, height):
vals = self._vals # local reference to avoid concurrency concerns
- is_wide = self.is_wide(width)
+ self._last_width = width
+ is_wide = self.is_wide()
# space available for content
More information about the tor-commits
mailing list