Python Forum
[Kivy] Unwanted format carryover
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Kivy] Unwanted format carryover
#1
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] Layout unwanted space WatcherMagic 2 2,902 Dec-12-2018, 09:37 PM
Last Post: WatcherMagic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020