- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Hide the console of an .exe file created with PyInstaller in Tkinter
To convert a standard Tkinter application into a window executable file, we generally use thePyintsaller package. It converts the application file into an executable application. However, we notice that when we open the executable (or .exe) file, it displays a command shell before opening the application window. We can hide or avoid the console by specifying pyinstaller --oneline filename --windowed command.
In this example, we will create an .exe file of the following program using PyInstaller.
#Import the required libraries from tkinter import * #Create an instance of Tkinter Frame win = Tk() #Set the geometry win.geometry("700x350") #Set the default color of the window win.config(bg= '#aad5df') def display_text(): Label(win, text= "Hello World!", background= 'white', foreground='purple1').pack() Button(win, text= "Click Me", background= "white", foreground= "black", font= ('Helvetica 13 bold'), command= display_text).pack(pady= 50) win.mainloop()
Now, open the terminal in the same location where you have saved app.py and run the following command −
> pyinstaller –onefile app.py –windowed
It will create an app.exe file in the Dist folder.
When we run the executable file located in the Dist folder, it will display a window with a button and a Label widget.
Notice that the .exe file didn't display the command shell before opening the application window.
- Converting Tkinter program to exe file
- How to compile a Python 3 app to an .exe using Tkinter?
- How to hide or disable the mouse pointer in Tkinter?
- Rundll32.exe Attack
- Hide an element from view with CSS
- How to show and hide widgets in Tkinter?
- Opening and reading a file with askopenfilename in Tkinter?
- Hide content with Bootstrap
- jQuery hide() with Examples
- How to hide and show canvas items on Tkinter?
- Disable the underlying window when a popup is created in Python TKinter
- How to hide the controlling borders of an Ellipse using FabricJS?
- How to hide the controlling corners of an Ellipse using FabricJS?
- Save File Dialog Box in Tkinter
- When can a .class file get created in Java?