Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[solved] canvas.image and Setting Mouse Position

edited July 2012 in OpenSesame

Hello,

I am creating an experiment in which participants see a set of four pictures while hearing instructions to place a red or a blue square above or below some of the pictures via mouse clicks. I have a working experiment, but some of the details are not quite right. I can display the mouse and collect the clicks with no problem, but I don't see a way to set the mouse cursor starting location on each trial to the center of the display. I tried using the pygame function mouse.set_pos([x,y]), but get the following error:

experiment.run(): experiment started at Tue Jul 10 08:26:51 2012
Traceback (most recent call last):
  File "libopensesame\inline_script.pyo", line 121, in run
  File "", line 4, in 
AttributeError: legacy instance has no attribute 'set_pos'

I really need the mouse to start from the same position on every trial. Is there a way to do this?

Also, to make this work I had to display the images via canvas.image() because in order to get the mouse cursor (I'm using canvas.arrow) to refresh I have to use canvas.clear(), which if I understand correctly, also clears any images I've display via a sketchpad. As far as I can tell, the canvas.image() function requires an absolute file path and does not use the file pool. Have I misunderstood this? Do you have any suggestions about how I might avoid the absolute path so I can move this between machines without changing the path?

Thanks,
John

Comments

  • edited 11:09AM
    I tried using the pygame function mouse.set_pos([x,y]), but get the following error:

    That's because a mouse object is not the same as the PyGame mouse class, and doesn't have a set_pos() function. It is a layer on top of the selected back-end, which in your case is probably PyGame.

    What you could do is just bypass the mouse object and call pygame directly. You will no longer be able to switch to the psycho backend if you do this, but as long as the legacy back-end is selected it's fine:

    import pygame
    pygame.mouse.set_pos((exp.get('width')/2,exp.get('height')/2))
    As far as I can tell, the canvas.image() function requires an absolute file path and does not use the file pool.

    You can use exp.get_file(), as shown here: http://osdoc.cogsci.nl/python-inline-code/experiment-functions

    Cheers!

  • edited 11:09AM

    Thanks! Both suggestions worked great!

    John

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games