def _add_parameter_by_name(self, param): if param in self._label_name: return popts = self._instrument.get_shared_parameter_options(param) self._parameter_options[param] = popts nrows = self._table.props.n_rows self._table.resize(nrows + 1, 5) if 'doc' in popts: plabel = gtk.Label(param + ' [?]') plabel.set_tooltip_text(popts['doc']) else: plabel = gtk.Label(param) plabel.set_alignment(0, 0) plabel.show() self._row_num[param] = nrows self._table.attach(plabel, 1, 2, nrows, nrows + 1) vlabel = gtk.Label() val = self._instrument.get(param, query=False) self._cur_val[param] = val vlabel.set_markup('<b>%s</b>' % \ qt.format_parameter_value(self._parameter_options[param], val)) vlabel.set_alignment(0, 0) vlabel.show() self._table.attach(vlabel, 2, 3, nrows, nrows + 1) self._add_range_info(param, nrows) self._add_rate_info(param, nrows) self._label_name[param] = plabel self._label_val[param] = vlabel
def _do_update_parameters_timer(self): gtk.gdk.threads_enter() for param, val in self._update_dict.iteritems(): if param in self._label_val and self._cur_val[param] != val: self._label_val[param].set_markup('<b>%s</b>' % \ qt.format_parameter_value(self._parameter_options[param], val)) self._cur_val[param] = val self._update_dict = {} gtk.gdk.threads_leave() return True
def _update_cb(self, sender, ins_param, val): if ins_param not in self._watch: return info = self._watch[ins_param] ins = info['instrument'] param = info['parameter'] strval = qt.format_parameter_value(info['options'], val) self._tree_model.set(info['iter'], 2, strval) if not info.get('graph', False): return cols = self._get_ncols(info, val) plotname = 'watch_%s.%s' % (ins.get_name(), param) # Create temp file and setup plotting if 'tempfile' not in info: info['tempfile'] = temp.File(mode='w') cmd = 'qt.plot_file("%s", name="%s", clear=True)' % ( info['tempfile'].name, plotname) qt.cmd(cmd, callback=lambda *x: True) for i in range(cols - 2): cmd = 'qt.plot_file("%s", name="%s", valdim=%d)' % ( info['tempfile'].name, plotname, i + 2) qt.cmd(cmd, callback=lambda *x: True) else: info['tempfile'].reopen() # Allocate array, fill xs and ys with first point, shift otherwise if 'data' not in info or info['data'] is None: d = np.ones([info['points'], cols]) info['data'] = d r = self._get_row(info, val) for i in range(cols): d[:, i] = r[i] else: info['data'][:-1, :] = info['data'][1:, :] r = self._get_row(info, val, prevrow=info['data'][-2, :]) info['data'][-1, :] = r np.savetxt(info['tempfile'].get_file(), info['data']) info['tempfile'].close() cmd = 'qt.plots["%s"].update()' % (plotname, ) qt.cmd(cmd)
def _update_cb(self, sender, ins_param, val): if ins_param not in self._watch: return info = self._watch[ins_param] ins = info['instrument'] param = info['parameter'] strval = qt.format_parameter_value(info['options'], val) self._tree_model.set(info['iter'], 2, strval) if not info.get('graph', False): return cols = self._get_ncols(info, val) plotname = 'watch_%s.%s' % (ins.get_name(), param) # Create temp file and setup plotting if 'tempfile' not in info: info['tempfile'] = temp.File(mode='w') cmd = 'qt.plot_file("%s", name="%s", clear=True)' % (info['tempfile'].name, plotname) qt.cmd(cmd, callback=lambda *x: True) for i in range(cols - 2): cmd = 'qt.plot_file("%s", name="%s", valdim=%d)' % (info['tempfile'].name, plotname, i+2) qt.cmd(cmd, callback=lambda *x: True) else: info['tempfile'].reopen() # Allocate array, fill xs and ys with first point, shift otherwise if 'data' not in info or info['data'] is None: d = np.ones([info['points'], cols]) info['data'] = d r = self._get_row(info, val) for i in range(cols): d[:,i] = r[i] else: info['data'][:-1,:] = info['data'][1:,:] r = self._get_row(info, val, prevrow=info['data'][-2,:]) info['data'][-1,:] = r np.savetxt(info['tempfile'].get_file(), info['data']) info['tempfile'].close() cmd = 'qt.plots["%s"].update()' % (plotname, ) qt.cmd(cmd)
def _update_cb(self, sender, ins_param, val): if ins_param not in self._watch: return info = self._watch[ins_param] ins = info['instrument'] param = info['parameter'] strval = qt.format_parameter_value(info['options'], val) self._tree_model.set(info['iter'], 2, strval) if not info.get('graph', False): return plotname = 'watch_%s.%s' % (ins.get_name(), param) if 'data' not in info or info['data'] is None: cols = self._get_ncols(info, val) d = np.zeros([info['points'], cols], dtype=np.float) r = self._get_row(info, val) d[0, :] = self._get_row(info, val) info['data'] = d info['tempfile'] = temp.File(mode='w') cmd = 'qt.plot_file("%s", name="%s", clear=True)' % ( info['tempfile'].name, plotname) qt.cmd(cmd, callback=lambda *x: do_print(x)) for i in range(cols - 2): cmd = 'qt.plot_file("%s", name="%s", valdim=%d)' % ( info['tempfile'].name, plotname, i + 2) qt.cmd(cmd, callback=lambda *x: do_print(x)) else: info['tempfile'].reopen() info['data'][0:-1, :] = info['data'][1:, :] r = self._get_row(info, val, prevrow=info['data'][-2, :]) info['data'][-1, :] = self._get_row(info, val, prevrow=info['data'][-2, :]) np.savetxt(info['tempfile'].get_file(), info['data']) info['tempfile'].close() cmd = 'qt.plots["%s"].update()' % (plotname, ) qt.cmd(cmd)
def _update_cb(self, sender, ins_param, val): if ins_param not in self._watch: return info = self._watch[ins_param] ins = info['instrument'] param = info['parameter'] strval = qt.format_parameter_value(info['options'], val) self._tree_model.set(info['iter'], 2, strval) if not info.get('graph', False): return plotname = 'watch_%s.%s' % (ins.get_name(), param) if 'data' not in info or info['data'] is None: cols = self._get_ncols(info, val) d = np.zeros([info['points'], cols], dtype=np.float) r = self._get_row(info, val) d[0,:] = self._get_row(info, val) info['data'] = d info['tempfile'] = temp.File(mode='w') cmd = 'qt.plot_file("%s", name="%s", clear=True)' % (info['tempfile'].name, plotname) qt.cmd(cmd, callback=lambda *x: do_print(x)) for i in range(cols - 2): cmd = 'qt.plot_file("%s", name="%s", valdim=%d)' % (info['tempfile'].name, plotname, i+2) qt.cmd(cmd, callback=lambda *x: do_print(x)) else: info['tempfile'].reopen() info['data'][0:-1,:] = info['data'][1:,:] r = self._get_row(info, val, prevrow=info['data'][-2,:]) info['data'][-1,:] = self._get_row(info, val, prevrow=info['data'][-2,:]) np.savetxt(info['tempfile'].get_file(), info['data']) info['tempfile'].close() cmd = 'qt.plots["%s"].update()' % (plotname, ) qt.cmd(cmd)
def _update_value(self, val, widget=None): _enable_widget(widget) fmtval = qt.format_parameter_value(self._param_opts, val) self.set_text(fmtval)