Skip to content

Instantly share code, notes, and snippets.

@sagittarius-a
Forked from icecr4ck/binja_ui_template.py
Created February 6, 2025 15:12
Show Gist options
  • Save sagittarius-a/bc2fd3c7499a11aa3c4dbf88fe27d5ce to your computer and use it in GitHub Desktop.
Save sagittarius-a/bc2fd3c7499a11aa3c4dbf88fe27d5ce to your computer and use it in GitHub Desktop.
Template for writing Binary Ninja UI plugins.
import sys
from PySide2.QtWidgets import (QApplication, QDialog, QPushButton, QLabel, QHBoxLayout)
from PySide2.QtCore import Qt
from binaryninjaui import (UIAction, UIActionHandler, Menu)
class GreatUI(QDialog):
def __init__(self, parent=None):
super(GreatUI, self).__init__(parent)
self.setWindowModality(Qt.NonModal)
self.title = QLabel(self.tr("Great UI"))
self.setWindowTitle(self.title.text())
self.testButton = QPushButton(self.tr("Press Me"))
buttons = QHBoxLayout()
buttons.addWidget(self.testButton)
self.setLayout(buttons)
self.testButton.clicked.connect(self.test)
def test(self):
print("GREAT SUCCESS")
def launchPlugin(context):
gui = GreatUI()
gui.exec_()
if __name__ == '__main__':
app = QApplication(sys.argv)
gui = GreatUI()
gui.exec_()
sys.exit(app.exec_())
else:
UIAction.registerAction("Great UI")
UIActionHandler.globalActions().bindAction("Great UI", UIAction(launchPlugin))
Menu.mainMenu("Tools").addAction("Great UI", "GUI")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment