当前位置: 首页>>代码示例>>Python>>正文


Python Output.widget方法代码示例

本文整理汇总了Python中Output.Output.widget方法的典型用法代码示例。如果您正苦于以下问题:Python Output.widget方法的具体用法?Python Output.widget怎么用?Python Output.widget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Output.Output的用法示例。


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

示例1: __init__

# 需要导入模块: from Output import Output [as 别名]
# 或者: from Output.Output import widget [as 别名]
class Builder:
    _READY = 0
    _SAVING = 1
    _EXECUTE = 2
    
    def __init__(self, config, window):
        self._l = logging.getLogger("plugin.builder")
        self._l.debug("Entered")
        self._window = window
        self._config = config
        # Store last build/compile command run for each document
        # during this session
        self._prev_commands = {} 
        
        # Map to record location of items found in the Output buffer
        # _item_locations[item number] ->
        #     if file loaded : a GtkTextBuffer mark
        #     else: a tuple of (path, line, col)
        self._item_locations = {}
        
        ui_builder = gtk.Builder()
        ui_builder.add_from_file(os.path.join(config.get_data_dir(), 'Builder.glade'))
        self._ui = ui_builder.get_object
        self._ui('dlg_unsaved_file').set_transient_for(window)
        self._ui('dlg_run_command').set_transient_for(window)
        
        # Add bottom panel console
        self._console = Output(config);
        self._console.set_item_selected_cb(self._goto)
        self._console.set_item_found_cb(self._record)
        bottom = self._window.get_bottom_panel()
        bottom.add_item(self._console.widget(), _('Build Output'), gtk.STOCK_EXECUTE)

        # Insert menu item Tools->Compile
        manager = self._window.get_ui_manager()
        self._action_group = gtk.ActionGroup("plugin_builder")
        self._action_group.add_actions([("plugin_builder_compile", None,
                                            _("_Compile"), "<control>F5",
                                            _("Compile the current document"),
                                            self._compile_doc),
                                        ("plugin_builder_build", None,
                                            _("_Build"), "<control>F6",
                                            _("Run the build command"),
                                            self._build)])
        manager.insert_action_group(self._action_group, -1)
        self._ui_id = manager.add_ui_from_string(ui_str)
        self._l.info(manager.get_ui())
        self._save_action = manager.get_action('/ui/MenuBar/FileMenu/FileSaveMenu')
        self._l.info(self._save_action)
        
    def deactivate(self):
        self._l.debug("Entered")
        
        # Remove menu item Tools->Compile File
        manager = self._window.get_ui_manager()
        manager.remove_ui(self._ui_id)
        manager.remove_action_group(self._action_group)
        manager.ensure_update()
        
        # Remove bottom panel console
        bottom = self._window.get_bottom_panel()
        bottom.remove_item(self._console.widget())
        
        # Tidy up
        self._window = None
        self._config = None
        self._action_group = None
        
    def _compile_doc(self, action):
        self._l.debug("Entered")
        rootdir = None
        doc = self._window.get_active_document()
        if doc:
            rootdir = os.path.dirname(doc.get_uri_for_display())
        self._generate_output(self._config.compile_cmd, rootdir)
        
        
    def _build(self, action):
        self._l.debug("Entered")
        rootdir = None
        doc = self._window.get_active_document()
        rootdir = self._config.build_root(doc)
        self._generate_output(self._config.build_cmd, rootdir)


    def _generate_output(self, get_cmd_func, rootdir):
        self._l.debug("Entered")
        bp = self._window.get_bottom_panel()
        bp.activate_item(self._console.widget())
        bp.set_property("visible", True)
        doc = self._window.get_active_document()
        active_tab = self._window.get_active_tab()
        
        unsaved = self._window.get_unsaved_documents()
        self._l.info("There are %d unsaved documents" % len(unsaved))
        self._doc_handler_ids = {}
        self._state = self._EXECUTE
        if unsaved:
            self._state = self._SAVING
            md = self._ui('dlg_unsaved_file')
#.........这里部分代码省略.........
开发者ID:bamanzi,项目名称:gedit-2-addons,代码行数:103,代码来源:Builder.py


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