在python3中显示文本的更简单方法

在python3中显示文本的更简单方法,python,tkinter,python-3.5,Python,Tkinter,Python 3.5,我用tkinter在Python3中尝试了12小时显示文本,看起来很简单,但这就是我想到的。(最近刚刚开始使用python)但是必须有一种更简单的方式来显示窗口和其中的一些文本吗 from tkinter import * class Window(Frame): def __init__(self, master = None): Frame.__init__(self, master) self.master = master

我用tkinter在Python3中尝试了12小时显示文本,看起来很简单,但这就是我想到的。(最近刚刚开始使用python)但是必须有一种更简单的方式来显示窗口和其中的一些文本吗

    from tkinter import *

class Window(Frame):

    def __init__(self, master = None):
        Frame.__init__(self, master)

        self.master = master

        self.init_window()

    def init_window(self):
        self.master.title("GUI")
        self.pack(fill=BOTH, expand=1, command=self.showTxt())


    def showTxt(self):
        text = Label(self, text='Hello world...')
        text.pack()


root = Tk()
root.geometry("400x300")
app = Window(root)

root.mainloop()
试试这个:

from Tkinter import *
root = Tk()
T = Text(root, height=2, width=30)
T.pack()
T.insert(END, "Just a text Widget\nin two lines\n")
mainloop()

这其中哪一部分是“不容易的”?你可以将所有内容压缩为四行或五行,但你展示的版本更接近于你在现实世界中使用tkinter的方式(即:在教程或简单示例之外)。