Howdy, Stranger!

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

Supported by

[solved] Canvas.copy error

edited January 2015 in OpenSesame

Hi!

I am trying to copy a canvas created in one inline to another inline, later on in the same sequence. The idea is to use the final canvas of the first inline as basis for the second inline (there is a response in between, so I can't put it all in only one inline).

I have one experiment running with such a function fine, but in a slightly different version of the same experiment, the error below comes up (both experiments are 99% the same, except that one works, the other does not)

I get the following error trying to copy a canvas:

Error while executing inline script

phase: prepare
item: Scoring_Script
line: 113
exception message: 'NoneType' object has no attribute 'surface'
exception type: AttributeError

Traceback:
  File "dist\libopensesame\inline_script.py", line 150, in prepare
  File "dist\libopensesame\python_workspace.py", line 111, in _exec
  File "<string>", line 4, in <module>
  File "dist\openexp\_canvas\legacy.py", line 114, in copy
AttributeError: 'NoneType' object has no attribute 'surface'

Apparently, the code causing trouble is this:

Inline 1 (This code runs ok):

#Save final screen for feedback
self.FinScreen = self.offline_canvas()
exp.Screen4FB = self.FinScreen.copy(self.Target)

Inline 2

#Setup feedback canvas
self.TrialFB = self.offline_canvas()
self.TrialFB.copy(exp.Screen4FB)        #<---This line causes the problem (script runs fine if it is commented out)
self.TrialFB.set_font('mono', 30)

Any ideas why it does not work? Like i said, the entire experiment runs smoothly if I comment out that line. But it works just fine in another version of the same experiment...

Thanks for any clue, and hopefully a fix!
Regards,
Daniel

Comments

  • edited 2:31AM

    Hi Daniel,

    Could you perhaps include a bit more of the code? Specifically, where is self.target created, and is it a canvas object?

    Thanks,

    Edwin

  • edited 2:31AM

    Hi Edwin,

    Regarding your question, this is the bit of code that defines self.Target on the fist inline code:

    #Target Display
    self.Target = self.offline_canvas()
    self.Target.set_font('mono', 40)
    self.Target.image(exp.get_file(exp.Trial_BG + ".png"))
    self.Target.fixdot()
    

    Also, here is a dropbox link to the experiment itself.

    Thanks a lot for your help!
    Cheers,

    Daniel

  • edited December 2014

    Finally spotted the problem!

    The mistake is in the following line:

    self.FinScreen = self.offline_canvas()
    exp.Screen4FB = self.FinScreen.copy(self.Target)
    

    This should have been:

    self.FinScreen = self.offline_canvas()
    exp.Screen4FB = self.offline_canvas()
    exp.Screen4FB.copy(self.Target)
    

    The reason is that the copy method copies another canvas in place. It returns nothing, hence in your script exp.Screen4FB was a NoneType.

  • edited 2:31AM

    Hi Edwin!

    Sorry I did not answer before, thank you so much!
    Worked like a charm, as usual.

    Cheers,
    Daniel

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