Reputation: 1
Please how do I reference a member of class A in class B
Builder.load_string("""
<Main>
do_scroll_x: True
do_scroll_y: False
bar_width: 20
padding: 10
Carousel:
id: caro_slider
#direction: 'top'
padding: 10
orientation: 'vertical'
BoxLayout:
padding: 10
orientation: 'vertical'
Label:
text: "one two three"
Button:
text: 'Next'
background_color: 1, 0.1 ,0.1, 1
pos_hint: {'right': 1}
size_hint: None, None
size: '74sp', '35sp'
on_press: caro_slider.load_next()
BoxLayout:
orientation: 'vertical'
Label:
text: "five six seven"
Button:
text: "Click me"
background_color: 1, 0.1 ,0.1, 1
on_press: root.show_popup_item()
size_hint: .6, .2
pos_hint: {'center_x': 0.5, 'bottom': 1}
BoxLayout:
orientation: 'horizontal'
size_y: '35sp'
size_hint: 1, 0
Button:
text: 'Previous'
pos_hint: {'left': 1}
size_hint: None, None
size: '74sp', '35sp'
on_press: caro_slider.load_previous()
Button:
text: 'Next'
background_color: 1, 0.1 ,0.1, 1
pos_hint: {'right': 1}
size_hint: None, None
size: '74sp', '35sp'
on_press: caro_slider.load_next()
BoxLayout:
orientation: 'vertical'
size_hint: 1, None
Label:
text: "Please choose your choice"
size_hint: None, None
Label:
text: ''
size_hint: None, None
GridLayout:
orientation: 'horizontal'
size_hint: 1, None
rows: 1
row_force_default: True
row_default_height: '35sp'
CheckBox:
id: chk_box_4
height: '35sp'
group: root.group_list
size_hint: None, None
on_active: root.chk_chk(self)
Label:
text: "Four over there"
height: '35sp'
size_hint: None, None
Button:
text: 'Previous'
background_color: 1, 0.1 ,0.1, .5
pos_hint: {'left': 1}
size_hint: None, None
size: '74sp', '35sp'
on_press: caro_slider.load_previous()
# the popup
<Pops>
title: "Welcome!"
auto_dismiss: False
background_color: 0.1, 0.1 , 0.8, 0.9
size: 400, 250
size_hint: None, None
title_height: '40sp'
separator_height: '1sp'
separator_color: 1,1,1,1
BoxLayout:
orientation: 'vertical'
Label:
text: "Thanks and praises"
id: sub_title
max_lines: 5
size_hint: None, None
pos_hint: {'center_y': 0, 'center_x': 0}
Label:
id: composition
text: "Thanks be to GOD for this to [ref=work]work[/ref] and not to work."
markup: True
size_x: self.parent.size[0]
on_ref_press: print 'clicked the link', self.ids.caro_slider.slides ------> here is the problem
Button:
id: close_button
text: "Click to close"
background_color: 1, 0.1 ,0.1, 1
size_hint: .5, .5
pos_hint: {'center_x': 0.5}
on_press: root.dismiss()
""")
Upvotes: 0
Views: 332
Reputation: 29488
You need some reference to class A from class B. A simple general way to do it is to store the reference in your App class (i.e. App.get_running_app().classa = a
) then reference it with App.get_running_app().classa
. In specific cases there might be better places to put it than cluttering up your App though, for instance in the common parent of both class instances.
Upvotes: 2