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


Python widgets.Control类代码示例

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


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

示例1: size

 def size(self, dialog):
     """
     Creates slider components.
     """
     if dialog is None:
         return
     Control.size(self, dialog)
     if self.is_disabled():
         color = dialog.theme['slider']['disabled_color']
     else:
         color = dialog.theme['slider']['gui_color']
     if self.bar is None:
         path = self.IMAGE_BAR
         self.bar = dialog.theme[path]['image'].generate(
             color,
             dialog.batch, dialog.bg_group)
         self.padding = dialog.theme[path]['padding']
     if self.knob is None:
         path = self.IMAGE_KNOB
         self.knob = dialog.theme[path]['image'].generate(
             color,
             dialog.batch, dialog.highlight_group)
         self.offset = dialog.theme[path]['offset']
     if not self.markers and self.steps is not None:
         path = self.IMAGE_STEP
         for n in xrange(0, self.steps + 1):
             self.markers.append(
                 dialog.theme[path]['image'].generate(
                     color,
                     dialog.batch, dialog.fg_group))
         self.step_offset = dialog.theme[path]['offset']
     width, height = self.bar.get_needed_size(self.min_width, 0)
     left, right, top, bottom = self.padding
     self.width = width + left + right
     self.height = height + top + bottom
开发者ID:AngelFishy,项目名称:Kytten,代码行数:35,代码来源:slider.py

示例2: __init__

    def __init__(self, value=0.0, min_value=0.0, max_value=1.0, steps=None,
                 width=100, id=None, on_set=None, disabled=False):
        """
        Creates a new slider.

        @param min_value Minimum value
        @param max_value Maximum value
        @param steps None if this slider should cover the range from 0.0 to
                     1.0 smoothly, otherwise we will divide the range
                     up into steps.  For instance, 2 steps would give the
                     possible values 0, 0.5, and 1.0 (then multiplied by scale)
        @param width Minimum width of the tracking area.  Note that this
                     is the interior length of the slider, not the overall
                     size.
        @param id ID for identifying this slider.
        @param on_set Callback function for when the value of this slider
                      changes.
        @param diasbled True if the slider should be disabled
        """
        Control.__init__(self, id=id, disabled=disabled)
        self.min_value = min_value
        self.max_value = max_value
        self.steps = steps
        self.min_width = width
        self.on_set = on_set
        self.bar = None
        self.knob = None
        self.markers = []
        self.pos = max(
            min(float(value - min_value) / (max_value - min_value), 1.0),
            0.0)
        self.offset = (0, 0)
        self.step_offset = (0, 0)
        self.padding = (0, 0, 0, 0)
        self.is_dragging = False
开发者ID:AngelFishy,项目名称:Kytten,代码行数:35,代码来源:slider.py

示例3: __init__

    def __init__(self, text="", is_checked=False, id=None,
                 align=HALIGN_RIGHT, padding=4, on_click=None,
                 disabled=False):
        """
        Creates a new checkbox.  The provided text will be used to caption the
        checkbox.

        @param text Label for the checkbox
        @param is_checked True if we should start checked
        @param id ID for value
        @param align HALIGN_RIGHT if label should be right of checkbox,
                     HALIGN_LEFT if label should be left of checkbox
        @param padding Space between checkbox and label
        @param on_click Callback for the checkbox
        @param disabled True if the checkbox should be disabled
        """
        assert align in [HALIGN_LEFT, HALIGN_RIGHT]
        Control.__init__(self, id=id, disabled=disabled)
        self.text = text
        self.is_checked = is_checked
        self.align = align
        self.padding = padding
        self.on_click = on_click
        self.label = None
        self.checkbox = None
        self.highlight = None
开发者ID:chrisbiggar,项目名称:sidescrolltesting,代码行数:26,代码来源:checkbox.py

示例4: size

    def size(self, dialog):
        if dialog is None:
            return

        Control.size(self, dialog)
        if not self.set_document_style:
            self.do_set_document_style(dialog)
        if self.content is None:
            self.content = pyglet.text.layout.IncrementalTextLayout(
                self.document,
                self.content_width,
                self.max_height,
                multiline=True, batch=dialog.batch, group=dialog.fg_group)
            if self.is_fixed_size or (self.max_height and
                self.content.content_height > self.max_height):
                self.height = self.max_height
            else:
                self.height = self.content.content_height
            self.content.height = self.height
        if self.always_show_scrollbar or \
           (self.max_height and self.content.content_height > self.max_height):
            if self.scrollbar is None:
                self.scrollbar = VScrollbar(self.max_height)
            self.scrollbar.size(dialog)
            self.scrollbar.set(self.max_height, self.content.content_height)
        if self.scrollbar is not None:
            self.width = self.content_width + self.scrollbar.width
        else:
            self.width = self.content_width
开发者ID:AngelFishy,项目名称:Kytten,代码行数:29,代码来源:document.py

示例5: __init__

    def __init__(self, title, content=None, is_open=True, align=HALIGN_CENTER):
        Control.__init__(self)
        if align == HALIGN_LEFT:
            left_expand = False
            right_expand = True
        elif align == HALIGN_CENTER:
            left_expand = True
            right_expand = True
        else:  # HALIGN_RIGHT
            left_expand = True
            right_expand = False

        self.is_open = is_open
        self.folding_content = content
        self.book = Graphic(self._get_image_path())

        self.header = HorizontalLayout([
            Graphic(path=["section", "left"], is_expandable=left_expand),
            Frame(HorizontalLayout([
                      self.book,
                      Label(title, path=["section"]),
                  ]), path=["section", "center"],
                  use_bg_group=True),
            Graphic(path=["section", "right"], is_expandable=right_expand),
            ], align=VALIGN_BOTTOM, padding=0)
        layout = [self.header]
        if self.is_open:
            layout.append(content)

        VerticalLayout.__init__(self, content=layout, align=align)
开发者ID:chrisbiggar,项目名称:shiny-light,代码行数:30,代码来源:frame.py

示例6: __init__

    def __init__(self, width):
        """
        Creates a new scrollbar.

        @param width Width of the area for which we are a scrollbar
        """
        Control.__init__(self, width=width, height=0)
        self.__init2__(width)
开发者ID:AngelFishy,项目名称:Kytten,代码行数:8,代码来源:scrollbar.py

示例7: __init__

 def __init__(self, text="", anchor=ANCHOR_CENTER, menu=None,
              disabled=False):
     Control.__init__(self, disabled=disabled)
     self.text = text
     self.anchor = anchor
     self.menu = menu
     self.label = None
     self.background = None
     self.highlight = None
     self.is_selected = False
开发者ID:isS,项目名称:sy-game,代码行数:10,代码来源:menu.py

示例8: layout

    def layout(self, x, y):
        Control.layout(self, x, y)

        self.field.update(x, y, self.width, self.height)
        x, y, width, height = self.field.get_content_region()

        font = self.label.document.get_font()
        height = font.ascent - font.descent
        self.label.x = x
        self.label.y = y - font.descent
开发者ID:isS,项目名称:sy-game,代码行数:10,代码来源:menu.py

示例9: on_lose_focus

 def on_lose_focus(self):
     Control.on_lose_focus(self)
     self.delete()
     if self.saved_dialog is not None:
         self.size(self.saved_dialog)
         self.layout(self.x, self.y)
     if self.on_input is not None:
         if self.id is not None:
             self.on_input(self.id, self.get_text())
         else:
             self.on_input(self.get_text())
开发者ID:chrisbiggar,项目名称:micropylis,代码行数:11,代码来源:text_input.py

示例10: __init__

    def __init__(self):
        """
        Creates a new event manager for a dialog.

        @param content The Widget which we wrap
        """
        Control.__init__(self)
        self.controls = []
        self.control_areas = {}
        self.control_map = {}
        self.hover = None
        self.focus = None
        self.wheel_hint = None
        self.wheel_target = None
开发者ID:constantinius,项目名称:YaaGame,代码行数:14,代码来源:dialog.py

示例11: delete

 def delete(self):
     """
     Clean up our graphic elements
     """
     Control.delete(self)
     if self.checkbox is not None:
         self.checkbox.delete()
         self.checkbox = None
     if self.label is not None:
         self.label.delete()
         self.label = None
     if self.highlight is not None:
         self.highlight.delete()
         self.highlight = None
开发者ID:chrisbiggar,项目名称:sidescrolltesting,代码行数:14,代码来源:checkbox.py

示例12: delete

 def delete(self):
     """
     Clean up our graphic elements
     """
     Control.delete(self)
     if self.button is not None:
         self.button.delete()
         self.button = None
     if self.label is not None:
         self.label.delete()
         self.label = None
     if self.highlight is not None:
         self.highlight.delete()
         self.highlight = None
开发者ID:AngelFishy,项目名称:Kytten,代码行数:14,代码来源:button.py

示例13: layout

    def layout(self, x, y):
        """
        Places the Button.

        @param x X coordinate of lower left corner
        @param y Y coordinate of lower left corner
        """
        Control.layout(self, x, y)
        self.button.update(self.x, self.y, self.width, self.height)
        if self.highlight is not None:
            self.highlight.update(self.x, self.y, self.width, self.height)
        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
开发者ID:AngelFishy,项目名称:Kytten,代码行数:15,代码来源:button.py

示例14: __init__

 def __init__(self, id=None, text="", length=20, max_length=None, padding=0,
              on_input=None, disabled=False):
     Control.__init__(self, id=id, disabled=disabled)
     self.text = text
     self.length = length
     self.max_length = max_length
     self.padding = padding
     self.on_input = on_input
     self.document = pyglet.text.document.UnformattedDocument(text)
     self.document_style_set = False
     self.text_layout = None
     self.label = None
     self.caret = None
     self.field = None
     self.highlight = None
开发者ID:isS,项目名称:sy-game,代码行数:15,代码来源:text_input.py

示例15: __init__

    def __init__(self, text="", id=None, on_click=None, disabled=False):
        """
        Creates a new Button.  The provided text will be used to caption the
        button.

        @param text Label for the button
        @param on_click Callback for the button
        @param disabled True if the button should be disabled
        """
        Control.__init__(self, id=id, disabled=disabled)
        self.text = text
        self.on_click = on_click
        self.label = None
        self.button = None
        self.highlight = None
        self.is_pressed = False
开发者ID:AngelFishy,项目名称:Kytten,代码行数:16,代码来源:button.py


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