gpt4 book ai didi

python - 文本框不会自动删除自身

转载 作者:行者123 更新时间:2023-12-01 07:37:43 25 4
gpt4 key购买 nike

我希望文本框自动删除以前的输出,这样我就可以输入完整的句子,而无需将每个字母打印到文本框。然而,它会一直重复下去,所以当我点击保存按钮时,它会将每一行记录到我的剪贴板中。

我尝试使用 Tkinter 文本删除:text.delete(1.0,END)。但是,它不会删除任何内容。

class ExamplePanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent, size=(3000,2000))
self.cipherText = wx.StaticText(self, label="Ciphered Text: ", pos=(20, 30))

#A multiline TextCtrl- Shows the events in the program.
#I think this might be where the problem is but I do not know how to
#get it to only print once, perhaps after the user hits "enter" or something.
self.logger = wx.TextCtrl(self, pos=(300,20), size=(200,300), style=wx.TE_MULTILINE | wx.TE_READONLY)

        self.encrypt = wx.StaticText(self, label="Encryptor: ", pos=(20,60))
self.encryptEdit = wx.TextCtrl(self, value="", pos=(150, 60), size=(140,-1))
self.Bind(wx.EVT_TEXT, self.EncText, self.encryptEdit)
self.Bind(wx.EVT_CHAR, self.EncChar, self.encryptEdit)

    def EncText(self,event):
result = ''
message = event.GetString()
for i in range(0, len(message)):
result = result + chr(ord(message[i]) - 2)
result = result.replace(chr(30), ' ')
print(result + '\n\n')
self.logger.AppendText(result + '\n\n')

如上所述,我的目标是每当进行新的击键时将其清空文本框,这样它就不会一直重复下去。这就是它目前的样子:Current Output

最佳答案

尝试使用 .SetValue(result + '\n\n'),而不是 .ApppendText(result + '\n\n')。它应该替换 TextCtrl

中的文本<小时/>

请参阅文档 wx.TextCtrlwx.TextCtrl 基于 wx.TextEntry,因此您可以在 wx.TextEntry 的文档中找到 TextCtrl 的一些函数。 。还有SetValue()

关于python - 文本框不会自动删除自身,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56904803/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com