summaryrefslogtreecommitdiff
path: root/python/examples/hellosidebar.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/examples/hellosidebar.py')
-rw-r--r--python/examples/hellosidebar.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/python/examples/hellosidebar.py b/python/examples/hellosidebar.py
index 2fc0cbf7..5f798d09 100644
--- a/python/examples/hellosidebar.py
+++ b/python/examples/hellosidebar.py
@@ -21,7 +21,8 @@
# This is an example UI plugin which demonstrates how to add sidebar widgets to Binary Ninja.
# See .../api/ui/sidebar.h for interface details.
-from binaryninjaui import SidebarWidget, SidebarWidgetType, Sidebar, UIActionHandler
+from binaryninjaui import SidebarWidget, SidebarWidgetType, Sidebar, UIActionHandler, SidebarWidgetLocation, \
+ SidebarContextSensitivity
from PySide6 import QtCore
from PySide6.QtCore import Qt, QRectF
from PySide6.QtWidgets import QApplication, QHBoxLayout, QVBoxLayout, QLabel, QWidget
@@ -104,6 +105,18 @@ class HelloSidebarWidgetType(SidebarWidgetType):
# widget is visible and the BinaryView becomes active.
return HelloSidebarWidget("Hello", frame, data)
+ def defaultLocation(self):
+ # Default location in the sidebar where this widget will appear
+ return SidebarWidgetLocation.RightContent
+
+ def contextSensitivity(self):
+ # Context sensitivity controls which contexts have separate instances of the sidebar widget.
+ # Using `contextSensitivity` instead of the deprecated `viewSensitive` callback allows sidebar
+ # widget implementations to reduce resource usage.
+
+ # This example widget uses a single instance and detects view changes.
+ return SidebarContextSensitivity.SelfManagedSidebarContext
+
# Register the sidebar widget type with Binary Ninja. This will make it appear as an icon in the
# sidebar and the `createWidget` method will be called when a widget is required.