Python Forum

Full Version: Unwanted format carryover
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
I'm having trouble with tkinter, and I haven't been able to figure it out yet. I want to cascade three comboboxes connected to a database. I've got them partially functioning; that is, they load the default options properly at bootup, and the combobox after that is filtered to show just the relevant options from the combobox selection before it. It does not, however, cascade or update the other boxes when I manually modify a combo box; instead, it always displays the options from the top level selection.Link Removed