Hola bastante novato en python, estoy intentando hacer un interface con TK.
El codigo que os dejo intenta hacer lo siguiente: Cuando carga la ventana los Entry se llenan con valores de las propiedades de un fichero, esto funciona sin problemas. Estas propedades yo las cambio en los entry y cuando doy al boton debería actualizar los valores de todos los entry al fichero, el problema que tengo esque no se como actualizar los valores de los entry, ya que cuando doy al boton me pierde los valores. Codigo: #!/usr/bin/env python #_*_ coding: utf-8 _*_ #file: Propiedades_Tk1.py #Propiedades import Tkinter import win32com.client from win32com.client import gencache oApp = win32com.client.Dispatch('Inventor.Application') oApp.Visible = True mod = gencache.EnsureModule('{D98A091D-3A0F-4C3E-B36E-61F62068D488}',0,1,0) oApp = mod.Application(oApp) oApp.SilentOperation = True oDoc = oApp.ActiveDocument prop = oApp.ActiveDocument.PropertySets.Item("Design Tracking Properties") Descrip = prop('Description').Value Disenador = prop('Designer').Value class Inventor_tk(Tkinter.Tk): def __init__(self,parent): Tkinter.Tk.__init__(self,parent) self.parent = parent self.initialize() def initialize(self): self.grid() #Boton actulizar propiedades button = Tkinter.Button(self, text= u"Nueva Pieza", command=self.UpdatePropiedad) button.grid(column=4, row=5) #Descripcion labelDescrip = Tkinter.Label(self, text= "Descripcion: ") labelDescrip.grid(column=1, row=2) labelDescrip.grid(column=1, row= 2,sticky='W'+'E') DescripEntry = Tkinter.StringVar() DescripEntry.set (Descrip) EntryDescrip = Tkinter.Entry(self, textvariable=DescripEntry) #EntryDescrip.bind("<Return>", self.UpdatePropiedad) EntryDescrip.grid(column=2, row= 2,sticky='W'+'E') global NuevaDesc NuevaDesc = EntryDescrip.get() #Diseñador labelDesing = Tkinter.Label(self, text= u"Diseñador: ") labelDesing.grid(column=1, row=3) labelDesing.grid(column=1, row= 3,sticky='W'+'E') DesingEntry = Tkinter.StringVar() DesingEntry.set (Disenador) EntryDesign = Tkinter.Entry(self, textvariable=DesingEntry) #EntryDesign.bind("<Return>", self.UpdatePropiedad) EntryDesign.grid(column=2, row= 3,sticky='W'+'E') global NuevoDiseno NuevoDiseno = EntryDesign.get() def UpdatePropiedad(self): ### ###Fallo pierde valor de las variables, intentar corregir ### Descrip = prop ('Description').Value = NuevaDesc Disenador = prop ('Designer').Value = NuevoDiseno print Descrip print Disenador #Actualiza documento oDoc.Update if __name__ == "__main__": app = Inventor_tk(None) app.title('Propiedades de: '+ oApp.ActiveDocument.DisplayName) app.mainloop() Gracias por vuestra ayuda.
_______________________________________________ Python-es mailing list Python-es@python.org http://mail.python.org/mailman/listinfo/python-es FAQ: http://python-es-faq.wikidot.com/