我已经定义了单独的功能,并且有一个main()
功能。在main()
函数中,我有几个按钮,单击它们会调用其他函数。例如。
def main():
global root
global tkinter
global canvas
root = Tk()
root.title("Shapes Quiz - Flow Computing")
Button(root, text ="1", bg="Grey", width=10, command=pentagon).pack()
Button(root, text ="2", bg="Grey", width=10, command=circle).pack()
Button(root, text ="3", bg="Grey", width=10, command=diamond).pack()
Button(root, text ="4", bg="Grey", width=10, command=hexagon).pack()
Button(root, text ="5", bg="Grey", width=10, command=triangle).pack()
Button(root, text ="6", bg="Grey", width=10, command=square).pack()
Button(root, text ="7", bg="Grey", width=10, command=rectangle).pack()
Button(root, text ="8", bg="Grey", width=10, command=heptagon).pack()
Button(root, text ="9", bg="Grey", width=10, command=octagon).pack()
Button(root, text ="10", bg="Grey", width=10, command=oval).pack()
Button(root, text ="Help", bg="Grey", width=10, command=help).pack()
Button(root, text ="Clear", bg="Red", width=10, command=clearshapes).pack()
Button(root, text ="QUIT", bg="Red", width=10, command=quit).pack()
我确信必须有一种更简单的方法来组织这些按钮。我听说过使用框架和网格,甚至坐标;但我仍然不确定如何做到这一点。
我想组织按钮,使它们是水平的,而不是当前出现的垂直。