Example #1
0
def display_buttonBackground(_background, message, pressed, inputPressed):
    global button
    global buttonBackground
    #initialize font
    pygame.font.init()
    fontobject = pygame.font.Font(None, 18)

    #create buttonBackground surface and load the button image
    buttonBackground = pygame.Surface((512, 50))
    buttonBackground.fill(stddraw.pygameColor(stddraw.RED))
    button = pygame.image.load(os.path.join('saveIcon.png'))
    #check to see if the button is pressed
    if pressed:
        button.fill(stddraw.pygameColor(stddraw.LIGHT_GRAY))

    pygame.draw.line(buttonBackground, stddraw.pygameColor(stddraw.BLACK),
                     (0, 49), (511, 49))
    pygame.draw.rect(buttonBackground, stddraw.pygameColor(stddraw.BLACK),
                     (10, 10, 260, 30), 0)
    pygame.draw.rect(buttonBackground, stddraw.pygameColor(stddraw.WHITE),
                     (12, 12, 255, 25), 0)
    if inputPressed:
        pygame.draw.rect(buttonBackground,
                         stddraw.pygameColor(stddraw.BOOK_BLUE),
                         (10, 10, 259, 29), 2)

    if len(message) != 0:
        buttonBackground.blit(
            fontobject.render(message, 1, stddraw.pygameColor(stddraw.BLACK)),
            (15, 20))
    buttonBackground.blit(button, (290, 10))
    _background.blit(buttonBackground, (0, 0))

    pygame.display.flip()
    return buttonBackground
Example #2
0
def display_buttonBackground(_background, message, pressed, inputPressed):
    global button
    global buttonBackground
    #initialize font
    pygame.font.init()
    fontobject = pygame.font.Font(None, 18)

    #create buttonBackground surface and load the button image
    buttonBackground = pygame.Surface((512, 50))
    buttonBackground.fill(stddraw.pygameColor(stddraw.RED))
    button = pygame.image.load(os.path.join( 'saveIcon.png'))
    #check to see if the button is pressed
    if pressed:
        button.fill(stddraw.pygameColor(stddraw.LIGHT_GRAY))
    
    pygame.draw.line(buttonBackground, stddraw.pygameColor(stddraw.BLACK), (0, 49), (511, 49))
    pygame.draw.rect(buttonBackground, stddraw.pygameColor(stddraw.BLACK),
                   (10, 10,
                    260, 30), 0)
    pygame.draw.rect(buttonBackground, stddraw.pygameColor(stddraw.WHITE),
                   (12, 12,
                    255, 25), 0)
    if inputPressed:
        pygame.draw.rect(buttonBackground, stddraw.pygameColor(stddraw.BOOK_BLUE),
                   (10, 10,
                    259, 29), 2)

    if len(message) != 0:
        buttonBackground.blit(fontobject.render(message, 1, stddraw.pygameColor(stddraw.BLACK)), 
            (15, 20))
    buttonBackground.blit(button, (290, 10))
    _background.blit(buttonBackground, (0, 0))

    pygame.display.flip()
    return buttonBackground
def display_buttonBackground(_background, message):
    pygame.font.init()
    fontobject = pygame.font.Font(None, 18)
    buttonBackground = pygame.Surface((512, 50))
    buttonBackground.fill(stddraw.pygameColor(stddraw.RED))
    button = pygame.Surface((80, 30))

    button.fill(stddraw.pygameColor(stddraw.GRAY))
    button.blit(fontobject.render("Save", 1, (0,0,0)), (button.get_width() / 2 - 20, button.get_height() / 2 - 5))
        
    pygame.draw.line(buttonBackground, stddraw.pygameColor(stddraw.BLACK), (0, 49), (511, 49))
    pygame.draw.rect(buttonBackground, stddraw.pygameColor(stddraw.BLACK),
                   (10, 10,
                    260, 30), 0)
    pygame.draw.rect(buttonBackground, stddraw.pygameColor(stddraw.WHITE),
                   (12, 12,
                    255, 25), 0)
    if len(message) != 0:
        print "should be printing words"
        buttonBackground.blit(fontobject.render(message, 1, stddraw.pygameColor(stddraw.BLACK)), 
            (15, 20))
    buttonBackground.blit(button, (290, 10))
    _background.blit(buttonBackground, (0, 0))
    pygame.display.flip()
    return buttonBackground
Example #4
0
def display_buttonBackground(_background, message):
    pygame.font.init()
    fontobject = pygame.font.Font(None, 18)
    buttonBackground = pygame.Surface((512, 50))
    buttonBackground.fill(stddraw.pygameColor(stddraw.RED))
    button = pygame.Surface((80, 30))

    button.fill(stddraw.pygameColor(stddraw.GRAY))
    button.blit(fontobject.render("Save", 1, (0, 0, 0)),
                (button.get_width() / 2 - 20, button.get_height() / 2 - 5))

    pygame.draw.line(buttonBackground, stddraw.pygameColor(stddraw.BLACK),
                     (0, 49), (511, 49))
    pygame.draw.rect(buttonBackground, stddraw.pygameColor(stddraw.BLACK),
                     (10, 10, 260, 30), 0)
    pygame.draw.rect(buttonBackground, stddraw.pygameColor(stddraw.WHITE),
                     (12, 12, 255, 25), 0)
    if len(message) != 0:
        print "should be printing words"
        buttonBackground.blit(
            fontobject.render(message, 1, stddraw.pygameColor(stddraw.BLACK)),
            (15, 20))
    buttonBackground.blit(button, (290, 10))
    _background.blit(buttonBackground, (0, 0))
    pygame.display.flip()
    return buttonBackground
def window( threadName, delay):
    ## Main loop.
    global _surface

    _background = pygame.display.set_mode([512, 562])
    _surface = pygame.Surface((512, 512))
    _surface.fill(stddraw.pygameColor(stddraw.WHITE))
    _background.blit(_surface, (0, 50))
    display_buttonBackground(_background, "")

    name = get_name(_background) 

    print name + " was entered"
Example #6
0
def window(threadName, delay):
    ## Main loop.
    global _surface

    _background = pygame.display.set_mode([512, 562])
    _surface = pygame.Surface((512, 512))
    _surface.fill(stddraw.pygameColor(stddraw.WHITE))
    _background.blit(_surface, (0, 50))
    display_buttonBackground(_background, "")

    name = get_name(_background)

    print name + " was entered"
Example #7
0
def main():
    ## Main loop.
    global _surface
    global _background

    _background = pygame.display.set_mode([512, 562])
    _surface = pygame.Surface((512, 512))
    _surface.fill(stddraw.pygameColor(stddraw.WHITE))
    circle(0.5, 0.5, 0.5)
    _background.blit(_surface, (0, 50))
    display_buttonBackground(_background, "", False, False)

    name = get_name(_background) 

    print name + " was entered"
Example #8
0
def circle(x, y, r):
    """
    Draw on the surface a circle of radius r centered on (x, y).
    """
    global _surface

    ws = stddraw._factorX(2 * r)
    hs = stddraw._factorY(2 * r)
    if (ws <= 1) and (hs <= 1):
        stddraw._pixel(x, y)
    else:
        xs = stddraw._scaleX(x)
        ys = stddraw._scaleY(y)
        pygame.draw.ellipse(_surface, stddraw.pygameColor(stddraw.BLACK),
                            pygame.Rect(xs - ws / 2, ys - hs / 2, ws, hs), 1)
Example #9
0
def main():
    ## Main loop.
    global _surface
    global _background

    _background = pygame.display.set_mode([512, 562])
    _surface = pygame.Surface((512, 512))
    _surface.fill(stddraw.pygameColor(stddraw.WHITE))
    circle(0.5, 0.5, 0.5)
    _background.blit(_surface, (0, 50))
    display_buttonBackground(_background, "", False, False)

    name = get_name(_background)

    print name + " was entered"
Example #10
0
def circle(x, y, r):
    """
    Draw on the surface a circle of radius r centered on (x, y).
    """
    global _surface

    ws = stddraw._factorX(2*r)
    hs = stddraw._factorY(2*r)
    if (ws <= 1) and (hs <= 1):
        stddraw._pixel(x, y)
    else:
        xs = stddraw._scaleX(x)
        ys = stddraw._scaleY(y)
        pygame.draw.ellipse(_surface,
            stddraw.pygameColor(stddraw.BLACK),
            pygame.Rect(xs-ws/2, ys-hs/2, ws, hs), 1
            )
Example #11
0
def filledRectangle(x, y, w, h):
    """
    Draw on the surface a filled rectangle of width w and height h,
    centered on (x, y).
    """
    global _surface
    ws = stddraw._factorX(2 * w)
    hs = stddraw._factorY(2 * h)
    if (ws <= 1) and (hs <= 1):
        stddraw._pixel(x, y)
    else:
        xs = stddraw._scaleX(x)
        ys = stddraw._scaleY(y)
        pygame.draw.rect(_surface,
                         pygameColor(stddraw.pygameColor(stddraw.GRAY)),
                         pygame.Rect(xs - ws / 2, ys - hs / 2, ws, hs), 0)
        _draw()
def filledRectangle(x, y, w, h):
    """
    Draw on the surface a filled rectangle of width w and height h,
    centered on (x, y).
    """
    global _surface
    ws = stddraw._factorX(2*w)
    hs = stddraw._factorY(2*h)
    if (ws <= 1) and (hs <= 1):
        stddraw._pixel(x, y)
    else:
        xs = stddraw._scaleX(x)
        ys = stddraw._scaleY(y)
        pygame.draw.rect(_surface,
            pygameColor(stddraw.pygameColor(stddraw.GRAY)),
            pygame.Rect(xs-ws/2, ys-hs/2, ws, hs),
            0)
        _draw()