当我从Windows PowerShell运行这个脚本时,tkinter窗口将打开。但是,当我在IDE (Wing IDE 101 6.0)上运行脚本时,脚本将运行并返回,没有任何错误或弹出窗口。如何才能使tkinter窗口弹出,而不必使用powershell?
import tkinter as tk
from tkinter import *
class MyGame:
def __init__(self, master):
self.master = master
master.title('Stock Market Game')
self.startGameButton = tk.Button(master, text="Start New Game", command = self.startNewGame)
self.startGameButton.pack()
cWidth = 600
cHeight = 400
self.canvas = tk.Canvas(master, width = cWidth, height = cHeight)
self.canvas.create_line(0, cHeight * 1/3, cWidth, cHeight * 1/3) # coordinates of start and end
self.canvas.pack()
self.canvas.bind("Start New Game", self.startNewGame)
def startNewGame(self):
pass
root = Tk()
gui = MyGame(root)
root.mainloop()
问题来源StackOverflow 地址:/questions/59385259/tkinter-window-opens-from-command-line-but-not-ide
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。