diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2022-11-11 17:41:30 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2022-11-13 12:09:49 +0900 |
commit | da9cd0c056c8275033fca84a1c8d49a8edb0c8ee (patch) | |
tree | 2521f74c0b2868d82518e13053fb01cc179e9a23 /superkaramba/examples/service_group | |
parent | 5dab6232ef3b3715630cf88eb40c4c6021e65f07 (diff) | |
download | tdeutils-da9cd0c056c8275033fca84a1c8d49a8edb0c8ee.tar.gz tdeutils-da9cd0c056c8275033fca84a1c8d49a8edb0c8ee.zip |
superkaramba: convert examples to python3.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'superkaramba/examples/service_group')
-rw-r--r-- | superkaramba/examples/service_group/service_group.py | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/superkaramba/examples/service_group/service_group.py b/superkaramba/examples/service_group/service_group.py index 276b9c8..a56835e 100644 --- a/superkaramba/examples/service_group/service_group.py +++ b/superkaramba/examples/service_group/service_group.py @@ -16,23 +16,25 @@ import karamba # simple function to display def create_text(widget, line, depth, disp, name=None, command=None, icon=None): + print(name) + print(disp) x = depth*30 - y = line*7 + y = line*12 width = 400 - height = 8 + height = 12 drop_txt = karamba.createText(widget, x, y, width, height, disp) - karamba.changeTextSize(widget, drop_txt, 7) + karamba.changeTextSize(widget, drop_txt, 11) karamba.changeTextColor(widget, drop_txt, 252,252,252) - # create a (very narrow! only an 8-pixel-high area!) + # create a (very narrow! only an 12-pixel-high area!) # service click area to demonstrate that commands get # executed correctly. if name: karamba.createServiceClickArea( widget, x,y,width,height, - name, command, icon) + str(name), str(command), str(icon)) # okay. you really should be looking up the KDE Developer documentation @@ -92,14 +94,14 @@ def display_svc_group(widget, rel_path, line, depth): for (type, d) in grps: - if type is 0: + if type == 0: # it's a - sub_relpath = d['relpath'] - icon = d.get('icon', 'unknown') - caption = d.get('caption', None) - comment = d.get('comment', None) + sub_relpath = d[b'relpath'].decode('utf-8') + icon = d.get(b'icon', 'unknown').decode('utf-8') + caption = d.get(b'caption', b'').decode('utf-8') + comment = d.get(b'comment', b'').decode('utf-8') cmt = '' # get at least something to display @@ -109,23 +111,24 @@ def display_svc_group(widget, rel_path, line, depth): cmt = caption msg = "SVCGRP: %s %s" % (icon, cmt) + print("MSG="+msg) create_text(widget, line, depth, msg) line += 1 - line = display_svc_group(widget, sub_relpath, + line = display_svc_group(widget, str(sub_relpath), line, depth+1) - elif type is 1 and d.has_key('menuid'): + elif type == 1 and b'menuid' in d: - relpath = d.get('relpath', '') - cmd = d['exec'] - icon = d.get('icon', 'unknown') - name = d.get('name', None) - genericname = d.get('genericname', None) + relpath = d.get(b'relpath', b'').decode('utf-8') + cmd = d[b'exec'].decode('utf-8') + icon = d.get(b'icon', 'unknown').decode('utf-8') + name = d.get(b'name', b'').decode('utf-8') + genericname = d.get(b'genericname', b'') cmt = '' # get at least something to display if genericname: - cmt = genericname + cmt = genericname.decode('utf-8') elif name: cmt = name |