| Issue 78: | MTScatterWidget position not updated/correct | |
| 1 person starred this issue and may be notified of changes. | Back to list |
What steps will reproduce the problem? Run the code: (also at: http://dpaste.com/hold/64106/) NOTE: You need an image, any image, named "pic1.jpg" in the same directory as the code. ---- from pymt import * class MTTest(MTScatterImage): def __init__(self, pos): filename = "pic1.jpg" MTScatterImage.__init__(self, filename=filename, pos=pos) def on_touch_up(self, touches, touchID, x,y): print "Touch at:" , x, y MTScatterImage.on_touch_up(self, touches, touchID, x, y) def pymt_plugin_activate(w, ctx): ctx.c = MTTest(pos = (w.width/2, w.height/2)) w.add_widget(ctx.c) def pymt_plugin_deactivate(w, ctx): w.remove_widget(ctx.c) if __name__ == '__main__': w = MTWindow() ctx = MTContext() pymt_plugin_activate(w, ctx) runTouchApp() pymt_plugin_deactivate(w, ctx) ----- You'll notice in the output that although you move the widget on the screen, the self.pos variable is not being updated correctly. It should update with the widget's position on the screen. ----- As a temporary workaround, you can use the following code: (also at: http://dpaste.com/hold/64108/) ----- from pymt import * class MTTest(MTScatterImage): def __init__(self, pos): filename = "pic1.jpg" MTScatterImage.__init__(self, filename=filename, pos=pos) def on_touch_up(self, touches, touchID, x,y): touchpos = self.to_local(x, y) print "Touch at:" , touchpos actualx = x - touchpos[0] actualy = y - touchpos[1] position = (actualx, actualy) print position #if self.collide_point(x, y): # print "Touched the widget!" MTScatterImage.on_touch_up(self, touches, touchID, x, y) def pymt_plugin_activate(w, ctx): ctx.c = MTTest(pos = (w.width/2, w.height/2)) w.add_widget(ctx.c) def pymt_plugin_deactivate(w, ctx): w.remove_widget(ctx.c) if __name__ == '__main__': w = MTWindow() ctx = MTContext() pymt_plugin_activate(w, ctx) runTouchApp() pymt_plugin_deactivate(w, ctx) ---- Notice that now the position is correctly reported.
Jul 7, 2009
Sorry, the code for the first part should be:
from pymt import *
class MTTest(MTScatterImage):
def __init__(self, pos):
filename = "pic1.jpg"
MTScatterImage.__init__(self, filename=filename, pos=pos)
def on_touch_up(self, touches, touchID, x,y):
print "Touch at:" , x, y
print self.pos
MTScatterImage.on_touch_up(self, touches, touchID, x, y)
def pymt_plugin_activate(w, ctx):
ctx.c = MTTest(pos = (w.width/2, w.height/2))
w.add_widget(ctx.c)
def pymt_plugin_deactivate(w, ctx):
w.remove_widget(ctx.c)
if __name__ == '__main__':
w = MTWindow()
ctx = MTContext()
pymt_plugin_activate(w, ctx)
runTouchApp()
pymt_plugin_deactivate(w, ctx)
---
The code on DPaste.com is correct.
Jul 7, 2009
This issue was closed by a000bb946b.
Status:
Fixed
|
Owner: txprog
Labels: Component-Core Milestone-0.3