Python Forum
Programming Python as a MS Windows app? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Programming Python as a MS Windows app? (/thread-13323.html)



Programming Python as a MS Windows app? - Brian123 - Oct-10-2018

Is it possible to create a Python program that I can click on just like my other Microsoft Windows applications on my desktop?
Any program that I write in Python needs me to go to the dos prompt to run the program so it would be nice to be able to put the Python created program on my desktop and be able to click on it to run the program. Can this be done?

Brian123


RE: Programming Python as a MS Windows app? - nilamo - Oct-10-2018

Sure. Using a simple bat file, you can do anything you could do from the command line. If you don't want a command prompt to pop open when you run it, you could use something like py2exe or pyinstaller to create an executable. But those are packaging things, and not useful if your program is still under construction.


RE: Programming Python as a MS Windows app? - Yoriz - Oct-10-2018

Yes it's possible, you can use cx_freeze


RE: Programming Python as a MS Windows app? - Brian123 - Oct-10-2018

(Oct-10-2018, 05:14 AM)Yoriz Wrote: Yes it's possible, you can use cx_freeze
Good to know thanks. I must test cx_Freeze. I hope it's freeware.

Now that I have installed cx_Freeze, how do I use it to turn a python script into exe code?


RE: Programming Python as a MS Windows app? - buran - Oct-10-2018

it's not just cx_freeze. There are also other tools, like pyinstaller.
Also probably the easiest (i.e. no need to convert to exe) is to create shortcut to your python interpreter. Then edit the properties of the shortcut and add the full path to your script in the Target field:
[attachment=480]
In this case you will need to ask user to press a key at the end of the script because otherwise the CommandPrompt window will close automatically when the script execution ends.
Finally, if you wish to make *real* GUI program you need to look at some of the GUI packages. Tkinter comes is included in Windows distributions bu there are others/better ones


RE: Programming Python as a MS Windows app? - Brian123 - Oct-10-2018

(Oct-10-2018, 05:46 AM)Brian123 Wrote:
(Oct-10-2018, 05:14 AM)Yoriz Wrote: Yes it's possible, you can use cx_freeze
Good to know thanks. I must test cx_Freeze. I hope it's freeware.

Now that I have installed cx_Freeze, how do I use it to turn a python script into exe code?

I managed to find some info on how to use cxFreeze. I need to find a while so it is part of the system. I can't remember how I made Python part of the system so it is reconsidered when I type "python" at the prompt. At the moment if I type cxFreeze at the dos prompt I get a message that DOS doers not know this program. Any help would be great to get me on to the next step thanks.

Brian


RE: Programming Python as a MS Windows app? - nilamo - Oct-10-2018

If you installed it through pip, it should already work from the command line. If you didn't install it through pip, then you should.


RE: Programming Python as a MS Windows app? - Brian123 - Oct-10-2018

(Oct-10-2018, 06:37 AM)buran Wrote: it's not just cx_freeze. There are also other tools, like pyinstaller. Also probably the easiest (i.e. no need to convert to exe) is to create shortcut to your python interpreter. Then edit the properties of the shortcut and add the full path to your script in the Target field: [attachment=480] In this case you will need to ask user to press a key at the end of the script because otherwise the CommandPrompt window will close automatically when the script execution ends. Finally, if you wish to make *real* GUI program you need to look at some of the GUI packages. Tkinter comes is included in Windows distributions bu there are others/better ones
It would be nice to be able to send someone a program that I have written so they can use it on their computer so cxFreeze might be better as it turns code into exe files. But I might try both. Thanks for the info. Brian


RE: Programming Python as a MS Windows app? - Brian123 - Oct-17-2018

There must be some way to use cxFreeze.
If you have installed this program then what did you type in to use this program?