是否有任何好的GUI支持Pygame表面作为应用程序中的小部件?
如果这不可行或不实用,哪个GUI工具包具有最佳图形组件?我希望通过SDL包装器保持快速渲染.
我正在使用pygame编写程序,我需要一些GUI配置文本字段和按钮进行控制.我已经使用pygame制作了按钮,但我只能用pygame写一个文本字段.也许我需要将tkinter与pygame一起使用.
我想如果没有办法在一个窗口中将pygame part和tkinter部分组合在一起,那么我可以将它们放入2个独立的窗口中.
我希望tkinter部分可以更新我的pygame部分中的全局变量,如果有任何问题会有吗?我可以从pygame部分创建一个tkinter的子进程,这样tkinter部分就可以"看到"pygame部分中的全局变量并修改它们.
我可以这样做吗?有任何陷阱吗?
我想在 pygame 中创建一个菜单栏,就像 tkinter 中的菜单栏一样。
from tkinter import *
def donothing():
filewin = Toplevel(root)
button = Button(filewin, text="Do nothing button")
button.pack()
root = Tk()
menubar = Menu(root)
filemenu = Menu(menubar, tearoff=0)
filemenu.add_command(label="New", command=donothing)
filemenu.add_command(label="Open", command=donothing)
filemenu.add_command(label="Save", command=donothing)
filemenu.add_command(label="Save as...", command=donothing)
filemenu.add_command(label="Close", command=donothing)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=root.quit)
menubar.add_cascade(label="File", menu=filemenu)
editmenu = Menu(menubar, tearoff=0)
editmenu.add_command(label="Undo", command=donothing)
editmenu.add_separator()
editmenu.add_command(label="Cut", command=donothing)
editmenu.add_command(label="Copy", command=donothing)
editmenu.add_command(label="Paste", command=donothing)
editmenu.add_command(label="Delete", command=donothing)
editmenu.add_command(label="Select All", command=donothing)
menubar.add_cascade(label="Edit", menu=editmenu)
helpmenu = Menu(menubar, tearoff=0)
helpmenu.add_command(label="Help Index", command=donothing)
helpmenu.add_command(label="About...", command=donothing)
menubar.add_cascade(label="Help", menu=helpmenu)
root.config(menu=menubar)
root.mainloop() …Run Code Online (Sandbox Code Playgroud) def addnewunit(title, text, style):
ctypes.windll.user32.MessageBoxW(0, text, title, style)
Run Code Online (Sandbox Code Playgroud)
我已经看到很多人展示了这段代码,但是没有人指定如何实际使是/否工作。它们是按钮,它们就在那里,但是如何指定单击或单击时实际发生的情况?