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


Python DockGroup.add方法代码示例

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


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

示例1: test_add_signal

# 需要导入模块: from etk.docking import DockGroup [as 别名]
# 或者: from etk.docking.DockGroup import add [as 别名]
    def test_add_signal(self):
        events = []
        item_in = []
        item_in_after = []
        def event_handler(self, w):
            events.append(w)
            item_in.append(w in self.items)

        def event_handler_after(self, w):
            item_in_after.append(w in self.items)


        dockgroup = DockGroup()
        dockgroup.connect('add', event_handler)
        dockgroup.connect_after('add', event_handler_after)

        dockitem1 = DockItem()
        dockgroup.add(dockitem1)
        self.assertEquals([dockitem1], events)
        self.assertEquals([True], item_in)
        self.assertEquals([True], item_in_after)

        dockitem2 = DockItem()
        dockgroup.insert_item(dockitem2)
        self.assertEquals([dockitem1], events)
        self.assertEquals([True], item_in)
        self.assertEquals([True], item_in_after)
开发者ID:ReadonShaw,项目名称:etk.docking,代码行数:29,代码来源:test_dockgroup.py

示例2: test_construction

# 需要导入模块: from etk.docking import DockGroup [as 别名]
# 或者: from etk.docking.DockGroup import add [as 别名]
    def test_construction(self):
        win = gtk.Window(gtk.WINDOW_TOPLEVEL)
        frame = DockFrame()
        paned = DockPaned()
        group = DockGroup()
        item = DockItem()

        win.add(frame)
        frame.add(paned)
        paned.add(group)
        group.add(item)

        layout = DockLayout()

        layout.add(frame)

        assert frame in layout.frames
        print layout._signal_handlers
        self.assertEquals(4, len(layout._signal_handlers))
        self.assertEquals(9, len(layout._signal_handlers[frame]))

        layout.remove(frame)

        assert not layout._signal_handlers, layout._signal_handlers
        assert frame not in layout.frames
开发者ID:ReadonShaw,项目名称:etk.docking,代码行数:27,代码来源:test_docklayout.py

示例3: test_drag_drop_on_group

# 需要导入模块: from etk.docking import DockGroup [as 别名]
# 或者: from etk.docking.DockGroup import add [as 别名]
    def test_drag_drop_on_group(self):
        win = gtk.Window(gtk.WINDOW_TOPLEVEL)
        frame = DockFrame()
        paned = DockPaned()
        group = DockGroup()
        item = DockItem()

        layout = self.layout

        layout.add(frame)

        win.add(frame)
        frame.add(paned)
        paned.add(group)
        group.add(item)

        win.set_default_size(200, 200)
        win.show_all()

        while gtk.events_pending():
            gtk.main_iteration()


        context = StubContext(group, [group.items[0]])

        group.do_drag_begin(context)
        x, y = 30, 30
        layout.on_widget_drag_motion(group, context, x, y, 0)

        assert layout._drag_data
        assert layout._drag_data.drop_widget is group

        layout.on_widget_drag_drop(group, context, x, y, 0)
开发者ID:ReadonShaw,项目名称:etk.docking,代码行数:35,代码来源:test_docklayout.py

示例4: test_construction_after_setting_layout

# 需要导入模块: from etk.docking import DockGroup [as 别名]
# 或者: from etk.docking.DockGroup import add [as 别名]
    def test_construction_after_setting_layout(self):
        win = gtk.Window(gtk.WINDOW_TOPLEVEL)
        frame = DockFrame()
        paned = DockPaned()
        group = DockGroup()
        item = DockItem()

        layout = DockLayout()

        layout.add(frame)

        win.add(frame)
        frame.add(paned)
        paned.add(group)
        group.add(item)

        assert frame in layout.frames
        self.assertEquals(4, len(layout._signal_handlers))
        self.assertEquals(9, len(layout._signal_handlers[frame]))

        paned.remove(group)

        self.assertEquals(2, len(layout._signal_handlers), layout._signal_handlers)
        assert frame in layout._signal_handlers.keys(), layout._signal_handlers
        assert paned in layout._signal_handlers.keys(), layout._signal_handlers
        assert group not in layout._signal_handlers.keys(), layout._signal_handlers
        assert item not in layout._signal_handlers.keys(), layout._signal_handlers
        assert frame in layout.frames
开发者ID:ReadonShaw,项目名称:etk.docking,代码行数:30,代码来源:test_docklayout.py

示例5: test_item_added_signal

