I'm making a travel/tourism app using Kivy as my project and I need to pass some value from a widget to another screen that'll display information of a location.
I am able to share information between different screens using this Kivy - Screen Manager - Accessing attribute in other class method, however this doesn't seem to work when I try to pass variables from a widget that isn't directly a screen.
I have a chatting interface created using RecycleView that has a button to "see more" information on the current location we're talking about, but I am unable to pass values from this Row widget to the LocationInfo widget/screen.
Here is the relevant code
Relevant Python code
class TourismRoot(ScreenManager):
def open_location_info_page(self, locationname):
self.current = 'LocationInfoPage'
class LocationInfo(Screen):
cityname = StringProperty()
def test_print(self):
print(self.cityname)
Relevant KV code
TourismRoot:
id: screen_manager
FirstTimeRun:
id: firstrunid
name: 'FirstRun'
manager: screen_manager
FirstTimeRun2:
id: firstrun2id
name: 'FirstRun_2'
manager: screen_manager
nickname: firstrunid.entered_nickname #taking value from another screen, works
LoginScreen:
id: loginscreenid
name: 'Login'
manager: screen_manager
ChatBotScreen:
id: chatbotid
name: 'ChatBot'
manager: screen_manager
nickname: firstrunid.entered_nickname
LocationInfo:
id: locationinfo
name: 'LocationInfoPage'
manager: screen_manager
cityname: chatbotid.ids.lb_chat_row #gives error
<Row>:
BoxLayout:
Label:
id: lb_chat_row
text: 'stuff'
GridLayout:
Button:
id: bt_chat_row
text: root.button_text
font_size: "18dp"
text_size: self.size
on_release: app.root.open_location_info_page(root.ids.lb_chat_row.text)
<ChatBotScreen>
ScrollView:
size_hint_y: 85
RecycleView:
id: chatbase_list
viewclass: 'Row'
data: []
RecycleBoxLayout:
orientation: 'vertical'
padding: "15dp", "45dp", "15dp", "15dp"
default_size_hint: 1, None
size_hint_y: None
height: self.minimum_height
as you can see, the Row widget is actually a viewclass of a RecycleView and thus I cannot simply make it a screen and pass values (I tried, it messed up the layout).
The current code gives the following error:
kivy.lang.builder.BuilderException: Parser: File "<inline>", line 47:
...
45: name: 'LocationInfoPage'
46: manager: screen_manager
>> 47: cityname: chatbotid.ids.lb_chat_row
48:
49:<Row>:
...
BuilderException: Parser: File "<inline>", line 47:
...
45: name: 'LocationInfoPage'
46: manager: screen_manager
>> 47: cityname: chatbotid.ids.lb_chat_row
48:
49:<Row>:
...
AttributeError: 'super' object has no attribute '__getattr__'
Any help is greatly appreciated~