Header Ads

ad

Windows Application using Python


In the last post we saw how text can be extracted from an Image file using python,if you find this useful check it here and in this post we will see how we can convert our Python programs into windows application so lets start.

we write python scripts for solving different-different problems.now what if you wanna share this script  to your friend.you might be thinking that it is to easy to share ,just share the python file to your friend.But that will be a good option if your friend already knows about python and also Python must be installed in his/her Machine.



Now Suppose you have made the solution of your friend's problem and you want to share the solution to your friend but your friend does not  know about the python language and also python is not installed in their Machine in that case the above method won't work so you need to convert your python code into .exe file format before sharing it your friend .I am sure you guys know about .exe file format in case you don't no need to worry.

What is .exe Files ?

.exe files are the executable file formats that Microsoft windows uses for their Applications Programs.

Requirements :-  Now you have understood that .exe file should be shared  but what are the requirements for converting the python file into .exe file ? , you need the following library for this task.

  • auto-py-to-exe

Installation :- Open your command prompt or cmd and type the below command.

pip install auto-py-to-exe

you can verify that the installation is successful by checking the version of the auto-py-to-exe just write the below code for checking the version.

auto-py-to-exe --version










Code :- Lets write a Simple Python program and convert it into the .exe format.

Step 1 :- make the python file let say "file.py". that will print the multiplication table of the number entered by the user.

while True:
    try:
        number  = int(input("Enter the Number"))
        for  each_multiplier in range(1,11):
           print(f"{number} x {each_multiplier} = {number*each_multiplier}")                                       
        choice = input("press 1 to exit")
        if int(choice) == 1:
           break
    except Exceptions as e:
        print(e)
        input("Some error occured")

Step 2 :- Now open the command prompt and run the auto-py-to-exe command.



Step 3 :- once you enter the command Auto Py to Exe application will start immediately.





Step 4 :- Select script path where your file is located and in the settings tab enter the path of the destination folder.




Step 5 :- Click on the Convert .Py to .Exe after that building procedure will start and in few second you will get your exe file.Building time is dependent on how long your program is.



the moment your build is successful click on the open output folder.you will see that a folder of your filename is generated go to inside that folder where you will see the .exe file of your python file.




See here it is,



step 6 :- Hurray you just made your first Windows app.



you might be wondering that windows app has colorful graphical user interface(GUI) .yea i agree you can also make the colorful GUI using tkinter library and do this same procedure for making your GUI based windows application.

I hope you have learning something new today , Now I would like to request you follow and share this blog with your friends.Keep Learning.

Thank You for Reading the Post


No comments