我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用sip.delete()。
def clear(self): try: model = self._item.model() except (AttributeError, RuntimeError): pass else: model.columnsInserted.disconnect(self._on_columns_inserted) self.new_field_requested.disconnect(model.insert_field) self._item = None self._fields = [] self._new_field_edit = None self.setTitle('') if self.layout() is not None: while self.layout().count(): item = self.layout().takeAt(0) if item: item.widget().deleteLater() sip.delete(self.layout()) layout = QtWidgets.QFormLayout() layout.setFieldGrowthPolicy(layout.FieldsStayAtSizeHint) self.setLayout(layout)
def main(argv=sys.argv): import sip app = QApplication(argv) argv = app.arguments() w = OWImageViewer() w.show() w.raise_() if len(argv) > 1: data = Orange.data.Table(argv[1]) else: data = Orange.data.Table('zoo-with-images') w.setData(data) rval = app.exec_() w.saveSettings() w.onDeleteWidget() sip.delete(w) app.processEvents() return rval
def tearDown(self): if hasattr(self, "dialog"): self.dialog.close() if hasattr(self, "form"): self.form.close_all() QApplication.instance().processEvents() QTest.qWait(self.CLOSE_TIMEOUT) self.form.close() QApplication.instance().processEvents() QTest.qWait(self.CLOSE_TIMEOUT) sip.delete(self.form) self.form = None QApplication.instance().processEvents() QTest.qWait(self.CLOSE_TIMEOUT)
def selection_changed(self): selected = [obj.text() for obj in self.note_list.selectedItems()] to_del = [] if len(selected) > len(self.selected_notes): # Something was added for note in selected: if note not in self.selected_notes: cb = QtWidgets.QComboBox() cb.addItems(["1/4", "1/2"] + list(map(str, range(1, 11)))) cb.setCurrentIndex(2) item = QtWidgets.QTreeWidgetItem(self.selected_notes_report, [note, "1"]) self.selected_notes_report.setItemWidget(item, 1, cb) item.setFlags(QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled) self.selected_notes[note] = item else: for note in self.selected_notes: if note not in selected: to_del.append(note) for note in to_del: item = self.selected_notes[note] del self.selected_notes[note] sip.delete(item) self.note_list.search_input.clear() self.note_list.search_input.setFocus(True)
def eraseItem(self): for x in self.ui.treeWidget_2.selectedItems():#delete with write click menu #item = self.ui.treewidget.takeItem(self.ui.treewidget.currentRow()) sip.delete(x) #item.delete
def delete_stream(self, videoframe): """Removes selected stream/videoframe from grid""" videoframe.hide() # If one or two frames if len(self.videoframes) < 3: # Reset coordinates and delete frame self.coordinates = VideoFrameCoordinates(x=0, y=0) self.delete_videoframe(videoframe) # If one frame left after deletion if len(self.videoframes) == 1: # Set last frame's coordinates to (0,0) and update coordinates last_frame = self.videoframes[0] last_frame._coordinates = self.coordinates self.update_new_stream_coordinates() # Otherwise there are more frames else: # Get coordinates of frame x = videoframe._coordinates.x y = videoframe._coordinates.y self.coordinates = VideoFrameCoordinates(x=x, y=y) # Determine which frames need to be moved index = self.videoframes.index(videoframe) frames_to_move = self.videoframes[index + 1:] # Delete frame and all its children self.delete_videoframe(videoframe) # Move remaining frames for frame in frames_to_move: self.relocate_frame(frame, self.coordinates)
def delete_videoframe(self, videoframe): """Deletes a videoframe and all its children from grid""" self.videoframes.remove(videoframe) self.removeWidget(videoframe) sip.delete(videoframe) videoframe = None
def clear(self): """ Clear all thumbnails and close/delete the preview window if used. """ self.__grid.clear() if self.__previewWidget is not None: self.__closePreview()
def tearDownClass(cls): cls.app.quit() sip.delete(cls.app) cls.app = None