Beispiel #1
0
def drawPlayerNameEntry(game_panel):
    # Creates text prompting user for player name
    player_name_text = Text(Point(80, 70), "Player Name:")
    player_name_text.setStyle("bold")
    player_name_text.setSize(14)
    player_name_text.draw(game_panel)
    # Provides an entry box for user to enter player name
    player_name_entry = Entry(Point(195, 70), 18)
    player_name_entry.setFill("white")
    player_name_entry.draw(game_panel)
    # Return objects
    return player_name_text, player_name_entry
def make_text_with_input(x, y, col, size, text, init_value="", width=10):
    begin = 0
    if col == 1:
        begin = 220
    elif col == 2:
        begin = 580
    elif col == 3:
        begin = 920
    elif col == 4:
        begin = 1180
    text = make_text(x, y, size, text)
    entry = Entry(Point(begin, y), width)
    entry.setFill("white")
    entry.setText(init_value if init_value != "None" else "")
    entry.draw(win)
    return entry, text
Beispiel #3
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