Ткинтер - половина окна исчезнет - PullRequest
0 голосов
/ 08 января 2020

Я готовил GUI для игры PaperSoccer, используя python с tkinter, и я столкнулся с проблемой с отображением окна.

Нижняя половина моей игровой доски не отображается: enter image description here

Ниже приведены важные фрагменты кода, который я использовал: Я благодарен за любую помощь.

class GameWindow(tk.Tk):

    def __init__(self, *args, **kwargs):
        tk.Tk.__init__(self, *args, **kwargs)


        container = tk.Frame(self)
        container.pack(fill = BOTH, expand = True)
        self.geometry("400x700")
        self.update()
        self.frames = {}

        for F in (Menu, NewGameBU, BBMenu, NewGameBB):
            frame = F(container, self)

            self.frames[F] = frame
            frame.grid(row=0, column=0, sticky="nsew")

        self.show_frame(Menu)

    def show_frame(self, cont):
        frame = self.frames[cont]
        frame.tkraise()




class Menu(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        label = tk.Label(self, text="Paper Football", font=LARGE_FONT)
        label.pack(pady=10, padx=10)

        button_new_game = tk.Button(self, text="New Game user-bot",
                                    command=lambda: controller.show_frame(NewGameBU), width="25")
        button_new_game.pack()

        button_new_bot_game = tk.Button(self, text="New Game bot-bot",
                                        command=lambda: controller.show_frame(BBMenu), width="25")
        button_new_bot_game.pack()

        button_instructions = tk.Label(self, text="How To Play", fg="blue", cursor="hand2", width="25")
        button_instructions.pack()
        button_instructions.bind("<Button-1>", lambda e: webbrowser.open_new("https://en.wikipedia.org/wiki/Paper_soccer"))

        button_instructions.pack()

        button_quit = tk.Button(self, text="Quit",
                                command=self.destroy, width="25")
        button_quit.pack()




class NewGameBU(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        self.boardGui = BoardGui()
        # self.boardGui.file = open('../controller/temp_fw_trained', 'rb')
        # self.boardGui.bot = pickle.load(self.boardGui.file)
        self.boardGui.agent = self.boardGui.bot
        self.boardGui.env = Game()
        self.boardGui.board = Board(self)
        self.boardGui.board.draw_board()
        self.boardGui.board.color_current_point()
        self.boardGui.board.color_allowable_points()
        # self.boardGui.board.canvas.bind('<>', self.get_move())
        self.boardGui.board.canvas.bind('<Button>', self.boardGui.on_click)
        self.boardGui.board.canvas.pack(fill = BOTH, expand = True)
        button1 = tk.Button(self, text="Restart Game",
                            command=lambda: controller.show_frame(NewGameBU))
        button1.pack(side=BOTTOM)

        button2 = tk.Button(self, text="Return",
                            command=lambda: controller.show_frame(Menu))
        button2.pack(side=BOTTOM)
app = GameWindow()
app.mainloop()
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...