| | |
Running a program by double-click (windows)
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: May 2008
Posts: 13
Reputation:
Solved Threads: 3
Just starting Python and I have a question about how to run it just by double-clicking. With simple things like
Any help would be greatly appreciated since I want to begin on a little project and for it to make any sense I'd need it to start up by itself. I've been searching the forums but there are pages upon pages of people trying to make it into an executable or irrelevant information and I'm not quite sure what the proper keywords for this is. Sorry for the trivial question.
print "Hello World" the wait for user input clause can be added and it will run by double clicking and give the desired output, but when I try it with something that uses a window for example it will not. All I get is some compiled python file that does nothing. I don't really want to make an executable if possible since I'd think there'd be a way to do this without one. Any help would be greatly appreciated since I want to begin on a little project and for it to make any sense I'd need it to start up by itself. I've been searching the forums but there are pages upon pages of people trying to make it into an executable or irrelevant information and I'm not quite sure what the proper keywords for this is. Sorry for the trivial question.
•
•
Join Date: Jul 2006
Posts: 608
Reputation:
Solved Threads: 150
Actually, it probably does something and then closes the window immediately -- which means you can't see it!
Try this:
If you double-click this, you should get output in a command prompt window.
Jeff
Try this:
Python Syntax (Toggle Plain Text)
print "Hello, World" raw_input("Press <Enter> to exit.")
If you double-click this, you should get output in a command prompt window.
Jeff
•
•
Join Date: May 2008
Posts: 13
Reputation:
Solved Threads: 3
The raw_input part is what I meant by "wait for user input clause". Sorry for not being more clear, but this does not seem to work with some programs. Here's an example of a program I'm trying to do this with (got it as example code from one of the forums):
What would I have to do to code like this to make it double-clickable?
Python Syntax (Toggle Plain Text)
# import all the Tkinter methods from Tkinter import * # create a window frame frame1 = Tk() # create a label label1 = Label(frame1, text="Hello, world!") # pack the label into the window frame label1.pack() frame1.mainloop() # run the event-loop/program
What would I have to do to code like this to make it double-clickable?
Last edited by Kabooom; May 25th, 2008 at 1:58 pm.
•
•
Join Date: May 2008
Posts: 13
Reputation:
Solved Threads: 3
Hmm maybe my install is bad then. Even by renaming it .pyw as I did before, all I get is a .pyc (Compiled Python File). Clicking on this does nothing but show a command prompt for an instant and it disappears. Are you also using Windows XP jrcagle?
EDIT: Oh and to note I get the .pyc file from both .py and .pyw
EDIT: And another thing to add... Code using wxPython works fine, but the examples with Tkinter do not. Didn't plan on using Tkinter anyway, but after clicking it a ton of times it looks like the command prompt says something isn't defined. Unless anyone has a reason for this I'll probably mark this as solved in a couple hours.
EDIT: Oh and to note I get the .pyc file from both .py and .pyw
EDIT: And another thing to add... Code using wxPython works fine, but the examples with Tkinter do not. Didn't plan on using Tkinter anyway, but after clicking it a ton of times it looks like the command prompt says something isn't defined. Unless anyone has a reason for this I'll probably mark this as solved in a couple hours.
Last edited by Kabooom; May 25th, 2008 at 9:45 pm. Reason: added info
![]() |
Similar Threads
- Windows Explorer Problem/Virus (Viruses, Spyware and other Nasties)
- How do i run perl on windows 98 (Perl)
- 7 Tips to Keep your PC Running At Peak Performance (Windows tips 'n' tweaks)
- "Your Windows is corrupted with spyware virus" Popup (Viruses, Spyware and other Nasties)
- Ie Favorites replaced with C:/ WINDOWS folder (Viruses, Spyware and other Nasties)
- SP2 Windows update; lost internet connection (HJT Log) (Viruses, Spyware and other Nasties)
- Desktop folder shortcuts quit, can't double-click & launch media files (Viruses, Spyware and other Nasties)
- IE hijacked-> res://sp.html#96676 (Viruses, Spyware and other Nasties)
Other Threads in the Python Forum
- Previous Thread: If and Else
- Next Thread: Fibonacci sequence
| Thread Tools | Search this Thread |
Tag cloud for Python
accessdenied apache application argv beginner book change code color dictionary dynamic edit editing enter examples excel file filename float format ftp function gui homework import inches input java keyboard lapse library line lines linux list lists loop microphone mouse movingimageswithpygame mysql newb number numbers numeric output parameters parsing path port prime program programming projects py2exe pygame pyopengl pyqt python random recursion recursive redirect remote reverse rpg scrolledtext search server session simple smtp software sprite ssh statictext string strings syntax table tennis terminal text thread threading time tkinter tlapse trick tuple tutorial ubuntu unicode unit urllib urllib2 variable windows wordgame wxpython