# 需要导入模块: from etk.docking import DockGroup [as 别名]
# 或者: from etk.docking.DockGroup import add [as 别名]
    def test_item_added_signal(self):
        add_events = []
        item_added_events = []

        def on_add(self, widget):
            add_events.append(widget)

        def on_item_added(dockgroup, child):
            item_added_events.append(child)

        dockitem1 = DockItem()
        dockitem2 = DockItem()
        dockgroup = DockGroup()
        dockgroup.connect('add', on_add)
        dockgroup.connect('item-added', on_item_added)
        dockgroup.add(dockitem1)
        dockgroup.insert_item(dockitem2)

        self.assertTrue(dockitem1 in item_added_events)
        self.assertTrue(dockitem1 in add_events)
        self.assertTrue(dockitem2 in item_added_events)
        self.assertFalse(dockitem2 in add_events)

        dockitem2.destroy()
        dockitem1.destroy()
        dockgroup.destroy()
开发者ID:ReadonShaw,项目名称:etk.docking,代码行数:28,代码来源:test_dockgroup.py

示例6: test_get_widgets

# 需要导入模块: from etk.docking import DockGroup [as 别名]
# 或者: from etk.docking.DockGroup import add [as 别名]
    def test_get_widgets(self):
        win = gtk.Window(gtk.WINDOW_TOPLEVEL)
        frame = DockFrame()
        paned = DockPaned()
        group = DockGroup()
        item = DockItem()
        label = gtk.Label()

        layout = DockLayout()

        layout.add(frame)

        win.add(frame)
        frame.add(paned)
        paned.add(group)
        group.add(item)
        item.add(label)

        group2 = DockGroup()
        paned.add(group2)

        paned.set_name('foo')

        widgets = list(layout.get_widgets('foo'))
        assert len(widgets) == 1
        assert widgets[0] is paned

        widgets = list(layout.get_widgets('EtkDockGroup'))
        assert len(widgets) == 2
        assert widgets[0] is group
        assert widgets[1] is group2
开发者ID:ReadonShaw,项目名称:etk.docking,代码行数:33,代码来源:test_docklayout.py

示例7: test_add

# 需要导入模块: from etk.docking import DockGroup [as 别名]
# 或者: from etk.docking.DockGroup import add [as 别名]
    def test_add(self):
        dockitem = DockItem()
        dockgroup = DockGroup()
        dockgroup.add(dockitem)

        self.assertTrue(dockitem in dockgroup)

        dockitem.destroy()
        dockgroup.destroy()
开发者ID:ReadonShaw,项目名称:etk.docking,代码行数:11,代码来源:test_dockgroup.py

示例8: MainWindow

