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


Python Manager.delete方法代码示例

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


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

示例1: UIResourceList

# 需要导入模块: from pyglet_gui.manager import Manager [as 别名]
# 或者: from pyglet_gui.manager.Manager import delete [as 别名]
class UIResourceList(object):
    def __init__(self, window, batch):
        self.window = window
        self.batch = batch
        self._resource_menu = None

    def render(self):
        self.remove()

        content = Frame(
            Scrollable(
                VerticalContainer(
                    [
                        SectionHeader("Resources"),
                        UIResourceSection("Primary Resources", "primary", is_open=True),
                        UIResourceSection("Processed Material", "processed_material", is_open=False),
                        UIResourceSection("Raw Material", "raw_material", is_open=False),
                        OneTimeButton("Close", self.remove),
                    ],
                    align=HALIGN_LEFT,
                ),
                height=400,
            )
        )

        self._resource_menu = Manager(
            content, window=self.window, batch=self.batch, anchor=ANCHOR_TOP_LEFT, theme=resource_menu_theme
        )

    def remove(self, *args):
        if self._resource_menu:
            self._resource_menu.delete()
开发者ID:JStation,项目名称:omphalos,代码行数:34,代码来源:__init__.py

示例2: VerticalHUD

# 需要导入模块: from pyglet_gui.manager import Manager [as 别名]
# 或者: from pyglet_gui.manager.Manager import delete [as 别名]
class VerticalHUD():
    def __init__(self, window, batch, space, level, height, width):
        self.space = space
        self.level = level
        status_text = pyglet.text.decode_attributed('''
Time: 0 sec \n
Points: 0 points \n
FPS: 00.00 FPS
''')
        self.status_doc = Document(status_text, height=height, width=width)
        status_frame = Frame(self.status_doc)
        inv_text = pyglet.text.decode_html("<h4>Inventory</h4>")
        inventory_header = Document(inv_text, width=width)
        self.inventory_container = VerticalContainer([])

        container = VerticalContainer([inventory_header, self.inventory_container])
        self.inventory_frame = Frame(container)
        container = VerticalContainer([status_frame, self.inventory_frame])
        self.manager = Manager(container, window=window, batch=batch,
                group=RenderingOrder.hud, anchor=ANCHOR_TOP_RIGHT, theme=theme,
                is_movable=False)
        self.window = window
        self.window.push_handlers(on_draw=self.on_draw)
        self.tick = 0
        # Currently disabled
        #self.init_effects(space, level)

    def init_effects(self, space, level):
        pos = (self.inventory_frame.x,
               self.inventory_frame.y + self.inventory_frame.height / 2 - 50)
        self.inventory_effect = Effects.Inventory(space, pos, "Inventory",
                self.inventory_frame.width, self.inventory_frame.height + 100,
                ["H2O(l)", "CH4(g)", "NaCl(s)"], gui_container = self.inventory_container)

    def get_effects(self):
        return []
        #currently disabled
        #return [self.inventory_effect]

    def on_draw(self):
        self.tick += 1
        if self.tick > 30:
            return
        self.tick = 0
        self.update_status()

    def update_status(self):
        level_time = self.window.level.get_time()
        points = self.window.level.get_points()
        status_text = '''
Time: %d sec
Points: %d points
FPS: %.2f FPS
''' % (level_time, points, pyglet.clock.get_fps())
        self.status_doc.set_text(status_text)

    def delete(self):
        self.window.remove_handlers(on_draw = self.on_draw)
        self.manager.delete()
开发者ID:Norberg,项目名称:molecule,代码行数:61,代码来源:HUD.py

示例3: TestContainer

# 需要导入模块: from pyglet_gui.manager import Manager [as 别名]
# 或者: from pyglet_gui.manager.Manager import delete [as 别名]
class TestContainer(TestPygletGUI):
    """
    This test case tests basic functionality of
    a container. We use an empty widgets for this.
    """

    def setUp(self):
        super().setUp()

        self.container = Container([Viewer(width=50, height=50),
                                    Viewer(width=50, height=50)])

        self.manager = Manager(self.container, window=self.window, batch=self.batch, theme=self.theme)

    def test_set_manager(self):
        """
        Tests that the manager is set for every children.
        """
        # manager size is correct
        for item in self.container.content:
            self.assertTrue(item.has_manager())

    def test_deletion(self):
        self.manager.delete()

        # confirm that widget is also deleted
        for item in self.container.content:
            self.assertFalse(item.has_manager())

    def test_add(self):
        """
        Tests that we can add a new item.
        """
        item = Viewer(width=50, height=50)
        self.container.add(item)

        self.assertEqual(item.has_manager(), True)

    def test_remove(self):
        """
        Tests that we can remove a new item.
        """
        item = self.container.content[0]
        self.container.remove(item)

        self.assertEqual(item.has_manager(), False)

    def tearDown(self):
        self.manager.delete()
        super().tearDown()
