本文整理匯總了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
#.........這裏部分代碼省略.........