Tk version changes

R

Robin Becker

I have some tkinter code that used to work in 2.2, but is failing in
2.3. I guess it's because the Tcl version is different. Looking in the
text.tcl file I see that we now have ::tk::priv and
::tk::TextClosestGap.

I can get this to work reasonably in 2.3.2, but how should I make this
kind of code version independent? Should I rely on the python version or
attempt to check which variables are present in Tk? If the latter does
anyone know which version of Tk this changed?

def _textB1(self,event):
'''special binding for our disabled texts
Allows dragging to select and copy, but not editing
'''
w, x, y = event.widget, event.x, event.y
call = w.tk.call
call('set','::tkPriv(selectMode)','char')
call('set','::tkPriv(mouseMoved)',0)
call('set','::tkPriv(pressX)',x)
call('set','::tkPriv(pressX)',x)
w.mark_set('insert',call('tkTextClosestGap',str(w),x,y))
w.mark_set('anchor','insert')
w.focus()
w.tag_remove('sel','0.0','end')
return 'break'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,169
Messages
2,570,920
Members
47,463
Latest member
FinleyMoye

Latest Threads

Top