小编Pyt*_*ast的帖子

如何创建 Tkinter 主菜单

我目前正在 Tkinter 中创建一个问答游戏。该游戏由登录页面、测验、显示结果的图表和乒乓球游戏组成。测验和登录使用 Tkinter 库作为 GUI,图形使用 MatPlotLib,pong 使用 pygame。有什么方法可以链接主菜单中的所有这些模块,例如创建一个 Tkinter GUI,然后为每个按钮分配一个命令以启动相应的 python 文件?

编辑:添加我尝试过的代码。

from tkinter import *
import sqlite3
import sys
import time
import importlib


importlib.import_module('Quiz')

class Menu:
    def __init__(self, master):
        
        #Setting up the window
        self.master = master
        self.master.geometry("1350x800+50+50")
        self.master.title("Main Menu")

        self.quizLaunch = Button(self.master, text="Quiz", command = quizApplication)
        self.quizLaunch.pack()

root = Tk()
Menu(root)
root.mainloop()
Run Code Online (Sandbox Code Playgroud)

python pygame tkinter matplotlib

2
推荐指数
1
解决办法
111
查看次数

标签 统计

matplotlib ×1

pygame ×1

python ×1

tkinter ×1