【发布时间】:2019-04-18 23:26:03
【问题描述】:
所以我目前正在尝试制作一个程序,允许我输入一个字符串,该字符串输出到 tkinter 中的文本窗口。但是,当在 simpledialog.askstring 窗口中按下“取消”按钮时,我收到一条错误消息。
这是我在 Python Shell 中收到的错误消息:
_tkinter.TclError: wrong # args: should be ".!text insert index chars ?tagList chars tagList ...?"
我只是想让程序在按下取消按钮时什么都不做。 :(
from tkinter import *
from tkinter import simpledialog
import tkinter.messagebox
class Thing:
def __init__(self):
global buttonThing
global window
window = Tk()
frame1 = Frame(window)
frame1.pack()
buttonThing = Button(frame1, text = "click me", command = self.clickMe)
buttonThing.pack()
self.text =Text(window)
self.text.pack()
window.mainloop()
def clickMe(self):
uwu = simpledialog.askstring("hey","put stuff")
self.text.insert(END, uwu)
Thing()
【问题讨论】:
标签: python python-3.x tkinter