Ejemplo n.º 1
0
    def __init__(self, text='Label', active=False, on_click=None):
        ''' Create toggle button. '''

        self._active = active
        Button.__init__(self, text, on_click)
        if self._active:
            self._state = state.activated
Ejemplo n.º 2
0
 def __init__(self, parentState=None, text="", pos=(0, 0)):
     Button.__init__(self, None, None, parentState)
     self.text = text
     self.rect = pygame.Rect(0, 0, 0, 0).move(pos[0], pos[1])
     #print text
     self.selected = False
     self.createText()
Ejemplo n.º 3
0
    def __init__(self, text='Label', active=False, on_click=None):
        ''' Create toggle button. '''

        self._active = active
        Button.__init__(self, text, on_click)
        if self._active:
            self._state = state.activated
Ejemplo n.º 4
0
 def __init__( self, parentState=None, text="", pos=(0,0) ):
     Button.__init__( self, None, None, parentState )
     self.text = text
     self.rect = pygame.Rect( 0, 0, 0, 0 ).move( pos[0], pos[1] )
     #print text
     self.selected = False
     self.createText()
Ejemplo n.º 5
0
 def __init__(self, parentState=None, text="", pos=(0, 0)):
     Button.__init__(self, None, None, parentState)
     self.text = text
     self.image = self.FileSaveButtonText.render(text, False,
                                                 pygame.Color(0, 0, 0))
     self.rect = self.image.get_rect()
     self.rect.topleft = pos
Ejemplo n.º 6
0
    def __init__(self,
                 surf_off,
                 surf_on,
                 start_value=False,
                 dimen=resource.get_dimen("switch_button")):
        """

        :param surf_off: surface to display if this is switch value is False
         :type surf_off: pygame.Surface
        :param surf_on: surface to display if this is switch value is True
         :type surf_on: pygame.Surface
        :param dimen: the dimension of this button
        """
        if surf_off.get_width() is not dimen.width \
                or surf_off.get_height() is not dimen.height:
            surf_off = pygame.transform.scale(surf_off, dimen.wh())

        if surf_on.get_width() is not dimen.width \
                or surf_on.get_height() is not dimen.height:
            surf_on = pygame.transform.scale(surf_on, dimen.wh())

        Button.__init__(self, surf_off, dimen)

        self.__switch_val = start_value

        self.__image_off = surf_off
        self.__image_on = surf_on
Ejemplo n.º 7
0
 def __init__(self, channel, led):
     Button.__init__(self, channel)
     self.led = led
     self.camera = Camera()
     self.camera.led = False
     self.toggle = True
     self.led.turnOn()
     self._actionMode2()
Ejemplo n.º 8
0
 def __init__(self,image=None):
     self.mImage=None
     Button.__init__(self)
     self.setSize(0,0)
     if type(image) == type("abc"):
         self.mImage=Image.load(image)
     else:
         self.mImage=image
         
     self.adjustSize()
Ejemplo n.º 9
0
 def __init__(self, position, image, image_hovered, on_click, enabled=True):
     """Initializes a new image button. Takes the position, the path of the image,
     the path of the image when hovered and an on-click method as parameters,
     as well as a boolean indicating whether the button is disabled.
     :type position: tuple
     :type on_click: function
     :type enabled: bool"""
     self.image = image
     self.image_hovered = image_hovered
     Button.__init__(self, position, on_click, enabled)
Ejemplo n.º 10
0
    def __init__(self, panel, nums_grid, msg, w, h, color, alt_color, text_color, row, col):
        Button.__init__(self, msg, w, h, color, alt_color, text_color)
        self.panel = panel
        self.nums_grid = nums_grid
        left_padding = self.panel.rect.left + (self.panel.rect.width - 250) / 2
        # self.rect.left = self.panel.rect.left + col * w
        self.rect.left = left_padding + col * w
        self.rect.top = self.panel.rect.bottom - 150 + row * h

        self.num = int(msg)
Ejemplo n.º 11
0
    def __init__( self, entity, entNum, pos, parentState=None ):
        if entity.bWidth is not None and not entity.forceUseRect:
            firstFrame = entity.sheet.subsurface( pygame.Rect( entity.bdx, entity.bdy, entity.bWidth, entity.bHeight ) )
        elif entity.wbWidth is not None and not entity.forceUseRect:
            firstFrame = entity.sheet.subsurface( pygame.Rect( entity.wbdx, entity.wbdy, entity.wbWidth, entity.wbHeight ) )
        else:
            firstFrame = entity.sheet.subsurface( pygame.Rect( 0, 0, entity.width, entity.height ) )
        Button.__init__( self, scaleSurface( firstFrame, 0.5 ), pos, parentState )

        self.entNum = entNum
Ejemplo n.º 12
0
 def __init__(self, parent = None):
     Button.__init__(self, parent)
     TextBase.__init__(self)
     ImageBase.__init__(self)
     self.imgSize = 16, 16
     self.textGap = 0
     self.margin = 5, 5, 5, 5
     self.altCmd = ''
     self.changeEvent('text', self.onResize)
     self.changeEvent('textGap', self.onResize)
     self.changeEvent('imgSize', self.onResize)
