Example #1
0
def main():
    win = GraphWin("Dice Poker", 600, 400)
    win.setBackground("green3")
    banner = Text(Point(300, 30), "Python Poker Parlor")
    banner.setSize(24)
    banner.setFill("yellow2")
    banner.setStyle("bold")
    banner.draw(win)
    letsPlayBtn = Button(win, Point(300, 300), 400, 40, "Let's Play!")
    letsPlayBtn.activate()
    exitBtn = Button(win, Point(300, 350), 400, 40, "Exit")
    exitBtn.activate()
    showHighScores(win)

    while True:
        p = win.getMouse()

        if letsPlayBtn.clicked(p):
            win.close()
            inter = GraphicsInterface()
            app = PokerApp(inter)
            app.run()
            break

        if exitBtn.clicked(p):
            win.close()
            break
Example #2
0
def drawGamePanel():

    # Creates gray Game Panel window
    game_panel = GraphWin("Game Panel", 300, 300)
    game_panel.setBackground("gray")

    # Creates title text with background
    title_background = Rectangle(Point(0, 0), Point(300, 40))
    title_background.setFill("white")
    title_background.draw(game_panel)
    title_text = Text(Point(150, 20), "BoilerMazer")
    title_text.setSize(30)
    title_text.setStyle("bold")
    title_text.draw(game_panel)

    # Creates exit button and text
    exit_button = Rectangle(Point(250, 260), Point(300, 300))
    exit_button.setFill("red")
    exit_button.draw(game_panel)
    exit_text = Text(Point(275, 281), "EXIT")
    exit_text.setSize(14)
    exit_text.draw(game_panel)

    # Creates green button, which will be used for new player and start options
    green_button = Rectangle(Point(100, 260), Point(200, 300))
    green_button.setFill("green")
    green_button.draw(game_panel)
    return game_panel
Example #3
0
def main():

    # create the application window
    win = GraphWin("Dice Roller")
    win.setCoords(0, 0, 10, 10)
    win.setBackground("green2")

    # Draw the interface widgets
    die1 = DieView(win, Point(3, 7), 2)
    die2 = DieView(win, Point(7, 7), 2)
    rollButton = CButton(win, Point(5, 4.5), 1.5, "Roll Dice")
    rollButton.activate()
    quitButton = CButton(win, Point(5, 1), 1, "Quit")

    # Event loop
    pt = win.getMouse()
    while not quitButton.clicked(pt):
        if rollButton.clicked(pt):
            value1 = randrange(1, 7)
            die1.setValue(value1)
            value2 = randrange(1, 7)
            die2.setValue(value2)
            quitButton.activate()
        pt = win.getMouse()

    # close up shop
    win.close()
Example #4
0
def debug_window():
    from graphics import GraphWin

    win = GraphWin('Floor', SCREEN_WIDTH_PX, SCREEN_HEIGHT_PX)
    win.setBackground("black")

    for circle in circle_grid():
        for [x, y] in circle.points(factor=1.):
            win.plotPixel(x, y, "white")
    
    # for circle in circle_grid():
    #     for [x, y] in circle.points(factor=2.):
    #         win.plotPixel(x, y, "white")

    for donut_slice in donut_grid():
        for [x, y] in donut_slice:
            win.plotPixel(x, y, "white")
            sleep(0.001)

    # gaze = RandomPoint.pick()
    # stimulus = random.choice(STIMULI_COORDENATES)
    # for i in np.arange(0,1000,0.01): 
    #     gaze = gaze.add(gaze.pick(r=1))
    #     x, y = (gaze.x*10)+stimulus[0]+50, (gaze.y*6)+stimulus[1]+50
    #     win.plotPixel(x, y, "white")
    #     if x > stimulus[0]+100 or x < stimulus[0]:
    #         gaze = RandomPoint.pick()
    #         stimulus = random.choice(STIMULI_COORDENATES)

    #     if y > stimulus[1]+100 or y < stimulus[1]:
    #         gaze = RandomPoint.pick()
    #         stimulus = random.choice(STIMULI_COORDENATES)

    win.getKey()
    win.close()
