Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Can';不显示tk窗口_Python_Function_Class_Tkinter - Fatal编程技术网

Python Can';不显示tk窗口

Python Can';不显示tk窗口,python,function,class,tkinter,Python,Function,Class,Tkinter,我是Python新手,所以我尝试使用Pyscripter编辑器测试一些简短的脚本/程序 但是我不能让它工作。没有输出 from Tkinter import* class Myclassx: def __init__(self): windx = Tk() btnx = Button(text="okayx",command =self.printx) btnx.pack() def printx(self):

我是Python新手,所以我尝试使用Pyscripter编辑器测试一些简短的脚本/程序 但是我不能让它工作。没有输出

from Tkinter import*
class Myclassx:
     def __init__(self):
        windx = Tk()
        btnx = Button(text="okayx",command =self.printx)
        btnx.pack()
     def printx(self):
        print "see you later"
oleyx=Myclassx()

非常感谢。

如果您的意思是看不到窗口,那么您错过了
windx.mainloop()

从Tkinter导入*
类别Myclassx:
定义初始化(自):
windx=Tk()
btnx=按钮(text=“okayx”,command=self.printx)
btnx.pack()

windx.mainloop()#请您更具体地说一句“我不能让它工作”好吗?您遇到了什么错误?请使用更具描述性的标题。感谢它现在起作用了,但它说“未定义全局名称‘windx’”@sabitgencoglu,这没有意义。你能按原样发布你的代码吗?(不,不是答案。按原样回溯编辑您的问题)按下按钮时,程序应显示“稍后见”pressed@sabitgencoglu(显示“待会儿见”)也可以。正如我在前面的评论中所说,请按原样发布您的代码。哦,我现在看到了。。嗯,我在窗口的某个地方(按钮正下方)等着它。我想我需要一个标签或文本框来显示它。无论如何,我怎么能将我的帖子标记为“已解决”?给“falsetru”一些名声
from Tkinter import*
class Myclassx:
     def __init__(self):
        windx = Tk()
        btnx = Button(text="okayx",command =self.printx)
        btnx.pack()
        windx.mainloop() # <----
     def printx(self):
        print "see you later"

oleyx=Myclassx()