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


Python factory.Factory方法代码示例

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


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

示例1: on_key_press

# 需要导入模块: import factory [as 别名]
# 或者: from factory import Factory [as 别名]
def on_key_press(self, window, event):
        """Handle a keyboard event"""
        maker = Factory()

        self.set_urgency_hint(False)

        mapping = self.terminator.keybindings.lookup(event)

        if mapping:
            dbg('Window::on_key_press: looked up %r' % mapping)
            if mapping == 'full_screen':
                self.set_fullscreen(not self.isfullscreen)
            elif mapping == 'close_window':
                if not self.on_delete_event(window,
                        gtk.gdk.Event(gtk.gdk.DELETE)):
                    self.on_destroy_event(window,
                            gtk.gdk.Event(gtk.gdk.DESTROY))
            elif mapping == 'new_tab':
                self.tab_new(self.get_focussed_terminal())
            else:
                return(False)
            return(True) 
开发者ID:OWASP,项目名称:NINJA-PingU,代码行数:24,代码来源:window.py

示例2: tab_new

# 需要导入模块: import factory [as 别名]
# 或者: from factory import Factory [as 别名]
def tab_new(self, widget=None, debugtab=False, _param1=None, _param2=None):
        """Make a new tab"""
        cwd = None
        profile = None

        if self.get_property('term_zoomed') == True:
            err("You can't create a tab while a terminal is maximised/zoomed")
            return

        if widget:
            cwd = widget.get_cwd()
            profile = widget.get_profile()

        maker = Factory()
        if not self.is_child_notebook():
            dbg('Making a new Notebook')
            notebook = maker.make('Notebook', window=self)
        return self.get_child().newtab(debugtab, cwd=cwd, profile=profile) 
开发者ID:OWASP,项目名称:NINJA-PingU,代码行数:20,代码来源:window.py

示例3: rotate

# 需要导入模块: import factory [as 别名]
# 或者: from factory import Factory [as 别名]
def rotate(self, widget, clockwise):
        """Rotate children in this window"""
        self.set_pos_by_ratio = True
        maker = Factory()
        # collect all paned children in breadth-first order
        paned = []
        for child in self.get_children():
            if maker.isinstance(child, 'Paned'):
                paned.append(child)
        for p in paned:
            for child in p.get_children():
                if child not in paned and maker.isinstance(child, 'Paned'):
                    paned.append(child)
        # then propagate the rotation
        for p in paned:
            p.rotate(widget, clockwise)
        self.show_all()
        widget.grab_focus()
        
        while gtk.events_pending():
            gtk.main_iteration_do(False)
        self.set_pos_by_ratio = False 
开发者ID:OWASP,项目名称:NINJA-PingU,代码行数:24,代码来源:window.py

示例4: get_visible_terminals

# 需要导入模块: import factory [as 别名]
# 或者: from factory import Factory [as 别名]
def get_visible_terminals(self):
        """Walk down the widget tree to find all of the visible terminals.
        Mostly using Container::get_visible_terminals()"""
        terminals = {}
        if not hasattr(self, 'cached_maker'):
            self.cached_maker = Factory()
        maker = self.cached_maker
        child = self.get_child()

        if not child:
            return([])

        # If our child is a Notebook, reset to work from its visible child
        if maker.isinstance(child, 'Notebook'):
            pagenum = child.get_current_page()
            child = child.get_nth_page(pagenum)

        if maker.isinstance(child, 'Container'):
            terminals.update(child.get_visible_terminals())
        elif maker.isinstance(child, 'Terminal'):
            terminals[child] = child.get_allocation()
        else:
            err('Unknown child type %s' % type(child))

        return(terminals) 
开发者ID:OWASP,项目名称:NINJA-PingU,代码行数:27,代码来源:window.py

示例5: group_tab

# 需要导入模块: import factory [as 别名]
# 或者: from factory import Factory [as 别名]
def group_tab(self, widget):
        """Group all terminals in the current tab"""
        maker = Factory()
        notebook = self.get_child()

        if not maker.isinstance(notebook, 'Notebook'):
            dbg('not in a notebook, refusing to group tab')
            return

        pagenum = notebook.get_current_page()
        while True:
            group = _('Tab %d') % pagenum
            if group not in self.terminator.groups:
                break
            pagenum += 1
        for terminal in self.get_visible_terminals():
            terminal.set_group(None, group) 
开发者ID:OWASP,项目名称:NINJA-PingU,代码行数:19,代码来源:window.py

