Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have written a program in Python with a tkinter GUI front-end. When this is run from the script there are no issues.

I packaged it using cx_freeze to an exe file and running it from there works for the majority of the program. However, it has a problem: when trying to assign a value to a StringVar object in one of the functions an exception is raised and kills the program.

When the same function is accessed from a different point in the program it functions normally. Any idea what could be wrong?

The section of code that causes the issue is as follows (I added the messagebox so I could see what it failed on):

if keyDetail.get('default', False):
    try:
        self.entries[key].set(keyDetail['default'])
    except Exception as err:
        messagebox.showinfo('error', 'key: %s, default: %s, error: %s'%(key, keyDetail['default'], err))

self.entries[key] is a tk.StringVar.

When this is run, I get the following message in the messagebox:

key: orderNo, default: Order Number, error: can't set "PY_VAR16:0"

share|improve this question
I'm not sure why Tcl would fail to set a value for a variable which is not array, because it would end up creating a variable even if it didn't exist. But, if it is not too late for your program, my tip is to drop the usage of Tcl variables; you don't need that in your Python code. Also, do you like global variables ? When you create a Tcl variable through Tkinter, you are always creating global variables (without you explicitly knowing). If you were in pure Tcl code then creating (local) variables is a must, but you already have such things in Python. You can arrange to use Tkinter with them. – mmgp Dec 21 '12 at 1:03

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.