Dialogs, events and scriptforge in python

I have a simple test dialog with a “Buscar” button.

What I intend, using Scripforge and python, is to assign an event to the button. This event should perform some tasks in the dialog, for example write a text in the textfield.

But I don’t quite understand the instructions to associate the event to the button.

Any help?

This is the code I have written

def dialogo(Event = None):

    dlg = CreateScriptService('SFDialogs.Dialog', 'GlobalScope', 'EasyFirebird', 'Dialog1')

    txt_user = dlg.Controls('txt1')
    txt_user.Value ='sysdba'
    btn_buscar = dlg.Controls('cmdBuscar')

    btn_buscar.OnActionPerformed = control_event_handler(btn_buscar.XControlModel)

    if dlg.Execute():
        txt_user.Value = 'JC'

def control_event_handler(event = uno):
    # dlg = CreateScriptService("SFDialogs.DialogEvent", event)
    msgbox('Evento running')

dialogo()

An this is the dialog

image

You make the “connection” in the properties of the button, as in the following thread:

Well, I know how to assign an event to a control in a “normal” dialog. The queston were about how to do it with Scriptforge.
Any case thanks for your response

Linking an event to a macro can be done

  • manually (as Wanderer explained)
  • by code: only with ScriptForge

Both modes let you execute the linked macro with or without ScriptForge.

Yes, I’ve realized that.
My objetive was learn to do it by code with ScriptForge, and I realized that I need to study better the wiki examples

You can find many examples of dialogs managed with Python scripts using the ScriptForge library here:
https://wiki.documentfoundation.org/Macros/ScriptForge#Dialogs,_Menus,_and_Forms

This a work in progress that will be completed in the coming weeks.

In addition: On… event properties (among which OnActionPerformed) are URI strings that reference a script triggered for an event. Read its specification in the scripting framework URI specification.

1 Like