0

I'm trying to make a simple graphical memory card game in Python with Tkinter.

For this, I would like to display three different pages. To swap between one page to another i'm using .tkraise() to push up the different frames to be displayed on the window. However i'm not able to display the high_score_page (frame).

My idea is that, by using a global variable "win" that is set to False in the beginning, I'll display the high_score_page when that "win" variable is True. I'm using an if statement for this. So

if win is True: high_score_page(master)

The first two pages ("input_page" and "game_page") display just fine, but the high_score_page wont show up.

Do you guys have any ideas of how to tackle this problem?

All input is appreciated, thanks :)

GitHub branch

Here is some of the code:

def input_page(master):

    frame_start = Frame(master)
    frame_start.grid(row=0, column=0, sticky="news")

    label_input = Label(frame_start, text="How many rows would you like to have?:")
    label_input.grid(row=0, column=0)

    entry_rows = Entry(frame_start)
    entry_rows.grid(row=0,column=1)

    start = Button(frame_start, text="start", command=lambda: game_page(entry_rows.get(), master))
    start.grid(row=1, column=0)


def game_page(entry, master):

    global win

    if win is True:
        high_score_page(master)
        print(win)

    if win is False:
        frame_game = Frame(master)
        frame_game.grid(row=0, column=0, sticky="news")
        rows = get_board_size(entry)

        buttons = create_buttons(rows, frame_game)
        place_buttons(frame_game, buttons)

        frame_game.tkraise()


def high_score_page(master):

    frame_high_score = Frame(master)
    frame_high_score.grid(row=0, column=0, sticky="news")

    name_entry = Label(frame_high_score, text="blablabla")
    name_entry.grid(column=0, row=0)

    frame_high_score.tkraise()

Lucas
  • 11
  • 1

0 Answers0