- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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.
Example
app.py
#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()
Output
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.
- Related Articles
- Converting Tkinter program to exe file
- How to create a directly-executable cross-platform GUI app using Python(Tkinter)?
- How to create a borderless fullscreen application using Python-3 Tkinter?
- How to create an impressive GUI in Python using Tkinter?
- Hide the console of an .exe file created with PyInstaller in Tkinter
- How can Tensorflow be used to compile the model using Python?
- How to exit from Python using a Tkinter Button?
- How to resize an image using Tkinter?
- How to compile code using Arduino IDE
- How can Tensorflow be used to compile the exported model using Python?
- How to get a string from a tkinter filedialog in Python 3?
- How to create a WebView in an iOS App using Swift?
- How to create a WebView in an Android App using Kotlin?
- How can Tensorflow be used to compile and fit the model using Python?
- How can Tensorflow be used with Estimator to compile the model using Python?
