Howdy, Stranger!

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

Supported by

Is it possible to delete text element on canvas without clear/draw new canvas?


I have a problem presenting running text on a canvas with a background image. It is somehow very slow, although the image (.jpg) is only 76kb with a scale factor of 3 (to make it fullscreen 1920x1080). Does anyone has an idea how to speed up my code?

I also tried drawing a new canvas instead of clearing the old one. However, i had not a speed performance. The letters from the introduction_1 string appear very slowly on the screen and I have the feeling, that the characters further down the string are printed even slower on the screen.

Can anyone help me speed up a running text on a canvas with a background jpg? It's just the introduction to my experiment, so I don't need exact timing.





  • edited October 2022

    Hi @Lars ,

    Just a quick response to your question as formulated in the title of this post: Yes, you can delete elements from a canvas object, but (I think) only if you named them:

    And then:

    del my_canvas["my_named_element"]

    Whether this helps your script getting faster I cannot tell from a first glance. If you want a more detailed response, could you please copy-paste the code here? Or even better, upload the experiment?



    Did you like my answer? Feel free to Buy Me A Coffee :)

  • Hi @lvanderlinden,

    Thank you very much! It is much faster!

    For some reasons the text gets bigger as if it is still overdrawn. By using the clear function, the text keeps the shape, but is clearing the canvas. However, Iam satisfied with the solution. To replicate my function, use the codeblock below and run the function with some (random) text.

    Thank you again!



    Here is my function. It prints character for character on the canvas and is now very fast, even with a background picture.

    def print_text(text, sleep=0, image_path=None, scale=None, x=None, y=None, imagex=None):
      blah = text + '\n'
      text_part = ''
      base = canvas(font_size = 30)
      if image_path != None:
        if imagex == None:
           base.image(image_path, scale = scale)
           base.image(image_path, scale = scale, x=imagex)
      for l in blah:
        base["text"]=Text(text_part+l, center=False, y=y, x=x)
        del base["text"]
        text_part = text_part+l
      return base;
  • Sorry to spam you again. The Text gets bigger, indeed, because the text element is not deleted. Can you help me solving this standalone example below?

    1. draw a red line
    2. make the line green
    3. make the line disappear (delete)
    my_canvas = Canvas()
    my_canvas['my_line'] = Line(-100, -100, 100, 100, color='red')
    my_canvas['my_line'].color = 'green'
    del my_canvas['my_line']

    Thank you,


  • Hi Lars,

    I think the above script (and hopefully the other one too) works fine if you change the backend from Legacy to PsychoPy or Expyriment.

    Could you try that?



    Did you like my answer? Feel free to Buy Me A Coffee :)

  • Sorry for the late response! It works!

    Thank you

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 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