set mouse cursor position

1,052 views
Skip to first unread message

Xrzys

unread,
Jun 17, 2012, 1:41:57 PM6/17/12
to Kivy users support
How to set mouse position to (100,100) when i started programm?

Xrzys

unread,
Jun 17, 2012, 3:09:43 PM6/17/12
to Kivy users support
ok I found:

mouse.set_pos([1, 1])

but it's not working on android why?

Mathieu Virbel

unread,
Jun 18, 2012, 6:44:27 AM6/18/12
to kivy-...@googlegroups.com
Hi,

We don't support that, where did you found "mouse.set_pos"?
Again, kivy is touch based, you should work with touch instead.
And manipulating the cursor feel wrong...

Mathieu

Xrzys

unread,
Jun 18, 2012, 3:21:41 PM6/18/12
to Kivy users support
ok but I want to check when mouse button (left or right) was pressed
and I cant found the good way :((I create on widget a button and want
to move cursor on the right position on the screen (on button area)
then I know when mouse button was pressed...
Is there another way to check when mouse button was pressed? please
help me

Mathieu Virbel

unread,
Jun 18, 2012, 4:17:42 PM6/18/12
to kivy-...@googlegroups.com
In the on_touch_* event, you can check if the dispatched touch have a
"button" profile, and check which one:

if 'button' in touch.profile:
print 'touch have a button pressed:', touch.button

Xrzys

unread,
Jun 26, 2012, 2:36:22 PM6/26/12
to kivy-...@googlegroups.com
ok thank you but can you write here working code for it because I can't handle it :(

Xrzys

unread,
Jul 1, 2012, 7:48:48 AM7/1/12
to kivy-...@googlegroups.com

 Hello,

 
I just wrote simple code to check when mouse button was pressed:
 
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.widget import Widget
 
liczba = 0
 
class MyApp(App):
 
 def build(self):
      parent = Widget()
 
 def nacisnij(self):
     global liczba
     print liczba
     liczba = liczba + 1
     a = Button(text='My first button')
     a.bind(on_press=nacisnij)
     c = Label(text='testowy')
 
if 'button' in touch.profile:
       print 'touch have a button pressed:', touch.button
 
     parent.add_widget(c)
     parent.add_widget(a)
 
     return parent
if __name__ == '__main__':
    MyApp().run()
 
 
but It's not working I dont see any "touch have a button pressed:' in console and I have an error :(
 
     if 'button' in touch.profile:
 NameError: name 'touch' is not defined
 
why?
 

Xrzys

unread,
Jul 1, 2012, 10:08:25 AM7/1/12
to kivy-...@googlegroups.com
Ok thnak you Mathieu.... i worte a code...
 
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.widget import Widget
liczba = 0
class MyPaint(Widget):
 def on_touch_down(self, touch):

  if 'button' in touch.profile:
   print 'touch have a button pressed:', touch.button

class MyApp(App):
 
 def build(self):
  parent = Widget()
 
  def nacisnij(self):
   global liczba
   print liczba
   liczba = liczba + 1
  a = Button(text='My first button')
  a.bind(on_press=nacisnij)
  c = Label(text='testowy')
  parent.add_widget(c)
  parent.add_widget(a)
  
  return MyPaint()
if __name__ == '__main__':
    MyApp().run()
now i see in the console  'touch have a button pressed:' left or right but... widget is black and I don't see any button-widget :/ can someone help me?
Reply all
Reply to author
Forward
0 new messages