I have a Value Error that is caught, in the exception block when I have no problem printing to the terminal, however, i cannot insert any text into the text widget. Heres the code snippet, any ideas?


if len( errorCode ) == 0 and len( errorCodeHex ) >= 1:

errorCode = str( int( errorCodeHex, 16 ) )

#Enable Input to be entered into the Text Box
self.errorInformation["state"] = NORMAL

if len( errorCode ) == 0 and len( errorCodeHex ) == 0:
self.errorInformation.insert( END, 'Please enter either a hex or a decimal error code \n\n' )

elif errorInfo.has_key( errorCode ):

self.errorInformation.insert( END, 'Decimal Value: \t\t\t' + 'Hex Value: \t\t' + 'Error Message: \n\n' )
self.errorInformation.insert( END, errorCode + '\t\t\t' + '0x' + errorInfo[errorCode][0] + '\t\t' + errorInfo[errorCode][1] + '\n\n' )


if len( errorCodeHex ) < 1:
self.errorInformation.insert( END, 'There is no Error Code with the value: ' + errorCode + '\n\n' )

self.errorInformation.insert( END, 'There is no Error Code with the value: ' + errorCodeHex + '\n\n' )

except ValueError:
self.errorInformation.insert( END, 'Please Enter a Valid Hexidecimal Number \n\n' )

8 Years
Discussion Span
Last Post by Tommy.Leedberg

I don't think you would use errorInformation.insert() to update a text widget.
Which GUI are you using?
if it is wxPython you would do self.errorInformation.SetValue("value")


Im using tkinter, im rather new to gui programing so ive just been following examples that ive had up till now. Everything else works fine except that one insert statement.


Okay ,I don't know tkinter, but I googled it in the syntax is right, are you sure that self.errorInformation is properly defined?


yup the statement works everywhere except for the exception block. if i were to change the statement to say Print 'Enter a valid hex number' it would print fine to the console.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.