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


Python MainWindow.get_flow_graph方法代码示例

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


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

示例1: __init__

# 需要导入模块: from MainWindow import MainWindow [as 别名]
# 或者: from MainWindow.MainWindow import get_flow_graph [as 别名]
class ActionHandler:
    """
    The action handler will setup all the major window components,
    and handle button presses and flow graph operations from the GUI.
    """

    def __init__(self, file_paths, platform):
        """
        ActionHandler constructor.
        Create the main window, setup the message handler, import the preferences,
        and connect all of the action handlers. Finally, enter the gtk main loop and block.

        Args:
            file_paths: a list of flow graph file passed from command line
            platform: platform module
        """
        self.clipboard = None
        for action in Actions.get_all_actions(): action.connect('activate', self._handle_action)
        #setup the main window
        self.platform = platform;
        self.main_window = MainWindow(platform)
        self.main_window.connect('delete-event', self._quit)
        self.main_window.connect('key-press-event', self._handle_key_press)
        self.get_page = self.main_window.get_page
        self.get_flow_graph = self.main_window.get_flow_graph
        self.get_focus_flag = self.main_window.get_focus_flag
        #setup the messages
        Messages.register_messenger(self.main_window.add_report_line)
        Messages.send_init(platform)
        #initialize
        self.init_file_paths = file_paths
        Actions.APPLICATION_INITIALIZE()
        #enter the mainloop
        gtk.main()

    def _handle_key_press(self, widget, event):
        """
        Handle key presses from the keyboard and translate key combinations into actions.
        This key press handler is called prior to the gtk key press handler.
        This handler bypasses built in accelerator key handling when in focus because
        * some keys are ignored by the accelerators like the direction keys,
        * some keys are not registered to any accelerators but are still used.
        When not in focus, gtk and the accelerators handle the the key press.

        Returns:
            false to let gtk handle the key action
        """
        # prevent key event stealing while the search box is active
        if self.main_window.btwin.search_entry.has_focus(): return False
        if not self.get_focus_flag(): return False
        return Actions.handle_key_press(event)

    def _quit(self, window, event):
        """
        Handle the delete event from the main window.
        Generated by pressing X to close, alt+f4, or right click+close.
        This method in turns calls the state handler to quit.

        Returns:
            true
        """
        Actions.APPLICATION_QUIT()
        return True

    def _handle_action(self, action):
        #print action
        ##################################################
        # Initalize/Quit
        ##################################################
        if action == Actions.APPLICATION_INITIALIZE:
            for action in Actions.get_all_actions(): action.set_sensitive(False) #set all actions disabled
            #enable a select few actions
            for action in (
                Actions.APPLICATION_QUIT, Actions.FLOW_GRAPH_NEW,
                Actions.FLOW_GRAPH_OPEN, Actions.FLOW_GRAPH_SAVE_AS,
                Actions.FLOW_GRAPH_CLOSE, Actions.ABOUT_WINDOW_DISPLAY,
                Actions.FLOW_GRAPH_SCREEN_CAPTURE, Actions.HELP_WINDOW_DISPLAY,
                Actions.TYPES_WINDOW_DISPLAY, Actions.TOGGLE_BLOCKS_WINDOW,
                Actions.TOGGLE_REPORTS_WINDOW, Actions.TOGGLE_HIDE_DISABLED_BLOCKS,
                Actions.TOOLS_RUN_FDESIGN, Actions.TOGGLE_SCROLL_LOCK,
                Actions.CLEAR_REPORTS, Actions.SAVE_REPORTS,
                Actions.TOGGLE_AUTO_HIDE_PORT_LABELS, Actions.TOGGLE_SNAP_TO_GRID
            ): action.set_sensitive(True)
            if ParseXML.xml_failures:
                Messages.send_xml_errors_if_any(ParseXML.xml_failures)
                Actions.XML_PARSER_ERRORS_DISPLAY.set_sensitive(True)

            if not self.init_file_paths:
                self.init_file_paths = Preferences.files_open()
            if not self.init_file_paths: self.init_file_paths = ['']
            for file_path in self.init_file_paths:
                if file_path: self.main_window.new_page(file_path) #load pages from file paths
            if Preferences.file_open() in self.init_file_paths:
                self.main_window.new_page(Preferences.file_open(), show=True)
            if not self.get_page(): self.main_window.new_page() #ensure that at least a blank page exists

            self.main_window.btwin.search_entry.hide()
            for action in (
                Actions.TOGGLE_REPORTS_WINDOW,
                Actions.TOGGLE_BLOCKS_WINDOW,
#.........这里部分代码省略.........
开发者ID:Appiah,项目名称:gnuradio,代码行数:103,代码来源:ActionHandler.py


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