开发者ID:Norberg,项目名称:pyglet-gui,代码行数:52,代码来源:test_container.py

示例4: GenericButtonTest

# 需要导入模块: from pyglet_gui.manager import Manager [as 别名]
# 或者: from pyglet_gui.manager.Manager import delete [as 别名]
class GenericButtonTest(object):
    def setUp(self):
        self.manager = Manager(self.button, window=self.window, batch=self.batch, theme=self.theme)

    def test_creation(self):
        self.assertNotEqual(self.button.width, 0)
        self.assertNotEqual(self.button.height, 0)
        self.assertEqual(self.button.is_loaded, True)

    def test_press(self):
        self.button.on_mouse_press(0, 0, None, None)
        self.assertEqual(self.button.is_pressed, True)

    def test_delete(self):
        self.manager.delete()
        self.assertEqual(self.button.is_loaded, False)
开发者ID:baccenfutter,项目名称:pyglet-gui,代码行数:18,代码来源:test_button.py

示例5: TestButton

# 需要导入模块: from pyglet_gui.manager import Manager [as 别名]
# 或者: from pyglet_gui.manager.Manager import delete [as 别名]
class TestButton(TestPygletGUI):

    def setUp(self):
        TestPygletGUI.setUp(self)
        self.button = Button(label="test")
        self.manager = Manager(self.button, window=self.window, batch=self.batch, theme=self.theme)

    def test_creation(self):
        self.assertNotEqual(self.button.width, 0)
        self.assertNotEqual(self.button.height, 0)
        self.assertEqual(self.button.is_loaded, True)

    def test_press(self):
        self.button.on_mouse_press(0, 0, None, None)
        self.assertEqual(self.button.is_pressed, True)

    def test_delete(self):
        self.manager.delete()

        self.assertEqual(self.button.is_loaded, False)
开发者ID:eggfu,项目名称:pyglet-gui,代码行数:22,代码来源:test_button.py

示例6: TestSpacer

# 需要导入模块: from pyglet_gui.manager import Manager [as 别名]
# 或者: from pyglet_gui.manager.Manager import delete [as 别名]
class TestSpacer(TestPygletGUI):
    """
    Tests that the spacer is working correctly
    inside containers.
    """
    def setUp(self):
        TestPygletGUI.setUp(self)

        self.widgets = []
        for i in range(2):
            self.widgets.append(Viewer(width=100, height=50))
        for i in range(2):
            self.widgets.append(Viewer(width=20, height=50))

        self.container = VerticalContainer([HorizontalContainer([self.widgets[0],
                                                           self.widgets[1]], padding=0),
                                         HorizontalContainer([Spacer(),
                                                           self.widgets[2],
                                                           Spacer(),
                                                           self.widgets[3],
                                                           Spacer()], padding=0)], padding=0)

        self.manager = Manager(self.container, window=self.window, batch=self.batch, theme=self.theme)

    def test_initial(self):
        self.assertEqual(self.container.width, 200)

        # space left for the spacers occupy:
        width_left = 200 - 40

        # expected spacer size
        spacer_size = int(width_left/3.)

        # Spacers should occupy same space
        self.assertEqual(self.widgets[2].x, self.container.x + spacer_size)
        self.assertEqual(self.widgets[3].x, self.widgets[2].x + self.widgets[2].width + spacer_size)

    def tearDown(self):
        self.manager.delete()
        super(TestSpacer, self).tearDown()
开发者ID:baccenfutter,项目名称:pyglet-gui,代码行数:42,代码来源:test_spacer.py

示例7: TestSlider

