Python tkinter将.exe文件添加到程序内部的框架中

2024-09-24 20:30:06 发布

您现在位置:Python中文网/ 问答频道 /正文

在我的毕业设计中,我正在用Python 3.7制作一个arcade GUI。现在我有点困在这里了,我想做的是,当你打开一个新页面时(通过点击按钮),我想要它,这样一个可执行文件(例如:pacman)将在框架内播放,而不是使用“os”方法

当你点击“播放”按钮时,是否有可能使游戏在窗口/框架内开始,而不是在程序外打开

下面是我的一段代码:

definit(自身、主控):

帧。init(自,主)

    self.frameName="GamePage"
    backgr = Image.open("Gamepage_background.png")
    render = ImageTk.PhotoImage(backgr)
    background = Label(self, image=render)
    background.image = render
    background.place(x=0, y=0, relwidth=1, relheight=1)

    Button(self, text = "Go back to main page",font=('Arcade Interlaced',15),bg="black",fg="white",command=lambda: master.changeFrame(0)).pack(side=BOTTOM, anchor = W , pady= 15, padx= 15)

    Button(self, text = "Pac Man",font=('Arcade Interlaced',30),bg="purple",fg="white",command = master.openPacman).place(anchor = CENTER, relx= 0.27, rely= 0.275, width = 475, height = 125) #voorlopig in orde in 1920x1080

    Button(self, text = "Space Invaders",font=('Arcade Interlaced',30),bg="purple",fg="white",command= master.openSpaceinvaders,  wraplength = 350, justify = CENTER).place(anchor = CENTER, relx= 0.74, rely= 0.275, width = 475, height = 125)'''

我想要的是,当我点击两个游戏中的一个时,它会打开一个新的框架,游戏在框架内进行,而不是在外部进行

谢谢你,我希望我能很快找到答案


Tags: textself框架游戏placebuttonrendercommand