示例6: get_visible_terminals

# 需要导入模块: import factory [as 别名]
# 或者: from factory import Factory [as 别名]
def get_visible_terminals(self):
        """Walk the widget tree to find all of the visible terminals. That is,
        any terminals which are not hidden in another Notebook pane"""
        if not hasattr(self, 'cached_maker'):
            self.cached_maker = Factory()
        maker = self.cached_maker
        terminals = {}

        for child in self.get_offspring():
            if not child:
                continue
            if maker.isinstance(child, 'Terminal'):
                terminals[child] = child.get_allocation()
            elif maker.isinstance(child, 'Container'):
                terminals.update(child.get_visible_terminals())
            else:
                err('Unknown child type %s' % type(child))

        return(terminals) 
开发者ID:OWASP,项目名称:NINJA-PingU,代码行数:21,代码来源:container.py

示例7: reconfigure

# 需要导入模块: import factory [as 别名]
# 或者: from factory import Factory [as 别名]
def reconfigure(self):
        """Update configuration for the whole application"""

        if self.config['handle_size'] in xrange(0, 6):
            gtk.rc_parse_string("""
                style "terminator-paned-style" {
                    GtkPaned::handle_size = %s 
                }
                class "GtkPaned" style "terminator-paned-style" 
                """ % self.config['handle_size'])
            gtk.rc_reset_styles(gtk.settings_get_default())

        # Cause all the terminals to reconfigure
        for terminal in self.terminals:
            terminal.reconfigure()

        # Reparse our keybindings
        self.keybindings.configure(self.config['keybindings'])

        # Update tab position if appropriate
        maker = Factory()
        for window in self.windows:
            child = window.get_child()
            if maker.isinstance(child, 'Notebook'):
                child.configure() 
开发者ID:OWASP,项目名称:NINJA-PingU,代码行数:27,代码来源:terminator.py

示例8: is_child_notebook

# 需要导入模块: import factory [as 别名]
# 或者: from factory import Factory [as 别名]
def is_child_notebook(self):
        """Returns True if this Window's child is a Notebook"""
        maker = Factory()
        return(maker.isinstance(self.get_child(), 'Notebook')) 
开发者ID:OWASP,项目名称:NINJA-PingU,代码行数:6,代码来源:window.py

示例9: on_delete_event

# 需要导入模块: import factory [as 别名]
# 或者: from factory import Factory [as 别名]
def on_delete_event(self, window, event, data=None):
        """Handle a window close request"""
        maker = Factory()
        if maker.isinstance(self.get_child(), 'Terminal'):
            dbg('Window::on_delete_event: Only one child, closing is fine')
            return(False)
        elif maker.isinstance(self.get_child(), 'Container'):
            return(self.confirm_close(window, _('window')))
        else:
            dbg('unknown child: %s' % self.get_child()) 
开发者ID:OWASP,项目名称:NINJA-PingU,代码行数:12,代码来源:window.py

示例10: add

# 需要导入模块: import factory [as 别名]
# 或者: from factory import Factory [as 别名]
def add(self, widget, metadata=None):
        """Add a widget to the window by way of gtk.Window.add()"""
        maker = Factory()
        gtk.Window.add(self, widget)
        if maker.isinstance(widget, 'Terminal'):
            signals = {'close-term': self.closeterm,
                       'title-change': self.title.set_title,
                       'split-horiz': self.split_horiz,
                       'split-vert': self.split_vert,
                       'unzoom': self.unzoom,
                       'tab-change': self.tab_change,
                       'group-all': self.group_all,
                       'ungroup-all': self.ungroup_all,
                       'group-tab': self.group_tab,
                       'ungroup-tab': self.ungroup_tab,
                       'move-tab': self.move_tab,
                       'tab-new': [self.tab_new, widget],
                       'navigate': self.navigate_terminal}

            for signal in signals:
                args = []
                handler = signals[signal]
                if isinstance(handler, list):
                    args = handler[1:]
                    handler = handler[0]
                self.connect_child(widget, signal, handler, *args)

            widget.grab_focus() 
开发者ID:OWASP,项目名称:NINJA-PingU,代码行数:30,代码来源:window.py

示例11: tab_change

