Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/333.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中使用tkinter添加非按钮标题的方法_Python_Text_Tkinter - Fatal编程技术网

我需要一种在python中使用tkinter添加非按钮标题的方法

我需要一种在python中使用tkinter添加非按钮标题的方法,python,text,tkinter,Python,Text,Tkinter,到目前为止,我的代码是: import tkinter def hello(): a = tkinter.Button(text ="what is this", padx = 10, pady = 10) a.pack() c = tkinter.Button(text ="what do you want", padx = 10, pady = 10) c.pack() b = tkinter.Button(text = "Welcome to the i

到目前为止,我的代码是:

import tkinter

def hello():
    a = tkinter.Button(text ="what is this", padx = 10, pady = 10)
    a.pack()
    c = tkinter.Button(text ="what do you want", padx = 10, pady = 10)
    c.pack()

b = tkinter.Button(text = "Welcome to the interface. click to get started", command = hello, padx = 10, pady = 10)
b.pack()

我想点击第一个按钮,让它显示下一个按钮,上面有一点文字。我试着把打印作为最后的手段,但正如我所想的那样,它是空壳。似乎什么都不管用。我看到了一些关于“文本”小部件的东西,但我无法让它工作。

您想要使用的是
标签。标签是在tk窗口上显示文本的一种方式。例如,您正在使用
c=tkinter.Button(text=“what do you want”,padx=10,pady=10)
。要将其创建为文本,应使用
c=tkinter.Label(text=“what you want”,padx=10,pady=10)

此外,这个问题提供的关于你想做什么的信息很少,因此很难显示你的要求

如果您希望在按钮上方有文字,则应使用:

examplelabel = tkinter.Label(text = "Example Text")
examplelabel.pack()
examplebutton = tkinter.Button(...)
examplebutton.pack()

很抱歉,如果这个答案不好,我对这种类型的python不太在行。

您想要使用的是
标签。标签是在tk窗口上显示文本的一种方式。例如,您正在使用
c=tkinter.Button(text=“what do you want”,padx=10,pady=10)
。要将其创建为文本,应使用
c=tkinter.Label(text=“what you want”,padx=10,pady=10)

此外,这个问题提供的关于你想做什么的信息很少,因此很难显示你的要求

如果您希望在按钮上方有文字,则应使用:

examplelabel = tkinter.Label(text = "Example Text")
examplelabel.pack()
examplebutton = tkinter.Button(...)
examplebutton.pack()

很抱歉,如果这个答案不好,我对这种类型的python不太在行。

每次单击时,您想在上面添加新行还是只添加一行文本,根据单击的按钮进行更改?因此,使用
标签而不是按钮?每次单击时,您想在上面添加新行还是只添加一行文本,根据单击的按钮进行更改?是否使用
标签而不是按钮?