473,837 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1455
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***********@A cm.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...@gmai l.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.pytho n
Mar 30 '08 #6

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

Similar topics

0
1857
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 explain it in details, 1. Python initialization and finalization is done in the *main* thread. 2. For each new thread I create a separate sub-interpreter . 3. Using PyRun_String("import myModule"...) before execution of python
49
2639
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 code sample where newbies expect the two function calls below to both print : def f( list= ): print list.append!(1) f() # prints
2
2457
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 "/opt/sfw/lib/python2.3/lib-tk/Tkinter.py", line 38, in ? import _tkinter # If this fails your Python may not be configured for Tk
11
2550
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 random number generator in the context of a mixed Python/C++ programming problem. I encountered a vexing type conversion problem.
3
1603
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 python 2.3.5, and no difference. When I rearranged my path to move cygwin and a bunch of other stuff (.net, etc) after C:\python23, the problem went away. Is this problem known to anyone but me? Any diagnosis, solution of 12 or fewer steps,...
2
2779
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 the debug version built by me, both downloaded today to have the latest version).
3
2618
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 2.0.3 to the new one, I get error when I visit PuthonScript in the ZMI. "invalid syntax (Script (Python), line 1)"
25
7761
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 minutes with Python 3 times a week since, have 14 years of computing experience, 8 years in mathematical computing and 4 years in unix admin and perl, i have quickly found the official doc: http://python.org/doc/2.4.1/lib/module-gzip.html
6
2351
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 solution. My code can be downloaded from here: http://www.tprimke.net/konto/PyObject-problem.tar.bz2. There are some scripts for GNU/Linux system (bash to be precise). All you need to know is that there are four classes. (Of course, you may...
10
2286
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
9843
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10630
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10275
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9407
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7005
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5670
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5851
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4476
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4045
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.