当我从Windows PowerShell运行此脚本时,将打开tkinter窗口。但是,当我从IDE(Wing IDE 101 6.0)运行脚本时,该脚本将运行并返回,而不会出现任何错误或弹出窗口。如何无需使用powershell弹出tkinter窗口?
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()