本文整理汇总了Python中pyglet_gui.core.Viewer.has_manager方法的典型用法代码示例。如果您正苦于以下问题:Python Viewer.has_manager方法的具体用法?Python Viewer.has_manager怎么用?Python Viewer.has_manager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyglet_gui.core.Viewer
的用法示例。
在下文中一共展示了Viewer.has_manager方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_add
# 需要导入模块: from pyglet_gui.core import Viewer [as 别名]
# 或者: from pyglet_gui.core.Viewer import has_manager [as 别名]
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)
示例2: TestDialog
# 需要导入模块: from pyglet_gui.core import Viewer [as 别名]
# 或者: from pyglet_gui.core.Viewer import has_manager [as 别名]
class TestDialog(TestPygletGUI):
"""
This test case tests basic functionality of
widget+manager. We use an empty widget for this.
"""
def setUp(self):
super(TestDialog, self).setUp()
self.widget = Viewer(width=50, height=50)
self.manager = Manager(self.widget, window=self.window, batch=self.batch, theme=self.theme)
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, 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
#.........这里部分代码省略.........