Mercurial > hg > orthanc-book
comparison Sphinx/source/plugins/python/sample-python-button.py @ 975:eb49a4ad8fbc
Python plugin: Extending the Orthanc Explorer interface
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 29 Aug 2023 14:04:48 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
974:01f61385877f | 975:eb49a4ad8fbc |
---|---|
1 import orthanc | |
2 import platform | |
3 | |
4 def ExecutePython(output, uri, **request): | |
5 s = 'Python version: %s' % platform.python_version() | |
6 output.AnswerBuffer(s, 'text/plain') | |
7 | |
8 orthanc.RegisterRestCallback('/execute-python', ExecutePython) | |
9 | |
10 orthanc.ExtendOrthancExplorer(''' | |
11 $('#lookup').live('pagebeforeshow', function() { | |
12 $('#sample-python-button').remove(); | |
13 | |
14 var b = $('<a>') | |
15 .attr('id', 'sample-python-button') | |
16 .attr('data-role', 'button') | |
17 .attr('href', '#') | |
18 .attr('data-icon', 'forward') | |
19 .attr('data-theme', 'a') | |
20 .text('Execute sample Python plugin') | |
21 .button() | |
22 .click(function(e) { | |
23 $.get('../execute-python', function(answer) { | |
24 alert(answer); | |
25 }); | |
26 }); | |
27 | |
28 b.insertAfter($('#lookup-result')); | |
29 }); | |
30 ''') |