7

I want to create a pop up window inside the game which will display result for a small game, if you click OK, the game continues, but that doesn't matter. How do you even create such box so it will pop up when I call it? I read question with pgu, what is pgu? Is it another external library?

Simeon Aleksov
  • 1,275
  • 1
  • 13
  • 25
  • you can treat popup window as another sprite in Pygame. Create class with `draw()`, `update()`, `handle_event()` and use similar like `Player` or `Enemy`. – furas Jan 13 '17 at 20:56
  • [PyGame GUIs](http://www.pygame.org/wiki/gui) - there is link to `pgu` and `OcempGUI` – furas Jan 13 '17 at 21:00

4 Answers4

8

I used tkinter and created a message box,

from tkinter import *
from tkinter import messagebox
Tk().wm_withdraw() #to hide the main window
messagebox.showinfo('Continue','OK')
Simeon Aleksov
  • 1,275
  • 1
  • 13
  • 25
7

You can treat popup window like another sprite in Pygame.

Create class with draw(), update(), handle_event() and use it similar to Player and Enemy.

Simple example with own Button in PyGame


You may also use one of PyGame modules for GUI but some of themy may need changes in code because they run own event loop.

Example GUIs

More on PyGame page: PyGame GUIs

furas
  • 134,197
  • 12
  • 106
  • 148
1

You can use PyZenity, installable via Pip. Then, you can just do:

from PyZenity import *
cancel = Question('Continue game?')
Mat Jones
  • 936
  • 1
  • 10
  • 27
1

you can use pyautogui alert or confirm.

    if something_happens:
       pyautogui.alert("you have done this")
charchit
  • 1,492
  • 2
  • 6
  • 17