Skip to content

Commit 9d17bf3

Browse files
committed
Merge branch '2.9'
2 parents 9dbb419 + 67b8140 commit 9d17bf3

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

docs/src/gui/qtvcp.adoc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,10 @@ Here we show how to add new functions and override existing ones.
278278
# reference: https://ruivieira.dev/python-monkey-patching-for-readability.html
279279
import types
280280
281+
# import the handlerfile to get reference to it's libraries
282+
# use <screenname>_handler
283+
import qtdragon_handler as hdlr
284+
281285
# This is actually an unbounded function with 'obj' as a parameter.
282286
# You call this function without the usual preceding 'self.'
283287
# This is because will will not be patching it into the original handler class instance
@@ -302,9 +306,9 @@ def on_keycall_F11(self,event,state,shift,cntrl):
302306
print ('Hello')
303307
304308
# We are referencing the KEYBIND library that was instantiated in the
305-
# original handler class instance by adding 'self.' to it.
309+
# original handler class instance by adding 'hdlr.' to it (from the imp).
306310
# This function tells KEYBIND to call 'on_keycall_F10' when F10 is pressed
307-
self.KEYBIND.add_call('Key_F10','on_keycall_F10')
311+
hdlr.KEYBIND.add_call('Key_F10','on_keycall_F10')
308312
309313
# Here we are instance patching the original handler file to add a new
310314
# function that calls our new function (of the same name)

lib/python/qtvcp/qt_makegui.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,17 +346,14 @@ def add_handler(method, f):
346346
# this is the function that is injected into the handler file to read an override file
347347
# this will be called from qtvcp.py later
348348
def call_user_command_(self, klass, rcfile = "~/.qtvcprc"):
349-
#user_command_file = inifile.find("DISPLAY", "USER_COMMAND_FILE") or ""
350-
#if user_command_file:
351-
# rcfile = user_command_file
352349
rcfile = os.path.expanduser(rcfile)
353350
if os.path.exists(rcfile):
354351
log.info('Handler Override file found at: yellow<{}>'.format(rcfile))
355352
try:
356353
local = {'self': klass, 'rcfile': rcfile}
357354
exec(compile(open(rcfile, "rb").read(), rcfile, 'exec'),local)
358355
except Exception as e:
359-
log.warning(e)
356+
log.exception(e)
360357
else:
361358
log.info('No Handler Override file at: yellow<{}>'.format(rcfile))
362359

0 commit comments

Comments
 (0)