def main():
    #draw main window
    win = GraphWin('Dice Roller', 500, 500)
    win.setCoords(0, 0, 10, 10)
    win.setBackground('green2')

    #draw die and buttons
    die1 = DieView(win, Point(3, 6.5), 2)
    die2 = DieView(win, Point(7, 6.5), 2)
    rollButton = Button(win, Point(3, 2.5), 4, 1, 'Roll Dice')
    rollButton.activate()
    quitButton = Button(win, Point(8, 2.5), 2, 1, 'Quit')

    #event loop
    pt = win.getMouse()
    while not quitButton.clicked(pt):
        if rollButton.clicked(pt):
            a, b = randrange(1, 7), randrange(1, 7)
            die1.setValue(a)
            die2.setValue(b)
            quitButton.activate()
            pt = win.getMouse()

    #clean up
    win.close()
Example #6
0
 def run(self):
     while self.money >= 10 and self.interface.wantToPlay():
         self.playRound()
     scoreboard = Scoreboard()
     for score in scoreboard.top10:
         if self.money > int(score.score):
             win2 = GraphWin("Dice Poker", 600, 400)
             win2.setBackground("green3")
             banner = Text(Point(300, 30),
                           "New High Score!\nPlease enter your name:")
             banner.setSize(24)
             banner.setFill("yellow2")
             banner.setStyle("bold")
             banner.draw(win2)
             textbox = Entry(Point(300, 150), 30)
             textbox.draw(win2)
             enter_btn = Button(win2, Point(300, 200), 60, 30, "Enter")
             enter_btn.activate()
             p = win2.getMouse()
             playerName = str(textbox.getText())
             if enter_btn.clicked(p):
                 scoreboard.addScore(playerName, self.money)
                 scoreboard.sortScores()
                 scoreboard.saveScores()
                 break
     self.interface.close()
Example #7
0
def setup(keybinds: Keybindings, square_size: int) -> Tuple[State, GraphWin]:
    '''
    Initializes the graphics and the list representing the grid
    '''
    rows, cols = (4, 9)
    start = (0, 4)

    grid_height = 0
    row_scale = rows * square_size
    if row_scale < 350:
        grid_height = 350
    else:
        grid_height = row_scale

    grid_width = 0
    col_scale = cols * square_size
    if col_scale < 350:
        grid_width = 350
    else:
        grid_width = col_scale

    # set up initial window
    win = GraphWin("Robot", grid_width, grid_height, autoflush=False)
    win.setBackground("green")

    help_str = '\n'.join(
        map(
            lambda item: 'Press {keys} to {desc}'.format(
                keys=', '.join(item[0]), desc=item[1][1]), keybinds.items()))
    help_text = Text(Point(win.getWidth() / 2,
                           win.getHeight() / 5 * 4), help_str)
    help_text.setFill("white")
    help_text.draw(win)

    return (State((rows, cols), start, Facing.RIGHT), win)
Example #8
0
def main():
    win = GraphWin('Dice Roller')
    win.setCoords(0, 0, 10, 10)
    win.setBackground('green2')

    die1 = MultiSidedDie(6)
    die2 = MultiSidedDie(6)
    dieView1 = DieView(win, Point(3, 7), 2)
    dieView2 = DieView(win, Point(7, 7), 2)

    rollButton = Button(win, Point(5, 4.5), 6, 1, 'Roll Dice')
    rollButton.activate()

    quitButton = Button(win, Point(5, 1), 2, 1, 'Quit')

    point = win.getMouse()
    while not quitButton.clicked(point):
        if rollButton.clicked(point):
            die1.roll()
            dieView1.drawValue(die1.getValue())
            die2.roll()
            dieView2.drawValue(die2.getValue())
            quitButton.activate()
        point = win.getMouse()

    win.close()
Example #9
0
def main():
    print("This program plots the growth of a 10-year investment!")

    principal = eval(input("Enter the initial principal: "))
    apr = eval(input("Enter the annualized interest rate: "))

    win = GraphWin("Investment Growth Chart", 320, 240)
    win.setBackground("white")
    win.setCoords(-1.75, -200, 11.5, 10400)

    Text(Point(-1, 0), "0.0K").draw(win)
    Text(Point(-1, 2500), "2.5K").draw(win)
    Text(Point(-1, 5000), "5.0K").draw(win)
    Text(Point(-1, 7500), "7.5K").draw(win)
    Text(Point(-1, 10000), "10.0K").draw(win)

    bar = Rectangle(Point(0, 0), Point(1, principal))
    bar.setFill("green")
    bar.setWidth(2)
    bar.draw(win)

    for year in range(1, 11):
        principal = principal * (1 + apr)
        bar = Rectangle(Point(year, 0), Point(year + 1, principal))
        bar.setFill("green")
        bar.setWidth(2)
        bar.draw(win)

    input("Press <Enter> to quit.")
    win.close()