# 需要导入模块: from pyglet_gui.manager import Manager [as 别名]
# 或者: from pyglet_gui.manager.Manager import delete [as 别名]
class TestSlider(TestPygletGUI):

    def setUp(self):
        TestPygletGUI.setUp(self)
        self.slider = HorizontalSlider(min_value=0, max_value=10)
        self.manager = Manager(self.slider, window=self.window, batch=self.batch, theme=self.theme)

    def test_set_value(self):
        self.slider.set_knob_pos(0.5)
        self.assertEqual(self.slider.value, 5)

    def test_mouse_slide(self):

        # push the slider to the minimum
        self.slider.on_mouse_press(0, 0, None, None)
        self.assertEqual(self.slider.value, 0)

        # push the slider to the maximum
        self.slider.on_mouse_press(10000, 0, None, None)
        self.assertEqual(self.slider.value, 10)

    def tearDown(self):
        self.manager.delete()
        super(TestSlider, self).tearDown()
开发者ID:baccenfutter,项目名称:pyglet-gui,代码行数:26,代码来源:test_slider.py

示例8: TestInput

# 需要导入模块: from pyglet_gui.manager import Manager [as 别名]
# 或者: from pyglet_gui.manager.Manager import delete [as 别名]
class TestInput(TestPygletGUI):

    def setUp(self):
        TestPygletGUI.setUp(self)
        self.input = TextInput(text="test")
        self.manager = Manager(self.input, window=self.window, batch=self.batch, theme=self.theme)

    def test_focus(self):
        self.input.on_gain_focus()

        self.assertEqual(self.input.is_focus(), True)

        self.input.on_lose_focus()
        self.assertEqual(self.input.is_focus(), False)

    def test_input(self):
        self.assertEqual(self.input.get_text(), "test")
        self.input.on_gain_focus()
        self.input.on_text("text")
        self.assertEqual(self.input.get_text(), "text")  # it starts with all text selected, so 'test' is erased.
        self.input.on_text(" text")
        self.assertEqual(self.input.get_text(), "text text")

    def test_motion(self):
        self.input.on_gain_focus()

        self.input.on_text_motion(pyglet.window.key.MOTION_RIGHT)
        # 'test|' where | is the carret.
        self.assertEqual(self.input.get_text(), "test")

        self.input.on_text_motion(pyglet.window.key.MOTION_BACKSPACE)
        # 'tes|'
        self.assertEqual(self.input.get_text(), "tes")

        self.input.on_text_motion(pyglet.window.key.MOTION_LEFT)
        # 't|es'
        self.input.on_text_motion(pyglet.window.key.MOTION_LEFT)

        self.input.on_text_motion(pyglet.window.key.MOTION_DELETE)
        # 't|s'
        self.assertEqual(self.input.get_text(), "ts")

    def test_delete(self):
        self.manager.delete()

    def test_delete_without_focus(self):
        self.input.on_gain_focus()
        self.input.on_lose_focus()
        self.manager.delete()

    def test_delete_with_focus(self):
        self.input.on_gain_focus()
        self.manager.delete()
开发者ID:baccenfutter,项目名称:pyglet-gui,代码行数:55,代码来源:test_text_input.py

示例9: __init__

# 需要导入模块: from pyglet_gui.manager import Manager [as 别名]
# 或者: from pyglet_gui.manager.Manager import delete [as 别名]
class HorizontalHUD:
    def __init__(self, window, batch, space, level, height, width):
        self.space = space
        self.level = level
        self.height = height
        self.width = width
        progress_text = "Progress: ..."
        self.progress_doc = Document(progress_text, width = width/2)
        objective_doc = Document(level.objective, width = width/2)
        left_frame = Frame(VerticalContainer([objective_doc, None,
            self.progress_doc]), is_expandable = True)
        self.left_container = VerticalContainer([left_frame])
        victory_formula = level.victory_condition[0]
        info_frame = self.create_info_frame(victory_formula)
        self.info_container = VerticalContainer([info_frame])
        container = HorizontalContainer([self.left_container, self.info_container])
        self.manager = Manager(container, window=window, batch=batch,
                group=RenderingOrder.hud, anchor=ANCHOR_BOTTOM_LEFT,
                theme=theme, is_movable=False)
        self.window = window
        self.window.push_handlers(on_draw=self.on_draw)
        self.tick = 0
        self.init_effects(space, level)

    def init_effects(self, space, level):
        pos = (self.left_container.x + self.left_container.width / 2,
               self.left_container.y + self.left_container.height / 2 - 50)
        self.victory = Effects.VictoryInventory(space, pos, "Victory Inventory",
                self.left_container.width, self.left_container.height + 100,
                level.victory_condition)

    def get_effects(self):
        return [self.victory]

    def update_info_text(self, formula):
        info_frame = self.create_info_frame(formula)
        for content in self.info_container.content:
            self.info_container.remove(content)
        self.info_container.add(info_frame)

    def create_info_frame(self, formula):
        cml = CachedCml.getMolecule(formula)
        info_text = pyglet.text.decode_html("<b>%s</b><br> %s" %
                ( cml.property.get("Name", "Undefined"),
                  cml.property.get("Description", "No Description Available")
                ))
        info_doc = Document(info_text, height=self.height, width=self.width/2,
                is_fixed_size = True)
        info_frame = Frame(info_doc)
        return info_frame


    def on_draw(self):
        self.tick += 1
        if self.tick > 30:
            return
        self.tick = 0
        self.update_progress()

    def update_progress(self):
        progress_text = self.victory.progress_text()
        self.progress_doc.set_text("Progress: " + progress_text)

    def delete(self):
        self.window.remove_handlers(on_draw = self.on_draw)
        self.manager.delete()
