def __init__( self, parent, controller, size, title, msg_key ): pubsub.__init__(self) #proxy the keys self.proxy(MSG_KEY, controller, msg_key) #initialize values self[RUNNING_KEY] = True self[X_DIVS_KEY] = 8 self[Y_DIVS_KEY] = 8 self[MARKER_KEY] = 2.0 #init panel and plot wx.Panel.__init__(self, parent, style=wx.SIMPLE_BORDER) self.plotter = plotter.channel_plotter(self) self.plotter.SetSize(wx.Size(*size)) self.plotter.set_title(title) self.plotter.set_x_label('Inphase') self.plotter.set_y_label('Quadrature') self.plotter.enable_point_label(False) self.plotter.enable_grid_lines(True) self.subscribe(MSG_KEY, self.handle_msg) #initial update self.update_grid()
def __init__(self, parent=None, sizer=None, proportion=0, flag=wx.EXPAND, ps=None, key='', value=None, callback=None, converter=converters.identity_converter(), size=None, *args, **kwds): pubsub.__init__(self) #wx.BoxSizer.__init__(self, wx.VERTICAL) if size is not None and size != (-1, -1): print "Size:", size # kwds['size'] = size #wx.Panel.__init__(self, parent, *args, **kwds) wx.Panel.__init__ ( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.Size( 500,300 ), style = wx.TAB_TRAVERSAL ) if size is not None and size != (-1, -1): self.SetMinSize(size) #self.SetSizeHints(*size) self._parent = parent self._key = key self._converter = converter self._callback = callback self._widgets = list() #add to the sizer if provided if sizer: sizer.Add(self, proportion, flag) #proxy the pubsub and key into this form if ps is not None: assert key self.proxy(EXT_KEY, ps, key) #no pubsub passed, must set initial value else: self.set_value(value) self._sizer = wx.BoxSizer(wx.VERTICAL) if size is not None and size != (-1, -1): self._sizer.SetMinSize(size) self._sizer.SetSizeHints(self) self.SetSizer(self._sizer) self.SetBackgroundColour(wx.BLACK)
def __init__(self, parent=None, sizer=None, proportion=0, flag=wx.EXPAND, ps=None, key='', value=None, callback=None, converter=converters.identity_converter(), size=None, *args, **kwds): pubsub.__init__(self) #wx.BoxSizer.__init__(self, wx.VERTICAL) if size is not None and size != (-1, -1): print "Size:", size # kwds['size'] = size #wx.Panel.__init__(self, parent, *args, **kwds) wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.Size(500, 300), style=wx.TAB_TRAVERSAL) if size is not None and size != (-1, -1): self.SetMinSize(size) #self.SetSizeHints(*size) self._parent = parent self._key = key self._converter = converter self._callback = callback self._widgets = list() #add to the sizer if provided if sizer: sizer.Add(self, proportion, flag) #proxy the pubsub and key into this form if ps is not None: assert key self.proxy(EXT_KEY, ps, key) #no pubsub passed, must set initial value else: self.set_value(value) self._sizer = wx.BoxSizer(wx.VERTICAL) if size is not None and size != (-1, -1): self._sizer.SetMinSize(size) self._sizer.SetSizeHints(self) self.SetSizer(self._sizer) self.SetBackgroundColour(wx.BLACK)
def __init__( self, parent, controller, size, title, units, show_gauge, real, minval, maxval, decimal_places, msg_key, sample_rate_key, ): pubsub.__init__(self) wx.Panel.__init__(self, parent, style=wx.SUNKEN_BORDER) #setup self.peak_val_real = NEG_INF self.real = real self.units = units self.decimal_places = decimal_places #proxy the keys self.proxy(MSG_KEY, controller, msg_key) #initialize values self[RUNNING_KEY] = True self[VALUE_REAL_KEY] = minval #setup the box with display and controls main_box = wx.BoxSizer(wx.HORIZONTAL) sizer = forms.static_box_sizer( parent=self, sizer=main_box, label=title, bold=True, orient=wx.VERTICAL, proportion=1, ) sizer.AddStretchSpacer() forms.static_text( parent=self, sizer=sizer, ps=self, key=VALUE_REPR_KEY, width=size[0], converter=forms.str_converter(), ) sizer.AddStretchSpacer() self.gauge_real = forms.gauge( parent=self, sizer=sizer, style=wx.GA_HORIZONTAL, ps=self, key=VALUE_REAL_KEY, length=size[0], minimum=minval, maximum=maxval, num_steps=DEFAULT_GAUGE_RANGE, ) #hide/show gauges self.gauge_real.ShowItems(show_gauge) self.SetSizerAndFit(main_box) #register events self.subscribe(MSG_KEY, self.handle_msg)
def __init__(self, parent, controller, size, title, msg_key): pubsub.__init__(self) #proxy the keys self.proxy(MSG_KEY, controller, msg_key) #initialize values self[RUNNING_KEY] = True self[X_DIVS_KEY] = 8 self[Y_DIVS_KEY] = 8 self[MARKER_KEY] = 2.0 #init panel and plot wx.Panel.__init__(self, parent, style=wx.SIMPLE_BORDER) self.plotter = plotter.channel_plotter(self) self.plotter.SetSize(wx.Size(*size)) self.plotter.set_title(title) self.plotter.set_x_label('Inphase') self.plotter.set_y_label('Quadrature') self.plotter.enable_point_label(False) self.plotter.enable_grid_lines(True) self.subscribe(MSG_KEY, self.handle_msg) #initial update self.update_grid()
def __init__( self, parent, controller, size, title, frame_rate, num_inputs, sample_rate_key, t_scale, v_scale, v_offset, xy_mode, ac_couple_key, trigger_level_key, trigger_mode_key, trigger_slope_key, trigger_channel_key, decimation_key, msg_key, use_persistence, persist_alpha, trig_mode, y_axis_label, ): pubsub.__init__(self) #check num inputs assert num_inputs <= len(CHANNEL_COLOR_SPECS) #setup self.sampleses = None self.num_inputs = num_inputs autorange = not v_scale self.autorange_ts = 0 v_scale = v_scale or 1 self.frame_rate_ts = 0 #proxy the keys self.proxy(MSG_KEY, controller, msg_key) self.proxy(SAMPLE_RATE_KEY, controller, sample_rate_key) self.proxy(TRIGGER_LEVEL_KEY, controller, trigger_level_key) self.proxy(TRIGGER_MODE_KEY, controller, trigger_mode_key) self.proxy(TRIGGER_SLOPE_KEY, controller, trigger_slope_key) self.proxy(TRIGGER_CHANNEL_KEY, controller, trigger_channel_key) self.proxy(DECIMATION_KEY, controller, decimation_key) #initialize values self[RUNNING_KEY] = True self[XY_MARKER_KEY] = 2.0 self[CHANNEL_OPTIONS_KEY] = 0 self[XY_MODE_KEY] = xy_mode self[X_CHANNEL_KEY] = 0 self[Y_CHANNEL_KEY] = 1 self[AUTORANGE_KEY] = autorange self[T_PER_DIV_KEY] = t_scale self[X_PER_DIV_KEY] = v_scale self[Y_PER_DIV_KEY] = v_scale self[T_OFF_KEY] = 0 self[X_OFF_KEY] = v_offset self[Y_OFF_KEY] = v_offset self[T_DIVS_KEY] = 8 self[X_DIVS_KEY] = 8 self[Y_DIVS_KEY] = 8 self[Y_AXIS_LABEL] = y_axis_label self[FRAME_RATE_KEY] = frame_rate self[TRIGGER_LEVEL_KEY] = 0 self[TRIGGER_CHANNEL_KEY] = 0 self[TRIGGER_MODE_KEY] = trig_mode self[TRIGGER_SLOPE_KEY] = wxgui.TRIG_SLOPE_POS self[T_FRAC_OFF_KEY] = 0.5 self[USE_PERSISTENCE_KEY] = use_persistence self[PERSIST_ALPHA_KEY] = persist_alpha if self[TRIGGER_MODE_KEY] == wxgui.TRIG_MODE_STRIPCHART: self[T_FRAC_OFF_KEY] = 0.0 for i in range(num_inputs): self.proxy(common.index_key(AC_COUPLE_KEY, i), controller, common.index_key(ac_couple_key, i)) #init panel and plot wx.Panel.__init__(self, parent, style=wx.SIMPLE_BORDER) self.plotter = my_plotter(self) self.plotter.SetSize(wx.Size(*size)) self.plotter.SetSizeHints(*size) self.plotter.set_title(title) self.plotter.enable_legend(True) self.plotter.enable_point_label(True) self.plotter.enable_grid_lines(True) self.plotter.set_use_persistence(use_persistence) self.plotter.set_persist_alpha(persist_alpha) #setup the box with plot and controls self.control_panel = scope_window.control_panel(self) main_box = wx.BoxSizer(wx.HORIZONTAL) main_box.Add(self.plotter, 1, wx.EXPAND) main_box.Add(self.control_panel, 0, wx.EXPAND) self.SetSizerAndFit(main_box) #register events for message self.subscribe(MSG_KEY, self.handle_msg) #register events for grid for key in [ common.index_key(MARKER_KEY, i) for i in range(self.num_inputs) ] + [ TRIGGER_LEVEL_KEY, TRIGGER_MODE_KEY, T_PER_DIV_KEY, X_PER_DIV_KEY, Y_PER_DIV_KEY, T_OFF_KEY, X_OFF_KEY, Y_OFF_KEY, T_DIVS_KEY, X_DIVS_KEY, Y_DIVS_KEY, XY_MODE_KEY, AUTORANGE_KEY, T_FRAC_OFF_KEY, TRIGGER_SHOW_KEY, XY_MARKER_KEY, X_CHANNEL_KEY, Y_CHANNEL_KEY, ]: self.subscribe(key, self.update_grid) #register events for plotter settings self.subscribe(USE_PERSISTENCE_KEY, self.plotter.set_use_persistence) self.subscribe(PERSIST_ALPHA_KEY, self.plotter.set_persist_alpha) #initial update self.update_grid()
def __init__( self, parent, controller, size, title, frame_rate, num_inputs, sample_rate_key, t_scale, v_scale, v_offset, xy_mode, ac_couple_key, trigger_level_key, trigger_mode_key, trigger_slope_key, trigger_channel_key, decimation_key, msg_key, use_persistence, persist_alpha, trig_mode, y_axis_label, ): pubsub.__init__(self) #check num inputs assert num_inputs <= len(CHANNEL_COLOR_SPECS) #setup self.sampleses = None self.num_inputs = num_inputs autorange = not v_scale self.autorange_ts = 0 v_scale = v_scale or 1 self.frame_rate_ts = 0 #proxy the keys self.proxy(MSG_KEY, controller, msg_key) self.proxy(SAMPLE_RATE_KEY, controller, sample_rate_key) self.proxy(TRIGGER_LEVEL_KEY, controller, trigger_level_key) self.proxy(TRIGGER_MODE_KEY, controller, trigger_mode_key) self.proxy(TRIGGER_SLOPE_KEY, controller, trigger_slope_key) self.proxy(TRIGGER_CHANNEL_KEY, controller, trigger_channel_key) self.proxy(DECIMATION_KEY, controller, decimation_key) #initialize values self[RUNNING_KEY] = True self[XY_MARKER_KEY] = 2.0 self[CHANNEL_OPTIONS_KEY] = 0 self[XY_MODE_KEY] = xy_mode self[X_CHANNEL_KEY] = 0 self[Y_CHANNEL_KEY] = 1 self[AUTORANGE_KEY] = autorange self[T_PER_DIV_KEY] = t_scale self[X_PER_DIV_KEY] = v_scale self[Y_PER_DIV_KEY] = v_scale self[T_OFF_KEY] = 0 self[X_OFF_KEY] = v_offset self[Y_OFF_KEY] = v_offset self[T_DIVS_KEY] = 8 self[X_DIVS_KEY] = 8 self[Y_DIVS_KEY] = 8 self[Y_AXIS_LABEL] = y_axis_label self[FRAME_RATE_KEY] = frame_rate self[TRIGGER_LEVEL_KEY] = 0 self[TRIGGER_CHANNEL_KEY] = 0 self[TRIGGER_MODE_KEY] = trig_mode self[TRIGGER_SLOPE_KEY] = wxgui.TRIG_SLOPE_POS self[T_FRAC_OFF_KEY] = 0.5 self[USE_PERSISTENCE_KEY] = use_persistence self[PERSIST_ALPHA_KEY] = persist_alpha if self[TRIGGER_MODE_KEY] == wxgui.TRIG_MODE_STRIPCHART: self[T_FRAC_OFF_KEY] = 0.0 for i in range(num_inputs): self.proxy(common.index_key(AC_COUPLE_KEY, i), controller, common.index_key(ac_couple_key, i)) #init panel and plot wx.Panel.__init__(self, parent, style=wx.SIMPLE_BORDER) self.plotter = my_plotter(self) self.plotter.SetSize(wx.Size(*size)) self.plotter.SetSizeHints(*size) self.plotter.set_title(title) self.plotter.enable_legend(True) self.plotter.enable_point_label(True) self.plotter.enable_grid_lines(True) self.plotter.set_use_persistence(use_persistence) self.plotter.set_persist_alpha(persist_alpha) #setup the box with plot and controls self.control_panel = scope_window.control_panel(self) main_box = wx.BoxSizer(wx.HORIZONTAL) main_box.Add(self.plotter, 1, wx.EXPAND) main_box.Add(self.control_panel, 0, wx.EXPAND) self.SetSizerAndFit(main_box) #register events for message self.subscribe(MSG_KEY, self.handle_msg) #register events for grid for key in [common.index_key(MARKER_KEY, i) for i in range(self.num_inputs)] + [ TRIGGER_LEVEL_KEY, TRIGGER_MODE_KEY, T_PER_DIV_KEY, X_PER_DIV_KEY, Y_PER_DIV_KEY, T_OFF_KEY, X_OFF_KEY, Y_OFF_KEY, T_DIVS_KEY, X_DIVS_KEY, Y_DIVS_KEY, XY_MODE_KEY, AUTORANGE_KEY, T_FRAC_OFF_KEY, TRIGGER_SHOW_KEY, XY_MARKER_KEY, X_CHANNEL_KEY, Y_CHANNEL_KEY, ]: self.subscribe(key, self.update_grid) #register events for plotter settings self.subscribe(USE_PERSISTENCE_KEY, self.plotter.set_use_persistence) self.subscribe(PERSIST_ALPHA_KEY, self.plotter.set_persist_alpha) #initial update self.update_grid()
def __init__( self, parent, controller, size, title, real, fft_size, baseband_freq, sample_rate_key, y_per_div, y_divs, ref_level, average_key, avg_alpha_key, peak_hold, msg_key, use_persistence, persist_alpha, ): pubsub.__init__(self) #setup self.samples = EMPTY_TRACE self.real = real self.fft_size = fft_size self._reset_peak_vals() self._traces = dict() #proxy the keys self.proxy(MSG_KEY, controller, msg_key) self.proxy(AVERAGE_KEY, controller, average_key) self.proxy(AVG_ALPHA_KEY, controller, avg_alpha_key) self.proxy(SAMPLE_RATE_KEY, controller, sample_rate_key) #initialize values self[PEAK_HOLD_KEY] = peak_hold self[Y_PER_DIV_KEY] = y_per_div self[Y_DIVS_KEY] = y_divs self[X_DIVS_KEY] = 8 #approximate self[REF_LEVEL_KEY] = ref_level self[BASEBAND_FREQ_KEY] = baseband_freq self[RUNNING_KEY] = True self[USE_PERSISTENCE_KEY] = use_persistence self[PERSIST_ALPHA_KEY] = persist_alpha for trace in TRACES: #a function that returns a function #so the function wont use local trace def new_store_trace(my_trace): def store_trace(*args): self._traces[my_trace] = self.samples self.update_grid() return store_trace def new_toggle_trace(my_trace): def toggle_trace(toggle): #do an automatic store if toggled on and empty trace if toggle and not len(self._traces[my_trace]): self._traces[my_trace] = self.samples self.update_grid() return toggle_trace self._traces[trace] = EMPTY_TRACE self[TRACE_STORE_KEY + trace] = False self[TRACE_SHOW_KEY + trace] = False self.subscribe(TRACE_STORE_KEY + trace, new_store_trace(trace)) self.subscribe(TRACE_SHOW_KEY + trace, new_toggle_trace(trace)) #init panel and plot wx.Panel.__init__(self, parent, style=wx.SUNKEN_BORDER) self.plotter = plotter.channel_plotter(self) self.plotter.SetSize(wx.Size(*size)) self.plotter.set_title(title) self.plotter.enable_legend(True) self.plotter.enable_point_label(True) self.plotter.enable_grid_lines(True) self.plotter.set_use_persistence(use_persistence) self.plotter.set_persist_alpha(persist_alpha) #setup the box with plot and controls main_box = wx.BoxSizer(wx.HORIZONTAL) main_box.Add(self.plotter, 1, wx.EXPAND) self.SetSizerAndFit(main_box) #register events self.subscribe(AVERAGE_KEY, self._reset_peak_vals) self.subscribe(MSG_KEY, self.handle_msg) self.subscribe(SAMPLE_RATE_KEY, self.update_grid) for key in ( BASEBAND_FREQ_KEY, Y_PER_DIV_KEY, X_DIVS_KEY, Y_DIVS_KEY, REF_LEVEL_KEY, ): self.subscribe(key, self.update_grid) self.subscribe(USE_PERSISTENCE_KEY, self.plotter.set_use_persistence) self.subscribe(PERSIST_ALPHA_KEY, self.plotter.set_persist_alpha) #initial update self.plotter.enable_point_label(False) self.update_grid()