Created
April 16, 2020 21:27
-
-
Save alexander-hanel/8f0cd7b53d5e55f73de97de09a0eec8b to your computer and use it in GitHub Desktop.
IDAPython PYQT Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from idaapi import PluginForm | |
from PyQt5 import QtCore, QtGui, QtWidgets | |
import sip | |
class MyPluginFormClass(PluginForm): | |
def OnCreate(self, form): | |
""" | |
Called when the widget is created | |
""" | |
# Get parent widget | |
self.parent = self.FormToPyQtWidget(form) | |
self.PopulateForm() | |
def PopulateForm(self): | |
# Create layout | |
layout = QtWidgets.QVBoxLayout() | |
# create an empty list | |
self.list = QtWidgets.QListWidget() | |
self.list.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection) | |
self.list.currentItemChanged.connect(self.print_item) | |
# item | |
self.list.addItem("WE NEED A HERO") | |
# table | |
self.table = QtWidgets.QTableWidget() | |
self.table.setRowCount(4) | |
self.table.setColumnCount(25) | |
self.table.setHorizontalHeaderLabels(["Rule File", "Rename", "Comment", "Pattern"]) | |
self.table.setItem(0,0, QtWidgets.QTableWidgetItem("Cell (1,1)")) | |
self.table.setItem(0,1, QtWidgets.QTableWidgetItem("Cell (1,2)")) | |
self.table.setItem(1,0, QtWidgets.QTableWidgetItem("Cell (2,1)")) | |
self.table.setItem(1,1, QtWidgets.QTableWidgetItem("Cell (2,2)")) | |
self.table.setItem(2,0, QtWidgets.QTableWidgetItem("Cell (3,1)")) | |
# create a button and connect it's "clicked" signal to our "add_item" slot | |
self.genbtn = QtWidgets.QPushButton("Generate Skelton From Current Function (Cursor)") | |
self.genbtn.clicked.connect(self.add_item) | |
self.addbtn = QtWidgets.QPushButton("Add Rule From Selected Attributes") | |
self.addbtn.clicked.connect(self.add_item) | |
layout.addWidget(self.table) | |
layout.addWidget(self.genbtn) | |
layout.addWidget(self.list) | |
layout.addWidget(self.addbtn) | |
layout.addWidget(self.list) | |
# make our created layout the dialogs layout | |
self.parent.setLayout(layout) | |
def add_item(self): | |
self.list.addItem("BRRRRRRRR") | |
def print_item(self): | |
print(self.list.currentItem().text()) | |
def OnClose(self, form): | |
""" | |
Called when the widget is closed | |
""" | |
pass | |
plg = MyPluginFormClass() | |
plg.Show("Demo Search") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment