#๐Ÿ”’ [KIVYMD] Get MDDatatable checked row with an MDButton

7 messages ยท Page 1 of 1 (latest)

vestal stratusBOT
#

@pearl cove

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

pearl cove
#
class StationListScreen(Screen):
    def __init__(self, **kwargs):
        super(StationListScreen, self).__init__(**kwargs)
        self.tableau = self.ids.table_liste_stations
        self.tableau = ""

    def on_pre_enter(self, **kwargs):
        bdd = DatabaseHelper()
        stations = bdd.select_stations()
        tab_box = self.ids.table_liste_stations
        tab_box.clear_widgets()
        data = StationInfo(stations).get_station_liste()
        self.tableau = MDDataTable(
            use_pagination=False,
            check=True,
            size_hint=(.1, .5) ,
            pos_hint={"center_x": .5, "center_y": .5},
            column_data=[
                ("Station", dp(40)),
                ("id", dp(30)),
            ],
            row_data=data,
        )
        tab_box.add_widget(self.tableau)

    def get_station_to_delete(self):
        print("kikou")
    pass
class MainApp(MDApp):

    def build(self):
        self.icon = "Icon/fuel.png"
        screenmanager = MDScreenManager()
        screenmanager.add_widget(MenuScreen(name="menu"))
        screenmanager.add_widget(AjoutScreen(name="addnewstations"))
        screenmanager.add_widget(StationListScreen(name="listestations"))
        return screenmanager

    def return_home(self):
        self.root.current = "menu"


MainApp().run()
#

kv file part :

#
<StationListScreen>
    Screen:
        name : "listestations"
        MDFloatLayout:
            size_hint: .3 , .005
            orientation:"horizontal"
            MDIconButton:
                icon: 'delete'
                pos_hint:{"center_x":.8,"center_y":self.height-2}
        MDBoxLayout:
            orientation:'horizontal'
            MDIconButton:
                id: btn_delete
                icon: 'trash'
                pos_hint:{"top":3}
                on_press:root.manager.get_screen("listestations").get_station_to_delete()
            MDBoxLayout:
                size_hint: .2 , .005
            MDBoxLayout
                id :table_liste_stations
                padding:[1,1,1,1]
                size_hint:.4,.4
                pos_hint:{"top":1}
            MDBoxLayout:
                size_hint: .3 , .005
#

[KIVYMD] Get MDDatatable checked row with an MDButton

vestal stratusBOT
#

@pearl cove

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.