- 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
How to compile a Python 3 app to an .exe using Tkinter?
Python is well-known for its rich library of extensions and packages. We can import and install the necessary packages from the library. However, if we require to run a Tkinter application with an executable file in Windows Operating System, then we can use the Pyinstaller package in Python. It converts a Python-based application to a native executable file (or.exe).
Follow the steps to compile a Tkinter-based application into an executable file,
Install Pyinstaller using 'pip install pyinstaller'.
Open the Command or Shell in the same directory where the application file is located and run the file using the command, pyinstaller --onefile app.py. It will create necessary folders such as binaries and other source files.
Go to > dist folder where the executable file of the application is located.
Run the .exe file.
#Import the required libraries from tkinter import * #Create an instance of Tkinter Frame win = Tk() #Set the geometry win.geometry("750x350") def display_text(): Label(win, text= "Hey There! Welcome to TutorialsPoint", font= ('Helvetica 22 bold'), foreground="navy").pack() #Create a Button Button(win, text= "Click Me", font= ('Helvetica 13 bold'), foreground= "OrangeRed3", background= "White", command= display_text).pack(pady=50) win.mainloop()
The .exe file will be created in the dist folder, as shown below.
Running the executable file of the application will display a window with a button on it.
Upon clicking the "Click Me" button, it will show a text label in the same window.
- Converting Tkinter program to exe file
- How to create a borderless fullscreen application using Python-3 Tkinter?
- How to create a directly-executable cross-platform GUI app using Python(Tkinter)?
- How to get a string from a tkinter filedialog in Python 3?
- Hide the console of an .exe file created with PyInstaller in Tkinter
- How to create an impressive GUI in Python using Tkinter?
- How to resize an image using Tkinter?
- Select all text in a Text widget using Python 3 with tkinter
- How to compile code using Arduino IDE
- How to create a WebView in an iOS App using Swift?
- How to create a WebView in an Android App using Kotlin?
- How to exit from Python using a Tkinter Button?
- How to compile a java program
- How to Compile a Lua Executable?
- How to compile a Typescript file?