Ejemplo n.º 13
0
 def __init__(self, parent=None):
     Button.__init__(self, parent)
     TextBase.__init__(self)
     ImageBase.__init__(self)
     self.imgSize = 16, 16
     self.textGap = 0
     self.margin = 5, 5, 5, 5
     self.altCmd = ''
     self.changeEvent('text', self.onResize)
     self.changeEvent('textGap', self.onResize)
     self.changeEvent('imgSize', self.onResize)
Ejemplo n.º 14
0
 def __init__( self, parentState, width, height ):
     Button.__init__( self, None, None, parentState, True )
     self.width = width
     self.height = height
     self.scale = None
     self.image = self.generateImage()
     self.rect = self.image.get_rect()
     if self.pos is None:
          MiniMap.pos = ( getResolution()[0]-width, getResolution()[1]-height )
     self.rect.topleft = self.pos
     self.held = False
     self.heldPos = None
     self.dragging = False
     self.panning = False
Ejemplo n.º 15
0
 def __init__(self, parentState, width, height):
     Button.__init__(self, None, None, parentState, True)
     self.width = width
     self.height = height
     self.scale = None
     self.image = self.generateImage()
     self.rect = self.image.get_rect()
     if self.pos is None:
         MiniMap.pos = (getResolution()[0] - width,
                        getResolution()[1] - height)
     self.rect.topleft = self.pos
     self.held = False
     self.heldPos = None
     self.dragging = False
     self.panning = False
Ejemplo n.º 16
0
    def __init__(self, entity, entNum, pos, parentState=None):
        if entity.bWidth is not None and not entity.forceUseRect:
            firstFrame = entity.sheet.subsurface(
                pygame.Rect(entity.bdx, entity.bdy, entity.bWidth,
                            entity.bHeight))
        elif entity.wbWidth is not None and not entity.forceUseRect:
            firstFrame = entity.sheet.subsurface(
                pygame.Rect(entity.wbdx, entity.wbdy, entity.wbWidth,
                            entity.wbHeight))
        else:
            firstFrame = entity.sheet.subsurface(
                pygame.Rect(0, 0, entity.width, entity.height))
        Button.__init__(self, scaleSurface(firstFrame, 0.5), pos, parentState)

        self.entNum = entNum
Ejemplo n.º 17
0
 def __init__(self, position, text, fonts, text_size, text_color,
              text_color_hover, on_click):
     """Initializes a new text button.
     Takes the position, the text, the list of font preferences, the text size, the text color,
     and an on-click method as parameters.
     :type position: tuple
     :type text: str
     :type fonts: list
     :type text_size: int
     :type text_color: tuple
     :type text_color_hover: tuple
     :type on_click: function"""
     self.text = text
     self.fonts = fonts
     self.text_size = text_size
     self.text_color = text_color
     self.text_color_hover = text_color_hover
     Button.__init__(self, position, on_click)
Ejemplo n.º 18
0
 def __init__(self, filepath, x, y, w=100, h=40, middle=False, colouron=(0,0,0), colouroff=(5,5,255),
              font='OpenSans-Bold.ttf'):
     """ (str, int, int, [int], [int], [bool], [(int, int, int)], [(int, int, int)]) -> PictureButton
     Returns a PictureButton with the given x and y co-ordinate.
     The x and y refer to a middle coordinate if "middle" is True.
     The filepath is saved and the image is internally loaded.
     The width and height are ignored.
     """
     Button.__init__(self, "", x, y, w, h, middle, colouron, colouroff, font)
     self.filepath = filepath                                # caption
     self.x, self.y = x, y
     if middle:                                              # center the button at the given co-ordinates
         self.x -= w // 2                                         # if the user requests this
         self.y -= h // 2
     self.width = w
     self.height = h
     self.rect = pygame.Rect(self.x, self.y, w, h)                     # Rect bounds
     self.colour_on = colouron                               # active colour
     self.colour_off = colouroff                             # inactive colour
     self.pressed = False                                    
     self.hovering = False
     self.font = pygame.font.Font(font, 32)
     self.load_picture(filepath)
Ejemplo n.º 19
0
 def __init__( self, menu=None ):
     Button.__init__( self, None, None, menu )
Ejemplo n.º 20
0
 def __init__( self, parentState=None ):
     Button.__init__( self, loadImage( "forwardarrow.png", 2 ), ( 670, 526 ), parentState )
Ejemplo n.º 21
0
 def __init__( self, parentState=None ):
     Button.__init__( self, loadImage( "forwardarrowsmall.png", 2 ), ( 116, 380 ), parentState )
Ejemplo n.º 22
0
 def __init__(self, text, rect):
     Button.__init__(self, text, rect)
Ejemplo n.º 23
0
 def __init__(self, pin):
   Button.__init__(self, pin)
Ejemplo n.º 24
0
 def __init__(self, menu=None):
     Button.__init__(self, None, None, menu)
Ejemplo n.º 25
0
 def __init__(self, parentState=None):
     Button.__init__(self, loadImage("forwardarrow.png", 2), (670, 526),
                     parentState)
Ejemplo n.º 26
0
 def __init__(self, parent=None):
     Button.__init__(self, parent)
     CaptureObject.__init__(self)
     self.useGlobalCapture = True
     self.tabStop = False
Ejemplo n.º 27
0
 def __init__(self, parentState=None):
     Button.__init__(self, None, None, parentState)
     self.rect = self.image.get_rect()
     self.rect.topleft = (90, 370)
Ejemplo n.º 28
0
	def __init__(self, text1, text2, rect):
		Button.__init__(self, text1, text2, rect)
		self.party = 'dem'
Ejemplo n.º 29
0
 def __init__( self, menu=None ):
     Button.__init__( self, None, None, menu )
     self.rect = self.image.get_rect()
     self.rect.topleft = ( 73, 370 ) #( 144, 338 )
Ejemplo n.º 30
0
 def __init__( self, parentState=None ):
     Button.__init__( self, loadImage( "bottomrightlayerclamp.png", 2 ), ( 0, 0 ), parentState )
Ejemplo n.º 31
0
 def __init__( self, theTile, tileNum, pos, parentState=None ):
     Button.__init__( self, theTile.image, pos, parentState )
     self.tileNum = tileNum
Ejemplo n.º 32
0
 def __init__(self, menu=None):
     Button.__init__(self, None, None, menu)
     self.rect = self.image.get_rect()
     self.rect.topleft = (24, 24)
Ejemplo n.º 33
0
 def __init__(self, parent = None):
     Button.__init__(self, parent)
     CaptureObject.__init__(self)
     self.useGlobalCapture = True
     self.tabStop = False
Ejemplo n.º 34
0
 def __init__(self, parentState=None):
     Button.__init__(self, loadImage("forwardarrowsmall.png", 2),
                     (116, 380), parentState)
Ejemplo n.º 35
0
 def __init__(self, text, rect, chart):
     Button.__init__(self, text, rect)
     self.chart = chart
     self.sorted = False
Ejemplo n.º 36
0
 def __init__(self, menu=None):
     Button.__init__(self, None, None, menu)
     self.rect = self.image.get_rect()
     self.rect.topleft = (60, 370)
     self.on = False
Ejemplo n.º 37
0
 def __init__( self, parentState=None, text="", pos=(0,0) ):
     Button.__init__( self, None, None, parentState )
     self.text = text
     self.image = self.FileLoadButtonText.render( text, False, pygame.Color( 0, 0, 0 ) )
     self.rect = self.image.get_rect()
     self.rect.topleft = pos
Ejemplo n.º 38
0
 def __init__(self, parentState=None):
     Button.__init__(self, None, None, parentState)
Ejemplo n.º 39
0
 def __init__( self, parentState=None ):
     Button.__init__( self,  None, None, parentState )
Ejemplo n.º 40
0
 def __init__( self, parentState=None ):
     Button.__init__( self, loadImage( "backarrowsmall.png", 2 ), ( 24, 380 ), parentState )
Ejemplo n.º 41
0
 def __init__( self, parentState=None ):
     Button.__init__( self, None, None, parentState )
     self.rect = self.image.get_rect()
     self.rect.topleft = ( 90, 370 )
Ejemplo n.º 42
0
 def __init__( self, parentState=None ):
     Button.__init__( self, loadImage( "backarrow.png", 2 ), ( 42, 526 ), parentState )
Ejemplo n.º 43
0
 def __init__(self, parentState=None):
     Button.__init__(self, loadImage("backarrow.png", 2), (42, 526),
                     parentState)
Ejemplo n.º 44
0
 def __init__( self, menu=None ):
     Button.__init__( self, None, None, menu )
     self.rect = self.image.get_rect()
     self.rect.topleft = ( 24, 24 )
Ejemplo n.º 45
0
 def __init__(self, text, rect, chart, demand):
     Button.__init__(self, text, rect)
     self.demand = demand
     self.chart = chart
     self.text = text
Ejemplo n.º 46
0
 def __init__( self, menu=None ):
     Button.__init__( self, None, None, menu )
     self.rect = self.image.get_rect()
     self.rect.topleft = ( 60, 370 )
     self.on = False
Ejemplo n.º 47
0
	def __init__(self, text1, text2, rect):
		Button.__init__(self, text1, text2, rect)
		self.right = True
Ejemplo n.º 48
0
 def __init__(self, text, rect, chart, party='dem', ascend=True, raw=True):
     Button.__init__(self, text, rect)
     self.chart = chart
     self.party = party
     self.ascend = ascend
     self.raw = raw
Ejemplo n.º 49
0
 def __init__(self, parentState=None):
     Button.__init__(self, loadImage("backarrowsmall.png", 2), (24, 380),
                     parentState)