def _create(self): struct = self.dm.getStructure(self.isInverse) for ws in struct: gparent = QTreeWidgetItem(self) gparent.setText(0, ws) for key in struct[ws]: parent = QTreeWidgetItem(gparent) parent.setText(0, key) parent.setFlags(parent.flags() | Qt.ItemIsTristate | Qt.ItemIsUserCheckable) if (self.inputList is not None and key == self.inputList[1] and ws == self.inputList[0]): channelsChecked = True gparent.setExpanded(True) self.curChecked = parent parent.setSelected(True) else: channelsChecked = False for k in struct[ws][key]: child = QTreeWidgetItem(parent) child.setFlags(child.flags()) child.setText(0, k) if channelsChecked: child.setCheckState(0, Qt.Checked) else: child.setCheckState(0, Qt.Unchecked)
def _init_widgets(self): self.clear() if self.simgr.am_none: return for stash_name, stash in self.simgr.stashes.items(): if not stash and stash_name not in ('active', 'deadended', 'avoided'): continue item = QTreeWidgetItem(self, ["%s (%d)" % (stash_name, len(stash))]) item.setFlags(item.flags() & ~Qt.ItemIsSelectable) for state in stash: subitem = QTreeWidgetItem(item, [str(state)]) subitem.setData(0, 1, state) item.addChild(subitem) self.addTopLevelItem(item) # errored states if self.simgr.errored: item = QTreeWidgetItem( self, ["%s (%d)" % ('errored', len(self.simgr.errored))]) item.setFlags(item.flags() & ~Qt.ItemIsSelectable) for estate in self.simgr.errored: subitem = QTreeWidgetItem(item, [str(estate)]) subitem.setData(0, 1, estate.state) item.addChild(subitem) self.addTopLevelItem(item)
def _createFilterTree(self, spatial_filters): av = self.model.activeView tally = self.model.statepoint.tallies[av.selectedTally] filters = tally.filters # create a tree for the filters self.treeLayout = QVBoxLayout() self.filterTree = QTreeWidget() self.treeLayout.addWidget(self.filterTree) self.treeExpander = Expander("Filters:", layout=self.treeLayout) self.treeExpander.expand() # start with filters expanded header = QTreeWidgetItem(["Filters"]) self.filterTree.setHeaderItem(header) self.filterTree.setItemHidden(header, True) self.filterTree.setColumnCount(1) self.filter_map = {} self.bin_map = {} for tally_filter in filters: filter_label = str(type(tally_filter)).split(".")[-1][:-2] filter_item = QTreeWidgetItem(self.filterTree, (filter_label,)) self.filter_map[tally_filter] = filter_item # make checkable if not spatial_filters: filter_item.setFlags(QtCore.Qt.ItemIsUserCheckable) filter_item.setToolTip(0, "Only tallies with spatial filters are viewable.") else: filter_item.setFlags(filter_item.flags() | QtCore.Qt.ItemIsTristate | QtCore.Qt.ItemIsUserCheckable) filter_item.setCheckState(0, QtCore.Qt.Unchecked) if isinstance(tally_filter, MeshFilter): filter_item.setCheckState(0, QtCore.Qt.Checked) filter_item.setFlags(QtCore.Qt.ItemIsUserCheckable) filter_item.setToolTip(0, "All Mesh bins are selected automatically") continue def _bin_sort_val(bin): if isinstance(bin, Iterable) and all([isinstance(val, float) for val in bin]): return np.sum(bin) else: return bin for bin in sorted(tally_filter.bins, key=_bin_sort_val): item = QTreeWidgetItem(filter_item, [str(bin),]) if not spatial_filters: item.setFlags(QtCore.Qt.ItemIsUserCheckable) item.setToolTip(0, "Only tallies with spatial filters are viewable.") else: item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) item.setCheckState(0, QtCore.Qt.Unchecked) bin = bin if not isinstance(bin, Iterable) else tuple(bin) self.bin_map[tally_filter, bin] = item # start with all filters selected if spatial filters are present if spatial_filters: filter_item.setCheckState(0, QtCore.Qt.Checked)
def createCourseTreeItem(self, name: str, courseId: str, chapterId: str, hasChild: bool): item = QTreeWidgetItem() item.setText(0, str(name)) item.setText(1, str(courseId)) item.setText(2, str(chapterId)) if hasChild is True: item.setFlags(item.flags() | Qt.ItemIsTristate | Qt.ItemIsUserCheckable) else: item.setFlags(item.flags() | Qt.ItemIsUserCheckable) item.setCheckState(0, Qt.Unchecked) return item
def create_node(item: Any) -> QTreeWidgetItem: child_node = QTreeWidgetItem() child_node.setFlags(child_node.flags() | Qt.ItemIsUserCheckable) child_node.setCheckState(0, Qt.CheckState.Checked) child_node.setData(1, 0, item) return child_node
def setup_possible_locations_tree(self): """ Creates the possible_locations_tree with all worlds, areas and nodes. """ self.possible_locations_tree.itemDoubleClicked.connect( self._on_tree_node_double_clicked) # TODO: Dark World names for world in self.game_description.world_list.worlds: world_item = QTreeWidgetItem(self.possible_locations_tree) world_item.setText(0, world.name) world_item.setExpanded(True) self._asset_id_to_item[world.world_asset_id] = world_item for area in world.areas: area_item = QTreeWidgetItem(world_item) area_item.area = area area_item.setText(0, area.name) area_item.setHidden(True) self._asset_id_to_item[area.area_asset_id] = area_item for node in area.nodes: node_item = QTreeWidgetItem(area_item) if isinstance(node, TranslatorGateNode): node_item.setText( 0, "{} ({})".format(node.name, node.gate)) else: node_item.setText(0, node.name) node_item.node = node if node.is_resource_node: node_item.setFlags(node_item.flags() & ~Qt.ItemIsUserCheckable) self._node_to_item[node] = node_item
def add_dir(self, dir_path, parent): sorted_list = sorted(self.list_dir(dir_path), key=lambda x: (x[0] not in self.dirs, x[0].lower())) for path, mtime in sorted_list: basename = os.path.basename(path) if len(basename) == 0: continue item = QTreeWidgetItem() item.setText(0, basename) self.index[item] = path parent.setFlags(parent.flags() | Qt.ItemIsTristate | Qt.ItemIsUserCheckable) item.setFlags(item.flags() | Qt.ItemIsUserCheckable) item.setCheckState( 0, Qt.Checked if parent.checkState(0) == Qt.Checked else Qt.Unchecked) parent.addChild(item) item.setText( 1, time.strftime("%b %d %Y %I:%M:%S %p", time.localtime(mtime))) if path in self.dirs and len(self.list_dir(path)) != 0: sub_item = QTreeWidgetItem() self.hidden[item] = sub_item item.addChild(sub_item) item.setIcon(0, QIcon(get_resource_path("images/folder.png")))
def btn_add(self): """ Add a new child for the time varying parameters """ items = self.ui.tree.selectedItems() if not items: return item: QTreeWidgetItem = items[0] key = item.text(0) # Only for time varying parameters if key and key not in self.vr3.get_varying(): return # If select toplevel item if key: parent = item # If its a child else: parent = item.parent() # Add item at the end new = QTreeWidgetItem(parent) new.setText(1, "0") new.setText(2, "0") new.setText(3, "0") new.setFlags(new.flags() | Qt.ItemIsEditable) parent.addChild(new) self.set_buttons_state()
def init_trees(self): ''' Draw hierarchical tree of fields in NWB file ''' self.tree_primary.clear() self.tree_secondary.clear() for var1 in self.primary_names: # primary variables list parent = QTreeWidgetItem(self.tree_primary, [var1, str(self.df[var1].dtype)]) parent.setFlags(parent.flags() | QtCore.Qt.ItemIsTristate | QtCore.Qt.ItemIsUserCheckable) parent.setCheckState(0, QtCore.Qt.Checked) for var2 in self.secondary_names: # secondary variables list parent = QTreeWidgetItem( self.tree_secondary, [var2, str(self.secondary_vars[var2].dtype)]) parent.setFlags(parent.flags() | QtCore.Qt.ItemIsTristate | QtCore.Qt.ItemIsUserCheckable) parent.setCheckState(0, QtCore.Qt.Checked)
def add_dict_to_tree(self, filesList): self.gui.file_tree.clear() for group in filesList: parent = QTreeWidgetItem(self.gui.file_tree) parent.setFlags(parent.flags() | Qt.ItemIsTristate | Qt.ItemIsUserCheckable) source_item = None for item_object, simVal in group.items(): if simVal == "Source": parent.setText(0, "{}".format(item_object.fn)) parent.setText(3, "{}".format(item_object.src_fqpath)) source_item = item_object assert source_item is not None for item_object, simVal in group.items(): if simVal == "Source": continue branch = QTreeWidgetItem(parent) branch.setFlags(branch.flags() | Qt.ItemIsUserCheckable) branch.setText(CLEANED_NAME_COLUMN, item_object.cn) branch.setText(FILE_NAME_COLUMN, item_object.fn) branch.setText(SOURCE_FQPATH_COLUMN, "%s" % (item_object.src_fqpath, )) branch.setText(DEST_FQPATH_COLUMN, "%s" % (item_object.dest_fqpath, )) if isinstance(simVal, (int, float)): branch.setText(SIMILARITY_COLUMN, "%0.5f" % (simVal, )) else: branch.setText(SIMILARITY_COLUMN, "%s" % (simVal, )) branch.setCheckState(0, Qt.Unchecked) branch.item_data = item_object self.gui.file_tree.setColumnWidth(CLEANED_NAME_COLUMN, 400) self.gui.file_tree.setColumnWidth(FILE_NAME_COLUMN, 400) self.gui.file_tree.setColumnWidth(SOURCE_FQPATH_COLUMN, 100) self.gui.file_tree.setColumnWidth(DEST_FQPATH_COLUMN, 100) self.gui.file_tree.setColumnWidth(SIMILARITY_COLUMN, 100)
def addItem(self, group, row, colList): rootIter = QTreeWidgetItemIterator(self, QTreeWidgetItemIterator.HasChildren) gparent = None while (rootIter.value()): item = rootIter.value() if item.text(0) == group and rootIter.value().parent() is None: gparent = item break rootIter += 1 parent = QTreeWidgetItem(gparent) parent.setText(0, row) parent.setFlags(parent.flags() | Qt.ItemIsTristate | Qt.ItemIsUserCheckable) for k in colList: child = QTreeWidgetItem(parent) child.setFlags(child.flags()) child.setText(0, k) child.setCheckState(0, Qt.Unchecked)
def add_address_to_list(qtreelist: QTreeWidget, addr): for i in range(qtreelist.topLevelItemCount()): item = qtreelist.topLevelItem(i) # type: QTreeWidgetItem if int(item.text(0), 16) == addr: return None # deduplicate item = QTreeWidgetItem(qtreelist) item.setText(0, "%#x" % addr) item.setFlags(item.flags() | Qt.ItemIsUserCheckable) item.setData(0, Qt.CheckStateRole, Qt.Checked) return item
def create_item(self, text, parent, index): after = None if index != 0: after = self.child_at(parent, index - 1) if parent is not None: item = QTreeWidgetItem(parent, after) else: item = QTreeWidgetItem(self, after) item.setText(0, text) item.setFlags(item.flags() | Qt.ItemIsEditable) return item
def get_plc_tags(self): self.tags.clear() self.ui.treeWidget with LogixDriver(self.ui.comboBox_ip.currentText()) as plc: self.tags = plc.get_tag_list() for i in self.tags: parent = QTreeWidgetItem(self.ui.treeWidget) parent.setText(0, "{}".format(i['tag_name'])) if type(i['data_type']) == str: parent.setText(1, i['data_type']) parent.setFlags(parent.flags() | Qt.ItemIsUserCheckable) parent.setCheckState(0, Qt.Unchecked) #for x in range(5): # child = QTreeWidgetItem(parent) # child.setFlags(child.flags() | Qt.ItemIsUserCheckable) # child.setText(0, "Child {}".format(x)) # child.setCheckState(0, Qt.Unchecked) self.ui.treeWidget.sortByColumn(0) self.ui.treeWidget.resizeColumnToContents(0)
def _init_widgets(self): layout = QGridLayout() row = 0 validation_failures = set() # name name_label = QLabel(self) name_label.setText("Name") name_box = QLineEdit(self) name_box.setText(NameGenerator.random_name()) def handle_name(txt): nonlocal validation_failures key = {'name'} if txt and not any(s.gui_data.name == txt for s in self.instance.states): validation_failures -= key else: validation_failures |= key validation_update() name_box.textEdited.connect(handle_name) layout.addWidget(name_label, row, 0) layout.addWidget(name_box, row, 1) row += 1 # address address_label = QLabel(self) address_label.setText("Address") address_box = QLineEdit(self) address_box.setText( hex(self.instance.project.entry ) if self._addr is None else hex(self._addr)) def handle_address(_): nonlocal validation_failures key = {'addr'} if parse_address() is not None: validation_failures -= key else: validation_failures |= key validation_update() def parse_address(): txt = address_box.text() try: return self.instance.project.kb.labels.lookup(txt) except KeyError: pass try: return int(txt, 16) except ValueError: return None address_box.textEdited.connect(handle_address) layout.addWidget(address_label, row, 0) layout.addWidget(address_box, row, 1) row += 1 # template template_label = QLabel(self) template_label.setText("Template") template_combo = QComboBox() template_combo.addItem("Blank State", 'blank') template_combo.addItem("Call state", 'call') template_combo.addItem("Entry state", 'entry') template_combo.addItem("Full-init state", 'full') def handle_template(_): base_allowed = template_combo.currentData() in ('blank', 'call') base_state_combo.setHidden(not base_allowed) base_state_label.setHidden(not base_allowed) template_combo.currentIndexChanged.connect(handle_template) layout.addWidget(template_label, row, 0) layout.addWidget(template_combo, row, 1) row += 1 # base state base_state_label = QLabel(self) base_state_label.setText('Base state') base_state_combo = QStateComboBox(self.instance, self) self._base_state_combo = base_state_combo layout.addWidget(base_state_label, row, 0) layout.addWidget(base_state_combo, row, 1) row += 1 # mode mode_label = QLabel(self) mode_label.setText("Mode") mode_combo = QComboBox(self) mode_combo.addItem("Symbolic", "symbolic") mode_combo.addItem("Static", "static") mode_combo.addItem("Fast-path", "fastpath") mode_combo.addItem("Tracing", "tracing") self._mode_combo = mode_combo def mode_changed(): self._options.clear() self._options.update( angr.sim_options.modes[mode_combo.currentData()]) for child in children_items: child.setCheckState( 0, Qt.Checked if child.text(0) in self._options else Qt.Unchecked) mode_combo.currentIndexChanged.connect(mode_changed) self._options.clear() self._options.update(angr.sim_options.modes[mode_combo.currentData()]) layout.addWidget(mode_label, row, 0) layout.addWidget(mode_combo, row, 1) row += 1 # options tree options_label = QLabel(self) options_label.setText("Options") options_tree = QTreeWidget(self) options_tree.setHeaderHidden(True) children_items = [] for name, members in angr.sim_options.__dict__.items(): if type(members) is not set: continue if name == 'resilience_options': continue parent = QTreeWidgetItem(options_tree) parent.setText(0, name) parent.setFlags(parent.flags() | Qt.ItemIsTristate | Qt.ItemIsUserCheckable) for option in members: child = QTreeWidgetItem(parent) child.setText(0, option) child.setFlags(child.flags() | Qt.ItemIsUserCheckable) child.setCheckState( 0, Qt.Checked if option in self._options else Qt.Unchecked) children_items.append(child) parent = QTreeWidgetItem(options_tree) parent.setText(0, "All options") parent.setFlags(parent.flags() | Qt.ItemIsTristate | Qt.ItemIsUserCheckable) for option in { x for x in angr.sim_options.__dict__.values() if type(x) is str and is_option(x) }: child = QTreeWidgetItem(parent) child.setText(0, option) child.setFlags(child.flags() | Qt.ItemIsUserCheckable) child.setCheckState( 0, Qt.Checked if option in self._options else Qt.Unchecked) children_items.append(child) def maintain_model(item: QTreeWidgetItem, _): option = item.text(0) if not is_option(option): return checked = item.checkState(0) if (option in self._options) == checked: return if checked: self._options.add(option) else: self._options.remove(option) for child in children_items: if child is not item and child.text(0) == option: child.setCheckState(0, checked) options_tree.itemChanged.connect(maintain_model) layout.addWidget(options_label, row, 0) layout.addWidget(options_tree, row, 1) row += 1 # options filter options_filter_label = QLabel(self) options_filter_label.setText("") options_filter_box = QLineEdit(self) options_filter_box.setPlaceholderText("Filter") def do_filter(text): for child in children_items: child.setHidden(text.upper() not in child.text(0)) options_filter_box.textEdited.connect(do_filter) layout.addWidget(options_filter_label, row, 0) layout.addWidget(options_filter_box, row, 1) row += 1 # buttons ok_button = QPushButton(self) ok_button.setText('OK') def do_ok(): name = name_box.text() template = template_combo.currentData() addr = parse_address() base_state = base_state_combo.state mode = mode_combo.currentData() if template in ('blank', 'call') and base_state is not None: if template == 'blank': self.state = self.instance.project.factory.blank_state( addr=addr, base_state=base_state, options=self._options) else: self.state = self.instance.project.factory.call_state( addr, base_state=base_state, options=self._options) self.state.gui_data.base_name = base_state.gui_data.name else: if template == 'blank': self.state = self.instance.project.factory.blank_state( addr=addr, mode=mode, options=self._options) elif template == 'call': self.state = self.instance.project.factory.call_state( addr, mode=mode, options=self._options) elif template == 'entry': self.state = self.instance.project.factory.entry_state( mode=mode, options=self._options) else: self.state = self.instance.project.factory.full_init_state( mode=mode, options=self._options) self.state.gui_data.base_name = name self.state.gui_data.is_base = True self.state.gui_data.name = name self.state.gui_data.is_original = True if self._create_simgr: self.instance.workspace.create_simulation_manager( self.state, name) self.close() ok_button.clicked.connect(do_ok) def validation_update(): ok_button.setDisabled(bool(validation_failures)) cancel_button = QPushButton(self) cancel_button.setText('Cancel') def do_cancel(): self.close() cancel_button.clicked.connect(do_cancel) buttons_layout = QHBoxLayout() buttons_layout.addWidget(ok_button) buttons_layout.addWidget(cancel_button) self.main_layout.addLayout(layout) self.main_layout.addLayout(buttons_layout)
def _init_widgets(self): layout = QGridLayout() row = 0 validation_failures = set() # name name_label = QLabel(self) name_label.setText("Name") name_box = QLineEdit(self) name_box.setText(NameGenerator.random_name()) def handle_name(txt): nonlocal validation_failures key = {'name'} if txt and not any(s.gui_data.name == txt for s in self.instance.states): validation_failures -= key else: validation_failures |= key validation_update() name_box.textEdited.connect(handle_name) layout.addWidget(name_label, row, 0) layout.addWidget(name_box, row, 1) row += 1 # address address_label = QLabel(self) address_label.setText("Address") address_box = QLineEdit(self) self._address_box = address_box address_box.setText( hex(self.instance.project.entry ) if self._addr is None else hex(self._addr)) def handle_address(_): nonlocal validation_failures key = {'addr'} if parse_address() is not None: validation_failures -= key else: validation_failures |= key validation_update() def parse_address(): txt = address_box.text() try: return self.instance.project.kb.labels.lookup(txt) except KeyError: pass try: return int(txt, 16) except ValueError: return None address_box.textEdited.connect(handle_address) layout.addWidget(address_label, row, 0) layout.addWidget(address_box, row, 1) row += 1 # template template_label = QLabel(self) template_label.setText("Template") template_combo = QComboBox() template_combo.addItem("Blank State", 'blank') template_combo.addItem("Call state", 'call') template_combo.addItem("Entry state", 'entry') template_combo.addItem("Full-init state", 'full') def handle_template(_): base_allowed = template_combo.currentData() in ('blank', 'call') base_state_combo.setHidden(not base_allowed) base_state_label.setHidden(not base_allowed) args_allowed = template_combo.currentData() in ("entry", ) args_label.setHidden(not args_allowed) args_edit.setHidden(not args_allowed) template_combo.currentIndexChanged.connect(handle_template) layout.addWidget(template_label, row, 0) layout.addWidget(template_combo, row, 1) row += 1 # base state base_state_label = QLabel(self) base_state_label.setText('Base state') base_state_combo = QStateComboBox(self.instance, self) self._base_state_combo = base_state_combo layout.addWidget(base_state_label, row, 0) layout.addWidget(base_state_combo, row, 1) row += 1 # args args_label = QLabel(self) args_label.setText('Args') args_edit = QLineEdit(self) self._args_edit = args_edit def handle_args(): self._args = [ self.instance.project.filename.encode() or b'dummy_filename' ] for x in args_edit.text().split(): if len(x) > 2 and x[0] == "`" and x[-1] == "`": tmp = [ symbol for symbol in self.instance.symbols if symbol.args[0].split('_')[0] == x[1:-1] ] if len(tmp) == 1: self._args.append(tmp[0]) else: self._args.append(x.encode()) args_edit.editingFinished.connect(handle_args) layout.addWidget(args_label, row, 0) layout.addWidget(args_edit, row, 1) row += 1 # fs_mount fs_label = QLabel(self) fs_label.setText('Filesystem') fs_button = QPushButton(self) fs_button.setText("Change") layout.addWidget(fs_label, row, 0) layout.addWidget(fs_button, row, 1) def fs_edit_button(): fs_dialog = FilesystemMount(fs_config=self._fs_config, instance=self.instance, parent=self) fs_dialog.exec_() self._fs_config = fs_dialog.fs_config fs_button.setText("{} Items".format(len(self._fs_config))) fs_button.clicked.connect(fs_edit_button) row += 1 # mode mode_label = QLabel(self) mode_label.setText("Mode") mode_combo = QComboBox(self) mode_combo.addItem("Symbolic", "symbolic") mode_combo.addItem("Static", "static") mode_combo.addItem("Fast-path", "fastpath") mode_combo.addItem("Tracing", "tracing") self._mode_combo = mode_combo def mode_changed(): if mode_combo.currentData() == "tracing": TraceState(self.instance, self._base_state_combo, self._address_box) self._options.clear() self._options.update( angr.sim_options.modes[mode_combo.currentData()]) for child in children_items: child.setCheckState( 0, Qt.Checked if child.text(0) in self._options else Qt.Unchecked) mode_combo.currentIndexChanged.connect(mode_changed) self._options.clear() self._options.update(angr.sim_options.modes[mode_combo.currentData()]) layout.addWidget(mode_label, row, 0) layout.addWidget(mode_combo, row, 1) row += 1 # options tree options_label = QLabel(self) options_label.setText("Options") options_tree = QTreeWidget(self) options_tree.setHeaderHidden(True) children_items = [] for name, members in angr.sim_options.__dict__.items(): if type(members) is not set: continue if name == 'resilience_options': continue parent = QTreeWidgetItem(options_tree) parent.setText(0, name) parent.setFlags(parent.flags() | Qt.ItemIsTristate | Qt.ItemIsUserCheckable) for option in members: child = QTreeWidgetItem(parent) child.setText(0, option) child.setFlags(child.flags() | Qt.ItemIsUserCheckable) child.setCheckState( 0, Qt.Checked if option in self._options else Qt.Unchecked) children_items.append(child) parent = QTreeWidgetItem(options_tree) parent.setText(0, "All options") parent.setFlags(parent.flags() | Qt.ItemIsTristate | Qt.ItemIsUserCheckable) for option in { x for x in angr.sim_options.__dict__.values() if type(x) is str and is_option(x) }: child = QTreeWidgetItem(parent) child.setText(0, option) child.setFlags(child.flags() | Qt.ItemIsUserCheckable) child.setCheckState( 0, Qt.Checked if option in self._options else Qt.Unchecked) children_items.append(child) def maintain_model(item: QTreeWidgetItem, _): option = item.text(0) if not is_option(option): return checked = item.checkState(0) if (option in self._options) == checked: return if checked: self._options.add(option) else: self._options.remove(option) for child in children_items: if child is not item and child.text(0) == option: child.setCheckState(0, checked) options_tree.itemChanged.connect(maintain_model) layout.addWidget(options_label, row, 0) layout.addWidget(options_tree, row, 1) row += 1 # options filter options_filter_label = QLabel(self) options_filter_label.setText("") options_filter_box = QLineEdit(self) options_filter_box.setPlaceholderText("Filter") def do_filter(text): for child in children_items: child.setHidden(text.upper() not in child.text(0)) options_filter_box.textEdited.connect(do_filter) layout.addWidget(options_filter_label, row, 0) layout.addWidget(options_filter_box, row, 1) row += 1 # buttons ok_button = QPushButton(self) ok_button.setText('OK') def do_ok(): name = name_box.text() template = template_combo.currentData() addr = parse_address() base_state = base_state_combo.state mode = mode_combo.currentData() if template in ('blank', 'call') and base_state is not None: if template == 'blank': self.state = self.instance.project.factory.blank_state( addr=addr, base_state=base_state, options=self._options) else: self.state = self.instance.project.factory.call_state( addr, base_state=base_state, options=self._options) self.state.gui_data.base_name = base_state.gui_data.name else: if template == 'blank': self.state = self.instance.project.factory.blank_state( addr=addr, mode=mode, options=self._options) elif template == 'call': self.state = self.instance.project.factory.call_state( addr, mode=mode, options=self._options) elif template == 'entry': self.state = self.instance.project.factory.entry_state( mode=mode, options=self._options, args=self._args) else: self.state = self.instance.project.factory.full_init_state( mode=mode, options=self._options) self.state.gui_data.base_name = name self.state.gui_data.is_base = True self.state.gui_data.name = name self.state.gui_data.is_original = True # TODO: there should prob be an am_event here def attach_addr_annotation(state): for i in range(len(state.solver.constraints)): if SrcAddrAnnotation not in [ type(a) for a in state.solver.constraints[i].annotations ]: state.solver.constraints[i] = \ state.solver.constraints[i].annotate(SrcAddrAnnotation(state.addr)) return state self.state.inspect.b(event_type='constraints', when=angr.BP_AFTER, action=attach_addr_annotation) # mount fs if self._fs_config: for path, real in self._fs_config: if os.path.isdir(real): fs = angr.SimHostFilesystem(real) fs.set_state(self.state) self.state.fs.mount(path, fs) if self._create_simgr: self.instance.workspace.create_simulation_manager( self.state, name) self.close() ok_button.clicked.connect(do_ok) def validation_update(): ok_button.setDisabled(bool(validation_failures)) cancel_button = QPushButton(self) cancel_button.setText('Cancel') def do_cancel(): self.close() cancel_button.clicked.connect(do_cancel) buttons_layout = QHBoxLayout() buttons_layout.addWidget(ok_button) buttons_layout.addWidget(cancel_button) self.main_layout.addLayout(layout) self.main_layout.addLayout(buttons_layout)