You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+17-7Lines changed: 17 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,6 +31,16 @@ There is also a drag n drop GUI editor. Look at the [Editor](https://github.com/
31
31
32
32
Changelog
33
33
===
34
+
*2019 April 1*
35
+
36
+
Event listener registration can now be done by the **do** instruction instead of **connect** (that stays available for compatibility reasons).
37
+
i.e.
38
+
```python
39
+
mybutton.onclick.do(myevent_listener)
40
+
```
41
+
42
+
*Older changes*
43
+
34
44
The current branch includes improvements about resource files handling.
35
45
App constructor accepts **static_file_path** parameter. Its value have to be a dictionary, where elements represents named resources paths.
36
46
@@ -105,7 +115,7 @@ class MyApp(App):
105
115
self.bt = gui.Button('Press me!')
106
116
107
117
# setting the listener for the onclick event of the button
108
-
self.bt.onclick.connect(self.on_button_pressed)
118
+
self.bt.onclick.do(self.on_button_pressed)
109
119
110
120
# appending a widget to another, the first argument is a string key
111
121
container.append(self.lbl)
@@ -214,7 +224,7 @@ Such events are a convenient way to define the application behavior.
214
224
Each widget has its own callbacks, depending on the type of user interaction it allows.
215
225
The specific callbacks for the widgets will be illustrated later.
216
226
217
-
In order to register a function as an event listener you have to call a function like eventname.connect (i.e. onclick.connect) passing as parameters the callback that will manage the event.
227
+
In order to register a function as an event listener you have to call a function like eventname.do (i.e. onclick.do) passing as parameters the callback that will manage the event.
218
228
Follows an example:
219
229
220
230
```py
@@ -231,7 +241,7 @@ class MyApp(App):
231
241
self.bt = gui.Button('Press me!')
232
242
233
243
# setting the listener for the onclick event of the button
234
-
self.bt.onclick.connect(self.on_button_pressed)
244
+
self.bt.onclick.do(self.on_button_pressed)
235
245
236
246
# appending a widget to another, the first argument is a string key
237
247
container.append(self.lbl)
@@ -249,13 +259,13 @@ class MyApp(App):
249
259
start(MyApp)
250
260
```
251
261
252
-
In the shown example *self.bt.onclick.connect(self.on_button_pressed)* registers the self's *on_button_pressed* function as a listener for the event *onclick* exposed by the Button widget.
262
+
In the shown example *self.bt.onclick.do(self.on_button_pressed)* registers the self's *on_button_pressed* function as a listener for the event *onclick* exposed by the Button widget.
253
263
Simple, easy.
254
264
255
265
Listener's callbacks will receive the emitter's instance firstly, then all other parameters provided by the specific event.
256
266
257
267
258
-
Besides the standard event registration (as aforementioned), it is possible to pass user parameters to listener functions. This can be achieves appending parameters to the *connect* function call.
268
+
Besides the standard event registration (as aforementioned), it is possible to pass user parameters to listener functions. This can be achieves appending parameters to the *do* function call.
259
269
260
270
```py
261
271
import remi.gui as gui
@@ -272,8 +282,8 @@ class MyApp(App):
272
282
self.bt2 = gui.Button('Hello name surname!')
273
283
274
284
# setting the listener for the onclick event of the buttons
self.fileOpenDialog=editor_widgets.EditorFileSelectionDialog('Open Project', 'Select the project file.<br>It have to be a python program created with this editor.', False, '.', True, False, self)
self.fileSaveAsDialog=editor_widgets.EditorFileSaveDialog('Project Save', 'Select the project folder and type a filename', False, '.', False, True, self)
print("Event: "+self.eventConnectionFuncName+" signal connection to: "+listener.attributes['editor_varname'] +" from:"+self.refWidget.attributes['editor_varname'])
0 commit comments