PyUI2 with Pygame

Help
Anonymous
2005-05-31
2013-03-08
  • Anonymous - 2005-05-31

    I have a question regarding the use of PyUI2 with Pygame.  I am trying to add PyUI2 into an existing Pygame project, but I am not sure how to tell PyUI2 to draw itself without erasing everything else.

    My main problem at the moment is that pyui2.draw() fills the screen with a black background, which overwrites anything else on the screen.  Do I need to reimplement draw, can I make this background transparent, or is there another way to wrap PyUI2 around my existing project?

     
    • Bluecat

      Bluecat - 2005-05-31

      You don't need to reimplement draw, PyUI2 has the functionality already there to let you do this.

      The renderers allow you to set a background drawing method. By default this is set to self.clear which simply erases the background. What you need to do, is to create a method with one parameter and during initialisation call the renderers setBackMethod function.

          from pyui2.desktop import getRenderer

          pyui2.init(width, height, "2d", 0, "MyApp")
          getRenderer().setBackMethod(myDrawingFunction, myParameter)

      That should be all there is to it. If you have any more problems please let me know.

      cheers

       
    • Anonymous - 2005-06-02

      Thanks for the prompt response!  I got it to work, although I have one more problem now.  PyUI2 intercepts Pygame's events, so I cannot intercept mouse clicks.  Is there a way to pass these events on to a function, while still allowing PyUI2 to read them?

       
      • Bluecat

        Bluecat - 2005-06-02

        You should be able to register an event through the desktop and attach a handler to get the mouseclick. Try this.

        getDesktop().registerHandler(pyui.locals.LMOUSEBUTTONDOWN, self.onMouseDown)

        def onMouseDown(self, event):
            # Event handling here
            return 0

        Give that a try. I haven't done this myself yet, but looking at the code, and the old PyUI docs, I think it should work.

        Let me know how you go.

        cheers

        John

         
        • Bluecat

          Bluecat - 2005-06-02

          Oops. Cut and paste error. Unfortunately you can't edit these posts.

          pyui.locals should be pyui2.locals.

           
          • Anonymous - 2005-06-03

            It worked!  Thanks again for the help.

             

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks