Navigation

    UBports Robot Logo

    UBports Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    How to start a pygame-sdl2 app from Scopes

    Support
    2
    4
    384
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      gmelchett last edited by gmelchett

      How do I start a simple pygame-sdl2 test app from Scopes, like the one below:

      #!/usr/bin/env python2
      import time
      import pygame_sdl2
      pygame_sdl2.import_as_pygame()
      
      import pygame.display
      
      pygame.init()
      di = pygame.display.Info()
      screen = pygame.display.set_mode((di.current_w, di.current_h), pygame.FULLSCREEN)
      screen.fill((255,255,255))
      
      pygame.draw.circle(screen, (255, 0, 0), (di.current_w/2, di.current_h/2), 100, 0)
      pygame.display.flip()
      
      time.sleep(2)
      

      I've remounted / as rw, and apt-get install'ed python-pygame-sdl2
      I've tried to create a .desktop file in ~/.local/share/applications
      and I see that Scopes get's redrawn, but no new icon appears.

      How should such a .desktop look like? Is it the right way to add an app to Scopes?

      Edit: After rebooting the phone, the icon of my app showed up. But how to reload .desktop files in a more smooth way?

      1 Reply Last reply Reply Quote 0
      • dobey
        dobey last edited by

        Firstly, some questions:

        1. Why are you using python2? It will be end of life next year, and we only support python3 on UT.
        2. Why are you installing this to rootfs rather than packaging your game into a click?
        3. What does your .desktop file look like?

        I don't recall if SDL2 is part of the rootfs, but you will need to include the pygame libraries directly within your click package.

        1 Reply Last reply Reply Quote 0
        • G
          gmelchett last edited by

          Hi @dobey,

          1. There are only a python2 pygame_sdl2 package available.
          2. Out of ignorance 🙂 No idea how to make a click. I'll give it a try.
          3. After a reboot Scopes shows up my icons. I guess as a click it will work better.

          Not sure if SDL2 got included when I installed pygame_sdl2 or not.
          Thanks!

          1 Reply Last reply Reply Quote 0
          • dobey
            dobey last edited by

            OK. I'm not sure why a python3 version of pygame isn't available in the Ubuntu repositories, so it looks like you will probably need to build your own version to work with python3, as part of the click packaging.

            You might want to check out clickable for making it easy to package an app up.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post