User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 423,011 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,976 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser: Programming Forums
Views: 845 | Replies: 1
Reply
Join Date: Mar 2006
Posts: 56
Reputation: Blujacker is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
Blujacker Blujacker is offline Offline
Junior Poster in Training

raise in Text()

  #1  
Sep 3rd, 2006
I have a problem:
How to insert raise in Text()?
for example i have file:
#my_program.py
a=ddd
and other file:
#my_file.py:
from Tkinter import*
root=Tk()
text=Text()
text.pack()
execfile('my_program.py')
#text.insert(END,raise)
mainloop()
In file my_program is Error. How to insert raise of this error in Text?

thanks
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2005
Posts: 1,109
Reputation: Ene Uran is an unknown quantity at this point 
Rep Power: 6
Solved Threads: 66
Ene Uran's Avatar
Ene Uran Ene Uran is offline Offline
Veteran Poster

Re: raise in Text()

  #2  
Sep 3rd, 2006
You can use function sys.exc_info() to fetch the error created by my_program.py:
# save as my_file.py
# executes a file my_program.py which has an error

from Tkinter import*
import sys

root=Tk()
text=Text()
text.pack()

try:
    execfile('my_program.py')
except:
    error = "%s --> %s in file my_program.py"% (sys.exc_info()[0], sys.exc_info()[1])
    
# put error msg raised by my_program.py into text field
text.insert(END, error)
mainloop()
I am always surprised by the things Python can do! Have fun with Python!
Last edited by Ene Uran : Sep 3rd, 2006 at 12:35 pm.
drink her pretty
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Python Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Python Forum

All times are GMT -4. The time now is 4:01 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC