Python Tkinter - Close dialog without closing main window

Just some guy

I'm trying to make a text entry dialog with Tkinter (Python 3.5) but I'm having some problems. This is my code:

class TextEntryDialog:
    def __init__(self, master):
        self.top = Toplevel(master)
        self.textField = Entry()
        self.textField.pack()

root = Tk()
ted = TextEntryDialog(root)
root.mainloop()

When I run this I get a dialog and a main window just like I want, but the problem is that when I close the dialog the main window closes as well. I would like the main window to stay open when the dialog closes, can anyone help me with this?

furas

Add titles to windows and you see

enter image description here

You add Entry to MainWindow.
And you close MainWindow but you think it is TextEntryDialog.

You have to add self.top (Toplevel) as parent in Entry to put it in correct window.

self.textField = Entry(self.top)

.

from tkinter import *

class TextEntryDialog:
    def __init__(self, master):
        self.top = Toplevel(master)
        self.top.title("TextEntryDialog")

        self.textField = Entry(self.top) # parent
        self.textField.pack()

root = Tk()
root.title("MainWindow")
ted = TextEntryDialog(root)
root.mainloop()

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

close sub-window without closing main window PyGTK in python

From Dev

How to close tkinter window without a button and not closing Python completely?

From Dev

Closing main window from toplevel window with tkinter in python

From Dev

exit python program without close Tkinter window

From Dev

Tkinter window not closing after closed file dialog

From Dev

Python 3 | Closing Window on Tkinter

From Dev

Vim close window without closing buffer

From Dev

How to close buffer without closing the window?

From Dev

Creating refreshable tkinter window without closing

From Dev

How to close tkinter window without a button?

From Dev

Python tkinter mainloop not quitting on closing the window

From Dev

How to close a login dialog and show the main window (PyQt4)

From Dev

Is it possible to close the ssh session without closing byobu or the window?

From Dev

Close window confirmation on mdi parent without closing child

From Dev

Closing a Toplevel Tkinter window

From Dev

Tkinter Splits Menu and Main Window Upon Attempted Close

From Dev

Close dialog window on webpage

From Dev

Javascript dialog window close

From Dev

Placing plot on Tkinter main window in Python

From Dev

python tkinter open new window with button click and close first window

From Dev

How to prevent tkinter window from closing when I close Windows command console

From Dev

Python Tkinter small window pops up momentarily before main window

From Dev

Update a dialog without closing it immediately?

From Dev

Set DialogResult without closing the Dialog

From Dev

Set DialogResult without closing the Dialog

From Dev

Tkinter - How can I make a button can create new window and close the main window

From Dev

How to close a sub form from another sub form without closing main form c#

From Dev

How to hide or close second dialogbox before opening the third dialogbox without hiding/ closing main WinForm

From Dev

DM script to close dialog window

Related Related

  1. 1

    close sub-window without closing main window PyGTK in python

  2. 2

    How to close tkinter window without a button and not closing Python completely?

  3. 3

    Closing main window from toplevel window with tkinter in python

  4. 4

    exit python program without close Tkinter window

  5. 5

    Tkinter window not closing after closed file dialog

  6. 6

    Python 3 | Closing Window on Tkinter

  7. 7

    Vim close window without closing buffer

  8. 8

    How to close buffer without closing the window?

  9. 9

    Creating refreshable tkinter window without closing

  10. 10

    How to close tkinter window without a button?

  11. 11

    Python tkinter mainloop not quitting on closing the window

  12. 12

    How to close a login dialog and show the main window (PyQt4)

  13. 13

    Is it possible to close the ssh session without closing byobu or the window?

  14. 14

    Close window confirmation on mdi parent without closing child

  15. 15

    Closing a Toplevel Tkinter window

  16. 16

    Tkinter Splits Menu and Main Window Upon Attempted Close

  17. 17

    Close dialog window on webpage

  18. 18

    Javascript dialog window close

  19. 19

    Placing plot on Tkinter main window in Python

  20. 20

    python tkinter open new window with button click and close first window

  21. 21

    How to prevent tkinter window from closing when I close Windows command console

  22. 22

    Python Tkinter small window pops up momentarily before main window

  23. 23

    Update a dialog without closing it immediately?

  24. 24

    Set DialogResult without closing the Dialog

  25. 25

    Set DialogResult without closing the Dialog

  26. 26

    Tkinter - How can I make a button can create new window and close the main window

  27. 27

    How to close a sub form from another sub form without closing main form c#

  28. 28

    How to hide or close second dialogbox before opening the third dialogbox without hiding/ closing main WinForm

  29. 29

    DM script to close dialog window

HotTag

Archive