[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [ease-dev] Button Keylistener Python
|
Hi Raphael,
You need to write the code of the call back as a String:
button = createButton('DoIt', 'callback()')
regards,
Yvan Lussaud.
Le jeudi 09 janvier 2025 à 13:03 +0100, Raphael Geissler via ease-dev a
écrit :
> Hi *,
>
> does anyone know, how I can add a key listener to a button within a
> Python EASE Script. I tried following, but I get following error.
>
> Code:
> ---------------------------------------------------------------------
> ------------------
> # name : Keylistener Example
> loadModule('/System/UI Builder')
>
> def callback():
> print('Button clicked')
>
> class MyKeyListener(org.eclipse.swt.events.KeyListener):
> def keyPressed(self, event):
> print("Key pressed:", event.character)
>
> def keyReleased(self, event):
> print("Key released:", event.character)
>
> createView('Example')
>
> button = createButton('DoIt', callback)
> button.addKeyListener(MyKeyListener())
> ---------------------------------------------------------------------
> ------------------
>
> Error:
> ---------------------------------------------------------------------
> ------------------
> org.eclipse.ease.ScriptExecutionException: Traceback (most recent
> call last):
> File "workspace://ease/working/keylistener_example.py", line 9, in
> <module>
> # Jonah Graham (Kichwa Coders) - initial API and implementation
> TypeError: JavaClass.__init__() takes 3 positional arguments but 4
> were given
> ---------------------------------------------------------------------
> ------------------
>
> Maybe someone has an idea what I do wrong...
>
> BR,
>
> Raphael
> _______________________________________________
> ease-dev mailing list
> ease-dev@xxxxxxxxxxx
> To unsubscribe from this list, visit
> https://www.eclipse.org/mailman/listinfo/ease-dev