From 370169058fc6f4a7ed6013d0f965ac75beff4f5e Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Fri, 14 Dec 2018 17:41:51 +0100 Subject: Created a demo GUI panel. --- python-plugins/hellopanel/__init__.py | 2 ++ python-plugins/hellopanel/core.py | 33 +++++++++++++++++++++++++++ python-plugins/hellopanel/panel.py | 43 +++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 python-plugins/hellopanel/__init__.py create mode 100644 python-plugins/hellopanel/core.py create mode 100644 python-plugins/hellopanel/panel.py diff --git a/python-plugins/hellopanel/__init__.py b/python-plugins/hellopanel/__init__.py new file mode 100644 index 0000000..6c4d22c --- /dev/null +++ b/python-plugins/hellopanel/__init__.py @@ -0,0 +1,2 @@ + +from hellopanel.core import HelloPlugin as AutoLoad diff --git a/python-plugins/hellopanel/core.py b/python-plugins/hellopanel/core.py new file mode 100644 index 0000000..42eb44d --- /dev/null +++ b/python-plugins/hellopanel/core.py @@ -0,0 +1,33 @@ + +from pychrysalide.features import * +from .panel import HelloPanel + + +class HelloPlugin(PluginModule): + """Simple demo plugin to build a GUI panel.""" + + + def get_interface(self): + """Provide the full plugin description.""" + + desc = { + + 'name' : 'HelloPanel', + 'desc' : 'Say hello in the main GUI', + 'version' : '0.1', + + 'actions' : [ PluginModule.PGA_PLUGIN_INIT ] + + } + + return desc + + + def init(self): + """Initialize the plugin.""" + + p = HelloPanel() + + register_panel(p); + + return True diff --git a/python-plugins/hellopanel/panel.py b/python-plugins/hellopanel/panel.py new file mode 100644 index 0000000..a06a08d --- /dev/null +++ b/python-plugins/hellopanel/panel.py @@ -0,0 +1,43 @@ + +from gi.repository import Gtk +from pychrysalide.features import * + + +DEFAULT_MSG = 'No active loaded binary' + + +class HelloPanel(PanelItem): + + def __init__(self): + """Initialize the GUI panel.""" + + self._label = Gtk.Label() + self._label.set_text(DEFAULT_MSG) + + params = { + + 'name' : 'Hello', + 'widget' : self._label, + + 'personality' : PanelItem.PIP_SINGLETON, + 'lname' : 'Hello panel description', + 'dock' : True, + 'path' : 'MEN' + + } + + super(HelloPanel, self).__init__(**params) + + + def _change_content(self, old, new): + """Get notified about loaded content change.""" + + if type(new) is LoadedBinary: + + count = len(list(new.processor.instrs)) + + self._label.set_text('Loaded binary with %u instructions' % count) + + else: + + self._label.set_text(DEFAULT_MSG) -- cgit v0.11.2-87-g4458