Howdy, Stranger!

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

Supported by

Getting reaction time during a canvas.show()

Hello!

So I am confused about how to record the time it takes for a mouse click when a canvas appear on the screen.
The thing I want to do is as follow:

  • I present a canvas;
  • I wait for a mouseclick to make it disappear.

So here is the code I used for now:


t = my_canvas_Practice_Sym.show() my_mouse = Mouse(visible=False) button, position, timestamp = my_mouse.get_click() while True: if button is not None: break var.reaction_time_canvas = timestamp - t

There are two things I am wonder here:

  • could you confirm that timestamp corresponds to the time of the mouseclick and not the time when the mouse is initiated?
  • I wonder if my approach is the best here for timing accuracy. First I draw the canvas and second I initiate the mouse. Could you confirm the time it takes to the mouse to initiate is so small it doesnt matter?

Thank you!

Comments

  • Hi,

    could you confirm that timestamp corresponds to the time of the mouseclick and not the time when the mouse is initiated?

    Confirmed.

    I wonder if my approach is the best here for timing accuracy. First I draw the canvas and second I initiate the mouse. Could you confirm the time it takes to the mouse to initiate is so small it doesnt matter?

    Probably true, but given the ease with which to fix it, there is no reason why not optimizing it.

    Also, yourwhile loop doesn't do anything currently. The button is pressed before, so that the while loop is effectively skipped. If you set the timeout of the mouse response to something else than infinite, you will probably even end up in an infinite loop. So, to fix it, here two suggstions:

    1) Drop the while loop and use the timeout keyword:

    # advantage: it is more straightforward and you write less code
    my_mouse = Mouse(visible=False,timeout = 2000) # 2 seconds timeout 
    # show
    t = my_canvas_Practice_Sym.show()
    button, position, timestamp = my_mouse.get_click()
    var.reaction_time_canvas = timestamp - t
    

    2) Combine timeout and while loop

    # advantage: This code is more flexible and you could add other computations to the loop
    my_mouse = Mouse(visible=False,timeout = 2) # 2 MILLISECONDS timeout 
    # show
    t = my_canvas_Practice_Sym.show()
    while True:
        button, position, timestamp = my_mouse.get_click()
        if button != None:
            var.reaction_time_canvas = timestamp - t
            break
    

    Hope this helps.

    Eduard

    Buy Me A Coffee

  • Hey Eduard!

    Thanks a lot yes it helps! I just do not understand why in the first example the canvas stop after a mouse click. I mean there is nothing indicating that my_canvas_Practice_Sym.show() should disappear after a mouse click no?

    Thank you!

    Sylvain

  • Hi,

    I think this is because the experiment is simply over, no? If you have a sleep statement after the loop, it would stay on screen? But I must admit I haven't tried it myself.

    Eduard

    Buy Me A Coffee

  • Hey Eduard,

    No I just meant with your example:

    # advantage: it is more straightforward and you write less code
    my_mouse = Mouse(visible=False,timeout = 2000) # 2 seconds timeout 
    # show
    t = my_canvas_Practice_Sym.show()
    button, position, timestamp = my_mouse.get_click()
    var.reaction_time_canvas = timestamp - t
    

    I do not get how

    my_canvas_Practice_Sym.show()
    

    Stop after a mouse click. Implicitely does it mean that showing the canvas just update the screen (like if we would set up a duration of 0ms to a sketchpad) and the script progress to the mouse object?
    I was assuming that when my_canvas_Practice_Sym.show() was called somewhat it was staying active (updating the screen indefinitely) but it is just a call to a single update of the screen right?

    Thank you!

    Best,

    Sylvain

  • HI,

    Yes, it is a single call. Basically, once updating the screen and showing the canvas and then immediately proceeding to the mouse response and waiting for a click until the end of the timeout (2000ms). Once it was clicked (or time is up) it will proceed with the code below, or in case there is no code anymore, with the next item in the sequence. Does that make sense?

    Eduard

    Buy Me A Coffee

  • Hey Eduard,

    Yes I get it, it makes sense. It is like a single update of the screen. Much more simple than what I imagined!

    Thanks!

    Best,

    Sylvain

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