• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python app_context.get_app函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中microdrop.app_context.get_app函数的典型用法代码示例。如果您正苦于以下问题:Python get_app函数的具体用法?Python get_app怎么用?Python get_app使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_app函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_label

    def get_label(self):
        app = get_app()

        vbox = app.main_window_controller.vbox2
        main_window_children = vbox.get_children()

        # Get reference to metadata label (or add it if necessary).
        labels = [widget for widget in main_window_children
                  if isinstance(widget, gtk.Label) and (widget.props.name ==
                                                        'metadata')]
        if labels:
            # Metadata label has already been added.  Use existing label.
            label_metadata = labels[0]
        else:
            # Metadata label has not been added.  Create new metadata label.
            label_metadata = gtk.Label()
            label_metadata.props.name = 'metadata'
            label_metadata.set_alignment(0, .5)  # Left, middle vertical align
            vbox.pack_start(label_metadata, False, False, 0)
            # Find position in main window `gtk.VBox` to insert metadata label
            # (after first set of labels).
            for i, child in enumerate(main_window_children):
                if not isinstance(child, gtk.Label):
                    break
            # Move metadata label to new position.
            vbox.reorder_child(label_metadata, i)
            # Display label
            label_metadata.show()
        return label_metadata
开发者ID:wheeler-microfluidics,项目名称:metadata_plugin,代码行数:29,代码来源:__init__.py


示例2: on_plugin_enable

 def on_plugin_enable(self):
     app = get_app()
     self.parent = app.builder.get_object("vbox2")
     self.window = gtk.ScrolledWindow()
     self.window.show_all()
     self.parent.add(self.window)
     super(ProtocolGridController, self).on_plugin_enable()
开发者ID:ryanfobel,项目名称:microdrop,代码行数:7,代码来源:protocol_grid_controller.py


示例3: _get_popup_menu

    def _get_popup_menu(self, item, column_title, value, row_ids,
                        menu_items=None):
        app = get_app()
        if menu_items is None:
            # Use list of tuples (menu label, callback) rather than a dict to
            # allow ordering.
            menu_items = []

        def request_field_filter(*args, **kwargs):
            from .field_filter_controller import FieldFilterController

            ffc = FieldFilterController()
            response = ffc.run(self.forms, self.enabled_fields_by_form_name)
            if response == gtk.RESPONSE_OK:
                self.emit('fields-filter-request',
                          ffc.enabled_fields_by_plugin)

        # Add menu entry to select enabled fields for each plugin
        menu_items += [('Select fields...', request_field_filter)]
        # Add seperator
        menu_items += [(None, None)]
        menu_items += [('Insert', lambda x: app.protocol.insert_step())]
        menu_items += [('Delete', self.delete_rows)]
        menu_items += [('Cut', self.cut_rows)]
        menu_items += [('Copy', self.copy_rows)]
        menu_items += [('Paste before', self.paste_rows_before)]
        menu_items += [('Paste after', self.paste_rows_after)]
        # Add seperator
        menu_items += [(None, None)]

        return super(ProtocolGridView, self)._get_popup_menu(item,
                                                             column_title,
                                                             value, row_ids,
                                                             menu_items)
开发者ID:wheeler-microfluidics,项目名称:microdrop,代码行数:34,代码来源:protocol_grid_controller.py


示例4: _create_accel_group

    def _create_accel_group(self, widget):
        class FocusWrapper(object):
            '''
            This class allows for a function to be executed, restoring the
            focused state of the protocol grid view if necessary.
            '''
            def __init__(self, controller, func):
                self.controller = controller
                self.func = func

            def __call__(self):
                focused = self.controller.widget.has_focus()
                self.func()
                if focused:
                    self.controller.widget.grab_focus()

        app = get_app()
        shortcuts = {
            '<Control>c': self.widget.copy_rows,
            '<Control>x': FocusWrapper(self, self.widget.cut_rows),
            'Delete': FocusWrapper(self, self.widget.delete_rows),
            '<Control>v': FocusWrapper(self, self.widget.paste_rows_after),
            '<Control><Shift>v': FocusWrapper(self,
                                              self.widget.paste_rows_before),
            '<Control><Shift>i': FocusWrapper(self, lambda:
                                              app.protocol.insert_step())}
        return get_accel_group(widget, shortcuts,
                               enabled_widgets=[self.widget])
