python - How to remove a button created by pygbutton -


I want to delete the button I created. I have created it:

  Button1 = pygbutton.PygButton ((50, 50, 60, 30), '1') button2 = pygbutton.Pygbutton ((120, 50, 60, 30), '2') button3 = pigbutton. Piegbutton (All for Biton = (Button 1, Button2, Button3) All Button =) (BB.Dre (Screen))   

However, when a button is clicked, I would like to clean the button in the screen and show something else on the screen.

How can I do this?

A common thought I thought was to create a new screen after pressing a button.

Actually, I have a boole that I had called buttonhubbed . As long as no button is pressed, we are just checking to see if the event was a button press. After pressing it, we set bool to true , making the background "clear" (by creating a new screen on the old one), and then continue to do whatever we want. My example code only "deletes" the button, changes the color of the background, and changes the caption on the window, but you use this idea, whatever you want about the status of your game post-button press. You can.

Here's an example, which you should be able to run on your machine for testing. Import pygame.locals from Piegut, Pagbutton * pygame.init () #Create "Pre-button Press Screen" width = 1024 height = 768 screen = pygame.display.set_mode ([ Width, height]) pygame.display.set_caption ('OLD SCREEN NAME') background = pygame.Surface (screen.get_size ()) background = background .convert () background.fill ((250, 250, 250)) screen. Blunt (background, [0,0]) pygame.display.flip () button1 = pygbutton.PygButton ((50, 50, 60, 30), '1') Button 2 = Pibbutton. Piegbutton ((120, 50, 60, 30, '2') Button 3 = Pegbutton. Piegbutton ((1950, 60, 30), '3') buttonconnected = false screenPostButtonPress (): width = 1024 height = 768 screen = pygame.display.set_mode ([width, height]) Pygame.display.set_caption ( 'NEW SCREEN NAME !!!!!!!') Background = Pugetam. Surface (screen. Gate_size ()) background = background. Convert () background .phil ((20, 20, 40)) screen.blit (background, [0,0]) pygame.display.flip () #buttons Not waiting on the screen after a button def is forobutanclick ( ): allButtons = [button1, button2, button3] buttonevent1 = button1.handleEvent (event) buttonevent2 = button2.handleEvent (event) buttonevent3 = button3.handleEvent (event) allButtons in B: b.draw (screen) in buttonevent1 'Click' or 'click' in buttonevent2 or 'click' in buttonevent3: Returns the wrong back true, while true: for event in pygame.event.get (): if event.type == QUIT: pygame.quit () sys.exit () # Press to enter a button Wait, once, press the button on the screen by creating a new screen "Clear" button == False and WaitingFattonClick () == False: ButtonBeanspress = True ScreenPortButtonPress () pygame.display.update ()

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -