我有一个绑定的组合键:Tkinter的神秘结合问题
self.parent.bind_all('<Control-n>', self.next_marked)
它应该带我去一个文本组件,其父母为框架的一个标签。
def next_marked(self, skip=False):
print (len(self.text.tag_ranges('definition')))
print('next_marked()')
self.text.focus_set()
print (self.text.index(INSERT))
next_tag = str(self.text.tag_nextrange('definition', 'insert+1c')[0])
print (self.text.index(INSERT))
spl = next_tag.split('.')
line = int(spl[0])
col = int(spl[1])
self.text.mark_set('insert', '%d.%d' % (line, col))
它这样做的时候,不使用热键,但是当我使用热键,它总是向下移动光标一行的位置,然后执行该功能。这是我的操作系统吗? (Windows 7)有关如何处理此问题的任何建议?
我使用Python 2.7和Tkinter的8.5
看起来好像ctrl-n已经绑定到tkinter文本框中的“下一行”。有一些方法可以优先考虑绑定......或者,使用不同的密钥。 –
在你的函数工作结束时'返回False吗? –