[Kivy] Unwanted format carryover - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: [Kivy] Unwanted format carryover (/thread-36071.html) |
Unwanted format carryover - hammer - Jan-14-2022 Updating a class attribute from a Kivy Textinput.text copies over an unexpected format. Below i am sorting through the child widgets to expose the one to modify. The children are a class that inherits Kivy Button with several attributes added. When the objects are created, the attribute data is supplied from a data table. To edit, the attribute data is displayed in the Kivy Textinput's. After editing, it is copied back to update the objects attributes.THIS IS WHEN THE FORMAT CHANGES- or gets included. For example, in animal.tagNo=self.cow_detBtn['tag'].text, the right hand side may show '44' but after executed, the left hand side shows ('44', ). So i must not be getting just the value. I have looked into stripping/replacing but not sure that will work here. for animal in self.loc_tabs[self.myCow.loc].content.children: if animal.type=="Cow": if str(animal.tagNo)==self.myCow.tagNo: if animal.tagClr==self.myCow.tagClr: if str(animal.tagYr)==self.myCow.tagYr: # update cow widget animal.tagNo=self.cow_detBtn['tag'].text, animal.tagClr=self.cow_detBtn['tagClr'].text, animal.tagYr=self.cow_detBtn['tagYr'].text, animal.type=self.cow_detBtn['type'].text, I have discovered the widget's attributes are a tuple. How do I get at updating the value? In other places in the program, I have the ability to use the instance passed by the on_press event which works as expected. ie instance.tagNo=self.cow_detBtn['tag'].text .Problem resolved. In a cut and paste i missed removing the "," from the end of the lines which made it look like a tuple. |