•
•
•
•
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
![]() |
•
•
Join Date: Mar 2006
Posts: 56
Reputation:
Rep Power: 3
Solved Threads: 0
I have a problem:
How to insert raise in Text()?
for example i have file:
and other file:
In file my_program is Error. How to insert raise of this error in Text?
thanks
How to insert raise in Text()?
for example i have file:
#my_program.py a=ddd
#my_file.py:
from Tkinter import*
root=Tk()
text=Text()
text.pack()
execfile('my_program.py')
#text.insert(END,raise)
mainloop()thanks
You can use function sys.exc_info() to fetch the error created by my_program.py:
I am always surprised by the things Python can do! Have fun with Python!
# 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() Last edited by Ene Uran : Sep 3rd, 2006 at 12:35 pm.
drink her pretty
![]() |
•
•
•
•
•
•
•
•
DaniWeb Python Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- edit text on a gif image in photoshop (Graphics and Multimedia)
- capturing text (C)
- i = system ("cd c:\text"); :( (C)
- Using string variables in a label or text box? (VB.NET)
- connect to text file database (Visual Basic 4 / 5 / 6)
Other Threads in the Python Forum
- Previous Thread: Frequently Used Python Commands
- Next Thread: Style question



Linear Mode