开发者ID:Norberg,项目名称:molecule,代码行数:68,代码来源:HUD.py

示例10: TestGridContainer

# 需要导入模块: from pyglet_gui.manager import Manager [as 别名]
# 或者: from pyglet_gui.manager.Manager import delete [as 别名]
class TestGridContainer(TestPygletGUI):
    """
    This test case tests basic functionality of
    a grid container.
    """

    def setUp(self):
        super().setUp()

        self.container = GridContainer([[Viewer(width=50, height=50), Viewer(width=50, height=50)],
                                     [Viewer(width=50, height=50), Viewer(width=50, height=50)]])

        self.manager = Manager(self.container, window=self.window, batch=self.batch, theme=self.theme)

    def test_top_down_draw(self):
        """
        Tests that the container's size was set correctly
        and the positions of its content is correct.
        """
        # manager size is correct
        self.assertEqual(self.container.width, 100 + self.container.padding)
        self.assertEqual(self.container.height, 100 + self.container.padding)

        # widget is centered in the window
        self.assertEqual(self.container.x, self.window.width // 2 - self.container.width // 2)
        self.assertEqual(self.container.y, self.window.height // 2 - self.container.height // 2)

    def test_bottom_up_draw(self):
        """
        Tests that the manager's size is modified
        if we set a new size to the widget.
        """
        self.container.content[0][0].width = 60
        self.container.content[0][0].height = 60
        self.container.content[0][0].parent.reset_size()

        # container width was set
        self.assertEqual(self.container.width, 110 + self.container.padding)
        # container height was set
        self.assertEqual(self.container.height, 110 + self.container.padding)

        # container was re-centered in the window
        self.assertEqual(self.container.x, self.window.width // 2 - self.container.width // 2)
        self.assertEqual(self.container.y, self.window.height // 2 - self.container.height // 2)

    def test_add_row(self):
        """
        Tests that if we add a row with 3 columns,
        we have the correct sizes.
        """
        self.container.add_row([Viewer(width=50, height=50),
                                Viewer(width=50, height=50),
                                Viewer(width=50, height=50)])

        self.assertEqual(self.container.width, 150 + 2 * self.container.padding)
        self.assertEqual(self.container.height, 150 + 2 * self.container.padding)

    def test_add_column(self):
        """
        Tests that if we add a column with 3 rows,
        we have the correct sizes.
        """
        self.container.add_column([Viewer(width=50, height=50),
                                   Viewer(width=50, height=50),
                                   Viewer(width=50, height=50)])

        self.assertEqual(self.container.width, 150 + 2 * self.container.padding)
        self.assertEqual(self.container.height, 150 + 2 * self.container.padding)

    def test_substitute_element(self):
        self.container.set(1, 1, Viewer(width=100, height=50))

        self.assertEqual(self.container.width, 150 + self.container.padding)
        self.assertEqual(self.container.height, 100 + self.container.padding)

    def tearDown(self):
        self.manager.delete()
        super().tearDown()
开发者ID:Norberg,项目名称:pyglet-gui,代码行数:80,代码来源:test_grid_container.py

示例11: TestDialog

# 需要导入模块: from pyglet_gui.manager import Manager [as 别名]
# 或者: from pyglet_gui.manager.Manager import delete [as 别名]

#.........这里部分代码省略.........
        """
        # manager size is correct
        self.assertEqual(self.manager.width, 50)
        self.assertEqual(self.manager.height, 50)

        # widget is centered in the window
        self.assertEqual(self.widget.x, self.window.width/2 - self.widget.width/2)
        self.assertEqual(self.widget.y, self.window.height/2 - self.widget.height/2)

    def test_bottom_up_draw(self):
        """
        Tests that the manager's size is modified
        if we set a new size to the widget.
        """
        self.widget.width = 60
        self.widget.parent.reset_size()

        # manager size was reset
        self.assertEqual(self.manager.width, self.widget.width)

        # widget and manager were re-centered in the window
        self.assertEqual(self.widget.x, self.window.width/2 - self.widget.width/2)
        self.assertEqual(self.manager.x, self.window.width/2 - self.manager.width/2)

    def test_substitute_widget(self):
        """
        Tests substitution of manager's content
        by other widget.
        """
        self.new_widget = Viewer(width=60, height=50)

        self.manager.content = self.new_widget

        self.assertTrue(not self.widget.has_manager())
        self.assertFalse(self.widget.is_loaded)

        self.assertTrue(self.new_widget.has_manager())
        self.assertTrue(self.new_widget.is_loaded)

        # manager size was reset, new widget position is correct
        self.assertEqual(self.manager.width, self.new_widget.width)
        self.assertEqual(self.new_widget.x, self.window.width/2 - self.new_widget.width/2)

    def test_window_resize(self):
        self.window.width = 100
        self.manager.on_resize(self.window.width, self.window.height)

        # manager size didn't changed.
        self.assertEqual(self.manager.width, 50)

        # manager is still centered.
        self.assertEqual(self.manager.x, self.window.width/2 - self.manager.width/2)

    def test_change_offset(self):
        self.manager.offset = (10, 0)

        # manager is centered with an offset.
        self.assertEqual(self.manager.x - 10, self.window.width/2 - self.manager.width/2)

    def test_change_anchor(self):
        self.manager.anchor = pyglet_gui.constants.ANCHOR_TOP_LEFT

        # manager is in correct position.
        self.assertEqual(self.manager.x, 0)

    def test_new_manager_is_on_top(self):
        other_manager = Manager(Viewer(width=50, height=50), window=self.window,
                              batch=self.batch,
                              theme=self.theme)

        # confirm that a new manager starts always on top
        self.assertTrue(other_manager.root_group.is_on_top())

    def test_new_manager_without_window(self):
        other_manager = Manager(Viewer(width=50, height=50),
                              batch=self.batch,
                              theme=self.theme)

        # confirm that a new manager without window starts
        # with no size
        self.assertTrue(other_manager.width, 0)

        # change the manager's window
        other_manager.window = self.window

        # confirm it has a size.
        self.assertEqual(self.manager.width, 50)

        # confirm it is in the correct position
        self.assertEqual(self.manager.x, self.window.width/2 - self.manager.width/2)

    def test_deletion(self):
        self.manager.delete()

        # confirm that widget is also deleted
        self.assertTrue(not self.widget.has_manager())

    def tearDown(self):
        self.manager.delete()
        super(TestDialog, self).tearDown()
开发者ID:baccenfutter,项目名称:pyglet-gui,代码行数:104,代码来源:test_dialog.py

示例12: TestVerticalContainer

# 需要导入模块: from pyglet_gui.manager import Manager [as 别名]
# 或者: from pyglet_gui.manager.Manager import delete [as 别名]
class TestVerticalContainer(TestPygletGUI):
    """
    This test case tests basic functionality of
    a vertical container.
    """

    def setUp(self):
        super(TestVerticalContainer, self).setUp()

        self.container = VerticalContainer([Viewer(width=50, height=50),
                                         Viewer(width=50, height=50)])

        self.manager = Manager(self.container, window=self.window, batch=self.batch, theme=self.theme)

    def _test_content_position(self):
        """
        Tests the position of the two widgets within the container.
        """
        # first widget y is the top y (container.y + container.height) minus its size (container.content[0].height)
        self.assertEqual(self.container.content[0].y,
                         self.container.y + self.container.height - self.container.content[0].height)

        # second widget y is the top y (container.y + container.height - container.content[0].height) minus its size
        # (container.content[1].height) minus the padding (self.container.padding)
        self.assertEqual(self.container.content[1].y,
                         self.container.y + self.container.height
                         - self.container.content[0].height - self.container.content[1].height
                         - self.container.padding)

    def test_top_down_draw(self):
        """
        Tests that the container's size was set correctly
        and the positions of its content is correct.
        """
        # manager size is correct
        self.assertEqual(self.container.width, 50)
        self.assertEqual(self.container.height, 100 + self.container.padding)

        # widget is centered in the window
        self.assertEqual(self.container.x, self.window.width // 2 - self.container.width // 2)
        self.assertEqual(self.container.y, self.window.height // 2 - self.container.height // 2)

        self._test_content_position()

    def test_bottom_up_draw(self):
        """
        Tests that the manager's size is modified
        if we set a new size to the widget.
        """
        self.container.content[0].width = 60
        self.container.content[0].height = 60
        self.container.content[0].parent.reset_size()

        # container width was set
        self.assertEqual(self.container.width, 60)
        # container height was set
        self.assertEqual(self.container.height, 110 + self.container.padding)

        # container was re-centered in the window
        self.assertEqual(self.container.x, self.window.width // 2 - self.container.width // 2)
        self.assertEqual(self.container.y, self.window.height // 2 - self.container.height // 2)

        self._test_content_position()

    def test_add_widget(self):
        self.container.add(Viewer(width=50, height=50))

        self.assertEqual(self.manager.width, 50)
        self.assertEqual(self.manager.height, 150 + 2 * self.container.padding)

        self._test_content_position()

    def test_remove_widget(self):
        self.container.remove(self.container.content[0])

        self.assertEqual(self.manager.width, 50)
        self.assertEqual(self.manager.height, 50 + self.container.padding)

    def tearDown(self):
        self.manager.delete()
        super(TestVerticalContainer, self).tearDown()
开发者ID:baccenfutter,项目名称:pyglet-gui,代码行数:83,代码来源:test_vertical_container.py

示例13: TestHorizontalContainer

# 需要导入模块: from pyglet_gui.manager import Manager [as 别名]
# 或者: from pyglet_gui.manager.Manager import delete [as 别名]
class TestHorizontalContainer(TestPygletGUI):
    """
    This test case tests basic functionality of
    an horizontal container.
    """

    def setUp(self):
        super().setUp()

        self.container = HorizontalContainer([Viewer(width=50, height=50),
                                           Viewer(width=50, height=50)])

        self.manager = Manager(self.container, window=self.window, batch=self.batch, theme=self.theme)

    def _test_content_position(self):
        """
        Tests the position of the two widgets within the container.
        """
        # first widget x is the left x (container.x)
        self.assertEqual(self.container.content[0].x,
                         self.container.x)

        # second widget x is the left x (container.x + container.content[0].width)
        # plus the padding (self.container.padding)
        self.assertEqual(self.container.content[1].x,
                         self.container.x + self.container.content[0].width
                         + self.container.padding)

    def test_top_down_draw(self):
        """
        Tests that the manager's size was set according to the child size.
        """
        # manager size is correct
        self.assertEqual(self.manager.width, 100 + self.container.padding)
        self.assertEqual(self.manager.height, 50)

        # widget is centered in the window
        self.assertEqual(self.container.x, self.window.width/2 - self.container.width/2)
        self.assertEqual(self.container.y, self.window.height/2 - self.container.height/2)

        self._test_content_position()

    def test_bottom_up_draw(self):
        """
        Tests that the manager's size is modified
        if we set a new size to the widget.
        """
        self.container.content[0].width = 60
        self.container.content[0].height = 60
        self.container.content[0].parent.reset_size()

        # manager width was set
        self.assertEqual(self.manager.width, 110 + self.container.padding)
        # container height was set
        self.assertEqual(self.container.height, 60)

        # container and manager were re-centered in the window
        self.assertEqual(self.container.x, self.window.width/2 - self.container.width/2)
        self.assertEqual(self.manager.y, self.window.height/2 - self.manager.height/2)

        self._test_content_position()

    def test_add_widget(self):
        self.container.add(Viewer(width=50, height=50))

        self.assertEqual(self.manager.width, 150 + 2*self.container.padding)
        self.assertEqual(self.manager.height, 50)

        self._test_content_position()

    def test_remove_widget(self):
        self.container.remove(self.container.content[0])

        self.assertEqual(self.manager.width, 50 + self.container.padding)
        self.assertEqual(self.manager.height, 50)

    def tearDown(self):
        self.manager.delete()
        super().tearDown()
开发者ID:tredfern,项目名称:pyglet-gui,代码行数:81,代码来源:test_horizontal_container.py


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