def __init__(self): window = gtk.Window(gtk.WINDOW_TOPLEVEL) window.set_title("Mpeg2-Player") window.set_default_size(640, 500) window.connect("destroy", self.on_destroy) vbox = gtk.VBox() window.add(vbox) hbox = gtk.HBox() vbox.pack_start(hbox, expand=False) video_mode_enum = Enum.named('video_mode').valued(*self.video_mode_keys) form = Form.of( video_mode_enum.using(default=self.video_mode_keys[0]), Filepath.named('output_path').using(default=''), Integer.named('bitrate').using(default=150, validators=[ValueAtLeast( minimum=25)], properties={'step': 25, 'label': 'Bitrate (KB/s)', }), String.named('transform_string').using(default='1,0,0,0,1,0,0,0,1'), Boolean.named('draw_cairo').using(default=False), ) self.video_mode_form_view = create_form_view(form) for field in ['video_mode', 'output_path', 'bitrate', 'transform_string', 'draw_cairo']: setattr(self, '%s_field' % field, self.video_mode_form_view.form\ .fields[field]) self.video_mode_field.proxy.connect('changed', self._on_mode_changed) self.video_source = None hbox.add(self.video_mode_form_view.widget) self.button = gtk.Button("Start") hbox.pack_start(self.button, False) self.button.connect("clicked", self.start_stop) self.aframe = gtk.AspectFrame(xalign=0.5, yalign=1.0, ratio=4.0 / 3.0, obey_child=False) self.pipeline = None self._proxy = None vbox.pack_start(self.aframe, expand=True) self.movie_view = GtkVideoView() self.movie_window = self.movie_view.widget self.aframe.add(self.movie_window) window.show_all() self.window = window
def get_channel_sweep_parameters(voltage=100, frequency=10e3, channels=None, parent=None): ''' Show dialog to select parameters for a sweep across a selected set of channels. Args ---- voltage (int) : Default actuation voltage. frequency (int) : Default actuation frequency. channels (pandas.Series) : Default channels selection, encoded as boolean array indexed by channel number, where `True` values indicate selected channel(s). parent (gtk.Window) : If not `None`, parent window for dialog. For example, display dialog at position relative to the parent window. Returns ------- (dict) : Values collected from widgets with the following keys: `'frequency'`, `voltage'`, and (optionally) `'channels'`. ''' # Create a form view containing widgets to set the waveform attributes # (i.e., voltage and frequency). form = Form.of(Float.named('voltage') .using(default=voltage, validators=[ValueAtLeast(minimum=0)]), Float.named('frequency') .using(default=frequency, validators=[ValueAtLeast(minimum=1)])) form_view = create_form_view(form) # If default channel selection was provided, create a treeview with one row # per channel, and a checkbox in each row to mark the selection status of # the corresponding channel. if channels is not None: df_channel_select = pd.DataFrame(channels.index, columns=['channel']) df_channel_select.insert(1, 'select', channels.values) view_channels = ListSelect(df_channel_select) # Create dialog window. dialog = gtk.Dialog(title='Channel sweep parameters', buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) # Add waveform widgets to dialog window. frame_waveform = gtk.Frame('Waveform properties') frame_waveform.add(form_view.widget) dialog.vbox.pack_start(child=frame_waveform, expand=False, fill=False, padding=5) # Add channel selection widgets to dialog window. if channels is not None: frame_channels = gtk.Frame('Select channels to sweep') frame_channels.add(view_channels.widget) dialog.vbox.pack_start(child=frame_channels, expand=True, fill=True, padding=5) # Mark all widgets as visible. dialog.vbox.show_all() if parent is not None: dialog.window.set_transient_for(parent) response = dialog.run() dialog.destroy() if response != gtk.RESPONSE_OK: raise RuntimeError('Dialog cancelled.') # Collection waveform and channel selection values from dialog. form_values = {name: f.element.value for name, f in form_view.form.fields.items()} if channels is not None: form_values['channels'] = (df_channel_select .loc[df_channel_select['select'], 'channel'].values) return form_values
def get_video_mode_form_view(video_modes=None, values=None, use_markup=True): form_view = create_form_view(get_video_mode_form(), values=values, use_markup=use_markup) return form_view
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)
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)
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)