The buttons have an on_release property not the dialog.See the the example fragments here
On Tuesday, January 18, 2022 at 12:18:47 PM UTC-10 Quantumrobs wrote:Hi everyone,I have a quick question regarding MDDialog. I am using a "simple" dialog popup to show a list of names and their ID numbers from a search box entry. I would like to grab the user selected row so I can use the data for a database lookup.I read a lot of documentation and cannot find the attribute for the on click event. I tried to guess at the attribute, but nothing I tried printed anything to the terminal when I tried them. I would like to know the binding syntax and the reference.Any assistance would be helpful.Thank you.
--You received this message because you are subscribed to the Google Groups "Kivy users support" group.To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/0649baa8-e5d5-4db9-9edf-31ce05fbd9e1n%40googlegroups.com.
If you are using a search entry box (TextInput?) you could use an event like on_text or on_text_validate.
If you want to add on_press and on_release event to a list item, you can create a new class derived from the ListItem and ButtonBehavior to add these button events to your line item object. https://kivy.org/doc/master/api-kivy.uix.behaviors.button.html?highlight=buttonbehavior#module-kivy.uix.behaviors.button
If you share a minimal executable example I can provide more a more prescriptive answer.
--
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/61e7705b.1c69fb81.18cde.acf8SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
I’m assuming you want the user to select an item on the participant_serach_popup.
And the ButtonBehavior to the definition of the SearchParticipantItem. Define the on_release action. You can use the self.text as the parameter… in kv it might looks something like this.
<SearchParticipantItem>:
on_release: self.look_up_item_in_database(self.text)
Read the ButtonBehavior example in the kivy docs, that uses a label. You will do something similar, adding ButtonBehavior to your existing SearchParticpantItem class.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/166C46DF-0CFF-4315-97C4-1609D052C1C0%40getmailspring.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/61e78b79.1c69fb81.560f4.14a5SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
Here are few things to consider some of this is style…
I prefer to put the screen names under the class instances under the ScreenManager. This will make a nice reference when you need to use the name to select a screen, all the screen names will be in the same place.
In KV writing the class name creates a class instance. You can add the required attributes under the instance. You have a number of classes that I suspect are very similar( AddParticipentScrren1, 2,3…) you may want to consider creating one customizable class and instancing that class multiple times, rather than creating 3 similar classes that will be error prone to maintain.
Putting those 2 ideas together…
WindowManager:
LoginScreen:
name: ‘login_screen’
MainScreen:
name: ‘main_screen’
UserScreen:
name: ‘user_screen’
AddParticipantScreen:
name: ‘aps_1’
version: 1 # version could be a NumericProperty, that customizes the AddParticipantScreen Class.
AddParticipantScreen:
name: ‘aps_2’
version: 2
AddParticipantScreen:
name: ‘aps_2’
version: 3
…
Should I be putting the SearchParticipantItem in the file the same way, or does it go someplace else besides indenting under WindowManager?
You can define a rule in kv, this is adding elements to the class definition. The rule definition always starts on the far left column.
<SearchParticipantItem>: # definition of a kivy rule
on_release: print(f’{self.text} was pressed’)
When you put a class in kivy without the angle brackets, you are instancing the class. Somewhere you are defining the screen (or a popup) that contains a list of SearchParticpantItems. It will look something like this:
<AddParticipantScreen>:
BoxLayout:
orientation: ‘vertical’
Label:
text: ‘Important stuff below’
MDList:
id:mdlist
SearchParticipantItem:
SearchParticipantItem:
SearchParticipantItem:
I added an id to show the list. When kv is compiled, an ids dictionary is created that allows you to easily access the widgets from python by using the ids dictionary.
class AddParticipantScreen(Screen):
def a_method(self):
print(self.ids) # will show the dictionary that contains mdlist, and the instance of the MDLIst.
Hope that helps!
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/27DD4E15-0AA1-4D51-9C2F-88402EA67A46%40getmailspring.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/61e796e5.1c69fb81.dea13.a387SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
It can some times be a challenge to find the relevant documentation. This is a key reference for working with kv: https://kivy.org/doc/master/api-kivy.lang.html?highlight=lang#module-kivy.lang
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/780937b8-b993-401a-b7ba-bd6398b84dd5%40Spark.
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/7nOzlqeGbP0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/61e80776.1c69fb81.5ae46.3a3bSMTPIN_ADDED_MISSING%40gmr-mx.google.com.
Thanks for letting me know. I’m glad to hear it worked out.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/2cb7fa8b4de7e.1a29f38c82f6d%40gmail.com.