Exemple #1
0
	def textbox_keyrelease(self, event):
		#if event.keysym_num in range(32, 128):
		#	print "'"+event.keysym+"'",
		#else:
		#	print event.keysym_num,
		currentline = event.widget.get('insert linestart', 'insert lineend')
		currentpos = event.widget.index('insert - 1 chars')
		#currentpos = event.widget.index('insert')
		char = event.widget.get('insert - 1 chars')
		if event.keysym_num in range(32, 128) and char == event.char:
			if char in delimitrset:
				j = currentpos.index('.') + 1
				i = k = int(currentpos[j:])
				while i >= 0 and currentline[i] in delimitrset:
					i -= 1
				while i >= 0 and not currentline[i] in delimitrset:
					i -= 1
				if i < 0:
					i = 0
				nowword = currentline[i:k]
				nowwordpos = currentpos[:j] + `i`
				print nowword.encode('gbk', 'replace'), nowwordpos,
				nowword = pyformat(nowword)
				print
				event.widget.delete(nowwordpos, currentpos)
				event.widget.insert(nowwordpos, nowword)
Exemple #2
0
	def textbox_onreturn(self, event):
		currentline = event.widget.get('insert linestart', 'insert lineend')
		currentpos = event.widget.index('insert linestart')
		print currentline.encode('gbk', 'replace'), currentpos,
		currentline = pyformat(currentline)
		print
		event.widget.delete('insert linestart', 'insert lineend')
		event.widget.insert(currentpos, currentline)
Exemple #3
0
	def textbox_donowword(self, event):
		currentline = event.widget.get('insert linestart', 'insert lineend')
		currentpos = event.widget.index('insert')
		j = currentpos.index('.') + 1
		i = k = int(currentpos[j:])
		if i == len(currentline):
			i -= 1
		while i >= 0 and currentline[i] in delimitrset:
			i -= 1
		while i >= 0 and not currentline[i] in delimitrset:
			i -= 1
		if i < 0:
			i = 0
		nowword = currentline[i:k]
		nowwordpos = currentpos[:j] + `i`
		print nowword.encode('gbk', 'replace'), nowwordpos,
		nowword = pyformat(nowword)
		print
		event.widget.delete(nowwordpos, currentpos)
		event.widget.insert(nowwordpos, nowword)