我用Python做了一个简单的记事本。除了剪切/复制/粘贴,所有命令都可以。 它们在这里:
`def AppendSel(e = None):
d = txt.get(SEL_FIRST,SEL_LAST)
frm.clipboard_append(d)
def Cut(e = None):
AppendSel()
txt.delete(SEL_FIRST, SEL_LAST)
def Paste(e = None):
clipboard = frm.clipboard_get()
clipboard = clipboard.replace("\n", "\\n")
try:
start = txt.index("sel.first")
end = txt.index("sel.last")
txt.delete(start, end)
except TclError:
pass
txt.insert("insert", clipboard)`
当我选择'a',Ctrl+C,backspace,然后Ctrl+V,它粘贴'a''a''a''a'。我的错误在哪里,所以这个小程序可以正常运行?你知道吗
我发现的真正错误:错误在按键中。TkInter检测每一毫秒的压力。我怎样才能禁用它?你知道吗
注:凯文,这两个字符是必要的编码,否则它不接受上传。你知道吗
它看起来像你是附加到剪贴板与每个削减,但从来没有清除它。试试
clipboard_clear()
。Here is an example usage.相关问题 更多 >
编程相关推荐