Problem with ButtonRelease-2 event in Text widgets

andrea andrea at proceryon.at
Tue Sep 9 11:02:23 CEST 2003


I have a dialog with a Pmw.ScrolledText widget were a user can paste a
text with button-2.

After pasting i want to know how many characters are pasted. But when
the '<ButtonRelease-2>' event occurs the text is not pasted, this
happens afterward.
With '<KeyRelease>' events it works fine (eg 'Shift'+'Insert'). Why?

Is there a possibility to get the pasted text at this moment?


TIA!


###
sample code:
###

import Pmw

class CText:
	def show (self):
		dlg = Pmw.Dialog()
		
		self.textbox = Pmw.ScrolledText(dlg.interior())
		self.textbox.pack()
		self.textbox.component('text').bind('<KeyRelease>',
self.printLength)
		self.textbox.component('text').bind('<ButtonRelease-2>',
self.printLength)

		dlg.activate()

	def printLength (self, event):
		print len(self.textbox.get())


if( __name__ == '__main__' ):
	textObj = CText()
	textObj.show()




More information about the Python-list mailing list