Eclectic Media Git pingstats / 739e898
Makes UI Plot widgets intelligently choose backend - Changes PlotWidget to `_HipsterPlotWidget` - Makes Plot widgets inherit from either `PingWidget` or `_HipsterPlotWidget`, depending on `hipsterplot`'s existance within the module namespace - Adds `import pingstats` to import block to allow access to the pingstats namespace as a whole Ariana Giroux 4 months ago
1 changed file(s) with 7 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
3232
3333 ---
3434 """
35 import pingstats
3536 from . import Pings
3637 from . import PROG_NAME, __version__, X_COLUMN_SCALE, Y_ROW_SCALE
3738 from . import plot_pings
162163 print(status_string.center(self.columns, '-'))
163164
164165
165 class PlotWidget(PingWidget):
166 class _HipsterPlotWidget(PingWidget):
166167 """ Applies :py:data:`pingstats.X_COLUMN_SCALE` to self.columns. """
167168 def __init__(self, *args):
168 super(PlotWidget, self).__init__(*args)
169 super(_HipsterPlotWidget, self).__init__(*args)
169170 self.columns -= X_COLUMN_SCALE
170171 self.rows -= Y_ROW_SCALE
171172
172173
173 class RealtimePlot(PlotWidget):
174 class RealtimePlot(PingWidget if 'hipsterplot' not in dir(pingstats) else _HipsterPlotWidget):
174175 """ Displays real-time data on a plot. """
175176 def __init__(self, *args):
176177 super(RealtimePlot, self).__init__(*args)
177178 plot_pings(self.realtime_data, self.columns, self.rows)
178179
179180
180 class AveragePlot(PlotWidget):
181 class AveragePlot(PingWidget if 'hipsterplot' not in dir(pingstats) else _HipsterPlotWidget):
181182 """ Displays average data on a plot. """
182183 def __init__(self, *args):
183184 super(AveragePlot, self).__init__(*args)
184185 plot_pings(self.average_data, self.columns, self.rows)
185186
186187
187 class RealtimePane(PlotWidget):
188 class RealtimePane(PingWidget if 'hipsterplot' not in dir(pingstats) else _HipsterPlotWidget):
188189 """ Displays real-time data on a plot, along with the output of
189190 :py:meth:`pingstats.ui.RealtimeStatus`. """
190191 def __init__(self, columns, rows, pings):
195196 RealtimeStatus(columns, rows, pings)
196197
197198
198 class AveragePane(PlotWidget):
199 class AveragePane(PingWidget if 'hipsterplot' not in dir(pingstats) else _HipsterPlotWidget):
199200 """ Displays average data on a plot, along with the output of
200201 :py:meth:`pingstats.ui.AverageStatus`. """
201202 def __init__(self, columns, rows, pings):