def main():

    # create application window
    win = GraphWin("Three Door Monte", 600, 400)
    win.setCoords(0, 0, 15, 10)
    win.setBackground("darkgrey")

    # create game
    doorMonte = Game(win)

    # create replay and quit button
    quitbutton = Button(win, Point(11.25, 1), 3, 1.5, "Quit")
    quitbutton.activate()
    replay = Button(win, Point(3.75, 1), 3, 1.5, "Replay")

    # event loop
    click = win.getMouse()
    while not quitbutton.clicked(click):
        if doorMonte.doorPicked(click):
            replay.activate()
        elif replay.clicked(click):
            doorMonte.reset()
        click = win.getMouse()

    win.close()
Example #11
0
def main():

    # create the application window
    win = GraphWin("Dice Roller", )
    win.setCoords(0, 0, 10, 10)
    win.setBackground("green2")

    # draw the interface widgets

    b1 = Button(win, Point(4, 2), 3, 2, "Roll")
    b2 = Button(win, Point(8, 2), 3, 2, "Quit")

    d1 = DieView(win, Point(3, 6), 3)
    d2 = DieView(win, Point(7, 6), 3)

    # event loop

    while True:
        if b1.clicked(win.getMouse()):
            d1.setValue(MSdie().setValue())
            d2.setValue(MSdie().setValue())
        elif b2.clicked(win.getMouse()):
            return False

    # close the window
    win.close()
Example #12
0
class GraphicsDisplay(Display):
    def __init__(self, cols=None, rows=None, window=None, scale=None):
        super().__init__()
        if scale is not None:
            self.scale = scale
        else:
            self.scale = 0.036
        if window is not None:
            self.window = window
        else:
            windowWidth = self.scale * ((self.cols * characterDiameter) +
                                        ((self.cols + 1) * characterRadius))
            windowHeight = self.scale * ((self.rows * characterDiameter) +
                                         ((self.rows + 1) * characterRadius))
            self.window = GraphWin("Retrotextual",
                                   windowWidth,
                                   windowHeight,
                                   autoflush=False)
            self.window.setBackground("black")

        center = arr([characterDiameter, characterDiameter])
        for row in range(self.rows):
            for col in range(self.cols):
                self.characters.append(GraphicsCharacter(self, center))
                center[0] += characterDiameter + characterGap
            center[0] = characterDiameter
            center[1] = characterRadius * 5

    def show(self):
        self.window.update()
Example #13
0
def main():
    print("This program plots the growth of a 10-year investment.")
    print()

    principal = eval(input("Enter the initial principal: "))
    apr = eval(input("Enter the annualized interest rate: "))

    win = GraphWin("Investment Growth Chart", 320, 240)
    win.setBackground("white")
    win.setCoords(-1.75, -200, 11.5, 10400)

    Text(Point(-1, 0), "0.0K").draw(win)
    Text(Point(-1, 2500), "2.5K").draw(win)
    Text(Point(-1, 5000), "5.0K").draw(win)
    Text(Point(-1, 7500), "7.5K").draw(win)
    Text(Point(-1, 10000), "10.0K").draw(win)

    draw_bar(win, 0, principal)

    for year in range(1, 11):
        principal = principal * (1 + apr)
        draw_bar(win, year, principal)

    input("Press <Enter> to quit.")

    win.close()
Example #14
0
def main():

    # create the application window
    win = GraphWin("Dice Roller")
    win.setCoords(0,0,10,10)
    win.setBackground("gray")

    # draw the interface widgets
    die1 = DieView(win, Point(3,7), 2)
    die2 = DieView(win, Point(7,7), 2)
    rollButton = Button(win, Point(5,4.5), 6, 1, "Roll Dice")
    rollButton.activate()
    quitButton = Button(win, Point(5,1), 2, 1, "Quit")

    # event loop
    pt = win.getMouse()
    while not quitButton.clicked(pt):
        if rollButton.clicked(pt):
            # re-rolling value and pip color of die1
            value1 = randrange(1, 7)
            color = color_rgb(randrange(0,256), randrange(0,256), randrange(0,256))
            die1.setValue(value1)
            die1.setColor(color)
            # re-rolling value and pip color of die2
            value2 = randrange(1, 7)
            color = color_rgb(randrange(0,256), randrange(0,256), randrange(0,256))
            die2.setValue(value2)
            die2.setColor(color)
            quitButton.activate()
        pt = win.getMouse()

    # close up shop
    win.close()