开发者ID:ryanfobel,项目名称:microdrop,代码行数:28,代码来源:protocol_grid_controller.py


示例5: on_app_options_changed

    def on_app_options_changed(self, plugin_name):
        app = get_app()
        if plugin_name == self.name:
            app_values = self.get_app_values()
            reconnect = False

            if self.control_board.connected():
                for k, v in app_values.items():
                    if k == 'baud_rate' and self.control_board.baud_rate != v:
                        self.control_board.baud_rate = v
                        reconnect = True
                    if k == 'serial_port' and self.control_board.port != v:
                        reconnect = True

            if reconnect:
                self.connect()
                
            self._update_protocol_grid()
        elif plugin_name == app.name:
            # Turn off all electrodes if we're not in realtime mode and not
            # running a protocol.
            if (self.control_board.connected() and not app.realtime_mode and
                not app.running):
                logger.info('Turning off all electrodes.')
                self.control_board.set_state_of_all_channels(
                    np.zeros(self.control_board.number_of_channels())
                )
开发者ID:wheeler-microfluidics,项目名称:opendrop_plugin,代码行数:27,代码来源:__init__.py


示例6: get_actuated_area

 def get_actuated_area(self, electrode_states):
     '''
     Get area of actuated electrodes.
     '''
     app = get_app()
     actuated_electrodes = electrode_states[electrode_states > 0].index
     return app.dmf_device.electrode_areas.ix[actuated_electrodes].sum()
开发者ID:wheeler-microfluidics,项目名称:electrode_controller_plugin,代码行数:7,代码来源:__init__.py


示例7: on_step_run

    def on_step_run(self):
        """
        Handler called whenever a step is executed. Note that this signal
        is only emitted in realtime mode or if a protocol is running.

        Plugins that handle this signal must emit the on_step_complete
        signal once they have completed the step. The protocol controller
        will wait until all plugins have completed the current step before
        proceeding.

        return_value can be one of:
            None
            'Repeat' - repeat the step
            or 'Fail' - unrecoverable error (stop the protocol)
        """
        app = get_app()
        if not app.running:
            return

        self.kill_running_step()
        step_options = self.get_step_options()

        try:
            self.repeat_i = 0
            self.step_start_time = datetime.now()
            df_routes = self.get_routes()
            self.route_controller.execute_routes(
                df_routes, step_options['transition_duration_ms'],
                trail_length=step_options['trail_length'],
                on_complete=self.on_step_routes_complete,
                on_error=self.on_error)
        except:
            self.on_error()
开发者ID:Lucaszw,项目名称:droplet_planning_plugin,代码行数:33,代码来源:__init__.py


示例8: set_electrode_states

    def set_electrode_states(self, electrode_states):
        '''
        Set the state of multiple electrodes.

        Args:

            electrode_states (pandas.Series) : State of electrodes, indexed by
                electrode identifier (e.g., `"electrode001"`).

        Returns:

            (dict) : States of modified channels and electrodes, as well as the
                total area of all actuated electrodes.
        '''
        app = get_app()

        # Set the state of DMF device channels.
        self.electrode_states = (electrode_states
                                 .combine_first(self.electrode_states))

        def notify(step_number):
            emit_signal('on_step_options_changed', [self.name, step_number],
                        interface=IPlugin)
        gtk.idle_add(notify, app.protocol.current_step_number)

        result = self.get_state(electrode_states)
        result['actuated_area'] = self.get_actuated_area(self.electrode_states)
        return result
