def clear_download_forced(self, widget): """ Clears a download regardless of its status, and updates DB. :param widget: :return: """ widget.cleared = True DownloadViewListener.static_self.updateDownloadTile.emit( DDBDownloadTile(widget)) self.logger.info("Forcibly removing widget for video: {} - {}".format( widget.video.title, widget.__dict__)) try: sip.delete(widget) self.widgets.remove(widget) except RuntimeError as re_exc: if hasattr(self, 'video'): cur_vid = self.video else: cur_vid = "Non-existent video (nullptr)" if str( re_exc ) == "wrapped C/C++ object of type DownloadTile has been deleted": self.logger.exception( "Attempted to delete a nullptr widget: {}".format(cur_vid), exc_info=re_exc) else: self.logger.exception( "Unexpected RuntimeError on deleting widget: {}".format( cur_vid), exc_info=re_exc)
def deleteTest(self, test: Test): lay = self.AllCurrentTests lay.removeWidget(test) self.currentNumberOfTests -= 1 self.currentNumberOfTests = 0 if self.currentNumberOfTests < 0 else self.currentNumberOfTests delete(test) self.updateAllTestIndices()
def startRound(self, gameData): if self.board is not None: sip.delete(self.board) del self.board self.board = Board(self, self.config, self.currentMap, self.currentStage, self.bridge, self.currentGameTypeData, gameData) self.board.setFocusPolicy(Qt.StrongFocus) self.board.setFocus() self.central_widget.addWidget(self.board) self.central_widget.setCurrentWidget(self.board) self.gameStartSound.play() # reset player stats and end stage data if needed # placed here so if a player dies, the end stage will show the data # but from next round it will be showed as zeros if not gameData.firstPlayerDetails.isAlive: self.endOfStageTwoPlayers.resetFirstPlayerStats() gameData.firstPlayerDetails.points = 0 gameData.firstPlayerDetails.lives = 0 gameData.firstPlayerDetails.level = 0 gameData.firstPlayerSeparateTankDetails.resetStats() if gameData.secondPlayerDetails is not None: if not gameData.secondPlayerDetails.isAlive: self.endOfStageTwoPlayers.resetSecondPlayerStats() gameData.secondPlayerDetails.points = 0 gameData.secondPlayerDetails.lives = 0 gameData.secondPlayerDetails.level = 0 gameData.secondPlayerSeparateTankDetails.resetStats()
def search(self): if self.thread_search.is_alive(): self.log('正在搜索中!请稍后再试!') return if self.thread_detail.is_alive(): self.log('正在获取详情中!请稍后再试!') return # 清除现有的搜索结果 while self.grid.count() != 0: w = self.grid.itemAt(0).widget() self.grid.removeWidget(w) sip.delete(w) # 获取输入的关键词 self.searchword = self.txtSearchword.text().strip() # if self.searchword == R.string.NONE: # self.log('【警告】请输入关键词!') # return self.stackedWidget.setCurrentIndex(1) print('搜索:', self.searchword) self.log('正在搜索:「' + self.searchword + '」') self.log('...') # 根据输入获取json数组 # 开启线程搜索 # 因为线程只能被执行一次,所以只要线程没有在运行就得生成新的线程 self.thread_search = threading.Thread(target=self._search, name='') self.thread_search.start() pass
def clear(self): for c in self: self.libraries.l.removeWidget(c) c.setParent(None) c.restriction_changed.disconnect() sip.delete(c) self._items = []
def delete_done(self, spine_removals, other_removals): removals = [] for i, (name, remove) in enumerate(spine_removals): if remove: removals.append(self.categories['text'].child(i)) for category, parent in self.categories.iteritems(): if category != 'text': for i in xrange(parent.childCount()): child = parent.child(i) if unicode(child.data(0, NAME_ROLE) or '') in other_removals: removals.append(child) # The sorting by index is necessary otherwise Qt crashes with recursive # repaint detected message for c in sorted(removals, key=lambda x: x.parent().indexOfChild(x), reverse=True): sip.delete(c) # A bug in the raster paint engine on linux causes a crash if the scrollbar # is at the bottom and the delete happens to cause the scrollbar to # update b = self.verticalScrollBar() if b.value() == b.maximum(): b.setValue(b.minimum()) QTimer.singleShot(0, lambda: b.setValue(b.maximum()))
def killEmitterHandler(self, killEmitterData): if killEmitterData.targetType is Enemy: # add points, check if the enemy is flashing and if so, spawn a positive DeusEx enemy = self.enemies[killEmitterData.targetId] playerWrapper = self.playerWrappers[killEmitterData.shooterId] playerWrapper.player.points += enemy.tankDetails.points playerWrapper.separateTankDetails.details[ enemy.tankDetails.stringTankType]["count"] += 1 # if the enemy is flashing then give the players a positive DeusEx if enemy.isFlashing: self.deusExSpawner.spawn(isPositive=True) # remove the tank, its details and delete it for good del self.enemiesEtds[killEmitterData.targetId] self.scene.removeItem(self.enemies[killEmitterData.targetId]) sip.delete(self.enemies[killEmitterData.targetId]) del self.enemies[killEmitterData.targetId] self.enemiesCurrentlyAlive -= 1 self.enemyExplosionSound.play() # if there are no more enemy tank details that means that the stage is over if not self.enemiesEtds: self.stageEndInitiate() elif killEmitterData.targetType is Player: player = self.playerWrappers[killEmitterData.targetId].player player.resetPlayer() # if lives are less than 0, that means the player is dead if player.lives >= 0: self.hudPlayersLives[player.id].updateLives(player.lives) self.playerExplosionSound.play()
def standalone(password, path=None): from ..main import Application db = PasswordDB(password, path) app = Application([]) d = PasswordManager(db) d.exec_() sip.delete(d) sip.delete(app)
def clear_layout(self, layout): while layout.count(): child = layout.takeAt(0) if child.widget() is not None: child.widget().deleteLater() elif child.layout() is not None: self.clear_layout(child.layout()) sip.delete(layout)
def wild_check(self, state): if state == QtCore.Qt.Checked: self.wild = Wild() self.fon.addWidget(self.wild, 6, 0, 1, 2) else: self.fon.removeWidget(self.wild) sip.delete(self.wild) self.wild = None
def removeFolder(self, treeItem, rowItem): from PyQt5 import sip if treeItem: del self._droppedData[rowItem] sip.delete(treeItem) else: QMessageBox.warning(self, "Warning!", "There is no folder.")
def deleteUnit(self): _id = self.groupButton.checkedId() _button = self.groupButton.checkedButton() self.groupButton.removeButton(_button) delete(_button) customDeleteRecord(DB_Building_Unit, _id) self.updateUiEnabled()
def show_importance(self, title, importance, featurename): if type(self.canvas) != type(None): self.mylayout.removeWidget(self.canvas) sip.delete(self.canvas) self.canvas = MyMplCanvas() feature_num = self.feature_num_spinBox.value() self.canvas.update_figure(title, importance, featurename, feature_num) self.mylayout.addWidget(self.canvas, 0, 1)
def vplot_remove_plots(self, *plots: MatplotlibWidget): for plot in plots: if plot in self._plots: self._plots.remove(plot) if plot is not None: self._container.removeWidget(plot) plot.deleteLater() sip.delete(plot)
def closed(self, d): try: d.closed.disconnect(self.closed) self.memory.remove(d) except ValueError: pass else: sip.delete(d) del d
def clear_layout(layout): while layout.count(): child = layout.takeAt(0) if child.widget(): child.widget().deleteLater() child_layout = child.layout() if child_layout: clear_layout(child_layout) sip.delete(child_layout)
def removeProfile(self, name): try: action = self.profileActions.pop(name) except KeyError: pass else: self._profile_group.removeAction(action) self.menuPreferences.removeAction(action) sip.delete(action)
def detail(self, params): """ 跳转到详情页 :param params: 参数字典 {url', 'cover', 'title', 'latest', 'area', 'time','stars'} :return: None """ # 点击了某一部动漫 print('点击了:' + params['title']) self.currentEName = params['title'] self.currentEUrl = params['url'] # 跳转到详情页 self.stackedWidget.setCurrentIndex(2) # 在此页面清除原来的搜索结果,方便体验 while self.gridBtns.count() != 0: w = self.gridBtns.itemAt(0).widget() self.gridBtns.removeWidget(w) sip.delete(w) # print(params['url']) self.log_secondary('正在访问「' + params['title'] + '」') self.log_secondary('正在获取详情信息') self.log_secondary('...') # print('params:', params) # 设置 notnow = '暂无' # 标题 if params['title'].strip() == R.string.NONE: self.lblTitle.setText(notnow) pass else: self.lblTitle.setText(params['title']) # 时间 if params['time'].strip() == R.string.NONE: self.lblTime.setText(notnow) pass else: self.lblTime.setText(params['time']) # 地区 if params['area'].strip() == R.string.NONE: self.lblArea.setText(notnow) pass else: self.lblArea.setText(params['area']) # 演员 if params['stars'].strip() == R.string.NONE: self.lblStars.setText(notnow) pass else: self.lblStars.setText(params['stars']) # 加载封面 t = threading.Thread(target=setLabelImg, name='', args=(self.lblCover, params['cover'],)) t.start() self.thread_detail = threading.Thread(target=self._detail, name='', args=(params['url'],)) self.thread_detail.start() pass
def deleteLayout(self, cur_lay): if cur_lay is not None: while cur_lay.count(): item = cur_lay.takeAt(0) widget = item.widget() if widget is not None: widget.deleteLater() else: self.deleteLayout(item.layout()) sip.delete(cur_lay)
def dele(self): ids=self.args.index((self.sender(),)) for i in range( ids,ids-4,-1) : for j in range(len(self.args[i])): self.grid.removeWidget(self.args[i][j]) sip.delete(self.args[i][j]) self.args.pop(i) self.save_num-=1 # 调整内容页大小 self.innerpanel.resize(620,max(32*self.save_num+36,360-25-2-58))
def _delete_controller(self, controller): if isinstance(controller, QWidget): sip.delete(controller) controller = None else: for sub_con in dir(controller): if isinstance(sub_con, QWidget): sip.delete(sub_con) sub_con = None del controller
def refresh_pushButton_clicked(self): self.flowLayout.removeWidget(self.Short) sip.delete(self.Short) # layout:QWidget = self.flowLayout.itemList[0] # self.flowLayout.removeItem(layout) # 加载之前先清空子控件 # sip.delete(layout) print(self.flowLayout.itemList.__len__()) # self.scrollArea._widget.load() print("刷新成功")
def __del__(self): """ If this object is deleted it should also delete the wrapped object if it was created explicitly for this use. """ qobj = self._instance if is_scripter_child(qobj): if len(qobj.children()): print("Cannot delete", qobj, "because it has child objects") sip.delete(qobj)
def remove_cam(): if self.recordingTab.is_recording: dialog_popup(msg='Cannot remove stream while recording.') return False worker_thread.exit() self.cam_workers.pop(cam_id) self.cam_displays.pop(cam_id) self.sensorTabSensorsHorizontalLayout.removeWidget( camera_widget) sip.delete(camera_widget) return True
def clear_tree(self): root = self.dest_tree.invisibleRootItem() to_delete = [] for i in range(root.childCount()): child = root.child(i) for j in range(child.childCount()): sub_child = child.child(j) to_delete.append(sub_child) for item in to_delete: sip.delete(item)
def handle_double_click(self, item, column): # Delete chldren if is section if item.parent() is None: for i in reversed(range(item.childCount())): sip.delete(item.child(i)) # Delete if not section else: sip.delete(item) self.apply_tree_settings()
def deleteLayout(self, layout): if layout is not None: while layout.count(): item = layout.takeAt(0) widget = item.widget() if widget is not None: widget.deleteLater() else: self.deleteLayout(item.layout()) sip.delete(layout)
def click_delete_line(self): sender = self.sender() num = self.deleteLines.index(sender) self.grid_lines.removeWidget(self.lines[num]) sip.delete(self.lines[num]) del self.lines[num] self.grid_lines.removeWidget(self.deleteLines[num]) sip.delete(self.deleteLines[num]) del self.deleteLines[num]
def refresh_pushButton_clicked(self): self.init_sql() self.status_text_label.setText("刷新中") self.verticalLayout_2.removeWidget(self.scrollArea) # 加载之前先清空子控件 sip.delete(self.scrollArea ) # 删除控件的一个坑 https://my.oschina.net/yehun/blog/1813698 self.scrollArea = ScrollWindow() self.verticalLayout_2.addWidget(self.scrollArea) self.scrollArea._widget.load() self.status_text_label.setText("刷新成功") print("刷新成功")
def clearUnit(self): if len(self.unitDict) == 0: return tool_btn_list = self.unitDict.values() for var in self.groupButton.buttons(): self.groupButton.removeButton(var) for item in tool_btn_list: self.ui.horizontalLayout.removeWidget(item) delete(item) self.unitDict.clear()
def delete_done(self, spine_removals, other_removals): removals = [] for i, (name, remove) in enumerate(spine_removals): if remove: removals.append(self.categories['text'].child(i)) for category, parent in iteritems(self.categories): if category != 'text': for i in range(parent.childCount()): child = parent.child(i) if unicode_type(child.data(0, NAME_ROLE) or '') in other_removals: removals.append(child) # The sorting by index is necessary otherwise Qt crashes with recursive # repaint detected message for c in sorted(removals, key=lambda x:x.parent().indexOfChild(x), reverse=True): sip.delete(c) # A bug in the raster paint engine on linux causes a crash if the scrollbar # is at the bottom and the delete happens to cause the scrollbar to # update b = self.verticalScrollBar() if b.value() == b.maximum(): b.setValue(b.minimum()) QTimer.singleShot(0, lambda : b.setValue(b.maximum()))