这是我正在尝试制作我自己的Python列表生成器的代码你也可以将它用于你的个人使用,如果你想当我运行代码时输出是lbl2显示[]和我输入的主题ubuntu不工作相同在终端中没有错误
from tkinter import *
from tkinter import ttk
import tkinter.font as TkFont
import tkinter
from ttkthemes import themed_tk as tk
import random
root = tk.ThemedTk()
root.get_themes()
root.set_theme("ubuntu")
root.title(" List Generator")
root.geometry("300x300")
root.resizable(0 , 0)
Head = Label (root , text = "List Generator for Pyhton" , font=("Arial Bold" , 15))
Head.pack(anchor = CENTER )
lbl1 = Label (root , text = '''Type Words to make a List
Use space to seprate Words in List''' )
lbl1.pack(anchor = CENTER)
ListBox = Entry( root , width = 40)
ListBox.place( x = 26 , y = 100)
lbl2 = Label( root , text= "")
lbl2.place( x = 26 , y = 175)
#Done = ListBox.get()
#Output = Done.split()
def Donn():
Done = ListBox.get()
Output = Done.split()
lbl2.config(text = str(Output) )
Btn_Done = Button( root , text = "Convert" , command = Donn() )
Btn_Done.place(x = 117 , y = 125 )
root.mainloop()发布于 2021-07-17 15:04:18
你的问题在这里:
Btn_Done = Button( root , text = "Convert" , command = Donn() )command的参数需要是函数,但您传递的不是函数。您正在调用函数并传递它返回的内容,即None。要修复它,请传递函数本身:
Btn_Done = Button( root , text = "Convert" , command = Donn )https://stackoverflow.com/questions/68418189
复制相似问题