I have trouble using the simpledialog widget within a toplevel widget. The code extract below results in an empty pop-up window (entitled "Blocked fields"), a second pop-up window with the correct simpledialog (also working fine) and the main game window (not featured here in the code).
I want to get rid of the second obsolete window, and I reckon it must be a simple thing, but I am stuck (complete python newbie, if you can't tell already). Any hints highly appreciated!
import tkinter as tk
from tkinter import simpledialog
root = tk.Tk()
root.geometry("580x400+300+200")
root.title("Pah Tum")
#Popup window
block_request_top = tk.Toplevel()
block_request_top.title("Blocked fields")
entry_block = simpledialog.askinteger("Blocked fields", \
"Please enter a number of fields to be blocked. Choose an \
uneven number between 5,13]", parent=block_request_top, minvalue=5, \
maxvalue=13)
Easiest way to achieve this for this specific problem may be making use of
withdraw
,iconify
anddeiconify
methods by creatingentry_block
in between them as in:entire code:
I highly doubt that this is what you will eventually end up using though.