开发者ID:wheeler-microfluidics,项目名称:electrode_controller_plugin,代码行数:28,代码来源:__init__.py


示例9: edit_metadata

    def edit_metadata(self):
        from pygtkhelpers.schema import schema_dialog

        app = get_app()
        metadata = self.get_metadata()
        schema = json.loads(self.get_app_values()['json_schema'])
        video_config = json.loads(self.get_app_values().get('video_config',
                                                            'null'))
        if video_config is None:
            video_config = {}
        device_name = video_config.get('device_name')
        max_width = video_config.get('width', 320)
        max_fps = video_config.get('framerate', 15)
        try:
            data = schema_dialog(schema, data=metadata,
                                 device_name=device_name, max_width=max_width,
                                 max_fps=max_fps, title='Edit metadata',
                                 parent=app.main_window_controller.view)
        except ValueError:
            logger.info('Metadata edit cancelled.')
        except KeyError:
            logger.error('Error setting metadata scanner video config.',
                         exc_info=True)
        else:
            self.set_metadata(data)
开发者ID:wheeler-microfluidics,项目名称:metadata_plugin,代码行数:25,代码来源:__init__.py


示例10: on_experiment_log_changed

    def on_experiment_log_changed(self, experiment_log):
        # Reset number of completed DStat experiments for each step.
        self.dstat_experiment_count_by_step = {}
        self.dstat_experiment_data = None

        app = get_app()
        app_values = self.get_app_values()
        calibrator_file = app_values.get('calibrator_file', '')
        data = {'calibrator_file': calibrator_file}

        if hasattr(app, 'experiment_log') and app.experiment_log:
            app.experiment_log.metadata[self.name] = data

            # copy the calibrator file to the experiment log directory
            if calibrator_file:
                if not path(calibrator_file).isfile():
                    logger.error('Calibration file (%s) does not exist.' %
                                 calibrator_file)
                else:
                    try:
                        output_path = path(app.experiment_log.get_log_path()) / self.name
                        if not output_path.isdir():
                            output_path.mkdir()
                        path(calibrator_file).copy2(output_path / 'calibrator.csv')
                    except:
                        logger.error('Could not copy calibration file to the '
                                     'experiment log directory.' , exc_info=True)
开发者ID:wheeler-microfluidics,项目名称:dropbot-dx-accessories-plugin,代码行数:27,代码来源:__init__.py


示例11: on_selection_changed

 def on_selection_changed(self, grid_view):
     if self.selected_ids:
         _L().debug('selected_ids=%s', self.selected_ids)
         app = get_app()
         _L().debug('current_step_number=%d',
                        app.protocol.current_step_number)
         if app.protocol.current_step_number not in self.selected_ids:
             app.protocol.goto_step(self.selected_ids[0])
开发者ID:wheeler-microfluidics,项目名称:microdrop,代码行数:8,代码来源:protocol_grid_controller.py


示例12: on_step_swapped

 def on_step_swapped(self, *args):
     '''
     .. versionchanged:: 2.1.3
         Pass current step number to as argument to
         :meth:`update_nearest_step_labels`.
     '''
     app = get_app()
     step_i = app.protocol.current_step_number
     self.update_nearest_step_labels(step_i)
开发者ID:wheeler-microfluidics,项目名称:step_label_plugin,代码行数:9,代码来源:__init__.py


示例13: on_selection_changed

 def on_selection_changed(self, grid_view):
     if self.selected_ids:
         logging.debug('[ProtocolGridView].on_selection_changed: '
                       'selected_ids=%s', self.selected_ids)
         app = get_app()
         logging.debug('\tcurrent_step_number=%d',
                       app.protocol.current_step_number)
         if app.protocol.current_step_number not in self.selected_ids:
             app.protocol.goto_step(self.selected_ids[0])
开发者ID:ryanfobel,项目名称:microdrop,代码行数:9,代码来源:protocol_grid_controller.py


示例14: get_state

    def get_state(self, electrode_states):
        app = get_app()

        electrode_channels = (app.dmf_device.actuated_channels(electrode_states
                                                               .index))
        channel_states = pd.Series(electrode_states.values,
                                   index=electrode_channels)
        return {'electrode_states': electrode_states,
                'channel_states': channel_states}
开发者ID:wheeler-microfluidics,项目名称:electrode_controller_plugin,代码行数:9,代码来源:__init__.py


示例15: metadata

 def metadata(self):
     '''
     Add experiment index and experiment UUID to metadata.
     '''
     metadata = self._metadata.copy() if self._metadata else {}
     app = get_app()
     metadata['experiment_id'] = app.experiment_log.experiment_id
     metadata['experiment_uuid'] = app.experiment_log.uuid
     return metadata
开发者ID:wheeler-microfluidics,项目名称:dropbot-dx-accessories-plugin,代码行数:9,代码来源:__init__.py


示例16: on_step_options_changed

 def on_step_options_changed(self, plugin, step_number):
     logger.debug('[OpenDropPlugin] on_step_options_changed(): %s '
                  'step #%d' % (plugin, step_number))
     app = get_app()
     app_values = self.get_app_values()
     options = self.get_step_options(step_number)
     if (app.protocol and not app.running and not app.realtime_mode and
         (plugin == 'microdrop.gui.dmf_device_controller' or plugin ==
          self.name) and app.protocol.current_step_number == step_number):
         self.on_step_run()
开发者ID:wheeler-microfluidics,项目名称:opendrop_plugin,代码行数:10,代码来源:__init__.py


示例17: on_protocol_run

 def on_protocol_run(self):
     """
     Handler called when a protocol starts running.
     """
     app = get_app()
     if not self.control_board.connected():
         logger.warning("Warning: no control board connected.")
     elif (self.control_board.number_of_channels() <=
           app.dmf_device.max_channel()):
         logger.warning("Warning: currently connected board does not have "
                        "enough channels for this protocol.")
开发者ID:wheeler-microfluidics,项目名称:opendrop_plugin,代码行数:11,代码来源:__init__.py


示例18: update_steps

    def update_steps(self):
        app = get_app()
        num_steps = len(app.protocol.steps)

        protocol = []
        for i in range(num_steps):
            protocol.append(self.get_step_options(i))

        self.mqtt_client.publish('microdrop/droplet-planning-plugin/step-options',
                                  json.dumps(protocol, cls=PandasJsonEncoder),
                                  retain=True)
开发者ID:Lucaszw,项目名称:droplet_planning_plugin,代码行数:11,代码来源:__init__.py


示例19: on_protocol_pause

 def on_protocol_pause(self):
     """
     Handler called when a protocol is paused.
     """
     app = get_app()
     self._kill_running_step()
     if self.control_board.connected() and not app.realtime_mode:
         # Turn off all electrodes
         logger.debug('Turning off all electrodes.')
         self.control_board.set_state_of_all_channels(
             np.zeros(self.control_board.number_of_channels()))
开发者ID:wheeler-microfluidics,项目名称:opendrop_plugin,代码行数:11,代码来源:__init__.py


示例20: remove_labels

 def remove_labels(self):
     '''
     .. versionchanged:: 2.1.3
         Wrap with :func:`gtk_threadsafe` decorator to ensure the code runs
         in the main GTK thread.
     '''
     app = get_app()
     for child_i in app.main_window_controller.box_step.get_children():
         if any([child_i is self.label_most_recent_step_label,
                 child_i is self.label_next_step_label]):
             app.main_window_controller.box_step.remove(child_i)
     self.label_most_recent_step_label = None
     self.label_next_step_label = None
开发者ID:wheeler-microfluidics,项目名称:step_label_plugin,代码行数:13,代码来源:__init__.py



注:本文中的microdrop.app_context.get_app函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python client.connect函数代码示例发布时间:2022-05-27
下一篇:
Python api.create_object_graph函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap