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
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()
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()
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
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
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()
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()
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)
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)
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
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)
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)
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
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
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
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)
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)
def __init__( self, menu=None ): Button.__init__( self, None, None, menu )
def __init__( self, parentState=None ): Button.__init__( self, loadImage( "forwardarrow.png", 2 ), ( 670, 526 ), parentState )
def __init__( self, parentState=None ): Button.__init__( self, loadImage( "forwardarrowsmall.png", 2 ), ( 116, 380 ), parentState )
def __init__(self, text, rect): Button.__init__(self, text, rect)
def __init__(self, pin): Button.__init__(self, pin)
def __init__(self, menu=None): Button.__init__(self, None, None, menu)
def __init__(self, parentState=None): Button.__init__(self, loadImage("forwardarrow.png", 2), (670, 526), parentState)
def __init__(self, parent=None): Button.__init__(self, parent) CaptureObject.__init__(self) self.useGlobalCapture = True self.tabStop = False
def __init__(self, parentState=None): Button.__init__(self, None, None, parentState) self.rect = self.image.get_rect() self.rect.topleft = (90, 370)
def __init__(self, text1, text2, rect): Button.__init__(self, text1, text2, rect) self.party = 'dem'
def __init__( self, menu=None ): Button.__init__( self, None, None, menu ) self.rect = self.image.get_rect() self.rect.topleft = ( 73, 370 ) #( 144, 338 )
def __init__( self, parentState=None ): Button.__init__( self, loadImage( "bottomrightlayerclamp.png", 2 ), ( 0, 0 ), parentState )
def __init__( self, theTile, tileNum, pos, parentState=None ): Button.__init__( self, theTile.image, pos, parentState ) self.tileNum = tileNum
def __init__(self, menu=None): Button.__init__(self, None, None, menu) self.rect = self.image.get_rect() self.rect.topleft = (24, 24)
def __init__(self, parent = None): Button.__init__(self, parent) CaptureObject.__init__(self) self.useGlobalCapture = True self.tabStop = False
def __init__(self, parentState=None): Button.__init__(self, loadImage("forwardarrowsmall.png", 2), (116, 380), parentState)
def __init__(self, text, rect, chart): Button.__init__(self, text, rect) self.chart = chart self.sorted = False
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
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
def __init__(self, parentState=None): Button.__init__(self, None, None, parentState)
def __init__( self, parentState=None ): Button.__init__( self, None, None, parentState )
def __init__( self, parentState=None ): Button.__init__( self, loadImage( "backarrowsmall.png", 2 ), ( 24, 380 ), parentState )
def __init__( self, parentState=None ): Button.__init__( self, None, None, parentState ) self.rect = self.image.get_rect() self.rect.topleft = ( 90, 370 )
def __init__( self, parentState=None ): Button.__init__( self, loadImage( "backarrow.png", 2 ), ( 42, 526 ), parentState )
def __init__(self, parentState=None): Button.__init__(self, loadImage("backarrow.png", 2), (42, 526), parentState)
def __init__( self, menu=None ): Button.__init__( self, None, None, menu ) self.rect = self.image.get_rect() self.rect.topleft = ( 24, 24 )
def __init__(self, text, rect, chart, demand): Button.__init__(self, text, rect) self.demand = demand self.chart = chart self.text = text
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
def __init__(self, text1, text2, rect): Button.__init__(self, text1, text2, rect) self.right = True
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
def __init__(self, parentState=None): Button.__init__(self, loadImage("backarrowsmall.png", 2), (24, 380), parentState)