summaryrefslogtreecommitdiff
path: root/python/examples/hellosidebar.py
diff options
context:
space:
mode:
authorRusty Wagner <rusty.wagner@gmail.com>2024-02-12 14:54:00 -0500
committerRusty Wagner <rusty.wagner@gmail.com>2024-02-12 14:54:00 -0500
commit7d7e0fcd27812a42286ba736ed6d5217d87080a5 (patch)
tree78518d3176635f3bab7fea433d6ca7cba3a46eb6 /python/examples/hellosidebar.py
parent233e4395b5f6d56bb0c7a8da22f6c88480b260c2 (diff)
Add new sidebar APIs to the sidebar example
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.