473,386 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Problem with python

Hi there.
I downloaded python a couple of days ago from the official site and
have started writing simple programs in the python gui (this being my
first attempt at programming ever). The only thing is when I write
python code in a text editor and save it as a .py file, when I double
click it all that happens is a black box flashes up on the screen, but
nothing else!?

At first I thought this was because I had only written a hello world
program, and that the box had displayed "hello world" and then closed.
But then I wrote a program requiring user input and the same thing
happened... Am I doing something wrong?

Thanks in advance for any help!

//mac
Mar 29 '08 #1
5 1427
Lie
On Mar 30, 2:57*am, mac_the_sco...@hotmail.com wrote:
Hi there.
I downloaded python a couple of days ago from the official site and
have started writing simple programs in the python gui (this being my
first attempt at programming ever). The only thing is when I write
python code in a text editor and save it as a .py file, when I double
click it all that happens is a black box flashes up on the screen, but
nothing else!?

At first I thought this was because I had only written a hello world
program, and that the box had displayed "hello world" and then closed.
But then I wrote a program requiring user input and the same thing
happened... Am I doing something wrong?

Thanks in advance for any help!

//mac
open the program in IDLE (or any other Python IDEs). I'm guessing that
your program is printing a traceback (error) when trying to get input
that's why it immediately closes itself.
Mar 29 '08 #2
Lie wrote:
On Mar 30, 2:57 am, mac_the_sco...@hotmail.com wrote:
>Hi there.
I ... started writing simple programs in the python gui... when I write
python code ...[and]... double click it all that happens is a black box
flashes up on the screen, but nothing else!? ....

open the program in IDLE (or any other Python IDEs). I'm guessing that
your program is printing a traceback (error) when trying to get input
that's why it immediately closes itself.
Another possibility is to open a shell (or command window or "dos box"),
and in that window type in "python myfile.py" You'll see error messages
because the display window does not depend on the program staying alive.

By the way, a better thing to have said when you asked this would
include your OS, the python version, and the GUI system you are using.
Those details matter. If you are doing wxPython programming, for
example, you cannot easily use IDLE for your program (GUI systems
fight for control of the display).

-Scott David Daniels
Sc***********@Acm.Org
Mar 29 '08 #3
On Mar 29, 5:33*pm, Scott David Daniels <Scott.Dani...@Acm.Orgwrote:
Lie wrote:
On Mar 30, 2:57 am, mac_the_sco...@hotmail.com wrote:
Hi there.
I ... started writing simple programs in the python gui... *when I write
python code ...[and]... double click it all that happens is a black box
flashes up on the screen, but nothing else!? ....
open the program in IDLE (or any other Python IDEs). I'm guessing that
your program is printing a traceback (error) when trying to get input
that's why it immediately closes itself.

Another possibility is to open a shell (or command window or "dos box"),
and in that window type in "python myfile.py" You'll see error messages
because the display window does not depend on the program staying alive.

By the way, a better thing to have said when you asked this would
include your OS, the python version, and the GUI system you are using.
Those details matter. *If you are doing wxPython programming, for
example, you cannot easily use IDLE for your program (GUI systems
fight for control of the display).
The screen is real (r-e-a-l): all manners intended. Real. Just bid
and auction.
Mar 30 '08 #4
On Mar 30, 12:34*am, castiro...@gmail.com wrote:
>
The screen is real (r-e-a-l): all manners intended. *Real. *Just bid
and auction.
Please leave the newbies alone. They have enough trouble just getting
their Python environments running, without trying to decipher your
pseudo-profound chatterbot-speak.

-- Paul
Mar 30 '08 #5
Lie
mac_the_sco...@hotmail.com wrote to me:
(snip)
OK thanks mate you're the man :)
One more question though :P
If I write a python script in a text editor (I use Programmers
Notepad), how do I write indentations properly? e.g.:
---------------------------------------------------
temperature = input("How hot is the spam? ")
while temperature < hot_enough:
print "Not hot enough... Cook it a bit more..."
sleep(30)
temperature = input("OK. How hot is it now? ")
print "It's hot enough - You're done!"

(taken from hetland.org)
---------------------------------------------------
Is it simply a case of hitting the spacebar until it looks right?
Yep, it's just a matter of hitting spacebar until it looks right, but
you should also be aware that the Python Interpreter doesn't like it
if you mix tabs and spaces, so make sure you only use either one of
them. As an additional note, Python's style guideline says you should
use 4 spaces (additionally, most Python IDEs automatically convert
tabs into 4 spaces for convenience and to avoid mixing tabs and
cases).

PS: I'll mirror this to comp.lang.python
Mar 30 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Atul Kshirsagar | last post by:
I am embedding python in my C++ application. I am using Python *2.3.2* with a C++ extention DLL in multi-threaded environment. I am using SWIG-1.3.19 to generate C++ to Python interface. Now to...
49
by: Mark Hahn | last post by:
As we are addressing the "warts" in Python to be fixed in Prothon, we have come upon the mutable default parameter problem. For those unfamiliar with the problem, it can be seen in this Prothon...
2
by: gaool | last post by:
Hello, I try to launch a Python script on SunOS system but I have this error: """Traceback (most recent call last): File "ihm1_1.py", line 3, in ? from Tkinter import * File...
11
by: Faheem Mitha | last post by:
Hi, I'm not sure what would be more appropriate, so I'm ccing it to both alt.comp.lang.learn.c-c++ and comp.lang.python, with followup to alt.comp.lang.learn.c-c++. While working with a...
3
by: Al Christians | last post by:
I started having some problems running python programs (python 2.3) from the Win2k command line. I would get crashes with an NTVDM error. Even just executing python would cause it. I upgraded to...
2
by: Ugo Di Girolamo | last post by:
I have the following code, that seems to make sense to me. However, it crashes about 1/3 of the times. My platform is Python 2.4.1 on WXP (I tried the release version from the msi and...
3
by: krzychu | last post by:
Hi, I have installed brand new platform - Zope-2-7-6, Python 2.4.1, Plone 2.0.5, OS Debian 1:3.3.6-2. After import a old Plone site from the following platform Zope-2-7-4, Python 2.3.3, Plone...
25
by: Xah Lee | last post by:
Python Doc Problem Example: gzip Xah Lee, 20050831 Today i need to use Python to compress/decompress gzip files. Since i've read the official Python tutorial 8 months ago, have spent 30...
6
by: TPJ | last post by:
Help me please, because I really don't get it. I think it's some stupid mistake I make, but I just can't find it. I have been thinking about it for three days so far and I still haven't found any...
10
by: A.M | last post by:
Hi, I am having difficulty with shell scripting in Python. I use the following command to run a DOS command and put the return value in a Python variable:
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.