Skip to content

Commit 67b8140

Browse files
committed
qtvcp -docs: update user command recommended code layout
1 parent 1e3e6f0 commit 67b8140

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

docs/src/gui/qtvcp.adoc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,10 @@ Here we show how to add new functions and override existing ones.
285285
# reference: https://ruivieira.dev/python-monkey-patching-for-readability.html
286286
import types
287287
288+
# import the handlerfile to get reference to it's libraries
289+
# use <screenname>_handler
290+
import qtdragon_handler as hdlr
291+
288292
# This is actually an unbounded function with 'obj' as a parameter.
289293
# You call this function without the usual preceding 'self.'
290294
# This is because will will not be patching it into the original handler class instance
@@ -309,9 +313,9 @@ def on_keycall_F11(self,event,state,shift,cntrl):
309313
print ('Hello')
310314
311315
# We are referencing the KEYBIND library that was instantiated in the
312-
# original handler class instance by adding 'self.' to it.
316+
# original handler class instance by adding 'hdlr.' to it (from the imp).
313317
# This function tells KEYBIND to call 'on_keycall_F10' when F10 is pressed
314-
self.KEYBIND.add_call('Key_F10','on_keycall_F10')
318+
hdlr.KEYBIND.add_call('Key_F10','on_keycall_F10')
315319
316320
# Here we are instance patching the original handler file to add a new
317321
# function that calls our new function (of the same name)

0 commit comments

Comments
 (0)