def main():
    die_number = 0
    choice = True
    dice = []

    # Test the Window Display
    win = GraphWin("My Graphics Window", 1600, 600)
    win.setBackground('red')

    # Test the User Input for Number of Dice
    die_number = int(input('Enter number of dice to roll: '))
    my_dice = Dice_roller(die_number)

    # Get Dice Graphic for Number of Dice
    for i in range(die_number):
        die = dg.Dice(100)
        dice.append(die)

    # Test Rolling and Displaying Dice
    choice = int(input('Enter 1 to roll dice or 0 to quit: '))
    while choice == True:
        for j in range(5):
            offset = 0
            my_dice.roll_dice()
            for i in range(die_number):
                dice[i].draw_dice(win, Point(200 + offset, 200),
                                  int(my_dice.die[i]))
                offset = offset + 120
        choice = int(input('Enter 1 to roll again or 0 to quit: '))
Example #16
0
def main(window_width, window_height, square_dim, filename):

    window = GraphWin("Karnaugh Map", window_width, window_height)

    window.setBackground(color_rgb(255, 255, 255))

    for line in get_k_map_lines(window_width, window_height, square_dim):
        line.setWidth(1)
        line.setFill(color_rgb(0, 0, 0))
        line.draw(window)

    variables = [(chr(i), chr(i) + "'") for i in range(65, 91)]
    shuffle(variables)
    for label in get_k_map_variable_labels(window_width, window_height, square_dim, variables):
        label.setTextColor('black')
        label.setSize(30)
        label.draw(window)

    k_map_values = get_k_map_values()
    for text in get_k_map_text_values(window_width, window_height, square_dim, k_map_values):
        text.setTextColor('black')
        text.setSize(30)
        text.draw(window)
    # print(k_map_values)
    ps = window.postscript(colormode='color')
    img = Image.open(io.BytesIO(ps.encode('utf-8')))
    img.save(filename)

    window.close()
def main():

    # create the application window
    win = GraphWin("Dice Roller")
    win.setCoords(0, 0, 10, 10)
    win.setBackground("green2")

    # Draw the interface widgets
    die1 = DieView(win, Point(3,7), 2)
    die2 = DieView(win, Point(7,7), 2)
    rollButton = Button(win, Point(5,4.5), 6, 1, "Roll Dice")
    rollButton.activate()
    quitButton = Button(win, Point(5,1), 2, 1, "Quit")

    # Event loop
    pt = win.getMouse()
    while not quitButton.clicked(pt):
        if rollButton.clicked(pt):
            value1 = randrange(1,7)
            die1.setValue(value1)
            value2 = randrange(1,7)
            die2.setValue(value2)
            quitButton.activate()
        pt = win.getMouse()

    # close up shop
    win.close()
Example #18
0
def main():
    #create app window
    win = GraphWin("Dice Roller")
    win.setCoords(0, 0, 10, 10)
    win.setBackground('green2')

    #draw interface widgets
    die1 = DieView(win, Point(3, 7), 2)
    die2 = DieView(win, Point(7, 7), 2)
    rollButton = Button(win, Point(5, 4.5), 6, 1, 'Roll Dice')
    rollButton.activate()
    quitButton = Button(win, Point(5, 1), 2, 1, 'Quit')

    #event loop
    pt = win.getMouse()
    while not quitButton.clicked(pt):
        if rollButton.clicked(pt):
            value1 = randrange(1, 7)
            die1.setValue(value1)
            value2 = randrange(1, 7)
            die2.setValue(value2)
            quitButton.activate()
        pt = win.getMouse()

    #close shope
    win.close()
