4

anyone know how to hide python GUI Tkinter, I 've created keylogger, for GUI I used python module Tkinter , I want to add button called HIDE, so when user click it it will hide GUI , and when user press key like CTRL+E , it should unhide GUI....?

1
  • 2
    When the window is hidden it won't receive any keyboard or mouse events. Are you aware of that? It can only log keys pressed in the tkinter window. Commented Mar 31, 2014 at 15:03

4 Answers 4

20

To hide the default root window you can use

root.withdraw()

and to make it visible again you can use

root.deiconify()
Sign up to request clarification or add additional context in comments.

2 Comments

I tried to add root.withdraw() exitButtonPushed(), instead root.destroy() , but it wont work , see code above
thx, I will try another way , I will run keylogger.py when user click RUN , and when uses click HIDE it will exit from gui, but keylogger.py will stay running
4

Python 3:

from tkinter import Tk

root = Tk()
root.withdraw()

Comments

3

If you want to "hide" the window (NOT destroy it) and bring it back, then the way to do that is set the alpha channel.

To hide the window, set the alpha channel to 0:

master.attributes('-alpha', 0)

to restore the window set alpha to 1.0:

master.attributes('-alpha', 1.0)

[EDIT - had the incorrect type/range for the original answer. Range is 0 to 1.0 and is a float]

2 Comments

This isn’t supported on all systems; where not supported, Tkinter always uses 1.0. alpha
Thanks for the comment. Yea, I blew that answer originally.
0

To get rid of a GUI window I used the following in my code.

window.destroy()

and the following to bring it up again.

nameoffunction() window.lift()

1 Comment

window.destroy does nothing. If you want to call the destroy method you must include parenthesis: window.destroy(). If you call that on the root window, the program will exit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.