我用的是IDLE,但这应该足够让球滚动了。IDLE是在Windows上下载Python时随Python一起安装的IDE。您可以通过按Windows键并搜索空闲来打开它。在
这段代码很简单,但是它应该能让您很好地了解如何使用Tkinter库创建一个新窗口。我读到在Python 2.x上,需要导入大写为T的Tkinter,因此如果使用3.x,则可能需要将import更改为小写Timport os, Tkinter as tk
def boardf():
os.system("mode con cols=15 lines=7")
print (" ")
print (" | | ")
print (" -+ -+ - ")
print (" | | ")
print (" -+ -+ - ")
print (" | | ")
def play_x():
print("implement x logic here")
def play_y():
print("implement y logic here")
def create_window():
root_window = tk.Tk()
b_x = tk.Button(root_window, text="x", command=play_x)
b_y = tk.Button(root_window, text="y", command=play_y)
b_x.pack()
b_y.pack()
root_window.mainloop()
def main():
boardf()
create_window()
main()