Mouse support in TurtleArt
[note as of Turtle Blocks V87 no patching of tawindow.py is required and the python block code is in the sample myblock file]
It requires some modification of the program code, three new lines need to be added to the file tawindow.py near the beginning:
def __init__(self, win, path, parent=None, mycolors=None):
self.win = None
and three new lines about 1/4 way into the file:
def _buttonpress_cb(self, win, event):These changes are necessary so that the programmable block tamyblock.py can "see" the mouse event. Turtle Art's files can be modified with Browse and Pippy or with the Linux command line editor vi see Modifing_an_Activity
""" Button press """
x, y = xy(event)
self.button_press(event.get_state()>k.gdk.CONTROL_MASK, x, y)
Then a bit of code in the programmable block tamyblock.py makes it all happen.
def myblock(lc, x):
Help understanding the detail of Turtle Art's internal Object Oriented Python programming is at Python_code_block
(note: blog does not preserve indents, correct Python indenting is required)