Skip to content

Instantly share code, notes, and snippets.

@icecr4ck
Created June 12, 2019 19:33
Show Gist options
  • Save icecr4ck/eb5b9e4ecb9326c5f16a24f4809a5832 to your computer and use it in GitHub Desktop.
Save icecr4ck/eb5b9e4ecb9326c5f16a24f4809a5832 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