# 需要导入模块: import factory [as 别名]
# 或者: from factory import Factory [as 别名]
def tab_change(self, widget, num=None):
        """Change to a specific tab"""
        if num is None:
            err('must specify a tab to change to')

        maker = Factory()
        child = self.get_child()

        if not maker.isinstance(child, 'Notebook'):
            dbg('child is not a notebook, nothing to change to')
            return

        if num == -1:
            # Go to the next tab
            cur = child.get_current_page()
            pages = child.get_n_pages()
            if cur == pages - 1:
                num = 0
            else:
                num = cur + 1
        elif num == -2:
            # Go to the previous tab
            cur = child.get_current_page()
            if cur > 0:
                num = cur - 1
            else:
                num = child.get_n_pages() - 1

        child.set_current_page(num)
        # Work around strange bug in gtk-2.12.11 and pygtk-2.12.1
        # Without it, the selection changes, but the displayed page doesn't
        # change
        child.set_current_page(child.get_current_page())

    # FIXME: All of these (un)group_(all|tab) methods need refactoring work 
开发者ID:OWASP,项目名称:NINJA-PingU,代码行数:37,代码来源:window.py

示例12: move_tab

# 需要导入模块: import factory [as 别名]
# 或者: from factory import Factory [as 别名]
def move_tab(self, widget, direction):
        """Handle a keyboard shortcut for moving tab positions"""
        maker = Factory()
        notebook = self.get_child()

        if not maker.isinstance(notebook, 'Notebook'):
            dbg('not in a notebook, refusing to move tab %s' % direction)
            return

        dbg('moving tab %s' % direction)
        numpages = notebook.get_n_pages()
        page = notebook.get_current_page()
        child = notebook.get_nth_page(page)

        if direction == 'left':
            if page == 0:
                page = numpages
            else:
                page = page - 1
        elif direction == 'right':
            if page == numpages - 1:
                page = 0
            else:
                page = page + 1
        else:
            err('unknown direction: %s' % direction)
            return
        
        notebook.reorder_child(child, page) 
开发者ID:OWASP,项目名称:NINJA-PingU,代码行数:31,代码来源:window.py

示例13: enumerate_descendants

# 需要导入模块: import factory [as 别名]
# 或者: from factory import Factory [as 别名]
def enumerate_descendants(parent):
    """Walk all our children and build up a list of containers and
    terminals"""
    # FIXME: Does having to import this here mean we should move this function
    # back to Container?
    from factory import Factory

    containerstmp = []
    containers = []
    terminals = []
    maker = Factory()

    if parent is None:
        err('no parent widget specified')
        return

    for descendant in parent.get_children():
        if maker.isinstance(descendant, 'Container'):
            containerstmp.append(descendant)
        elif maker.isinstance(descendant, 'Terminal'):
            terminals.append(descendant)

        while len(containerstmp) > 0:
            child = containerstmp.pop(0)
            for descendant in child.get_children():
                if maker.isinstance(descendant, 'Container'):
                    containerstmp.append(descendant)
                elif maker.isinstance(descendant, 'Terminal'):
                    terminals.append(descendant)
            containers.append(child)

    dbg('%d containers and %d terminals fall beneath %s' % (len(containers), 
        len(terminals), parent))
    return(containers, terminals) 
开发者ID:OWASP,项目名称:NINJA-PingU,代码行数:36,代码来源:util.py

示例14: __init__

# 需要导入模块: import factory [as 别名]
# 或者: from factory import Factory [as 别名]
def __init__(self):
        """Class initialiser"""
        self.terminator = Terminator()
        self.maker = Factory()
        Container.__init__(self)
        self.signals.append({'name': 'resize-term', 
                             'flags': gobject.SIGNAL_RUN_LAST,
                             'return_type': gobject.TYPE_NONE, 
                             'param_types': (gobject.TYPE_STRING,)})


    # pylint: disable-msg=W0613 
开发者ID:OWASP,项目名称:NINJA-PingU,代码行数:14,代码来源:paned.py

示例15: propagate_title_change

# 需要导入模块: import factory [as 别名]
# 或者: from factory import Factory [as 别名]
def propagate_title_change(self, widget, title):
        """Pass a title change up the widget stack"""
        maker = Factory()
        parent = self.get_parent()
        title = widget.get_window_title()

        if maker.isinstance(self, 'Notebook'):
            self.update_tab_label_text(widget, title)
        elif maker.isinstance(self, 'Window'):
            self.title.set_title(widget, title)

        if maker.isinstance(parent, 'Container'):
            parent.propagate_title_change(widget, title) 
开发者ID:OWASP,项目名称:NINJA-PingU,代码行数:15,代码来源:container.py


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