# 需要导入模块: from etk.docking import DockGroup [as 别名]
# 或者: from etk.docking.DockGroup import add [as 别名]
class MainWindow(gtk.Window):
    def __init__(self):
        gtk.Window.__init__(self)

        self.set_default_size(500, 150)
        self.set_title('DockGroup Demo')
        self.set_border_width(4)
        self.file_counter = 1

        vbox = gtk.VBox()
        vbox.set_spacing(4)
        self.add(vbox)

        ########################################################################
        # Docking
        ########################################################################
        self.dg = DockGroup()
        vbox.pack_start(self.dg)

        ########################################################################
        # Testing Tools
        ########################################################################
        adddibutton = gtk.Button('Create docked items')
        adddibutton.child.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
        adddibutton.connect('clicked', self._on_add_di_button_clicked)
        vbox.pack_start(adddibutton, False, False)

        self.show_all()

    def _on_add_di_button_clicked(self, button):
        examples = [('calc', 'calculator', '#!/usr/bin/env python\n\nprint \'Hello!\''),
                    ('file-manager', 'Hi!', 'Hello!'),
                    ('fonts', 'ABC', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'),
                    ('style', 'abc', 'abcdefghijklmnopqrstuvwxyz'),
                    ('web-browser', 'browser', '0123456789'),
                    ('date', 'today', '9876543210')]

        for i in range(random.randrange(1, 10, 1)):
            icon_name, tooltip_text, text = random.choice(examples)

            # Create a TextView and set some example text
            scrolledwindow = gtk.ScrolledWindow()
            scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
            textview = gtk.TextView()
            textview.get_buffer().set_text(text)
            scrolledwindow.add(textview)

            # Create a DockItem and add our TextView
            di = DockItem(icon_name=icon_name, title='New %s' % self.file_counter, title_tooltip_text=tooltip_text)
            di.add(scrolledwindow)
            di.show_all()

            # Add out DockItem to the DockGroup
            self.dg.add(di)

            # Increment file counter
            self.file_counter += 1
开发者ID:ReadonShaw,项目名称:etk.docking,代码行数:59,代码来源:dockgroupdemo.py

示例9: test_get_n_items

# 需要导入模块: from etk.docking import DockGroup [as 别名]
# 或者: from etk.docking.DockGroup import add [as 别名]
    def test_get_n_items(self):
        dockgroup = DockGroup()
        self.assertTrue(dockgroup.get_n_items() == len(dockgroup) == 0)

        dockitem = DockItem()
        dockgroup.add(dockitem)
        self.assertTrue(dockgroup.get_n_items() == len(dockgroup) == 1)

        dockitem.destroy()
        dockgroup.destroy()
开发者ID:ReadonShaw,项目名称:etk.docking,代码行数:12,代码来源:test_dockgroup.py

示例10: test_item_num

# 需要导入模块: from etk.docking import DockGroup [as 别名]
# 或者: from etk.docking.DockGroup import add [as 别名]
    def test_item_num(self):
        dockitem1 = DockItem()
        dockitem2 = DockItem()
        dockgroup = DockGroup()
        dockgroup.add(dockitem1)

        self.assertTrue(dockgroup.item_num(dockitem1) == 0)
        self.assertTrue(dockgroup.item_num(dockitem2) is None)

        dockitem1.destroy()
        dockgroup.destroy()
开发者ID:ReadonShaw,项目名称:etk.docking,代码行数:13,代码来源:test_dockgroup.py

示例11: test_drag_begin

# 需要导入模块: from etk.docking import DockGroup [as 别名]
# 或者: from etk.docking.DockGroup import add [as 别名]
    def test_drag_begin(self):
        dockitem1 = DockItem()
        dockitem2 = DockItem()
        dockitem3 = DockItem()
        dockgroup = DockGroup()
        dockgroup.add(dockitem1)
        dockgroup.add(dockitem2)
        dockgroup.add(dockitem3)

        window = gtk.Window()
        window.add(dockgroup)
        window.set_size_request(200, 200)

        self.assertEquals(dockitem3, dockgroup._current_tab.item)
开发者ID:ReadonShaw,项目名称:etk.docking,代码行数:16,代码来源:test_dockgroup.py

示例12: test_remove_item

# 需要导入模块: from etk.docking import DockGroup [as 别名]
# 或者: from etk.docking.DockGroup import add [as 别名]
    def test_remove_item(self):
        dockitem1 = DockItem()
        dockitem2 = DockItem()
        dockgroup = DockGroup()
        dockgroup.add(dockitem1)
        dockgroup.add(dockitem2)
        dockgroup.remove_item(0)
        dockgroup.remove_item(None)

        self.assertTrue(dockitem1 not in dockgroup)
        self.assertTrue(dockitem2 not in dockgroup)

        dockitem1.destroy()
        dockitem2.destroy()
        dockgroup.destroy()
开发者ID:ReadonShaw,项目名称:etk.docking,代码行数:17,代码来源:test_dockgroup.py

示例13: test_get_nth_item

# 需要导入模块: from etk.docking import DockGroup [as 别名]
# 或者: from etk.docking.DockGroup import add [as 别名]
    def test_get_nth_item(self):
        dockitem1 = DockItem()
        dockitem2 = DockItem()
        dockgroup = DockGroup()
        dockgroup.add(dockitem1)
        dockgroup.add(dockitem2)

        self.assertTrue(dockgroup.get_nth_item(0) is dockitem1)
        self.assertTrue(dockgroup.get_nth_item(1) is dockitem2)
        self.assertTrue(dockgroup.get_nth_item(2) is None)
        self.assertTrue(dockgroup.get_nth_item(-1) is None)

        dockitem1.destroy()
        dockitem2.destroy()
        dockgroup.destroy()
开发者ID:ReadonShaw,项目名称:etk.docking,代码行数:17,代码来源:test_dockgroup.py

示例14: test_item_destroy

# 需要导入模块: from etk.docking import DockGroup [as 别名]
# 或者: from etk.docking.DockGroup import add [as 别名]
    def test_item_destroy(self):
        win = gtk.Window()
        dockitem = DockItem()
        dockgroup = DockGroup()
        dockgroup.add(dockitem)
        win.add(dockgroup)
        win.show_all()

        assert len(dockgroup.items) == 1
        dockitem.destroy()

        self.assertTrue(dockitem not in dockgroup)
        assert len(dockgroup.items) == 0

        win.destroy()
        dockgroup.destroy()
开发者ID:ReadonShaw,项目名称:etk.docking,代码行数:18,代码来源:test_dockgroup.py

示例15: test_prev_item

# 需要导入模块: from etk.docking import DockGroup [as 别名]
# 或者: from etk.docking.DockGroup import add [as 别名]
    def test_prev_item(self):
        dockitem1 = DockItem()
        dockitem2 = DockItem()
        dockgroup = DockGroup()
        dockgroup.add(dockitem1)
        dockgroup.add(dockitem2)
        self.assertTrue(dockgroup.get_current_item() == 1)

        dockgroup.prev_item()
        self.assertTrue(dockgroup.get_current_item() == 0)

        dockgroup.prev_item()
        self.assertTrue(dockgroup.get_current_item() == 0)

        dockitem1.destroy()
        dockitem2.destroy()
        dockgroup.destroy()
开发者ID:ReadonShaw,项目名称:etk.docking,代码行数:19,代码来源:test_dockgroup.py


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