[英]The Function is running without even calling in the code , can you update it for me , no errors shown in terminal
This is the Code I am trying to make my own Python List Generator You can use this for your personal use too , if you want When i run the code the output is lbl2 shows [] and the theme ubuntu that i Typed is not working same no errors in terminal这是我正在尝试制作自己的 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()
Your problem is here:你的问题在这里:
Btn_Done = Button( root , text = "Convert" , command = Donn() )
The parameter to command
needs to be a function, but you are not passing a function. command
的参数需要是一个函数,但您没有传递一个函数。 You are CALLING the function and passing what it returns, which is None
.您正在调用该函数并传递它返回的内容,即None
。 To fix it, pass the function itself:要修复它,请传递函数本身:
Btn_Done = Button( root , text = "Convert" , command = Donn )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.