示例#1
0
文件: image.py 项目: saebyn/nwgui
    def __init__(self, image, width, height, *args, **kwargs):
        Widget.__init__(self, width, height, *args, **kwargs)

        if image is None:
            self.image = pygame.Surface((0, 0))
        else:
            self.setImage(image)
示例#2
0
文件: container.py 项目: saebyn/nwgui
    def __init__(self, width, height, *args, **kwargs):
        self.image = pygame.Surface((width, height))
        Widget.__init__(self, width, height, *args, **kwargs)

        if 'background' in kwargs:
            background = kwargs['background']
        else:
            background = (255, 255, 255)

        if 'border' in kwargs:
            border = kwargs['border']
        else:
            border = None

        self.image.fill(background)

        if border is not None:
            pygame.draw.rect(self.image, border[1], self.rect, border[0])

        self.widgets = []

        initialWidgets = kwargs.pop('contents', [])
        for widget in initialWidgets:
            if type(widget) == type([]):
                self.add(*widget)
            else:
                self.add(widget)
示例#3
0
文件: label.py 项目: saebyn/nwgui
    def __init__(self, text, color=(0, 0, 0), background=(255, 255, 255),
                       padding=(0, 0), width=None, height=None, **kwargs):
        Widget.__init__(self, 1, 1, **kwargs)

        self.color = color
        self.background = background
        self.text = text
        self.padding = padding
        self.width = width
        self.height = height
        self._render()
        self._dirty = False
示例#4
0
文件: container.py 项目: saebyn/nwgui
    def moveToBack(self):
        # move all child widgets to their appropriate layers in front of self
        widgets = self._getWidgetsByLayer()
        layers = widgets.keys()
        # sort the keys so that we proceed from highest layer to lowest
        layers.sort(reverse=True)
        for layer in layers:
            # move this first widget to the back
            firstWidget = widgets[layer][0]
            firstWidget.moveToBack()

            # move the remaining widgets in this layer to the same layer
            for widget in widgets[layer][1:]:
                widget.changeLayer(firstWidget.layer)

        Widget.moveToBack(self)
示例#5
0
    def __init__(self, width, *args, **kwargs):
        root = kwargs.get('root')
        # _progress ranges from 0 to width
        self._progress = 0
        self._width = width

        # this is the number of pixels to adjust per progress % point
        self._progressPixelStep = width / 100.0

        self._baseImage = root.getGameObject() \
                              .getSpriteSource('gui') \
                              .get(self.PROGRESS_SPRITE)

        self._prepImage()

        Widget.__init__(self, width, self.image.get_height(),
                        *args, **kwargs)
示例#6
0
文件: button.py 项目: saebyn/nwgui
 def __init__(self, callback, *args, **kwargs):
     Widget.__init__(self, *args, **kwargs)
     BaseButton.__init__(self, callback)
示例#7
0
文件: container.py 项目: saebyn/nwgui
 def changeLayer(self, layer):
     Widget.changeLayer(self, layer)
     for widget in self.widgets:
         widget.updateLayer()
示例#8
0
文件: container.py 项目: saebyn/nwgui
    def kill(self):
        for widget in self.widgets:
            widget.kill()

        Widget.kill(self)
示例#9
0
文件: container.py 项目: saebyn/nwgui
    def hide(self):
        Widget.hide(self)

        for widget in self.widgets:
            widget.hide()
示例#10
0
文件: container.py 项目: saebyn/nwgui
    def show(self):
        Widget.show(self)

        for widget in self.widgets:
            widget.show()
示例#11
0
文件: container.py 项目: saebyn/nwgui
 def updateLayer(self):
     Widget.updateLayer(self)
     for widget in self.widgets:
         widget.updateLayer()
示例#12
0
文件: label.py 项目: saebyn/nwgui
    def update(self, *args):
        Widget.update(self, *args)

        if self._dirty:
            self._render()
            self._dirty = False
示例#13
0
文件: image.py 项目: saebyn/nwgui
    def __init__(self, sheetName, *args, **kwargs):
        root = kwargs.get('root')
        self.image = root.getGameObject().getSpriteSource('gui').get(sheetName)

        Widget.__init__(self, self.image.get_width(), self.image.get_height(),
                        *args, **kwargs)