예제 #1
0
class TextButton(Button):
	""" A button Widget with a Label.
	
	:param sprite: The sprite that will be used as the base of the widget.
	:param over: The sprite that will be used on top of the base when the button is selected.
	:type sprite: string or |KX_GameObject|
	:type over: string, |KX_GameObject| or None
	
	:param string font: The font of the label.
	:param string text: The text of the label.
	:param integer size: The size of the label.
	:param align: The alignation of the text in the label.
	:type align: :ref:`align-constant`
	
	.. attribute:: label
	
		Reference to the Label of this TextButton
	
	"""

	def __init__(self, sprite, over, font, text, size = 16, align = 0):
		super().__init__(sprite, over)
		
		sc = self.scale
		self.scale = [1,1,1]
		rt = self.rotation
		self.rotation = [0,0,0]
		
		self.label = Label(font, text, size, align, self.obj.worldPosition)
		self.label.position.z += 0.05
		self.label.middle_height = True
		font = self.label.font
		self.transformable.append(self.label)
		
		self.scale = sc
		self.rotation = rt
		
	def enable(self):
		""" It enables the button events. (Enabled by default) """
		super().enable()
		self.label.visible = True

	def disable(self):
		""" It disables the button events. """
		super().disable()
		self.label.visible = False
	
	def delete(self):
		""" Deletes the button """
		self.label.delete()
		super().delete()
예제 #2
0
class TextButton(Button):
    """ A button Widget with a Label.
	
	:param sprite: The sprite that will be used as the base of the widget.
	:param over: The sprite that will be used on top of the base when the button is selected.
	:type sprite: string or |KX_GameObject|
	:type over: string, |KX_GameObject| or None
	
	:param string font: The font of the label.
	:param string text: The text of the label.
	:param integer size: The size of the label.
	:param align: The alignation of the text in the label.
	:type align: :ref:`align-constant`
	
	.. attribute:: label
	
		Reference to the Label of this TextButton
	
	"""
    def __init__(self, sprite, over, font, text, size=16, align=0):
        super().__init__(sprite, over)

        sc = self.scale
        self.scale = [1, 1, 1]
        rt = self.rotation
        self.rotation = [0, 0, 0]

        self.label = Label(font, text, size, align, self.obj.worldPosition)
        self.label.position.z += 0.05
        self.label.middle_height = True
        font = self.label.font
        self.transformable.append(self.label)

        self.scale = sc
        self.rotation = rt

    def enable(self):
        """ It enables the button events. (Enabled by default) """
        super().enable()
        self.label.visible = True

    def disable(self):
        """ It disables the button events. """
        super().disable()
        self.label.visible = False

    def delete(self):
        """ Deletes the button """
        self.label.delete()
        super().delete()
예제 #3
0
    def __init__(self, sprite, over, font, text, size=16, align=0):
        super().__init__(sprite, over)

        sc = self.scale
        self.scale = [1, 1, 1]
        rt = self.rotation
        self.rotation = [0, 0, 0]

        self.label = Label(font, text, size, align, self.obj.worldPosition)
        self.label.position.z += 0.05
        self.label.middle_height = True
        font = self.label.font
        self.transformable.append(self.label)

        self.scale = sc
        self.rotation = rt
예제 #4
0
	def __init__(self, sprite, over, font, text, size = 16, align = 0):
		super().__init__(sprite, over)
		
		sc = self.scale
		self.scale = [1,1,1]
		rt = self.rotation
		self.rotation = [0,0,0]
		
		self.label = Label(font, text, size, align, self.obj.worldPosition)
		self.label.position.z += 0.05
		self.label.middle_height = True
		font = self.label.font
		self.transformable.append(self.label)
		
		self.scale = sc
		self.rotation = rt