vendredi 20 février 2015

String from Object Python

I am working on a project that uses XML to create a Tkinter GUI and need to know how to convert an object name to a string. For example:



# In the actual program, the value of widget variables is set by the values of XML attributes

label_name = "mylabel"

root = Tk()

exec(label_name+" = Label("+str(root)+", text='Hello World')")


Using str(root) does not work. What can I do to make this work?


Aucun commentaire:

Enregistrer un commentaire