2
을 고려하지 않습니다wordend 아포스트로피를
text.get('current wordstart', 'current wordend')
그러나이 아포스트로피와 단어를 고려하지 않습니다.
다른 방법이 있습니까?
을 고려하지 않습니다wordend 아포스트로피를
text.get('current wordstart', 'current wordend')
그러나이 아포스트로피와 단어를 고려하지 않습니다.
다른 방법이 있습니까?
Christian Gollwitzer 이상 comp.lang.tcl에서 해결 방법을 제공했습니다.
다음은 파이썬 3.4 용 테스트 코드입니다 :
import tkinter
import tkinter.messagebox as messagebox
class Creator(object):
def __init__(self):
root = self.root = tkinter.Tk()
# Main Frame
f_main = tkinter.Frame(root, borderwidth=6, relief='flat')
f_main.grid(row=0, column=0, sticky='nsew')
# Text widget and frame
f_txt = tkinter.Frame(f_main, borderwidth=2, relief="sunken")
f_txt.config(width=768, height=768)
f_txt.pack(padx=4, pady=4, side="bottom", fill="both", expand=True)
my_txt = self.text = tkinter.Text(f_txt)
my_txt.config(undo=True, wrap='word')
my_txt.grid(row=0, column=0, sticky="nsew")
my_txt.bind("<ButtonRelease-3>", self.test)
my_txt.focus_set()
def test(self, event=None):
txt = str(self.text)
a = "::tk::TextPrevPos {} current tcl_wordBreakBefore".format(txt)
b = "::tk::TextNextPos {} current tcl_wordBreakAfter".format(txt)
ind1 = self.root.tk.eval(a)
ind2 = self.root.tk.eval(b)
x = self.text.get(ind1, ind2)
messagebox.showinfo('info', x)
GUI = Creator()
GUI.root.mainloop()