0
Besvaret

How to access data entered into a dialog?

jaska tbaggins 9 år siden opdateret af Eugene Pankov (Project coordinator) 9 år siden 1
Hi,

I am developing a plugin for Ajenti, which needs a (modal/popup) dialog to appear in which the user can enter data, such as a name, choose from a list of templates, etc. I can design the dialog in XML, and bind the id of the dialog to the python code in a file main.py, but how do I access the data which was entered by the user?

By binding the UI element to an object in main.py, does it store once it is saved?

For example, if in main.py, I have...

....
self.container.name = ' '
self.container.status= ' '
self.binder = Binder(self, self)
....

and in layout/main.xml:

...
<dialog id="foo" visible="False" buttons="
      {'id': 'save', 'text': _('Create')},
      {'id': 'cancel', 'text': _('Cancel')},">

<vc>
<textbox bind="name" />
<textbox bind="status" />
</vc>

</dialog>

...


Will these items be bound?

Svar

Svar
Besvaret
Hi, you when your dialog is done (i.e., fires 'button' event), you need to .update() the binder, so that your data objects are updated with the new data from UI. Example: https://github.com/Eugeny/ajenti/blob/master/ajenti/plugins/configurator/configurator.py#L228-L248
Svar
Besvaret
Hi, you when your dialog is done (i.e., fires 'button' event), you need to .update() the binder, so that your data objects are updated with the new data from UI. Example: https://github.com/Eugeny/ajenti/blob/master/ajenti/plugins/configurator/configurator.py#L228-L248

Kundesupport af UserEcho