Search code examples
python-3.xtkinterlocationhidesimpledialog

Python simpledialog location and hide blank


This is my code

import tkinter as tk
from tkinter import simpledialog
root = tk.Tk()
# root.withdraw()
root.geometry("340x100+50+500")
user_input = simpledialog.askfloat(title="输入框", prompt="请输入内容:", parent=root, initialvalue=34)
user_input = user_input * 60
root.destroy()

When it's run, there was a blank form underneath it, and I wanted to hide it, so I added a piece of code

root.withdraw()

But the root.geometry("340x100+50+500") is not work

so how i do the root.withdraw() and root.geometry("340x100+50+500") both work?


Solution

  • When it's run, there was a blank form underneath it, and I wanted to hide it

    Pay attention to @Bryan Oakley and @acw1668

    The problem can be fixed.

    Pay attention to @Bryan Oakley and @acw1668

    Move root.withdraw() after root.geometry(...)

    Snippet:

    :
    root.geometry("340x100+50+500")
    root.withdraw()
    :
    

    Screenshot:

    enter image description here