如何解决python tkinter分别读取用户输入的文本标签每个字母
代码运行但是当我尝试写一些东西时,therminal 中有一个通知 Tkinter 回调中的异常 回溯(最近一次调用最后一次): 文件“C:\Users”,第 1883 行,调用 返回 self.func(*args) 文件“c:/Users”,第 11 行,在 Getting_Text 中 如果文本[0] == 'a': cget 中的文件“C:\Users”,第 1643 行 return self.tk.call(self._w,'cget','-' + key) 类型错误:只能将 str(不是“int”)连接到 str
还有:我是否必须将所有 alpfabet 放入所有字符中,例如 如果用户[0]== "a" 如果用户[0]== "b" 等等 我有没有办法喜欢上千个字符,例如 [0] 然后是 [1]... [100]
import tkinter as tk
#making main window
root = tk.Tk()
root.title("Encryptor")
root.geometry("600x300")
#getting text
def getting_Text():
user = text.get("1.0",'end-1c')
#I print it just to know if the programme work
print (user)
if text[0] == "a":
result.insert(tk.END,';','big')
if text[0] == "b":
result.insert(tk.END,"%","big")
#etc.
#UX of the window
prawy_margines = tk.Frame(root)
prawy_margines.pack (side=tk.RIGHT,expand =tk.YES,fill=tk.BOTH)
left_margin = tk.Frame(root)
left_margin.pack(side=tk.LEFT,expand=tk.YES,fill=tk.BOTH)
#after clicking button function getting_text() is used
button = tk.Button( root,text = "Encrypt",activebackground = "#FFFFFF",command=getting_Text)
button.pack( side = tk.TOP )
text=tk.Text(root,width=36,height=15 )
text.pack(side= tk.LEFT)
result= tk.Text(root,height=15 )
result.pack(side=tk.RIGHT)
# ):
root.mainloop()
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。