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?
Asked
Active
Viewed 2.3k times
7

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 Answers
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
-
wow dude, thanks! I wanted to use the messagebox but tkinter window showed up. – DavidPH Jun 18 '18 at 23:04
-
`messagebox.showinfo(title='Info', message='Hello World')`, first argument is the window title, second argument is the message – ATH Feb 19 '22 at 21:42
-
But ... we are talking about a **window in Pygame**. We all know (I guess) about Tkinter widgets ... – Apostolos Nov 01 '22 at 20:35
-
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
-
-
1I'm on my Windows machine right now, but it should be something like `pip install pyzenity` or `pip install PyZenity` in a terminal. – Mat Jones Jan 13 '17 at 17:12
1
you can use pyautogui alert or confirm.
if something_happens:
pyautogui.alert("you have done this")

charchit
- 1,492
- 2
- 6
- 17