Example #19
0
def main():

    # create the application window
    win = GraphWin("Dice Roller", WINDOW_WIDTH, WINDOW_HEIGHT)
    win.setBackground("black")

    # draw the interface widgets
    centerPoint = Point(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2)
    quit = Button(win, Point(WINDOW_WIDTH - 75, WINDOW_HEIGHT - 50), 75, 50,
                  'Quit')
    quit.activate()

    roll = Button(win, Point(WINDOW_WIDTH - 150, WINDOW_HEIGHT - 50), 75, 50,
                  'Roll')
    roll.activate()

    die1 = DieView(win, Point(WINDOW_WIDTH / 2 - 50, WINDOW_HEIGHT / 2), 50)
    die2 = DieView(win, Point(WINDOW_WIDTH / 2 + 50, WINDOW_HEIGHT / 2), 50)

    # event loop
    run = True
    while run:
        clickPoint = win.getMouse()
        if (roll.clicked(clickPoint)):
            die1.setValue(randrange(1, 7))
            die2.setValue(randrange(1, 7))
        run = not quit.clicked(clickPoint)

    # close the window
    win.close()
Example #20
0
def get_image_path():
    width, height = 300, 150
    win = GraphWin("Image Path", width, height)
    win.setBackground(color_rgb(0, 0, 0))

    path_entry = Entry(Point(width // 2, height // 2 - 50), 30)
    path_entry.draw(win)

    ok_button = Rectangle(Point(width - 50, height - 50),
                          Point(width - 5, height - 5))
    ok_button.setFill(color_rgb(255, 255, 255))
    ok_button.draw(win)
    ok_button_text = Text(ok_button.getCenter(), "OK")
    ok_button_text.setSize(15)
    ok_button_text.draw(win)

    while True:
        click = win.getMouse()
        clickx = click.getX()
        clicky = click.getY()

        if ok_button.getP1().getX() <= clickx <= ok_button.getP2().getX(
        ) and ok_button.getP1().getY() <= clicky <= ok_button.getP2().getY():
            win.close()
            return str(path_entry.getText())
def main():
    # Introduction
    print("This program plots the growth of a 10-year investment.")
    # Get principal and interest rate
    principal = float(input(" Enter the initial principal: "))
    apr = float(input(" Enter the annualized interest rate: "))
    # Create a graphics window with labels on left edge
    win = GraphWin("Investment Growth Chart ", 320, 240)
    win.setBackground("white")
    Text(Point(20, 230), ' 0.0K').draw(win)
    Text(Point(20, 180), ' 2.5K').draw(win)
    Text(Point(20, 130), ' 5.0K').draw(win)
    Text(Point(20, 80), ' 7.5K').draw(win)
    Text(Point(20, 30), '10.0K').draw(win)
    # Draw bar for initial principal
    height = principal * 0.02
    bar = Rectangle(Point(40, 230), Point(65, 230 - height))
    bar.setFill("green")
    bar.setWidth(2)
    bar.draw(win)
    # Draw bars for successive years
    for year in range(1, 11):
        # calculate value for the next year
        principal = principal * (1 + apr)
        # draw bar for this value
        xll = year * 25 + 40
        height = principal * 0.02
        bar = Rectangle(Point(xll, 230), Point(xll + 25, 230 - height))
        bar.setFill("green")
        bar.setWidth(2)
        bar.draw(win)
    input(" Press <Enter> to quit ")
    win.close()
Example #22
0
def main() :
    # Introduction
    print ( " This program plots the growth of a 10-year investment . " )
    # Get principal and interest rate
    principal = float(input ("Enter the initial principal : "))
    apr = float(input("Enter the annualized interest rate : "))
    # Create a graphics window with labels on left edge
    win = GraphWin ("Investment Growth Chart ", 320 , 240)
    win.setBackground ("white")
    win.setCoords (-1.75, -200 , 11.5, 10400)

    Text(Point (- 1, 0) , ' 0.0K').draw (win)
    Text(Point (- 1, 2500) , '2.5K').draw (win)
    Text(Point (- 1, 5000) , ' 5.0K').draw (win)
    Text(Point (- 1, 7500) , ' 7.5k').draw (win)
    Text(Point (- 1, 10000) , '10.0K').draw (win)
    # Draw bar f or init ial princ ipal
    bar = Rectangle (Point (0, 0) , Point (1, principal))
    bar.setFill ("green")
    bar.setWidth (2)
    bar.draw (win)
    # Draw a bar for each subsequent year
    for year in range (1, 11) :
        principal = principal * ( 1 + apr)
        bar = Rectangle (Point (year, 0), Point (year+ 1 , principal ))
        bar.setFill ("green")
        bar.setWidth (2)
        bar.draw(win)
    input(" Press <Enter> to quit.")
    win.close ()
Example #23
0
def create_window():
    width = int(1920 * SCALING)
    height = int(1080 * SCALING)

    # Create game window
    win = GraphWin("Black Jack", width, height, autoflush=False)
    win.setBackground(colour_rgb(135, 206, 250))
    return win
Example #24
0
def main():
    win = GraphWin("Three Button Monte", 500, 300)
    win.setCoords(-12, -12, 12, 12)
    win.setBackground("green3")

    door1 = Button(win, Point(-7.5, -8), 5, 18, "Door 1")
    door2 = Button(win, Point(0, -8), 5, 18, "Door 2")
    door3 = Button(win, Point(7.5, -8), 5, 18, "Door 3")
    direction = Text(Point(0, 10), "Pick a Door")
    direction.draw(win)
    x = random() * 3
    pt1 = pt2 = pt3 = False
    if 0 <= x < 1:
        pt1 = True
    elif 1 <= x < 2:
        pt2 = True
    else:
        pt3 = True

    door1.activate()
    door2.activate()
    door3.activate()
    click = win.getMouse()

    while door1.clicked(click) or door2.clicked(click) or door3.clicked(click):
        if door1.clicked(click):
            if pt1 == True:
                door1.update(win, "Victory!")
            else:
                if door2.clicked(click):
                    door2.update(win, "Correct Door.")
                    click = win.getMouse()
                else:
                    door3.update(win, "Correct door.")
                    click = win.getMouse()
        elif door2.clicked(click):
            if pt2 == True:
                door2.update(win, "Victory!")
            else:
                if door3.clicked(click):
                    door3.update(win, "Correct Door.")
                    click = win.getMouse()
                else:
                    door1.update(win, "Correct door.")
                    click = win.getMouse()
        else:
            if pt3 == True:
                door3.update(win, "Victory!")
            else:
                if door2.clicked(click):
                    door2.update(win, "Correct Door.")
                    click = win.getMouse()
                else:
                    door1.update(win, "Correct door.")
                    click = win.getMouse()

    win.getMouse()
Example #25
0
def create_labeled_window():
    window = GraphWin("Investment Growth Chart", 320, 240)
    window.setBackground("white")
    window.setCoords(-1.75, -200, 11.5, 10400)

    Text(Point(-1, 0), "0.0K").draw(window)
    Text(Point(-1, 2500), "2.5K").draw(window)
    Text(Point(-1, 5000), "5.0K").draw(window)
    Text(Point(-1, 7500), "7.5K").draw(window)
    Text(Point(-1, 10000), "10.0K").draw(window)

    return window
Example #26
0
def main():

    # create the application window
    window = GraphWin("Dice Roller")
    window.setCoords(0, 0, 10, 10)
    window.setBackground("green2")

    # draw the interface widgets

    # event loop

    # close the window
    window.close()
def window():
    win = GraphWin("얘기 카운트", 1280, 720)
    win.setBackground(color_rgb(17, 22, 15))

    historyText = Text(Point(480, 360), '')
    historyText.setFill(color_rgb(255, 255, 255))
    historyText.setFace("arial")
    historyText.setSize(16)
    historyText.draw(win)

    rect = Rectangle(Point(960, 0), Point(1280, 720))
    rect.setFill(color_rgb(17, 22, 15))
    rect.draw(win)

    clockText = Text(Point(1117, 16), "")
    clockText.setFill(color_rgb(255, 255, 255))
    clockText.setFace("courier")
    clockText.setSize(16)
    clockText.draw(win)

    yaegiConstText = Text(Point(1117, 300), "%s 횟수" % toFilter)
    yaegiConstText.setFill(color_rgb(255, 255, 255))
    yaegiConstText.setFace("arial")
    yaegiConstText.setSize(36)
    yaegiConstText.draw(win)

    yaegiNumberText = Text(Point(1117, 420), "0")
    yaegiNumberText.setFill(color_rgb(255, 255, 255))
    yaegiNumberText.setFace("arial")
    yaegiNumberText.setSize(36)
    yaegiNumberText.draw(win)

    line = graphics.Line(Point(960, 0), Point(960, 720))
    line.setFill(color_rgb(200, 200, 200))
    line.draw(win)

    while not win.checkMouse():
        clockText.setText(
            "%s KST" %
            datetime.datetime(2020, 1, 1).now().isoformat().split('.')[0])
        yaegiNumberText.setText(str(yaegiCount))
        historyText.setText('\n'.join(history))

        sleep(1)

    win.close()

    running = False

    global f
    f.write('%s count: %d' % (toFilter, yaegiCount))
Example #28
0
def main():
    win = GraphWin("Five Click House", 500, 500)
    win.setBackground(color_rgb(43, 43, 43))

    p = win.getMouse()
    p1 = Point(p.getX(), p.getY())
    p = win.getMouse()
    p2 = Point(p.getX(), p.getY())
    base = Rectangle(p1, p2)  # Base of the house, initial rectangle.
    base.setOutline(color_rgb(180, 180, 180))
    base.draw(win)

    dist = sqrt((p2.getX() - p1.getX())**2 +
                (p2.getY() - p1.getY())**2)  # Distance between p1 and p2.
    baseHeight = p1.getY() - p2.getY()  # Height of the 'base' object.
    baseWidth = p2.getX() - p1.getX()  # Width of the 'base' object.
    doorWidth = (baseWidth / 5)

    p = win.getMouse()
    p3 = Point(p.getX(), p.getY())  # Third Mouse Click.
    p4 = Point((p3.getX() - doorWidth / 2), p3.getY())  # Top left of door.
    p5 = Point(p3.getX() + doorWidth / 2,
               p1.getY())  # Bottom right of the door.
    door = Rectangle(p4, p5)
    door.setOutline(color_rgb(180, 180, 180))
    door.draw(win)

    p = win.getMouse()
    p6 = Point(p.getX(), p.getY())  # Fourth Click.
    p7 = Point(p6.getX() - doorWidth / 4,
               p6.getY() - doorWidth / 4)  # Top left of the window.
    p8 = Point(p6.getX() + doorWidth / 4,
               p6.getY() + doorWidth / 4)  # Bottom right of the window
    window = Rectangle(p7, p8)
    window.setOutline(color_rgb(180, 180, 180))
    window.draw(win)

    p = win.getMouse()
    p9 = Point(p.getX(), p.getY())  # Fifth Mouse Click, also tip of roof.
    p10 = Point(p1.getX(), p1.getY() - baseHeight)  # Left corner of roof.
    p11 = Point(p2.getX(), p2.getY())  # Right corner of roof.
    roof = Polygon(p9, p10, p11)
    roof.setOutline(color_rgb(180, 180, 180))
    roof.draw(win)

    print("Distance between p1 and p2:", dist)
    print("p1 x:", p1.getX(), "\np1 y:", p1.getY(), "\np2 x:", p2.getX(),
          "\np2 y:", p2.getY())
    print("Base Height:", baseHeight, "\nBase Width:", baseWidth)
    win.getMouse()
    win.close()
Example #29
0
def main():
	# create the application window
	win = GraphWin("Dice Poker", WINDOW_WIDTH, WINDOW_HEIGHT)
	win.setBackground("black")

	# draw the interface widgets
	centerPoint = Point(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2)
	quit = Button(win, Point(WINDOW_WIDTH - 50, WINDOW_HEIGHT - 50), 75, 50, 'Quit')
	quit.activate()

	roll = Button(win, Point(WINDOW_WIDTH - 125, WINDOW_HEIGHT - 50), 75, 50, 'Roll')
	roll.activate()

	m = (WINDOW_WIDTH / 5) + (5*25)
	for k in range(5):
		hand.append(DieView(win, Point(WINDOW_WIDTH / 2 - m, WINDOW_HEIGHT / 2), 100))
		m -= 125

	scoreText = Text(Point(50, 50), "Score Text Goes Here...")
	scoreText.setTextColor("white")
	scoreText.draw(win)

	global helpText
	helpText = Text(Point(WINDOW_WIDTH - 200, 75), "Help Text Goes Here...")
	helpText.setTextColor("white")
	helpText.draw(win)

	playHand()

	# event loop
	run = True
	while run:
		updateScore(scoreText)
		clickPoint = win.getMouse()
		if (roll.clicked(clickPoint)):
			playHand()
		run = ( (not quit.clicked(clickPoint)) and (playerAmount >= 10) )
	updateScore(scoreText)

	# By now, player has exhausted funds
	if (playerAmount <= 10):
		helpText.setText(helpText.getText() + "\nYou've don't have enough for another roll.")
		roll.deactivate()
		while (not quit.clicked(clickPoint)): # Wait till the user clicks quit
			clickPoint = win.getMouse()

	# close the window
	win.close()
Example #30
0
def show_total(amount):
    totalWin = GraphWin("Transaction", 250,250)
    totalWin.setBackground("Yellow")

    amountText = Text(Point(125,50), amount)
    amountText.setStyle("bold")
    amountText.draw(totalWin)
    amountLabel = Text(Point(50,50), "Total:")
    amountLabel.draw(totalWin)

    tenderedBox = Entry(Point(125,100), 5)
    tenderedBox.setText("0")
    tenderedBox.setFill("white")
    tenderedBox.draw(totalWin)
    label = Text(Point(50,100), "Given: ")
    label.draw(totalWin)

    button = Image(Point(125, 200), "icons/button.png")
    button.draw(totalWin)
    buttonRect = Rectangle(Point(50,184), Point(203,218))

    calcFlag = False
    while True:
        errorFlag = False
        try:
            click = totalWin.getMouse()
        except:
            totalWin.close()
            break
        if(isPtInRect(buttonRect, click)):
            if(calcFlag):
                    change.undraw()
            try:
                tendered = tenderedBox.getText()
            except:
                errorFlag = True
                tenderedBox.setText("0")
            if(float(tendered) < amount):
                errorFlag = True
                tenderedBox.setText(str(amount))
            if(not errorFlag):
                change = Text(Point(125, 150), "Change:    "
                              + str(float(tendered) - amount))
                change.setStyle("bold")
                change.draw(totalWin)
                calcFlag = True
    return
Example #31
0
def main():

    #Create the game view window
    win = GraphWin("GameView")
    win.setCoords(0, 0, 10, 10)
    win.setBackground("green2")

    winCount = 0
    loseCount = 0
    correct = randrange(1,4)
    choice = 0

    # draw the buttons
    cb1 = Button(win, Point(1.75,3), 3, 5, "Option 1")
    cb1.activate()
    cb2 = Button(win, Point(5.125,3), 3, 5, "Option 2")
    cb2.activate()
    cb3 = Button(win, Point(8.5,3), 3, 5, "Option 3")
    cb3.activate()
    qb = Button(win, Point(8.5,9), 3, 1, "Quit")

    pt = win.getMouse()
    
    while not qb.clicked(pt):
        
        if cb1.clicked(pt):
            choice = 1
        elif cb2.clicked(pt):
            choice = 2
        elif cb3.clicked(pt):
            choice = 3

        if choice == correct:
            winCount = winCount + 1
            print("you win, keep going or quit")
        else:
            loseCount = loseCount + 1
            print("you lose, keep going or quit")

        qb.activate()
        pt = win.getMouse()
        
    wMessage = str(winCount)
    lMessage = str(loseCount)
    print("you won "+wMessage+" times.")
    print("you lost "+lMessage+" times.")
    win.close()
Example #32
0
if __name__ == "__main__":
    results_dir = 'results'
    for f in (f for f in os.listdir(results_dir) if f.endswith('.log')):
        hist = json.load(open(os.path.join(results_dir, f)))
        colors = None
        for i, game in enumerate(hist):
            score = [0, 0]
            images = []
            names = game['players']
            size = int(game['size'])

            dim = 600
            left_marg = 50
            top_marg = 200
            win = GraphWin(game, dim + 2*left_marg, dim + top_marg + 50)
            win.setBackground(color_rgb(255, 255, 255))

            if not colors:
                colors = {names[0]: 'blue', names[1]: 'red'}
                p1 = Text(Point(left_marg + dim//2, 30), names[0])
                p1.setFill(colors[names[0]])
                p1.setSize(20)
                score1 = Text(Point(left_marg + dim//6, 70), '0:0')
                score1.setFill(colors[names[0]])
                score1.setSize(30)

                vs = Text(Point(left_marg + dim//2, 70), 'vs')
                vs.setFill('black')
                vs.setSize(20)

                p2 = Text(Point(left_marg + dim//2, 110), names[1])