Skip to content

Commit

Permalink
qtvcp -docs: update user command recommended code layout
Browse files Browse the repository at this point in the history
  • Loading branch information
c-morley committed Jun 14, 2023
1 parent 1e3e6f0 commit 67b8140
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions docs/src/gui/qtvcp.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ Here we show how to add new functions and override existing ones.
# reference: https://ruivieira.dev/python-monkey-patching-for-readability.html
import types
# import the handlerfile to get reference to it's libraries
# use <screenname>_handler
import qtdragon_handler as hdlr
# This is actually an unbounded function with 'obj' as a parameter.
# You call this function without the usual preceding 'self.'
# This is because will will not be patching it into the original handler class instance
Expand All @@ -309,9 +313,9 @@ def on_keycall_F11(self,event,state,shift,cntrl):
print ('Hello')
# We are referencing the KEYBIND library that was instantiated in the
# original handler class instance by adding 'self.' to it.
# original handler class instance by adding 'hdlr.' to it (from the imp).
# This function tells KEYBIND to call 'on_keycall_F10' when F10 is pressed
self.KEYBIND.add_call('Key_F10','on_keycall_F10')
hdlr.KEYBIND.add_call('Key_F10','on_keycall_F10')
# Here we are instance patching the original handler file to add a new
# function that calls our new function (of the same name)
Expand Down

0 comments on commit 67b8140

Please sign in to comment.