2 Display line is a mouse tool to display the line index of the line clicked, counting from one, and the line itself.
6 from __future__ import absolute_import
7 #Init has to be imported first because it has code to workaround the python bug where relative imports don't work if the module is imported as a main module.
11 __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
12 __date__ = '$Date: 2008/21/04 $'
13 __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
17 "The mouse tool base class, which does nothing."
18 def button1(self, event):
19 "The left button was clicked, <Button-1> function."
22 def buttonRelease1(self, event):
23 "The left button was released, <ButtonRelease-1> function."
26 def destroyEverything(self):
28 self.canvas.delete('mouse_item')
30 def destroyEverythingGetFocus(self):
31 "Destroy items and get the focus for the canvas."
32 self.destroyEverything()
33 self.canvas.focus_set()
35 def getReset( self, window ):
36 "Reset the mouse tool to default."
37 self.setWindowItems( window )
38 self.destroyEverything()
41 def getTagsGivenXY( self, x, y ):
42 "Get the tag for the x and y."
43 tags = self.canvas.itemcget( self.canvas.find_closest(x, y), 'tags')
44 currentEnd = ' current'
45 if tags.find( currentEnd ) != - 1:
46 return tags[ : - len( currentEnd ) ]
49 def isSelectionTool(self):
50 "Return if this mouse tool is a selection tool."
53 def keyPressDown(self, event):
54 "The down arrow was pressed."
57 def keyPressLeft(self, event):
58 "The left arrow was pressed."
61 def keyPressReturn(self, event):
62 "The return key was pressed."
65 def keyPressRight(self, event):
66 "The right arrow was pressed."
69 def keyPressUp(self, event):
70 "The up arrow was pressed."
73 def motion( self, event, shift = False ):
74 "The mouse moved, <Motion> function."
77 def setWindowItems( self, window ):
78 "Set the canvas and items."
79 self.canvas = window.canvas
80 self.repository = window.repository
84 "Update the mouse tool."