Simple problem with GUI!!

M

mohan

Hello Guys,

I am a beginner with Python programming and would like to implement
some GUI functionalities along with my main work. So I was trying to
implement one basic program (available from books).
Here is the code,

############################
import Tkinter

TopLevelWindowObj = Tkinter.Tk() # Creating a root window
QuitObj = Tkinter.Button(TopLevelWindowObj, text = "QUIT", command =
TopLevelWindowObj.quit) # Creating a Button
QuitObj.pack() # Positioning the button
Tkinter.mainloop()
#############################

So, this is a code to display a window with a "QUIT" button and by
clickign the button the entire window is closed. When I execute this
program, the window does not close down but the window is completely
disabled and after a few seconds I get the following message in a
message window,

**************************************************************************
Message box name - Microsoft Visual C++ Runtime Library

Runtime Error!

program...\Python22\core\lib\site-packages\Pythonwin\Pythonwin.exe

This application has requested the Runtime to terminate it in an
unusual way.
Please contact the application's support team for more information.

************************************************************************************
At the end I had to close down my entire python compiler. I am using
Python compiler with following specs in Windows XP OS.

Pythonwin - Python IDE and GUI Framework for Windows.
PythonWin 2.2.1 (#34, Feb 25 2003, 11:29:09) [MSC 32 bit (Intel)] on
win32.
Portions Copyright 1994-2001 Mark Hammond

Please let me know why is this happening and also if I am missing
something in the way of programming.

Thanks in advance.

Cheers,
Mohan.
 
F

Fredrik Lundh

mohan said:
At the end I had to close down my entire python compiler. I am using
Python compiler with following specs in Windows XP OS.

Pythonwin - Python IDE and GUI Framework for Windows.
PythonWin 2.2.1 (#34, Feb 25 2003, 11:29:09) [MSC 32 bit (Intel)] on
win32.
Portions Copyright 1994-2001 Mark Hammond

Please let me know why is this happening and also if I am missing
something in the way of programming.

the PythonWin IDE doesn't work properly when you're running programs that
does their own Windows event handling. this is a problem with PythonWin, not
with Tkinter or your program. to solve this, you can either

1) check if you can make PythonWin run the program in a separate process

2) explicitly run the program in its own process (using "python.exe" or "pythonw.exe"),
from the command line.

3) switch to an IDE that runs Python code in a separate process (such as IDLE,
Wing, and most other modern IDE:s).

</F>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top