def fillEachPieceOfEquip(self, equip, side, pos): tooltip = eq2s_func.CookItemText(equip['item']) try: epnm = QTableWidgetItem(equip['item']['displayname']) epnm.setToolTip(tooltip.text) epnm.setData(1001, equip['item']['iconid']) epnm.setData(1002, equip['item']['displayname']) if side == 'l': epnm.setTextAlignment(Qt.AlignRight) else: epnm.setTextAlignment(Qt.AlignLeft) epicon = QTableWidgetItem() icon = QIcon() icon.addPixmap(eq2s_func.get_pixmap_in_db(equip['item']['iconid'])) epicon.setIcon(icon) epicon.setToolTip(tooltip.text) epicon.setData(1001, equip['item']['iconid']) epicon.setData(1002, equip['item']['displayname']) if side == 'l': self.leftEquipTable.setItem(pos, 0, epnm) self.leftEquipTable.setItem(pos, 1, epicon) elif side == 'r': self.rightEquipTable.setItem(pos, 0, epicon) self.rightEquipTable.setItem(pos, 1, epnm) except KeyError: pass
def slotEditUser(self, item=None): if not item: item = self.ui.userList.currentItem() self.ui.userList.setCurrentItem(item) user = item.getUser() if user.uid > -1: self.ui.userIDCheck.setChecked(True) self.ui.userID.setValue(user.uid) self.ui.username.setText(user.username) self.ui.realname.setText(user.realname) self.ui.pass1.setText(user.passwd) self.ui.pass2.setText(user.passwd) if "wheel" in user.groups: self.ui.admin.setChecked(True) else: self.ui.admin.setChecked(False) self.ui.noPass.setChecked(user.no_password) self.edititemindex = self.ui.userList.currentRow() self.ui.createButton.setText(_("Update")) icon = QIcon() icon.addPixmap(QPixmap(":/gui/pics/tick.png"), QIcon.Normal, QIcon.Off) self.ui.createButton.setIcon(icon) self.ui.cancelButton.setVisible(self.ui.createButton.isVisible())
class CompletionCandidate: def __init__(self, place_id, url, title, substrings): self.value = url self.place_id = place_id def get_positions(text): ans = set() text = text.lower() for ss in substrings: idx = text.find(ss.lower()) if idx > -1: ans |= set(range(idx, idx + len(ss))) return sorted(ans) self.left = make_highlighted_text(url, get_positions(url)) self.right = make_highlighted_text(title, get_positions(title)) self._icon = None def adjust_size_hint(self, option, ans): ans.setHeight(max(option.decorationSize.height() + 6, ans.height())) @property def icon(self): if self._icon is None: self._icon = QIcon() url = places.favicon_url(self.place_id) if url is not None: f = QApplication.instance().disk_cache.data(QUrl(url)) if f is not None: with closing(f): raw = f.readAll() p = QPixmap() p.loadFromData(raw) if not p.isNull(): self._icon.addPixmap(p) return self._icon def __repr__(self): return self.value def draw_item(self, painter, style, option): option.features |= option.HasDecoration option.icon = self.icon text_rect = style.subElementRect(style.SE_ItemViewItemText, option, None) x, y = text_rect.x(), text_rect.y() y += (text_rect.height() - self.left.size().height()) // 2 if not option.icon.isNull(): icon_rect = style.subElementRect(style.SE_ItemViewItemDecoration, option, None) icon_rect.setTop(y), icon_rect.setBottom(text_rect.bottom()) option.icon.paint(painter, icon_rect) option.icon = QIcon() width = (text_rect.width() // 2) - 10 painter.setClipRect(x, text_rect.y(), width, text_rect.height()) painter.drawStaticText(QPoint(x, y), self.left) painter.setClipRect(text_rect) x += width + 20 painter.drawStaticText(QPoint(x, y), self.right)
def cooked_info(self, item_obj): self.setWindowTitle('{} (Modified)'.format(item_obj['name'])) self.item_detail_label.setText(item_obj['info']) pixicon = eq2s_func.get_pixmap_in_db(item_obj['iconid']) ticon = QIcon() ticon.addPixmap(pixicon) self.setWindowIcon(ticon) self.item_icon_label.setPixmap(pixicon)
def main(): app = QApplication(sys.argv) controller = UFDebugTool() icon = QIcon() icon.addPixmap(QPixmap(os.path.join(icon_path, 'main.png')), QIcon.Normal, QIcon.Off) controller.setWindowIcon(icon) controller.show() sys.exit(app.exec_())
def __init__(self): super(UFDebugTool, self).__init__() self.ui = UFDebugToolUI(self) self.log_window = LogWindow(self) icon = QIcon() icon.addPixmap(QPixmap(os.path.join(icon_path, 'main.png')), QIcon.Normal, QIcon.Off) self.setWindowIcon(icon) self.log_window.setWindowIcon(icon) self.tornado_thread = TornadoThread() self.tornado_thread.start()
def slotAdvanced(self): icon_path = None if self.ui.scrollArea.isVisible(): icon_path = ":/gui/pics/expand.png" self.time_line.start() else: self.ui.scrollArea.show() icon_path = ":/gui/pics/collapse.png" self.time_line.start() icon = QIcon() icon.addPixmap(QPixmap(icon_path), QIcon.Normal, QIcon.Off) self.ui.addMoreUsers.setIcon(icon) self.checkUsers()
def make_multires_icon(path): """Makes a multi-resolution QIcon using images from the specified path. This function assumes that all files in the specified directory contain images that should be loaded into the QIcon. path -- Path to the directory containing the images from which the icon should be constructed. Should start with ":" if referencing a resource inside a packaged Qt resource file. """ icon = QIcon() # For each file found in the specified directory, add a pixmap of the file's contents to the icon. for file_info in QDir(path).entryInfoList(sort=QDir.Name): if file_info.isFile(): icon.addPixmap(QPixmap(file_info.absoluteFilePath())) return icon
def slotCheckCD(self): if self.check_media_stop: self.check_media_stop = False self.ui.progressBar.show() icon = QIcon() icon.addPixmap(QPixmap(":/gui/pics/dialog-error.png"), QIcon.Normal, QIcon.Off) self.ui.checkButton.setIcon(icon) self.ui.checkButton.setText("") self.checkMedia() else: self.check_media_stop = True self.ui.progressBar.show() icon = QIcon() icon.addPixmap(QPixmap(":/gui/pics/task-accepted.png"), QIcon.Normal, QIcon.Off) self.ui.checkButton.setIcon(icon) self.ui.checkButton.setText(_("Validate"))
def slotDeleteUser(self): if self.ui.userList.currentRow() == self.edititemindex: self.resetWidgets() self.ui.autoLogin.setCurrentIndex(0) _cur = self.ui.userList.currentRow() item = self.ui.userList.item(_cur).getUser() if item.uid in self.used_ids: self.used_ids.remove(item.uid) self.ui.userList.takeItem(_cur) self.ui.autoLogin.removeItem(_cur + 1) self.ui.createButton.setText(_("Add")) icon = QIcon() icon.addPixmap(QPixmap(":/gui/pics/user-group-new.png"), QIcon.Normal, QIcon.Off) self.ui.createButton.setIcon(icon) self.ui.cancelButton.hide() self.checkUsers()
def resetWidgets(self): # clear all self.edititemindex = None self.ui.username.clear() self.ui.realname.clear() self.ui.pass1.clear() self.ui.pass2.clear() self.ui.admin.setChecked(False) self.ui.noPass.setChecked(False) self.ui.userIDCheck.setChecked(False) self.ui.createButton.setEnabled(False) if self.ui.cancelButton.isVisible(): self.ui.cancelButton.setHidden(self.sender() == self.ui.cancelButton) self.checkUsers() self.ui.createButton.setText(_("Add")) icon = QIcon() icon.addPixmap(QPixmap(":/gui/pics/user-group-new.png"), QIcon.Normal, QIcon.Off) self.ui.createButton.setIcon(icon)
def whenCollectionTreesReceived(self, trees): locker = QMutex() locker.lock() self.collectionList.extend(trees['collection_list']) self.received += 1 locker.unlock() if self.received < self.qcount: return category_list_order = {} for each in self.collectionList: try: category_list_order[each['category']].append(each) except BaseException: category_list_order[each['category']] = [each] for each in category_list_order: cate_item = QTreeWidgetItem() cate_item.setText(0, each) for ea in category_list_order[each]: try: name_item = QTreeWidgetItem() name_item.setText(0, ea['name']) name_item.setText(1, 'Lv.{}'.format(ea['level'])) name_item.setText(2, 'Unpack Reward') name_item.setData(2, 1000, ea['reward_list']) for e in ea['reference_list']: pieces_item = QTreeWidgetItem() nm = e['name'] if e['id'] in self.foundList: nm += ' * Found *' pieces_item.setText(0, nm) icon = QIcon() icon.addPixmap(eq2s_func.get_pixmap_in_db(e['icon'])) pieces_item.setIcon(0, icon) name_item.addChild(pieces_item) cate_item.addChild(name_item) except BaseException as err: print( 'Something wrong when adding items to collection tree, \n{}' .format(err)) self.bigTree.addTopLevelItem(cate_item)
def resetWidgets(self): # clear all self.edititemindex = None self.ui.username.clear() self.ui.realname.clear() self.ui.pass1.clear() self.ui.pass2.clear() self.ui.admin.setChecked(False) self.ui.noPass.setChecked(False) self.ui.userIDCheck.setChecked(False) self.ui.createButton.setEnabled(False) if self.ui.cancelButton.isVisible(): self.ui.cancelButton.setHidden( self.sender() == self.ui.cancelButton) self.checkUsers() self.ui.createButton.setText(_("Add")) icon = QIcon() icon.addPixmap(QPixmap(":/gui/pics/user-group-new.png"), QIcon.Normal, QIcon.Off) self.ui.createButton.setIcon(icon)
def contextMenuEvent(self, event): if self.item != None: menu = QMenu(self.parent()) self.actionUpdate = QtWidgets.QAction(self.parent()) icon = QIcon() icon.addPixmap(QPixmap(":/icons/16x16/update"), QIcon.Normal, QIcon.Off) self.actionUpdate.setIcon(icon) self.actionUpdate.setObjectName(self.item.name) self.actionUpdate.setText("Update") self.actionUpdate.triggered.connect(self.onUpdate) menu.addAction(self.actionUpdate) self.actionDelete = QtWidgets.QAction(self.parent()) icon = QIcon() icon.addPixmap(QPixmap(":/icons/16x16/delete"), QIcon.Normal, QIcon.Off) self.actionDelete.setIcon(icon) self.actionDelete.setObjectName(self.item.name) self.actionDelete.setText("Supprimer") self.actionDelete.triggered.connect(self.onDelete) menu.addAction(self.actionDelete) menu.exec_(self.mapToGlobal(event.pos()))
def author_piece_sets(self): bLayout = QHBoxLayout() donateBtn = QPushButton() donateBtn.setFixedSize(60, 30) dicon = QIcon() dicon.addPixmap(eq2s_func.get_pixmap_in_db(1, 'eq2icon_reserve')) donateBtn.setIcon(dicon) donateBtn.setIconSize(QSize(60, 25)) donateBtn.clicked.connect(self.whenPaypalDonateClicked) donateBtn2 = QPushButton('ALIPAY') donateBtn2.setFixedSize(50, 30) donateBtn2.clicked.connect(self.whenAlipaylDonateClicked) author_Label = QLabel() author_text = '[Author] Fyoung [Email] [email protected] [Github] https://github.com/FYoungLee/EQ2Sheep' author_Label.setFixedHeight(30) author_Label.setText(author_text) bLayout.addWidget(author_Label) bLayout.addWidget(donateBtn) bLayout.addWidget(donateBtn2) return bLayout
def fillTable(self): levelrange = tuple(self.spells.keys()) r = 0 for level in sorted(levelrange): for spell in self.spells[level]: lvitem = QTableWidgetItem(str(spell['level'])) lvitem.setTextAlignment(Qt.AlignCenter) self.spellsTable.setItem(r, 0, lvitem) nmitem = QTableWidgetItem(spell['name']) nmitem.setTextAlignment(Qt.AlignCenter) try: ticon = QIcon() ticon.addPixmap( eq2s_func.get_pixmap_in_db(spell['icon']['id'], 'spellicons')) nmitem.setIcon(ticon) except: pass dtxt = eq2s_func.CookSpellText(spell) nmitem.setToolTip(dtxt) self.spellsTable.setItem(r, 1, nmitem) tieritem = QTableWidgetItem(spell['tier_name']) tieritem.setTextAlignment(Qt.AlignCenter) self.spellsTable.setItem(r, 2, tieritem) typeitem = QTableWidgetItem(spell['type'].capitalize()) typeitem.setTextAlignment(Qt.AlignCenter) self.spellsTable.setItem(r, 3, typeitem) gbitem = QTableWidgetItem(spell['given_by'].capitalize()) gbitem.setTextAlignment(Qt.AlignCenter) self.spellsTable.setItem(r, 4, gbitem) r += 1 self.spellsTable.horizontalHeader().setSectionResizeMode( 0, QHeaderView.ResizeToContents) self.spellsTable.horizontalHeader().setSectionResizeMode( 2, QHeaderView.ResizeToContents) self.spellsTable.horizontalHeader().setSectionResizeMode( 3, QHeaderView.ResizeToContents) self.spellsTable.horizontalHeader().setSectionResizeMode( 4, QHeaderView.ResizeToContents)
def cook_detail(self, detail): # window title try: self.item_detail = detail['item_list'][0] self.setWindowTitle(self.item_detail['displayname']) except (KeyError, IndexError) as err: QMessageBox().critical( self, 'Loading Error', 'Time out or Item did not exists.\nTry to reload again.\n{}'. format(err)) self.refreshBtn.setEnabled(True) return # icon handle pixicon = eq2s_func.get_pixmap_in_db(self.item_detail['iconid']) ticon = QIcon() ticon.addPixmap(pixicon) self.setWindowIcon(ticon) self.item_icon_label.setPixmap(pixicon) # set item name header name = '<h2><b>{}</b></h2><br>'.format(self.item_detail['displayname']) self.item_name_label.setText(name) # info start cook textInfo = eq2s_func.CookItemText(self.item_detail) # set to label self.item_detail_label.setText(textInfo.text) # buttons contorl self.dico_btn.setEnabled(True) if textInfo.has_set: self.sets_btn.setHidden(False) if 'typeinfo' in self.item_detail.keys(): if 'item_list' in self.item_detail['typeinfo'].keys(): self.contains_btn.setHidden(False) self.favorBtn.setEnabled(True) self.refreshBtn.setEnabled(True)
def fill_contains_table(self, contains_obj): try: for r, t in enumerate(contains_obj['item_list']): icon = QTableWidgetItem() ticon = QIcon() ticon.addPixmap(eq2s_func.get_pixmap_in_db(t['iconid'])) icon.setIcon(ticon) nm = QTableWidgetItem(t['displayname']) nm.setTextAlignment(Qt.AlignCenter) nm.setData(1, str(t['id'])) nm.setToolTip('Click for detail.') rlv = QTableWidgetItem(str(t['leveltouse'])) rlv.setTextAlignment(Qt.AlignCenter) tier = QTableWidgetItem(t['tier']) tier.setTextAlignment(Qt.AlignCenter) tp = QTableWidgetItem(t['type']) tp.setTextAlignment(Qt.AlignCenter) slot_text = '' try: for s in t['slot_list']: slot_text += s['name'] except KeyError: pass slot = QTableWidgetItem(slot_text) slot.setTextAlignment(Qt.AlignCenter) self.containsTable.setItem(r, 0, icon) self.containsTable.setItem(r, 1, nm) self.containsTable.setItem(r, 2, rlv) self.containsTable.setItem(r, 3, tier) self.containsTable.setItem(r, 4, tp) self.containsTable.setItem(r, 5, slot) self.containsTable.resizeColumnsToContents() except BaseException as err: QMessageBox().critical(self, 'Result Error', 'Try again.\n{}'.format(err)) return
def __init__(self, icon_path=None): super(About, self).__init__() self.setWindowTitle('pyPOCQuant :: About') self.setFixedSize(400, 500) self.setWindowFlags(Qt.WindowCloseButtonHint) self.icon_path = icon_path about_icon = QIcon() about_icon.addPixmap(self.style().standardPixmap( QStyle.SP_FileDialogInfoView)) self.setWindowIcon(about_icon) self.le = QLabel() self.build = QLabel( "[version: v%s %s]" % (versionInfo.get_version_string(), __operating_system__)) self.author = QLabel( "pyPOCQuant: Point of Care Test\nquantification tool. \n\nwritten by Andreas P. Cuny " "and Aaron Ponti") self.license = QLabel("Licensed under the GPL v3 license.") self.copyright = QLabel( "\u00a9 Copyright Andreas P. Cuny and Aaron Ponti \n2020. All rights reserved. \ \nCSB Laboratory & SCF @ ETH Zurich " "\nMattenstrasse 26 \n4058 Basel Switzerland ") self.dependencies = QTextBrowser() self.dependencies.setHtml( "The authors appreciate and use the following 3rd parties libraries: <br> \ <br>Python v3.6, under the <a href=https://docs.python.org/3/license.html>PSF License</a> \ <br>numpy v1.14.5, under the <a href=https://docs.scipy.org/doc/numpy-1.10.0/license.html>BSD 3-Clause License</a> \ <br>scipy v1.1.0, under the <a href=https://docs.scipy.org/doc/numpy-1.10.0/license.html>BSD 3-Clause License</a> \ <br>pandas v0.23.3, under the <a href=https://pandas.pydata.org/pandas-docs/stable/getting_started/overview.html>BSD 3-Clause License</a> \ <br>tqdm v4.23.4, under the <a href=https://github.com/tqdm/tqdm/blob/master/LICENCE>MIT License</a> \ <br>PyQT5, under the <a href=https://www.riverbankcomputing.com/static/Docs/PyQt5/introduction.html#license>GPL v3 License</a> \ <br>matplotlib, under the <a href=https://matplotlib.org/devel/license.html>PSF License</a>\ <br>pyqtgraph, under the <a href=https://github.com/pyqtgraph/pyqtgraph/blob/develop/LICENSE.txt>MIT License</a>\ <br>opencv-python v3.4.2.16, under the <a href=https://github.com/skvark/opencv-python/blob/master/LICENSE.txt>MIT License</a>\ <br>opencv-contrib-python v3.4.2.16, under the <a href=https://github.com/skvark/opencv-python/blob/master/LICENSE.txt>MIT License</a>\ <br>exifread, under the <a href=https://github.com/ianare/exif-py/blob/develop/LICENSE.txt>BSD 3-Clause License</a>\ <br>imutils, under the <a href=https://github.com/jrosebr1/imutils/blob/master/LICENSE.txt>MIT License</a>\ <br>pytesseract, under the <a href=https://github.com/madmaze/pytesseract/blob/master/LICENSE>Apache 2.0 License</a>\ <br>imageio, under the <a href=https://github.com/imageio/imageio/blob/master/LICENSE>BSD 2-Clause License</a>\ <br>rawpy, under the <a href=https://github.com/letmaik/rawpy/blob/master/LICENSE>MIT License</a>\ <br>pyzbar, under the <a href=https://github.com/NaturalHistoryMuseum/pyzbar/blob/master/LICENSE.txt>MIT License</a>\ <br>scikit-learn, under the <a href=https://github.com/scikit-learn/scikit-learn>BSD 3-Clause License</a>\ <br>scikit-image, under the <a href=https://github.com/scikit-image/scikit-image>BSD 3-Clause License</a>\ <br>nbconvert, under the <a href=https://github.com/jupyter/nbconvert/blob/master/LICENSE>BSD 3-Clause License</a>\ <br>jupytext, under the <a href=https://github.com/mwouts/jupytext/blob/master/LICENSE>MIT License</a>" ) self.dependencies.setReadOnly(True) self.dependencies.setOpenExternalLinks(True) logo = QtGui.QPixmap(self.icon_path) logo = logo.scaled(180, 256, Qt.KeepAspectRatio) self.le.setPixmap(logo) self.le.setAlignment(Qt.AlignCenter) self.build.setAlignment(Qt.AlignCenter) font_b = QtGui.QFont() font_b.setPointSize(9) self.build.setFont(font_b) font = QtGui.QFont() font.setPointSize(11) self.author.setFont(font) self.copyright.setFont(font) self.dependencies.setFont(font_b) v_box = QVBoxLayout() v_box.addWidget(self.le) v_box.addWidget(self.build) v_box.addWidget(self.license) v_box.addStretch() v_box.addWidget(self.author) v_box.addStretch() v_box.addWidget(self.copyright) v_box.addWidget(self.dependencies) v_box.addStretch() self.setLayout(v_box) p = self.palette() p.setColor(self.backgroundRole(), Qt.white) self.setPalette(p)
def __init__(self, noun: Noun, option: WordWidgetOption = None, parent: QObject = None, **kwargs): super().__init__(noun, option, parent, **kwargs) self.l_gender_title = QLabel(self.NOUN_GENDER_LABEL_TEXT) self.l_nounsn_title = QLabel(self.NOUNSN_LABEL_TEXT) self.l_nounpl_title = QLabel(self.NOUNPL_LABEL_TEXT) self.cmb_gender = QComboBox() self.le_nounsn = QLineEdit() self.le_nounpl = QLineEdit() self.lgr_word = QGridLayout() px_red = QPixmap(self.ICON_DEFAULT_SIZE, self.ICON_DEFAULT_SIZE) px_green = QPixmap(self.ICON_DEFAULT_SIZE, self.ICON_DEFAULT_SIZE) px_blue = QPixmap(self.ICON_DEFAULT_SIZE, self.ICON_DEFAULT_SIZE) px_yellow = QPixmap(self.ICON_DEFAULT_SIZE, self.ICON_DEFAULT_SIZE) px_red.fill(Qt.red) px_green.fill(Qt.green) px_blue.fill(Qt.blue) px_yellow.fill(Qt.yellow) ico_red = QIcon(px_red) ico_green = QIcon(px_green) ico_blue = QIcon(px_blue) ico_yellow = QIcon(px_yellow) ico_red.addPixmap(px_red, QIcon.Disabled) ico_green.addPixmap(px_green, QIcon.Disabled) ico_blue.addPixmap(px_blue, QIcon.Disabled) ico_yellow.addPixmap(px_yellow, QIcon.Disabled) self.cmb_gender.addItem(ico_blue, GrammaticalGender.MASCULINE.name) self.cmb_gender.addItem(ico_green, GrammaticalGender.NEUTRAL.name) self.cmb_gender.addItem(ico_red, GrammaticalGender.FEMININE.name) self.cmb_gender.addItem(ico_yellow, GrammaticalGender.PLURAL.name) self.lgr_word.addWidget(self.l_wordedit_title, 0, 0, 1, 3, Qt.AlignHCenter) self.lgr_word.addLayout(self.lhb_cmdbtns, 1, 0, 1, 3) self.lgr_word.addWidget(self.l_guid_title, 2, 0) self.lgr_word.addWidget(self.l_gender_title, 3, 0) self.lgr_word.addWidget(self.l_nounsn_title, 4, 0) self.lgr_word.addWidget(self.l_nounpl_title, 5, 0) self.lgr_word.addWidget(self.l_guid, 2, 1, 1, 2) self.lgr_word.addWidget(self.cmb_gender, 3, 1, 1, 2) self.lgr_word.addWidget(self.le_nounsn, 4, 1, 1, 2) self.lgr_word.addWidget(self.le_nounpl, 5, 1, 1, 2) self.lgr_word.setColumnStretch(0, 10) self.lgr_word.setColumnStretch(1, 12) self.lgr_word.setColumnStretch(2, 12) self.lgr_word.setColumnStretch(3, 66) self.lgr_word.setRowStretch(0, 10) self.lgr_word.setRowStretch(6, 90) self.setLayout(self.lgr_word) self.noun = noun self.init_editmode() self.cmb_gender.currentIndexChanged.connect(self.handle_cmb_gender_textchange)
def item_result_received(self, rst, apd=True): if apd: self.itemHistory.append(rst) if self.itemSearchTag: self.item_previous_btn.setEnabled(True) try: rows = len(rst['item_list']) # display the result into table if rows == 0: QMessageBox().warning( self, 'Loading Error', 'Time out or Data did not exists\nTry again.') self.item_find_btn.setEnabled(True) return except KeyError: QMessageBox().warning( self, 'Loading Error', 'Time out or Data did not exists\nTry again.') self.item_find_btn.setEnabled(True) return # set the table rows self.item_result_table.setRowCount(rows) # connect the table items to a function try: for r, t in enumerate(rst['item_list']): icon = QTableWidgetItem() ticon = QIcon() ticon.addPixmap(eq2s_func.get_pixmap_in_db(t['iconid'])) icon.setIcon(ticon) nm = QTableWidgetItem(t['displayname']) nm.setTextAlignment(Qt.AlignCenter) nm.setData(1001, t['id']) nm.setToolTip('Click for detail.') rlv = QTableWidgetItem(str(t['leveltouse'])) rlv.setTextAlignment(Qt.AlignCenter) tier = QTableWidgetItem(t['tier']) tier.setTextAlignment(Qt.AlignCenter) tp = QTableWidgetItem(t['type']) tp.setTextAlignment(Qt.AlignCenter) slot_text = '' try: for s in t['slot_list']: slot_text += s['name'] + ' ' except KeyError: pass slot = QTableWidgetItem(slot_text) self.item_result_table.setItem(r, 0, icon) self.item_result_table.setItem(r, 1, nm) self.item_result_table.setItem(r, 2, rlv) self.item_result_table.setItem(r, 3, tier) self.item_result_table.setItem(r, 4, tp) self.item_result_table.setItem(r, 5, slot) self.item_result_table.horizontalHeader().setSectionResizeMode( 0, QHeaderView.ResizeToContents) self.item_result_table.horizontalHeader().setSectionResizeMode( 1, QHeaderView.ResizeToContents) self.item_result_table.horizontalHeader().setSectionResizeMode( 2, QHeaderView.ResizeToContents) except BaseException as err: QMessageBox().critical(self, 'Result Error', 'Try again.\n{}'.format(err)) self.item_find_btn.setEnabled(True) return self.item_find_btn.setEnabled(True)
def __init__(self, ): super(About, self).__init__() self.setWindowTitle('pyIMD :: About') self.setFixedSize(320, 450) self.setWindowFlags(Qt.WindowCloseButtonHint) about_icon = QIcon() about_icon.addPixmap(self.style().standardPixmap( QStyle.SP_FileDialogInfoView)) self.setWindowIcon(about_icon) self.le = QLabel() self.build = QLabel("[build: v%s %s bit]" % (__version__, __operating_system__)) self.author = QLabel( "pyIMD: Inertial mass determination. \nWritten by Andreas P. Cuny and Gotthold\nFläschner" ) self.license = QLabel("Licensed under the GPL v3 license.") self.copyright = QLabel( "\u00a9 Copyright Andreas P. Cuny \n2018-2019. All rights reserved. \ \nCSB Laboratory @ ETH Zurich\nMattenstrasse 26 \n4058 Basel Switzerland" ) self.dependencies = QTextBrowser() self.dependencies.setHtml( "The authors appreciate and use the following 3rd parties libraries: <br> \ <br>Python v3.5, under the <a href=https://docs.python.org/3/license.html>PSF License</a> \ <br>lxml, under the <a href=https://github.com/lxml/lxml/blob/master/LICENSES.txt>BSD 3-Clause License</a> \ <br>numpy v1.14.5, under the <a href=https://docs.scipy.org/doc/numpy-1.10.0/license.html>BSD 3-Clause License</a> \ <br>scipy v1.1.0, under the <a href=https://docs.scipy.org/doc/numpy-1.10.0/license.html>BSD 3-Clause License</a> \ <br>pandas v0.23.3, under the <a href=https://pandas.pydata.org/pandas-docs/stable/getting_started/overview.html>BSD 3-Clause License</a> \ <br>nptdms v0.12.0, under the <a href=https://github.com/adamreeve/npTDMS>GPL v3 License</a> \ <br>tqdm v4.23.4, under the <a href=https://github.com/tqdm/tqdm/blob/master/LICENCE>MIT License</a> \ <br>plotnine v0.3.0, under the <a href=https://github.com/has2k1/plotnine/blob/master/LICENSE>GPL v2 License</a> \ <br>PyQT5, under the <a href=https://www.riverbankcomputing.com/static/Docs/PyQt5/introduction.html#license>GPL v3 License</a> \ <br>xmltodict, under the <a href=https://github.com/martinblech/xmltodict/blob/master/LICENSE>MIT License</a> \ <br>matplotlib, under the <a href=https://matplotlib.org/devel/license.html>PSF License</a>\ <br>pyqtgraph, under the <a href=https://github.com/pyqtgraph/pyqtgraph/blob/develop/LICENSE.txt>MIT License</a>\ <br>xmlunittest, under the <a href=https://github.com/Exirel/python-xmlunittest/blob/master/LICENSE>MIT License</a>" ) self.dependencies.setReadOnly(True) self.dependencies.setOpenExternalLinks(True) self.le.setAlignment(Qt.AlignCenter) self.build.setAlignment(Qt.AlignCenter) font_b = QtGui.QFont() font_b.setPointSize(9) self.build.setFont(font_b) font = QtGui.QFont() font.setPointSize(11) self.author.setFont(font) self.copyright.setFont(font) self.dependencies.setFont(font_b) logo = QtGui.QPixmap( resource_path( os.path.join(os.path.join("ui", "icons", "pyIMD_logo.png")))) logo = logo.scaled(250, 250, Qt.KeepAspectRatio) self.le.setPixmap(logo) v_box = QVBoxLayout() v_box.addWidget(self.le) v_box.addWidget(self.build) v_box.addWidget(self.license) v_box.addStretch() v_box.addWidget(self.author) v_box.addStretch() v_box.addWidget(self.copyright) v_box.addWidget(self.dependencies) v_box.addStretch() self.setLayout(v_box) p = self.palette() p.setColor(self.backgroundRole(), Qt.white) self.setPalette(p)
def build_aa_layout(self, pak): trees_id = self.get_tree_tabs(pak) trees_info = eq2s_func.get_db_content('aatree', 'id', trees_id) self.aa_maxpoints = {} self.aa_clickedpoints = {} self.aa_points_display = {} # store aa tabs self.aa_tables = {} tradeskilltabs = [] # adventure tabs for each in sorted(trees_id): name = trees_info[each]['name'] # store all tradeskill aa tab into a list, and make all of them next to adventure tabs. if name in ['Tradeskill', 'General', 'Far Seas']: tradeskilltabs.append(each) continue # jumping to tabs creating function tab = self.create_tabs(each) self.aa_maxpoints[each] = trees_info[each][ 'maxpointsperlevelnode_list'][-1]['maxpoints'] self.aa_clickedpoints[each] = 0 self.aa_points_display[each].setText('{} / {}'.format( self.aa_clickedpoints[each], self.aa_maxpoints[each])) self.tab_widget.addTab(tab, name) # tradeskill tabs for each in tradeskilltabs: tab = self.create_tabs(each) self.aa_maxpoints[each] = trees_info[each][ 'maxpointsperlevelnode_list'][-1]['maxpoints'] self.aa_clickedpoints[each] = 0 self.aa_points_display[each].setText('{} / {}'.format( self.aa_clickedpoints[each], self.aa_maxpoints[each])) self.tab_widget.addTab(tab, trees_info[each]['name']) self.splnodes = {} # construct the aa layout try: for e1 in trees_info: grid_n = eq2s_func.get_aa_tree_grid_modifier( trees_info[e1]['name']) for e2 in trees_info[e1]['alternateadvancementnode_list']: epicon = QTableWidgetItem() epicon.setFont(QFont("Times", 15, QFont.Black)) # get the crc group spells from local databases, cuz only one target provide, # so I just extract the only list from the returned dict. crcs = eq2s_func.get_db_content( 'crcspl', 'crc', (e2['spellcrc'], ))[e2['spellcrc']] # this dict intend to save ordered level(tier) crc spells, the keys means tier of this spell. crcdict = {} for each in crcs: crcdict[each['tier']] = each epicon.setData(1000, crcdict) self.splnodes[e2['nodeid']] = epicon epicon.setToolTip(eq2s_func.CookSpellText(crcs[0])) icon = QIcon() iconid = epicon.data(1000)[1]['icon']['id'] # backiconid = epicon.data(1000)[0]['icon']['backdrop'] icon.addPixmap( eq2s_func.get_pixmap_in_db(iconid, 'spellicons')) # epicon.setBackground(QBrush(eq2s_func.get_pixmap_in_db(backiconid, 'spellicons'))) epicon.setIcon(icon) self.aa_tables[e1].setItem( int(e2['ycoord'] * grid_n['y'] + 1), int(e2['xcoord'] * grid_n['x'] + 1), epicon) except BaseException as err: QMessageBox().critical(self, 'Loading Error', 'Something Bad Happen:\n{}'.format(err)) print(err) return self.fresh_tables() self.throw_aas(pak)