messagebox
is used to show messages to the user, a warning, etc, or to providea choice between yes/no/cancel/abort. What you're looking for instead is Radiobutton
.
Each Radiobutton has a value and is tied to a variable fetching that value. When you group many such buttons tied to the same variable, you get a one-of-many selections.
Here's a simple example, where the values are integers (starting from 0) for convenience. This is something you can change if you insist on strings. All you need is a frame with your radiobuttons and a launch game button, which reads your choice and passes it to your main app.
As commented by Bryan Oakley, while you can open up a secondary window, you don't need to. You can use the root window to display the choices, and once the user makes the choice you can replace the radiobuttons with the main part of the program. You can display a popup window if you want, but it's not the only solution.
import tkinter as tk
class StartGameMenuWindow:
def __init__(self, parent):
self.parent = parent
self.frame = tk.Frame(parent)
self.frame.pack()
self.menu_value = tk.IntVar()
self._create_items()
def _create_items(self):
modes = ('Basic', 'Advanced')
for value, mode in enumerate(modes):
tk.Radiobutton(self.frame,
text=mode,
variable=self.menu_value,
value=value).pack()
tk.Button(self.frame, text='Start game', command=self.launch).pack()
def launch(self):
value = self.menu_value.get()
self.frame.destroy()
# Launch your game window with `value` as input
root = tk.Tk()
m = StartGameMenuWindow(root)
tk.mainloop()
If you really want a popup window,
# instead of
self.frame = tk.Frame(parent)
self.frame.pack()
# use this, but make sure to rename `self.frame` everywhere in the class
self.window = tk.Toplevel()