Python Tkinter 模块未显示输出 [英] Python Tkinter module not showing output

查看:31
本文介绍了Python Tkinter 模块未显示输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试学习 Python 并在 Python 中尝试一些 GUI 并遇到了这个 Tkinter 模块.我的代码运行但我运行时没有出现窗口.我的代码如下

I am trying to learn Python and trying something GUI in Python and came across this Tkinter module. My code runs but the window does not appear when I run. My code is as follows

 #GUI

#from Tkinter import *
from Tkinter import *
#to create a root window 
root = Tk()

对此的任何帮助将不胜感激.程序运行,没有错误,但是 from/窗口没有显示

Any help on this would be appreciated. The program runs, gives no errors but the from/ window does not show up

推荐答案

将此添加到您的代码中 root.mainloop(), 这是一个教程.

Add this to your code root.mainloop(), Here's a tutorial.

回应您的评论

#Also note that `from <module> import *` is generally frowned upon
#since it can lead to namespace collisions. It's much better to only
#explicitly import the things you need.
from Tkinter import Tk, Label
root = Tk()
w = Label(root, text="Hello, world!")
w.pack()
root.mainloop()

这篇关于Python Tkinter 模块未显示输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