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


Python core.Viewer类代码示例

本文整理汇总了Python中pyglet_gui.core.Viewer的典型用法代码示例。如果您正苦于以下问题:Python Viewer类的具体用法?Python Viewer怎么用?Python Viewer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_add

    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)
开发者ID:Norberg,项目名称:pyglet-gui,代码行数:8,代码来源:test_container.py

示例2: __init__

    def __init__(self, label="", is_pressed=False, on_press=None):
        TwoStateController.__init__(self, is_pressed=is_pressed, on_press=on_press)
        Viewer.__init__(self)

        self.label = label

        # graphics
        self._label = None
        self._button = None
开发者ID:eggfu,项目名称:pyglet-gui,代码行数:9,代码来源:buttons.py

示例3: __init__

 def __init__(self, text="", bold=False, italic=False,
              font_name=None, font_size=None, color=None, path=None):
     Viewer.__init__(self)
     self.text = text
     self.bold = bold
     self.italic = italic
     self.font_name = font_name
     self.font_size = font_size
     self.color = color
     self.path = path
     self.label = None
开发者ID:JStation,项目名称:omphalos,代码行数:11,代码来源:gui.py

示例4: __init__

    def __init__(self, label="", is_pressed=False, on_press=None):
        TwoStateController.__init__(self, is_pressed=is_pressed, on_press=on_press)
        Viewer.__init__(self)
        if isinstance(label, str):
            self._document = pyglet.text.document.UnformattedDocument(label)
        else:
            self._document = label

        # graphics
        self._label = None
        self._button = None
开发者ID:Norberg,项目名称:pyglet-gui,代码行数:11,代码来源:buttons.py

示例5: layout

    def layout(self):
        Viewer.layout(self)
        # lays out graphics
        self._button.update(self.x, self.y, self.width, self.height)

        # centers the label on the middle of the button
        x, y, width, height = self._button.get_content_region()

        font = self._label.document.get_font()
        self._label.x = x + width/2 - self._label.content_width/2
        self._label.y = y + height/2 - font.ascent/2 - font.descent
        self._label.update()
开发者ID:eggfu,项目名称:pyglet-gui,代码行数:12,代码来源:buttons.py

示例6: __init__

    def __init__(self, document, width=0, height=0, is_fixed_size=False):
        Viewer.__init__(self, width, height)
        Controller.__init__(self)

        self.max_height = height
        if isinstance(document, str):
            self._document = pyglet.text.document.UnformattedDocument(document)
        else:
            self._document = document
        self._content = None
        self.content_width = width
        self._scrollbar = None
        self.set_document_style = False
        self.is_fixed_size = is_fixed_size
开发者ID:eggfu,项目名称:pyglet-gui,代码行数:14,代码来源:document.py

示例7: __init__

    def __init__(self, value=0.0, min_value=0.0, max_value=1.0, on_set=None, steps=None, width=0, height=0):
        ContinuousStateController.__init__(self, value=value,
                                           min_value=min_value,
                                           max_value=max_value,
                                           on_set=on_set)
        Viewer.__init__(self, width, height)

        self._bar = None    # a bar where the knob slides.
        self._knob = None   # the knob that moves along the bar.
        self._offset = (0, 0)  # offset of the knob image to its central position
        self._padding = (0, 0, 0, 0)  # padding of the bar image to its central position

        self.steps = steps
        self._markers = []  # markers in case of discrete steps.
        self._step_offset = (0, 0)
开发者ID:eggfu,项目名称:pyglet-gui,代码行数:15,代码来源:sliders.py

示例8: layout

    def layout(self):
        Viewer.layout(self)
        self._field.update(self.x, self.y, self.width, self.height)

        x, y, width, height = self._field.get_content_region()
        if self.is_focus():
            self._text_layout.begin_update()
            self._text_layout.x = self.x + self._padding
            self._text_layout.y = self.y - self._padding
            self._text_layout.end_update()
        else:
            # Adjust the text for font's descent
            descent = self._document.get_font().descent
            self._label.begin_update()
            self._label.x = self.x + self._padding
            self._label.y = self.y + self._padding - descent
            self._label.width = width - self._padding * 2
            self._label.end_update()
开发者ID:Norberg,项目名称:pyglet-gui,代码行数:18,代码来源:text_input.py

示例9: __init__

    def __init__(self, text="", length=20, max_length=None, padding=0, on_input=None):
        Viewer.__init__(self)
        FocusMixin.__init__(self)

        self._document = pyglet.text.document.UnformattedDocument(text)
        self._document_style_set = False  # check if style of document was set.

        self._length = length  # the length of the box in characters
        self._max_length = max_length  # the max length allowed for writing.
        self._on_input = on_input

        self._padding = 4 + padding

        # graphics loaded in both states
        self._field = None

        # graphics loaded in state "writing"
        self._text_layout = None
        self._caret = None

        # graphics loaded in state "label"
        self._label = None
开发者ID:Norberg,项目名称:pyglet-gui,代码行数:22,代码来源:text_input.py

示例10: test_substitute_widget

    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)
开发者ID:baccenfutter,项目名称:pyglet-gui,代码行数:18,代码来源:test_dialog.py

示例11: set_manager

 def set_manager(self, manager):
     Viewer.set_manager(self, manager)
     for item in self._content:
         item.set_manager(self._manager)
         item.parent = self
开发者ID:Norberg,项目名称:pyglet-gui,代码行数:5,代码来源:containers.py

示例12: TestDialog

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
#.........这里部分代码省略.........
开发者ID:baccenfutter,项目名称:pyglet-gui,代码行数:101,代码来源:test_dialog.py

示例13: __init__

 def __init__(self):
     Viewer.__init__(self)
     Controller.__init__(self)
     self._highlight = None
     self._highlight_flag = False
开发者ID:JStation,项目名称:omphalos,代码行数:5,代码来源:mixins.py

示例14: setUp

    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)
开发者ID:baccenfutter,项目名称:pyglet-gui,代码行数:5,代码来源:test_dialog.py

示例15: delete

 def delete(self):
     for item in self._content:
         item.delete()
     self._content = []
     Viewer.delete(self)
开发者ID:Norberg,项目名称:pyglet-gui,代码行数:5,代码来源:containers.py


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