def run(self): # Empty plugin form vbox # Get list of app option forms self.forms = emit_signal('get_app_form_class') self.form_views = {} self.clear_form() app = get_app() self.no_gui_names = set() for name, form in self.forms.iteritems(): # For each form, generate a pygtkhelpers formview and append the # view onto the end of the plugin vbox if form is None: schema_entries = [] else: # Only include fields that do not have show_in_gui set to False # in 'properties' dictionary schema_entries = [ f for f in form.field_schema if f.properties.get('show_in_gui', True) ] if not schema_entries: self.no_gui_names.add(name) continue gui_form = Form.of(*schema_entries) FormView.schema_type = gui_form self.form_views[name] = FormView() if name in app.core_plugins: self.core_plugins_vbox.pack_start(self.form_views[name].widget) self.frame_core_plugins.show() else: expander = gtk.Expander() expander.set_label(name) expander.set_expanded(True) expander.add(self.form_views[name].widget) self.plugin_form_vbox.pack_start(expander) for form_name, form in self.forms.iteritems(): if form_name in self.no_gui_names: continue form_view = self.form_views[form_name] values = self._get_app_values(form_name) fields = set(values.keys()).intersection(form_view.form.fields) for field in fields: value = values[field] proxy = proxy_for(getattr(form_view, field)) proxy.set_widget_value(value) form_field = form_view.form.fields[field] form_field.label_widget.set_text( re.sub(r'_', ' ', field).title()) self.dialog.show_all() response = self.dialog.run() if response == gtk.RESPONSE_OK: self.apply() elif response == gtk.RESPONSE_CANCEL: pass self.dialog.hide() return response
def run(self): # Empty plugin form vbox # Get list of app option forms self.forms = emit_signal('get_app_form_class') self.form_views = {} self.clear_form() app = get_app() self.no_gui_names = set() for name, form in self.forms.iteritems(): # For each form, generate a pygtkhelpers formview and append the view # onto the end of the plugin vbox if form is None: schema_entries = [] else: # Only include fields that do not have show_in_gui set to False in # 'properties' dictionary schema_entries = [f for f in form.field_schema\ if f.properties.get('show_in_gui', True)] if not schema_entries: self.no_gui_names.add(name) continue gui_form = Form.of(*schema_entries) FormView.schema_type = gui_form self.form_views[name] = FormView() if name in app.core_plugins: self.core_plugins_vbox.pack_start(self.form_views[name].widget) self.frame_core_plugins.show() else: expander = gtk.Expander() expander.set_label(name) expander.set_expanded(True) expander.add(self.form_views[name].widget) self.plugin_form_vbox.pack_start(expander) for form_name, form in self.forms.iteritems(): if form_name in self.no_gui_names: continue form_view = self.form_views[form_name] values = self._get_app_values(form_name) fields = set(values.keys()).intersection(form_view.form.fields) for field in fields: value = values[field] proxy = proxy_for(getattr(form_view, field)) proxy.set_widget_value(value) form_field = form_view.form.fields[field] form_field.label_widget.set_text( re.sub(r'_', ' ', field).title()) self.dialog.show_all() response = self.dialog.run() if response == gtk.RESPONSE_OK: self.apply() elif response == gtk.RESPONSE_CANCEL: pass self.dialog.hide() return response
def field_entry_dialog(field, value=None, title='Input value', parent=None, use_markup=True): if parent is None: parent = DEFAULTS.parent_widget form = Form.of(field) dialog = FormViewDialog(form, title=title, parent=parent) if value is not None: values = {field.name: value} else: values = None valid, response = dialog.run(values, use_markup=use_markup) return valid, response.values()[0]
def create_ui(self): self.widget = gtk.Assistant() self.widget.connect("prepare", self.assistant_prepared) self.widget.connect("cancel", self.cancel_button_clicked) self.widget.connect("close", self.close_button_clicked) self.widget.connect("apply", self.apply_button_clicked) # # Introduction # box = gtk.HBox() self.widget.append_page(box) self.widget.set_page_type(box, gtk.ASSISTANT_PAGE_INTRO) self.widget.set_page_title(box, "Introduction") content = ( "This wizard will guide you through the process of " "calibrating the high-voltage reference load feedback " "measurement circuit. This feedback circuit is used to " "measure the output voltage of the amplifier on the control" "board.\n\nSee " r'<a href="http://microfluidics.utoronto.ca/trac/dropbot/wiki/Control board calibration#high-voltage-attenuation-calibration">' "here</a> for more details." ) label = gtk.Label(content) label.set_use_markup(True) label.set_line_wrap(True) image = gtk.Image() img_path = pkg_resources.resource_filename("dmf_control_board_firmware", "gui/reference_feedback_intro.png") image.set_from_file(str(img_path)) box.pack_start(label, True, False, padding=15) box.pack_start(image, True, True, padding=5) self.widget.set_page_complete(box, True) # # Connect hardware # box = gtk.HBox() self.widget.append_page(box) self.widget.set_page_type(box, gtk.ASSISTANT_PAGE_CONTENT) self.widget.set_page_title(box, "Connect hardware") label = gtk.Label( ' - Connect DropBot "<tt>Out to Amp</tt>" to amplifier input.\n' " - Use T-splitter to connect amplifier output to:\n" ' 1) DropBot "<tt>In from Amp</tt>".\n' " 2) Oscilloscope input." ) image = gtk.Image() img_path = pkg_resources.resource_filename("dmf_control_board_firmware", "gui/reference_feedback_setup.png") image.set_from_file(str(img_path)) label.set_line_wrap(True) label.set_use_markup(True) box.pack_start(label, True, False, padding=15) box.pack_start(image, True, True, padding=5) self.widget.set_page_complete(box, True) # # Select frequencies # minimum = self.control_board.min_waveform_frequency maximum = self.control_board.max_waveform_frequency form = Form.of( Integer.named("start_frequency").using( default=minimum, optional=True, validators=[ValueAtLeast(minimum=minimum)] ), Integer.named("end_frequency").using( default=maximum, optional=True, validators=[ValueAtLeast(minimum=minimum)] ), Integer.named("number_of_steps").using(default=10, optional=True, validators=[ValueAtLeast(minimum=2)]), ) box = gtk.HBox() self.form_view = create_form_view(form) self.form_view.form.proxies.connect("changed", display) box.pack_start(self.form_view.widget, fill=False, padding=40) self.widget.append_page(box) self.widget.set_page_type(box, gtk.ASSISTANT_PAGE_CONTENT) self.widget.set_page_title(box, "Select calibration frequencies") self.widget.set_page_complete(box, True) # # Record measurements # box1 = gtk.VBox() self.widget.append_page(box1) self.widget.set_page_type(box1, gtk.ASSISTANT_PAGE_PROGRESS) self.widget.set_page_title(box1, "Record measurements") self.measurements_label = gtk.Label("Ready") self.measurements_label.set_line_wrap(True) self.measure_progress = gtk.ProgressBar() self.measure_progress.set_size_request(300, 40) box1.pack_start(self.measurements_label, True, True, 0) box1.pack_start(self.measure_progress, expand=False, fill=False, padding=15) self.box1 = box1 # # Confirm fitted parameters # box = gtk.VBox() self.widget.append_page(box) self.widget.set_page_type(box, gtk.ASSISTANT_PAGE_CONFIRM) self.widget.set_page_title(box, "Confirm fitted parameters") figure = Figure(figsize=(14, 8), dpi=60) self.canvas = FigureCanvasGTK(figure) toolbar = NavigationToolbar(self.canvas, self.widget) self.axis = figure.add_subplot(111) box.pack_start(self.canvas) box.pack_start(toolbar, False, False) self.widget.set_page_complete(box, True) # # Summary # box = gtk.VBox() self.widget.append_page(box) self.widget.set_page_type(box, gtk.ASSISTANT_PAGE_SUMMARY) self.widget.set_page_title(box, "Summary") label = gtk.Label( "Calibration of reference load feedback circuit is " "complete. The high-voltage output from amplifier " "should now be measured accurately by the control " "board." ) label.set_line_wrap(True) box.pack_start(label, True, True, 0) self.widget.set_page_complete(box, True)
Float: VIEW_FLOAT, Enum: VIEW_ENUM, }) #: map of view types to flatland element types view_widgets.update({ VIEW_FILEPATH: FilepathBuilder(), VIEW_DIRECTORY: DirectoryBuilder(), VIEW_FLOAT: FloatBuilder(), VIEW_ENUM: EnumBuilder(), }) widget_proxies.update({ FilepathWidget: FilepathProxy, DirectoryWidget: FilepathProxy, }) if __name__ == '__main__': window = gtk.Window() form = Form.of( Integer.named('overlay_opacity').using(default=20, optional=True), Float.named('float_value').using(default=10.37, optional=True), Filepath.named('log_filepath').using(default='', optional=True), Directory.named('devices_directory').using(default='', optional=True), ) dialog = FormViewDialog(form) print dialog.run()
def create_ui(self): self.widget = gtk.Assistant() self.widget.connect("prepare", self.assistant_prepared) self.widget.connect("cancel", self.cancel_button_clicked) self.widget.connect("close", self.close_button_clicked) self.widget.connect("apply", self.apply_button_clicked) # # Introduction # box = gtk.HBox() self.widget.append_page(box) self.widget.set_page_type(box, gtk.ASSISTANT_PAGE_INTRO) self.widget.set_page_title(box, "Introduction") content = ('This wizard will guide you through the process of ' 'calibrating the high-voltage reference load feedback ' 'measurement circuit. This feedback circuit is used to ' 'measure the output voltage of the amplifier on the control' 'board.\n\nSee ' r'<a href="http://microfluidics.utoronto.ca/trac/dropbot/wiki/Control board calibration#high-voltage-attenuation-calibration">' 'here</a> for more details.') label = gtk.Label(content) label.set_use_markup(True) label.set_line_wrap(True) image = gtk.Image() img_path = pkg_resources.resource_filename( 'dmf_control_board_firmware', 'gui/reference_feedback_intro.png') image.set_from_file(str(img_path)) box.pack_start(label, True, False, padding=15) box.pack_start(image, True, True, padding=5) self.widget.set_page_complete(box, True) # # Connect hardware # box = gtk.HBox() self.widget.append_page(box) self.widget.set_page_type(box, gtk.ASSISTANT_PAGE_CONTENT) self.widget.set_page_title(box, "Connect hardware") label = gtk.Label(' - Connect DropBot "<tt>Out to Amp</tt>" to amplifier input.\n' ' - Use T-splitter to connect amplifier output to:\n' ' 1) DropBot "<tt>In from Amp</tt>".\n' ' 2) Oscilloscope input.') image = gtk.Image() img_path = pkg_resources.resource_filename( 'dmf_control_board_firmware', 'gui/reference_feedback_setup.png') image.set_from_file(str(img_path)) label.set_line_wrap(True) label.set_use_markup(True) box.pack_start(label, True, False, padding=15) box.pack_start(image, True, True, padding=5) self.widget.set_page_complete(box, True) # # Select frequencies # minimum = self.control_board.min_waveform_frequency maximum = self.control_board.max_waveform_frequency form = Form.of( Integer.named('start_frequency').using( default=minimum, optional=True, validators=[ValueAtLeast(minimum=minimum), ]), Integer.named('end_frequency').using( default=maximum, optional=True, validators=[ValueAtLeast(minimum=minimum), ]), Integer.named('number_of_steps').using( default=10, optional=True, validators=[ValueAtLeast(minimum=2), ]), ) box = gtk.HBox() self.form_view = create_form_view(form) self.form_view.form.proxies.connect('changed', display) box.pack_start(self.form_view.widget, fill=False, padding=40) self.widget.append_page(box) self.widget.set_page_type(box, gtk.ASSISTANT_PAGE_CONTENT) self.widget.set_page_title(box, "Select calibration frequencies") self.widget.set_page_complete(box, True) # # Record measurements # box1 = gtk.VBox() self.widget.append_page(box1) self.widget.set_page_type(box1, gtk.ASSISTANT_PAGE_PROGRESS) self.widget.set_page_title(box1, "Record measurements") self.measurements_label = gtk.Label('Ready') self.measurements_label.set_line_wrap(True) self.measure_progress = gtk.ProgressBar() self.measure_progress.set_size_request(300, 40) box1.pack_start(self.measurements_label, True, True, 0) box1.pack_start(self.measure_progress, expand=False, fill=False, padding=15) self.box1 = box1 # # Confirm fitted parameters # box = gtk.VBox() self.widget.append_page(box) self.widget.set_page_type(box, gtk.ASSISTANT_PAGE_CONFIRM) self.widget.set_page_title(box, "Confirm fitted parameters") figure = Figure(figsize=(14, 8), dpi=60) self.canvas = FigureCanvasGTK(figure) toolbar = NavigationToolbar(self.canvas, self.widget) self.axis = figure.add_subplot(111) box.pack_start(self.canvas) box.pack_start(toolbar, False, False) self.widget.set_page_complete(box, True) # # Summary # box = gtk.VBox() self.widget.append_page(box) self.widget.set_page_type(box, gtk.ASSISTANT_PAGE_SUMMARY) self.widget.set_page_title(box, "Summary") label = gtk.Label('Calibration of reference load feedback circuit is ' 'complete. The high-voltage output from amplifier ' 'should now be measured accurately by the control ' 'board.') label.set_line_wrap(True) box.pack_start(label, True, True, 0) self.widget.set_page_complete(box, True)
element_views.update({ Filepath: VIEW_FILEPATH, Directory: VIEW_DIRECTORY, Float: VIEW_FLOAT, Enum: VIEW_ENUM, }) #: map of view types to flatland element types view_widgets.update({ VIEW_FILEPATH: FilepathBuilder(), VIEW_DIRECTORY: DirectoryBuilder(), VIEW_FLOAT: FloatBuilder(), VIEW_ENUM: EnumBuilder(), }) widget_proxies.update({ FilepathWidget: FilepathProxy, DirectoryWidget: FilepathProxy, }) if __name__ == '__main__': window = Gtk.Window() form = Form.of( Integer.named('overlay_opacity').using(default=20, optional=True), Float.named('float_value').using(default=10.37, optional=True), Filepath.named('log_filepath').using(default='', optional=True), Directory.named('devices_directory').using(default='', optional=True), ) dialog = FormViewDialog(form) print(dialog.run())
def create_ui(self): self.widget = gtk.Assistant() self.widget.connect("prepare", self.assistant_prepared) self.widget.connect("cancel", self.cancel_button_clicked) self.widget.connect("close", self.close_button_clicked) self.widget.connect("apply", self.apply_button_clicked) # # Introduction # box = gtk.HBox() self.widget.append_page(box) self.widget.set_page_type(box, gtk.ASSISTANT_PAGE_INTRO) self.widget.set_page_title(box, "Introduction") content = ('This wizard will guide you through the process of ' 'calibrating the device load feedback measurement circuit. ' 'This feedback circuit is used to measure the impedance ' 'between the actuated area and ground. This impedance is ' 'related to the volume of liquid between the actuated area' '\n\nSee ' r'<a href="http://microfluidics.utoronto.ca/trac/dropbot/wiki/Control board calibration#device-load-impedance-calibration">' 'here</a> for more details.') label = gtk.Label(content) label.set_use_markup(True) label.set_line_wrap(True) image = gtk.Image() img_path = pkg_resources.resource_filename( 'dmf_control_board_firmware', 'gui/impedance_feedback_intro.png') image.set_from_file(str(img_path)) box.pack_start(label, True, False, padding=15) box.pack_start(image, True, True, padding=5) self.widget.set_page_complete(box, True) # # Connect hardware # box = gtk.HBox() self.widget.append_page(box) self.widget.set_page_type(box, gtk.ASSISTANT_PAGE_CONTENT) self.widget.set_page_title(box, "Connect hardware") label = gtk.Label(' - Connect DropBot "<tt>Out to Amp</tt>" to amplifier input.\n' ' - Connect amplifier output to DropBot "<tt>In from Amp</tt>".\n' ' - Connect DropBot "<tt>0-39</tt>" to test board.') image = gtk.Image() img_path = pkg_resources.resource_filename( 'dmf_control_board_firmware', 'gui/impedance_feedback_setup.png') image.set_from_file(str(img_path)) label.set_line_wrap(True) label.set_use_markup(True) box.pack_start(label, True, False, padding=15) box.pack_start(image, True, True, padding=5) self.widget.set_page_complete(box, True) # # Select frequencies # form = Form.of( Integer.named('start_frequency').using( default=self.control_board.min_waveform_frequency, optional=True, validators= [ValueAtLeast(minimum= self.control_board.min_waveform_frequency), ValueAtMost(maximum= self.control_board.max_waveform_frequency)]), Integer.named('end_frequency').using( default=self.control_board.max_waveform_frequency, optional=True, validators= [ValueAtLeast(minimum= self.control_board.min_waveform_frequency), ValueAtMost(maximum= self.control_board.max_waveform_frequency)]), Integer.named('number_of_steps').using( default=10, optional=True, validators=[ValueAtLeast(minimum=2), ]), Integer.named('RMS_voltage').using( default=min(100, self.control_board.max_waveform_voltage), optional=True, validators= [ValueAtLeast(minimum=10), ValueAtMost(maximum= self.control_board.max_waveform_voltage)])) box = gtk.HBox() self.form_view = create_form_view(form) box.pack_start(self.form_view.widget, fill=False, padding=40) self.widget.append_page(box) self.widget.set_page_type(box, gtk.ASSISTANT_PAGE_CONTENT) self.widget.set_page_title(box, "Select calibration frequencies") self.widget.set_page_complete(box, True) ## # Record measurements # box1 = gtk.VBox() self.widget.append_page(box1) self.widget.set_page_type(box1, gtk.ASSISTANT_PAGE_PROGRESS) self.widget.set_page_title(box1, "Record measurements") self.measurements_label = gtk.Label('Ready.') self.measurements_label.set_line_wrap(True) self.measure_progress = gtk.ProgressBar() box1.pack_start(self.measurements_label, True, True, 0) box1.pack_start(self.measure_progress, expand=False, fill=False, padding=15) self.box1 = box1 # # Confirm fitted parameters # box = gtk.VBox() self.widget.append_page(box) self.widget.set_page_type(box, gtk.ASSISTANT_PAGE_CONFIRM) self.widget.set_page_title(box, "Confirm fitted parameters") self.figure = Figure(dpi=72) self.canvas = FigureCanvasGTK(self.figure) toolbar = NavigationToolbar(self.canvas, self.widget) #self.axis = figure.add_subplot(111) box.pack_start(self.canvas) box.pack_start(toolbar, False, False) self.widget.set_page_complete(box, True) ## # Summary # box = gtk.VBox() self.widget.append_page(box) self.widget.set_page_type(box, gtk.ASSISTANT_PAGE_SUMMARY) self.widget.set_page_title(box, "Summary") label = gtk.Label('Calibration of device load feedback circuit is ' 'complete. The impedance between actuated device ' 'area and ground should now be measured accurately ' 'by the control board.') label.set_line_wrap(True) box.pack_start(label, True, True, 0) self.widget.set_page_complete(box, True)
def create_ui(self): self.widget = gtk.Assistant() self.widget.connect("prepare", self.assistant_prepared) self.widget.connect("cancel", self.cancel_button_clicked) self.widget.connect("close", self.close_button_clicked) self.widget.connect("apply", self.apply_button_clicked) # # Introduction # box = gtk.HBox() self.widget.append_page(box) self.widget.set_page_type(box, gtk.ASSISTANT_PAGE_INTRO) self.widget.set_page_title(box, "Introduction") content = ( 'This wizard will guide you through the process of ' 'calibrating the device load feedback measurement circuit. ' 'This feedback circuit is used to measure the impedance ' 'between the actuated area and ground. This impedance is ' 'related to the volume of liquid between the actuated area' '\n\nSee ' r'<a href="http://microfluidics.utoronto.ca/trac/dropbot/wiki/Control board calibration#device-load-impedance-calibration">' 'here</a> for more details.') label = gtk.Label(content) label.set_use_markup(True) label.set_line_wrap(True) image = gtk.Image() img_path = pkg_resources.resource_filename( 'dmf_control_board_firmware', 'gui/impedance_feedback_intro.png') image.set_from_file(str(img_path)) box.pack_start(label, True, False, padding=15) box.pack_start(image, True, True, padding=5) self.widget.set_page_complete(box, True) # # Connect hardware # box = gtk.HBox() self.widget.append_page(box) self.widget.set_page_type(box, gtk.ASSISTANT_PAGE_CONTENT) self.widget.set_page_title(box, "Connect hardware") label = gtk.Label( ' - Connect DropBot "<tt>Out to Amp</tt>" to amplifier input.\n' ' - Connect amplifier output to DropBot "<tt>In from Amp</tt>".\n' ' - Connect DropBot "<tt>0-39</tt>" to test board.') image = gtk.Image() img_path = pkg_resources.resource_filename( 'dmf_control_board_firmware', 'gui/impedance_feedback_setup.png') image.set_from_file(str(img_path)) label.set_line_wrap(True) label.set_use_markup(True) box.pack_start(label, True, False, padding=15) box.pack_start(image, True, True, padding=5) self.widget.set_page_complete(box, True) # # Select frequencies # form = Form.of( Integer.named('start_frequency').using( default=self.control_board.min_waveform_frequency, optional=True, validators=[ ValueAtLeast( minimum=self.control_board.min_waveform_frequency), ValueAtMost( maximum=self.control_board.max_waveform_frequency) ]), Integer.named('end_frequency').using( default=self.control_board.max_waveform_frequency, optional=True, validators=[ ValueAtLeast( minimum=self.control_board.min_waveform_frequency), ValueAtMost( maximum=self.control_board.max_waveform_frequency) ]), Integer.named('number_of_steps').using(default=10, optional=True, validators=[ ValueAtLeast(minimum=2), ]), Integer.named('RMS_voltage').using( default=min(100, self.control_board.max_waveform_voltage), optional=True, validators=[ ValueAtLeast(minimum=10), ValueAtMost( maximum=self.control_board.max_waveform_voltage) ])) box = gtk.HBox() self.form_view = create_form_view(form) box.pack_start(self.form_view.widget, fill=False, padding=40) self.widget.append_page(box) self.widget.set_page_type(box, gtk.ASSISTANT_PAGE_CONTENT) self.widget.set_page_title(box, "Select calibration frequencies") self.widget.set_page_complete(box, True) ## # Record measurements # box1 = gtk.VBox() self.widget.append_page(box1) self.widget.set_page_type(box1, gtk.ASSISTANT_PAGE_PROGRESS) self.widget.set_page_title(box1, "Record measurements") self.measurements_label = gtk.Label('Ready.') self.measurements_label.set_line_wrap(True) self.measure_progress = gtk.ProgressBar() box1.pack_start(self.measurements_label, True, True, 0) box1.pack_start(self.measure_progress, expand=False, fill=False, padding=15) self.box1 = box1 # # Confirm fitted parameters # box = gtk.VBox() self.widget.append_page(box) self.widget.set_page_type(box, gtk.ASSISTANT_PAGE_CONFIRM) self.widget.set_page_title(box, "Confirm fitted parameters") self.figure = Figure(dpi=72) self.canvas = FigureCanvasGTK(self.figure) toolbar = NavigationToolbar(self.canvas, self.widget) #self.axis = figure.add_subplot(111) box.pack_start(self.canvas) box.pack_start(toolbar, False, False) self.widget.set_page_complete(box, True) ## # Summary # box = gtk.VBox() self.widget.append_page(box) self.widget.set_page_type(box, gtk.ASSISTANT_PAGE_SUMMARY) self.widget.set_page_title(box, "Summary") label = gtk.Label('Calibration of device load feedback circuit is ' 'complete. The impedance between actuated device ' 'area and ground should now be measured accurately ' 'by the control board.') label.set_line_wrap(True) box.pack_start(label, True, True, 0) self.widget.set_page_complete(box, True)