Python Forum
[Kivy] Acces atributes from a button defined in a class inside the .kv
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Kivy] Acces atributes from a button defined in a class inside the .kv
#1
Hello!
Lately I have been trying my luck on kivy, and I'm always having problem when I try to access attributes that have been defined in the .kv

For example, this time I'm trying to access the attributes of my buttons inside my class SlidingPopup (id:btn_yes and id:btn_no) where I'm using it in the FloatLayout.

<SlidingPopup@GridLayout>:
    id:class_sliding
    btn_no: btn_no
    rows:2
    canvas:
        Color:
            rgba: 1,1,1,.8
        Rectangle:
            size: self.size
            pos: self.pos
    Label:
        text: "Are you sure?"
        font_size: 24
    GridLayout:
        rows: 1
        spacing: 10
        padding: 10
        Button:
            id: btn_no
            text: "No"
            color: 1,0,0,1
        Button:
            id: btn_yes
            text: "Yes"
            color: 0,0,0,1

FloatLayout:
    Button:
        size_hint: .3,.3
        pos_hint: {"center_x": .5, "center_y": .5}
        text:"Open Menu"
        on_release:
            app.show_the_button(the_sliding_menu)
    
    SlidingPopup:
        id: the_sliding_menu
        size_hint: 1, .3
        top_hint: 0
        pos_hint: {"top":self.top_hint, "right":1}
I'm just looking for a way to define their bindings where I'm using them and not in the class definition (something like btn_no.one_release: ... but that actually works :D). Someone who can give me a hand with their wisdom?
Reply


Messages In This Thread
Acces atributes from a button defined in a class inside the .kv - by Tomli - Jun-09-2021, 12:30 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] image inside button rwahdan 4 7,200 Jul-12-2021, 08:49 PM
Last Post: deanhystad
  [Tkinter] Modify Class on Button Click KDog 4 4,016 May-11-2021, 08:43 PM
Last Post: KDog
  [Tkinter] Redirecting all print statements from all functions inside a class to Tkinter Anan 1 2,696 Apr-24-2021, 08:57 AM
Last Post: ndc85430
  Class function does not create command button Heyjoe 2 2,318 Aug-22-2020, 08:06 PM
Last Post: Heyjoe
  [Tkinter] Creation of Buttons with Shared Command Inside Class MulliganAgain 1 1,733 Jul-08-2020, 06:22 PM
Last Post: Yoriz
  [PyQt] I get a name Name Error: when calling a method inside a class radoo 2 2,426 Jun-11-2020, 05:02 PM
Last Post: radoo
  [PyQt] Problem how to click a button inside a group box? mart79 2 3,493 Aug-05-2019, 01:21 PM
Last Post: mart79
  [PySimpleGui] How to alter mouse click button of a standard submit button? skyerosebud 3 5,067 Jul-21-2019, 06:02 PM
Last Post: FullOfHelp
  Button in one class, methods in another one alan9979 4 2,915 Jul-11-2019, 01:57 AM
Last Post: joe_momma
  [Tkinter] button not defined OldManProgrammer 2 4,539 Nov-21-2018, 07:53 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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