def pen(p, xmax, ymax): pix = QPixmap(I('lt.png')) pen = QPen(QBrush(pix), 60) p.setPen(pen) p.drawRect(0, xmax/3, xmax/3, xmax/2)
def _create_bar_map(self): self._bar_map = QPixmap(self.width(), self.height()) self._paint_progress()
def initUI(self): self.transprot_mass =[] self.netprot_mass =[] self.filtering_is_on = 0 grid = QGridLayout() self.setLayout(grid) self.IP_list = IP_list(self) self.TransProt_list = TransProt_list(self) self.NetProt_list = NetProt_list(self) self.setWindowTitle('Гамма') self.setWindowIcon(QIcon('допочки\Gamma_200x200.png')) self.resize(740, 830) self.to_center() self.centralwidget = QWidget(self) self.tabWidget = QTabWidget(self.centralwidget) self.tabWidget.setGeometry(QRect(20, 20, 700, 750)) self.tab = QWidget() grid.addWidget(self.tab) self.cb_time = QCheckBox(self.tab) self.cb_time.setGeometry(QRect(360, 130, 120, 20)) self.cb_time.setText("Фильтр по времени") self.cb_prot = QCheckBox(self.tab) self.cb_prot.setGeometry(QRect(20, 130, 140, 20)) self.cb_prot.setText("Фильтр по протоколам") self.cb_addr = QCheckBox(self.tab) self.cb_addr.setGeometry(QRect(360, 290, 130, 20)) self.cb_addr.setText("Фильтр по IP-адресам") self.dt_beg = QDateTimeEdit(self.tab) self.dt_beg.setGeometry(QRect(360, 210, 150, 20)) self.dt_beg.setDateTime(QDateTime.currentDateTime()) self.dt_beg.setDisplayFormat("dd.MM.yyyy H:mm:ss.zzz") self.dt_beg.setCalendarPopup(True) self.dt_beg.setToolTip('Выбрать начальное время (>=)') self.dt_beg.setEnabled(False) self.dt_end = QDateTimeEdit(self.tab) self.dt_end.setGeometry(QRect(520, 210, 150, 20)) self.dt_end.setDateTime(QDateTime.currentDateTime()) self.dt_end.setDisplayFormat("dd.MM.yyyy H:mm:ss.zzz") self.dt_end.setCalendarPopup(True) self.dt_end.setToolTip('Выбрать конечное время (<)') self.dt_end.setEnabled(False) self.dt_beg.dateChanged.connect(lambda dc: self.date_changed(1)) self.dt_end.dateChanged.connect(lambda dc: self.date_changed(2)) #self.l_input_dir = QLabel(self.tab) #self.l_input_dir.setGeometry(QRect(102, 50, 180, 15)) #self.l_input_dir.setText("Выберите директорию с файлами") #self.l_or = QLabel(self.tab) #self.l_or.setGeometry(QRect(340, 50, 21, 16)) #self.l_or.setText("ИЛИ") self.l_input_file = QLabel(self.tab) self.l_input_file.setGeometry(QRect(300, 50, 90, 15)) self.l_input_file.setText("Выберите файлы") self.l_transpr = QLabel(self.tab) self.l_transpr.setGeometry(QRect(50, 190, 180, 16)) self.l_transpr.setEnabled(False) self.l_transpr.setText("Протоколы Транспортного уровня") self.l_netpr = QLabel(self.tab) self.l_netpr.setGeometry(QRect(50, 290, 180, 16)) self.l_netpr.setEnabled(False) self.l_netpr.setText("Протоколы Сетевого уровня") self.l_beg = QLabel(self.tab) self.l_beg.setGeometry(QRect(390, 190, 60, 16)) self.l_beg.setEnabled(False) self.l_beg.setText("Начиная с..") self.l_end = QLabel(self.tab) self.l_end.setGeometry(QRect(560, 190, 80, 16)) self.l_end.setEnabled(False) self.l_end.setText("Оканчивая до..") self.l_name = QLabel(self.tab) self.l_name.setGeometry(QRect(300, 450, 96, 16)) self.l_name.setText("Как назвать файл?") self.l_filt = QLabel(self.tab) self.l_filt.setGeometry(QRect(300, 10, 91, 16)) self.l_filt.setText("Выборка пакетов") self.line = QFrame(self.tab) self.line.setGeometry(QRect(0, 110, 690, 15)) self.line.setFrameShape(QFrame.HLine) self.line.setFrameShadow(QFrame.Sunken) self.line_2 = QFrame(self.tab) self.line_2.setGeometry(QRect(340, 120, 15, 300)) self.line_2.setFrameShape(QFrame.VLine) self.line_2.setFrameShadow(QFrame.Sunken) self.line_3 = QFrame(self.tab) self.line_3.setGeometry(QRect(0, 420, 690, 15)) self.line_3.setFrameShape(QFrame.HLine) self.line_3.setFrameShadow(QFrame.Sunken) #self.le_dir = QLineEdit(self.tab) #self.le_dir.setGeometry(QRect(110, 80, 211, 20)) #self.le_dir.setEnabled(False) #self.le_dir.setReadOnly(True) self.le_file = QLineEdit(self.tab) self.le_file.setGeometry(QRect(250, 80, 211, 20)) #self.le_file.setEnabled(False) self.le_file.setReadOnly(True) self.le_name = QLineEdit(self.tab) self.le_name.setGeometry(QRect(250, 480, 231, 20)) self.pt_transpr = QPlainTextEdit(self.tab) self.pt_transpr.setGeometry(QRect(50, 210, 271, 71)) self.pt_transpr.setEnabled(False) self.pt_transpr.setReadOnly(True) self.pt_netpr = QPlainTextEdit(self.tab) self.pt_netpr.setGeometry(QRect(50, 320, 271, 71)) self.pt_netpr.setEnabled(False) self.pt_netpr.setReadOnly(True) self.pt_addr = QPlainTextEdit(self.tab) self.pt_addr.setGeometry(QRect(390, 320, 271, 71)) self.pt_addr.setEnabled(False) self.pt_log = QPlainTextEdit(self.tab) self.pt_log.setGeometry(QRect(20, 610, 651, 101)) self.pt_log.setReadOnly(True) self.progressBar = QProgressBar(self.tab) self.progressBar.setGeometry(QRect(20, 580, 651, 20)) self.progressBar.setFormat("%v" + "%") self.progressBar.setMaximum(100) self.progressBar.setValue(0) #self.pb_dir = QPushButton(self.tab) #self.pb_dir.setGeometry(QRect(80, 80, 21, 20)) #self.pb_dir.setIcon(QIcon('допочки\_folder.png')) #self.pb_dir.clicked.connect(lambda gd: self.get_directory(1)) self.pb_file = QPushButton(self.tab) self.pb_file.setGeometry(QRect(220, 80, 21, 20)) self.pb_file.setIcon(QIcon('допочки\_folder.png')) self.pb_file.clicked.connect(lambda gf: self.get_files(1)) self.pb_time = QPushButton(self.tab) self.pb_time.setGeometry(QRect(480, 240, 71, 20)) self.pb_time.setToolTip('Добавить ещё временной отрезок') self.pb_time.setEnabled(False) self.pb_time.setText("Ещё!") self.pb_transpr = QPushButton(self.tab) self.pb_transpr.setGeometry(QRect(20, 210, 21, 20)) self.pb_transpr.setToolTip('Выбрать протоколы Транспортного уровня') self.pb_transpr.setIcon(QIcon('допочки\_blank.png')) self.pb_transpr.setEnabled(False) self.pb_transpr.clicked.connect(self.TransProt_list.exec) self.pb_netpr = QPushButton(self.tab) self.pb_netpr.setGeometry(QRect(20, 320, 21, 20)) self.pb_netpr.setToolTip('Выбрать протоколы Сетевого уровня') self.pb_netpr.setIcon(QIcon('допочки\_blank.png')) self.pb_netpr.setEnabled(False) self.pb_netpr.clicked.connect(self.NetProt_list.exec) self.pb_addr = QPushButton(self.tab) self.pb_addr.setGeometry(QRect(530, 290, 132, 20)) self.pb_addr.setText('Редактировать список') self.pb_addr.setEnabled(False) self.pb_addr.clicked.connect(self.IP_list.exec) self.pb_name = QPushButton(self.tab) self.pb_name.setGeometry(QRect(220, 480, 21, 20)) self.pb_name.setIcon(QIcon('допочки\_folder.png')) self.pb_name.clicked.connect(lambda ed: self.extract_to_directory(1)) self.pb_start = QPushButton(self.tab) self.pb_start.setGeometry(QRect(220, 510, 261, 41)) self.pb_start.setText("Начать выборку") self.pb_start.clicked.connect(self.do_it_motherFucker) #self.radiobutton = QRadioButton(self.tab) #self.radiobutton.setGeometry(QRect(84, 48, 20, 20)) #self.radiobutton_2 = QRadioButton(self.tab) #self.radiobutton_2.setGeometry(QRect(424, 48, 20, 20)) #self.radiobutton.raise_() #self.radiobutton_2.raise_() self.cb_time.raise_() self.cb_prot.raise_() self.cb_addr.raise_() self.dt_beg.raise_() self.dt_end.raise_() #self.l_input_dir.raise_() #self.l_or.raise_() self.l_input_file.raise_() self.l_transpr.raise_() self.l_netpr.raise_() self.l_beg.raise_() self.l_end.raise_() self.l_name.raise_() self.l_filt.raise_() self.line.raise_() self.line_2.raise_() self.line_3.raise_() #self.le_dir.raise_() self.le_file.raise_() self.le_name.raise_() self.pt_transpr.raise_() self.pt_netpr.raise_() self.pt_addr.raise_() self.pt_log.raise_() self.progressBar.raise_() #self.pb_dir.raise_() self.pb_file.raise_() self.pb_time.raise_() self.pb_transpr.raise_() self.pb_netpr.raise_() self.pb_addr.raise_() self.pb_name.raise_() self.pb_start.raise_() self.setCentralWidget(self.centralwidget) self.statusbar = QStatusBar(self) self.setStatusBar(self.statusbar) self.tabWidget.addTab(self.tab, "") self.cb_time.clicked['bool'].connect(self.dt_beg.setEnabled) self.cb_time.clicked['bool'].connect(self.dt_end.setEnabled) self.cb_time.clicked['bool'].connect(self.l_beg.setEnabled) self.cb_time.clicked['bool'].connect(self.l_end.setEnabled) self.cb_prot.clicked['bool'].connect(self.l_transpr.setEnabled) self.cb_prot.clicked['bool'].connect(self.l_netpr.setEnabled) self.cb_prot.clicked['bool'].connect(self.pt_transpr.setEnabled) self.cb_prot.clicked['bool'].connect(self.pt_netpr.setEnabled) self.cb_prot.clicked['bool'].connect(self.pb_transpr.setEnabled) self.cb_prot.clicked['bool'].connect(self.pb_netpr.setEnabled) self.cb_addr.clicked['bool'].connect(self.pt_addr.setEnabled) self.cb_addr.clicked['bool'].connect(self.pb_addr.setEnabled) #####------------------------------2_TAB self.tab_2 = QWidget() self.tabWidget.addTab(self.tab_2, "") self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), ("II работа с файлами")) self.l_merge = QLabel(self.tab_2) self.l_merge.setGeometry(QRect(300, 10, 180, 16)) self.l_merge.setText("Объединение файлов") self.l_arch = QLabel(self.tab_2) self.l_arch.setGeometry(QRect(300, 250, 180, 16)) self.l_arch.setText("Архивирование файлов") #self.radiobutton_3 = QRadioButton(self.tab_2) #self.radiobutton_3.setGeometry(QRect(84, 48, 20, 20)) #self.radiobutton_4 = QRadioButton(self.tab_2) #self.radiobutton_4.setGeometry(QRect(424, 48, 20, 20)) #self.l_input_dir2 = QLabel(self.tab_2) #self.l_input_dir2.setGeometry(QRect(102, 50, 180, 15)) #self.l_input_dir2.setText("Выберите директорию с файлами") #self.l_or2 = QLabel(self.tab_2) #self.l_or2.setGeometry(QRect(340, 50, 21, 16)) #self.l_or2.setText("ИЛИ") self.l_input_file2 = QLabel(self.tab_2) self.l_input_file2.setGeometry(QRect(102, 50, 180, 15))#442, 50, 90, 15)) self.l_input_file2.setText("Выберите файлы") self.l_name2 = QLabel(self.tab_2) self.l_name2.setGeometry(QRect(442, 50, 180, 15))#280, 140, 180, 16)) self.l_name2.setText("Куда сохранить результат?") self.l_ciph2 = QLabel(self.tab_2) self.l_ciph2.setGeometry(QRect(84, 298, 180, 15)) self.l_ciph2.setText("Убрать шифрованный трафик") self.l_arch2 = QLabel(self.tab_2) self.l_arch2.setGeometry(QRect(424, 298, 180, 15)) self.l_arch2.setText("Заархивировать файлы") #self.le_dir2 = QLineEdit(self.tab_2) #self.le_dir2.setGeometry(QRect(110, 80, 211, 20)) #self.le_dir2.setEnabled(False) self.le_file2 = QLineEdit(self.tab_2) self.le_file2.setGeometry(QRect(110, 80, 211, 20))#450, 80, 211, 20)) self.le_file2.setReadOnly(True) self.le_name2 = QLineEdit(self.tab_2) self.le_name2.setGeometry(QRect(450, 80, 211, 20))#260, 170, 180, 20)) #self.pb_dir2 = QPushButton(self.tab_2) #self.pb_dir2.setGeometry(QRect(80, 80, 21, 20)) #self.pb_dir2.setIcon(QIcon('допочки\_folder.png')) #self.pb_dir2.clicked.connect(lambda gd: self.get_directory(2)) self.pb_file2 = QPushButton(self.tab_2) self.pb_file2.setGeometry(QRect(80, 80, 21, 20))#420, 80, 21, 20)) self.pb_file2.setIcon(QIcon('допочки\_folder.png')) self.pb_file2.clicked.connect(lambda gf: self.get_files(2)) self.pb_name2 = QPushButton(self.tab_2) self.pb_name2.setGeometry(QRect(420, 80, 21, 20))#230, 170, 21, 20)) self.pb_name2.setIcon(QIcon('допочки\_folder.png')) self.pb_name2.clicked.connect(lambda ed: self.extract_to_directory(2)) self.pb_merge = QPushButton(self.tab_2) self.pb_merge.setGeometry(QRect(270, 170, 160, 20)) self.pb_merge.setText("Объединить") self.pb_merge.clicked.connect(self.merge_it_motherFucker) self.line_4 = QFrame(self.tab_2) self.line_4.setGeometry(QRect(0, 280, 690, 15)) self.line_4.setFrameShape(QFrame.HLine) self.line_4.setFrameShadow(QFrame.Sunken) self.line_5 = QFrame(self.tab_2) self.line_5.setGeometry(QRect(0, 580, 690, 15)) self.line_5.setFrameShape(QFrame.HLine) self.line_5.setFrameShadow(QFrame.Sunken) self.pt_log2 = QPlainTextEdit(self.tab_2) self.pt_log2.setGeometry(QRect(20, 610, 651, 101)) self.pt_log2.setReadOnly(True) self.graphicsView = QGraphicsView(self.tab_2) self.graphicsView.setGeometry(QRect(0, 330, 714, 277)) self.scene = QGraphicsScene() self.graphicsView.setScene(self.scene) self.scene.addPixmap(QPixmap('допочки\_in_working_3.png')) self.l_merge.raise_() self.l_arch.raise_() #self.l_input_dir2.raise_() #self.l_or2.raise_() self.l_input_file2.raise_() self.l_name2.raise_() #self.radiobutton_3.raise_() #self.radiobutton_4.raise_() #self.pb_dir2.raise_() self.pb_file2.raise_() self.pb_name2.raise_() #self.le_dir2.raise_() self.le_file2.raise_() self.le_name2.raise_() self.line_4.raise_() self.line_5.raise_() self.pt_log2.raise_() #####------------------------------2_TAB #####------------------------------3_TAB self.tab_3 = QWidget() self.tabWidget.addTab(self.tab_3, "") self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_3), ("III Проверка на аномальную активность")) self.tab_3.setEnabled(False) self.l_filt3 = QLabel(self.tab_3) self.l_filt3.setGeometry(QRect(300, 10, 91, 16)) self.l_filt3.setText("Выборка пакетов") self.l_input_file3 = QLabel(self.tab_3) self.l_input_file3.setGeometry(QRect(300, 50, 90, 15)) self.l_input_file3.setText("Выберите файлы") self.pb_file3 = QPushButton(self.tab_3) self.pb_file3.setGeometry(QRect(220, 80, 21, 20)) self.pb_file3.setIcon(QIcon('допочки\_folder.png')) self.pb_file3.clicked.connect(lambda gf: self.get_files(3)) self.le_file3 = QLineEdit(self.tab_3) self.le_file3.setGeometry(QRect(250, 80, 211, 20)) self.le_file3.setReadOnly(True) self.pb_graphy = QPushButton(self.tab_3) self.pb_graphy.setGeometry(QRect(270, 170, 160, 20)) self.pb_graphy.setText("Построить граф") #self.pb_graphy.clicked.connect(self.graph_it) #self.label_6 = QLabel(self.tab_3) #self.pixmap = QPixmap('допочки\_in_working_1.png') #self.label_6.setPixmap(self.pixmap) self.l_filt3.raise_() self.l_input_file3.raise_() self.pb_file3.raise_() self.le_file3.raise_() #####------------------------------3_TAB #####----------------------------IN_WORK self.tab_4 = QWidget() self.tabWidget.addTab(self.tab_4, "") self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_4), ("...IV visualization...")) self.tab_4.setEnabled(False) self.label_7 = QLabel(self.tab_4) self.pixmap_2 = QPixmap('допочки\_in_working_2.png') self.label_7.setPixmap(self.pixmap_2) #####----------------------------IN_WORK self.tabWidget.setCurrentIndex(0) self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), ("I выборка пакетов")) QMetaObject.connectSlotsByName(self) self.show()
def __init__(self, parent=None): QWidget.__init__(self, parent) self.current_pixmap_size = QSize(0, 0) self.pixmap = QPixmap() self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
def __init__(self, parent): self.current_img = QPixmap() self.current_url = QUrl() self.parent = parent self.dialogs = [] def __call__(self): if self.current_img.isNull(): return d = ImageView(self.parent, self.current_img, self.current_url) self.dialogs.append(d) d.finished.connect(self.cleanup, type=Qt.QueuedConnection) d() def cleanup(self): for d in tuple(self.dialogs): if not d.isVisible(): self.dialogs.remove(d) if __name__ == '__main__': import sys from calibre.gui2 import Application app = Application([]) p = QPixmap() p.load(sys.argv[-1]) u = QUrl.fromLocalFile(sys.argv[-1]) d = ImageView(None, p, u) d() app.exec_()
def paint(self, painter, option, index): QStyledItemDelegate.paint( self, painter, option, QModelIndex()) # draw the hover and selection highlights m = index.model() db = m.db try: book_id = db.id(index.row()) except (ValueError, IndexError, KeyError): return if book_id in m.ids_to_highlight_set: painter.save() try: painter.setPen(self.highlight_color) painter.setRenderHint(QPainter.Antialiasing, True) painter.drawRoundedRect(option.rect, 10, 10, Qt.RelativeSize) finally: painter.restore() marked = db.data.get_marked(book_id) db = db.new_api cdata = self.cover_cache[book_id] device_connected = self.parent().gui.device_connected is not None on_device = device_connected and db.field_for('ondevice', book_id) emblem_rules = db.pref('cover_grid_icon_rules', default=()) emblems = [] if self.emblem_size > 0: mi = None for i, (kind, column, rule) in enumerate(emblem_rules): icon_name, mi = self.render_emblem(book_id, rule, i, m.cover_grid_emblem_cache, mi, db, m.formatter, m.cover_grid_template_cache) if icon_name is not None: pixmap = self.cached_emblem(m.cover_grid_bitmap_cache, icon_name) if pixmap is not None: emblems.append(pixmap) if marked: emblems.insert( 0, self.cached_emblem(m.cover_grid_bitmap_cache, ':marked', m.marked_icon)) if on_device: emblems.insert( 0, self.cached_emblem(m.cover_grid_bitmap_cache, ':ondevice')) painter.save() right_adjust = 0 try: rect = option.rect rect.adjust(self.MARGIN, self.MARGIN, -self.MARGIN, -self.MARGIN) if self.emblem_size > 0: self.paint_emblems(painter, rect, emblems) orect = QRect(rect) if cdata is None or cdata is False: title = db.field_for('title', book_id, default_value='') authors = ' & '.join( db.field_for('authors', book_id, default_value=())) painter.setRenderHint(QPainter.TextAntialiasing, True) painter.drawText(rect, Qt.AlignCenter | Qt.TextWordWrap, '%s\n\n%s' % (title, authors)) if cdata is False: self.render_queue.put(book_id) else: if self.title_height != 0: trect = QRect(rect) rect.setBottom(rect.bottom() - self.title_height) if self.animating is not None and self.animating.row( ) == index.row(): cdata = cdata.scaled(cdata.size() * self._animated_size) dx = max(0, int((rect.width() - cdata.width()) / 2.0)) dy = max(0, rect.height() - cdata.height()) right_adjust = dx rect.adjust(dx, dy, -dx, 0) painter.drawPixmap(rect, cdata) if self.title_height != 0: rect = trect rect.setTop(rect.bottom() - self.title_height + 5) painter.setRenderHint(QPainter.TextAntialiasing, True) title = self.render_field(db, book_id) metrics = painter.fontMetrics() painter.setPen(self.highlight_color) painter.drawText( rect, Qt.AlignCenter | Qt.TextSingleLine, metrics.elidedText(title, Qt.ElideRight, rect.width())) if self.emblem_size > 0: return # We dont draw embossed emblems as the ondevice/marked emblems are drawn in the gutter if marked: try: p = self.marked_emblem except AttributeError: p = self.marked_emblem = m.marked_icon.pixmap(48, 48) self.paint_embossed_emblem(p, painter, orect, right_adjust) if on_device: try: p = self.on_device_emblem except AttributeError: p = self.on_device_emblem = QPixmap(I('ok.png')).scaled( 48, 48, transformMode=Qt.SmoothTransformation) self.paint_embossed_emblem(p, painter, orect, right_adjust, left=False) finally: painter.restore()
def __init__(self): super().__init__() for i in range(4): self._pic.append( QPixmap(resource_path("PIC/one" + str(i) + ".png")))
def __init__(self, parent): super(StartMenu, self).__init__(parent) self.tophbox = QHBoxLayout() self.hbox = QHBoxLayout() self.vbox = QVBoxLayout() self.label = QLabel() self.label.setPixmap(QPixmap('img/new-game.png')) self.label.setScaledContents(True) self.label.setFixedSize(600, 200) self.tophbox.addWidget(self.label) self.startbutton = Button(self, 'Start') self.startbutton.setEnabled(False) self.startbutton.setFixedHeight(100) self.tophbox.addWidget(self.startbutton) self.playeramt_label = QLabel('Number of players:') self.playeramt_label.setFixedWidth(125) self.playeramount = QComboBox() self.playeramount.setStyleSheet('color: rgb(0, 0, 0)') self.playeramount.setFixedWidth(50) self.playeramount.addItems([str(i) for i in range(2, 13)]) self.playeramount.setCurrentIndex(2) self.playeramount.setMaxVisibleItems(11) self.playeramount.currentTextChanged.connect(self.form_player_entries) self.score_label = QLabel('Score limit:') self.score_label.setFixedWidth(65) self.score_limit = QLineEdit() self.score_limit.setMaximumWidth(40) self.score_limit.setPalette(QPalette(Qt.white)) self.score_limit.setText('16') self.mode_label = QLabel('Game Mode:') self.mode_label.setFixedWidth(85) self.mode_select = QComboBox() self.mode_select.addItems(['Deal-1', 'Deal-4']) self.mode_select.setPalette(QPalette(Qt.white)) self.mode_select.setFixedWidth(100) self.mode_select.currentTextChanged.connect(self.update_playeramount) self.autofill_button = Button(self, 'Auto Fill') self.autofill_button.clicked.connect(self.auto_fill) self.clear_button = Button(self, 'Clear All') self.clear_button.clicked.connect(self.clear_all) self.player_entries = QVBoxLayout() self.spacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.hbox.addWidget(self.playeramt_label) self.hbox.addWidget(self.playeramount) self.hbox.addWidget(self.score_label) self.hbox.addWidget(self.score_limit) self.hbox.addWidget(self.mode_label) self.hbox.addWidget(self.mode_select) self.hbox.addWidget(self.autofill_button) self.hbox.addWidget(self.clear_button) self.vbox.addLayout(self.tophbox) self.vbox.addLayout(self.hbox) self.vbox.addLayout(self.player_entries) self.vbox.addItem(self.spacer) self.setLayout(self.vbox) self.form_player_entries()
def data(self, index, role): row, col = index.row(), index.column() if row >= len(self.matches): return None result = self.matches[row] if role == Qt.DisplayRole: if col == 1: t = result.title if result.title else _('Unknown') a = result.author if result.author else '' return ('<b>%s</b><br><i>%s</i>' % (t, a)) elif col == 2: return (result.price) elif col == 4: return ('<span>%s<br>%s</span>' % (result.store_name, result.formats)) return None elif role == Qt.DecorationRole: if col == 0 and result.cover_data: p = QPixmap() p.loadFromData(result.cover_data) p.setDevicePixelRatio( QApplication.instance().devicePixelRatio()) return p if col == 3: if result.drm == SearchResult.DRM_LOCKED: return (self.DRM_LOCKED_ICON) elif result.drm == SearchResult.DRM_UNLOCKED: return (self.DRM_UNLOCKED_ICON) elif result.drm == SearchResult.DRM_UNKNOWN: return (self.DRM_UNKNOWN_ICON) if col == 5: if result.downloads: return (self.DOWNLOAD_ICON) if col == 6: if result.affiliate: return (self.DONATE_ICON) elif role == Qt.ToolTipRole: if col == 1: return ('<p>%s</p>' % result.title) elif col == 2: return ('<p>' + _( 'Detected price as: %s. Check with the store before making a purchase to verify this price is correct. This price often does not include promotions the store may be running.' ) % result.price + '</p>') # noqa elif col == 3: if result.drm == SearchResult.DRM_LOCKED: return ('<p>' + _( 'This book as been detected as having DRM restrictions. This book may not work with your reader and you will have limitations placed upon you as to what you can do with this book. Check with the store before making any purchases to ensure you can actually read this book.' ) + '</p>') # noqa elif result.drm == SearchResult.DRM_UNLOCKED: return ('<p>' + _( 'This book has been detected as being DRM Free. You should be able to use this book on any device provided it is in a format calibre supports for conversion. However, before making a purchase double check the DRM status with the store. The store may not be disclosing the use of DRM.' ) + '</p>') # noqa else: return ('<p>' + _( 'The DRM status of this book could not be determined. There is a very high likelihood that this book is actually DRM restricted.' ) + '</p>') # noqa elif col == 4: return ('<p>%s</p>' % result.formats) elif col == 5: if result.downloads: return ('<p>' + _( 'The following formats can be downloaded directly: %s.' ) % ', '.join(result.downloads.keys()) + '</p>') elif col == 6: if result.affiliate: return ('<p>' + _( 'Buying from this store supports the calibre developer: %s.' ) % result.plugin_author + '</p>') elif role == Qt.SizeHintRole: return QSize(64, 64) return None
def __init__(self): QMainWindow.__init__(self) loadUi("ui_source/main.ui", self) self.title.setText("二手车管理软件 樱桃智库开发") # self.setStyleSheet("#MainWindow{background-color:#feffff}") pixMap = QPixmap("style/图片1.png").scaled(self.label.width(), self.label.height()) self.label.setPixmap(pixMap) # 设置窗口透明度,取值0-1 # self.setWindowOpacity(0.5) a = Panel1() self.b = Panel2() self.c = Panel3() self.d = Panel4() # d = c self.stackedWidget.addWidget(a) self.stackedWidget.addWidget(self.b) self.stackedWidget.addWidget(self.c) self.stackedWidget.addWidget(self.d) self.stackedWidget.setCurrentIndex(2) self.pushButton.clicked.connect(self.panel_1) self.pushButton_2.clicked.connect(self.panel_2) self.pushButton_3.clicked.connect(self.panel_3) self.pushButton_4.clicked.connect(self.panel_4) self.statusBar().hide() self.resize(1200, 920) self.setFixedSize(1200, 920) self.setWindowFlags(Qt.FramelessWindowHint) spin_icon = qtawesome.icon('mdi.minus', color='#1e704d') self.xxx.setIcon(spin_icon) # 设置图标 self.xxx.setIconSize(QSize(18, 18)) self.xxx.setText('') self.xxx.setGeometry(920, 0, 30, 30) self.xxx.setToolTip('最小化') styling_icon = qtawesome.icon('mdi.close', color='#1e704d') self.yyy.setIcon(styling_icon) # 设置图标 self.yyy.setIconSize(QSize(18, 18)) self.yyy.setText('') self.yyy.setGeometry(952, 0, 30, 30) self.yyy.setToolTip('关闭窗口') spin_icon = qtawesome.icon('fa5.plus-square', color='#687681') # #d4f1ef # 入库登记 self.pushButton.setIcon(spin_icon) # 设置图标 self.pushButton.setIconSize(QSize(25, 25)) spin_icon = qtawesome.icon('fa5.edit', color='#ac395d') # #d4f1ef # 车辆整备 self.pushButton_2.setIcon(spin_icon) # 设置图标 self.pushButton_2.setIconSize(QSize(25, 25)) spin_icon = qtawesome.icon('fa5.handshake', color='#166f6b') # #d4f1ef # 销售 self.pushButton_3.setIcon(spin_icon) # 设置图标 self.pushButton_3.setIconSize(QSize(25, 25)) spin_icon = qtawesome.icon('fa5.calendar-check', color='#1e704d') # #d4f1ef self.pushButton_4.setIcon(spin_icon) # 设置图标 self.pushButton_4.setIconSize(QSize(25, 25)) spin_icon = qtawesome.icon('ei.home-alt', color='#6074c3') # #d4f1ef self.main_copyright.setIcon(spin_icon) # 设置图标 self.main_copyright.setIconSize(QSize(25, 25))
def set_image(self, image_path): self.img = QPixmap(image_path) if self.img.width() > 640 or self.img.height() > 640: self.scale = 0.5
def __init__(self): self.drawn_once = False QSplashScreen.__init__(self, QPixmap(I('library.png'))) self.setWindowTitle(__appname__)
def show_picture(self): """展示图片""" self.screen_single.setPixmap(QPixmap(self.frame))
def exec_(self): dialog = QDialog(self.parent) textEdit = QTextEdit(dialog) buttonBox = QDialogButtonBox(dialog) layout = QVBoxLayout(dialog) labels = [] html = '' width = 400 height = 25 def triggeredCredit(): if textEdit.isVisible(): for i in range(2 if self.logo else 1, len(labels)): labels[i].show() textEdit.hide() else: for i in range(2 if self.logo else 1, len(labels)): labels[i].hide() textEdit.show() def triggeredClose(arg): dialog.close() dialog.setWindowTitle('About {}'.format(self.programName)) for key in self.__labelsKeys: value = self.__labels.get(key) if value: label = QLabel(dialog) label.setAlignment(Qt.AlignCenter) if key == 'website' or key == 'license': label.setText('<a href="{}">{}</a>'.format( value['url'], value['label'] if value['label'] else value['url'])) label.setTextFormat(Qt.RichText) label.setTextInteractionFlags(Qt.TextBrowserInteraction) label.setOpenExternalLinks(True) elif key == 'logo': image = QPixmap(self.logo) label.setPixmap(image.scaled(128, 128)) else: label.setText(value) labels.append(label) layout.addWidget(labels[len(labels) - 1]) for key in self.__creditsKeys: value = self.__credits.get(key) if len(value.get('contributors')) > 0: html += '<p><strong>{}</strong><br />{}</p>'.format( value.get('label'), '<br />'.join(value.get('contributors'))) if html: textEdit.setHtml('<center>{}</center>'.format(html)) layout.addWidget(textEdit) buttonBox.addButton( 'Credits', QDialogButtonBox.YesRole).clicked.connect(triggeredCredit) textEdit.close() textEdit.setReadOnly(True) buttonBox.addButton( 'Close', QDialogButtonBox.NoRole).clicked.connect(triggeredClose) layout.addWidget(buttonBox) dialog.setLayout(layout) height *= len(dialog.children()) if self.logo: height += 128 dialog.setFixedSize(width, height) return dialog.exec_()
def __init__(self, parent=None): QWidget.__init__(self, parent=parent) self.pix_map = QPixmap() self.image_rect = QRect()
def ImportCSV(self): '''Import Data from CSV file.''' # Lance un sélecteur de fichier pour choisir le fichier à écrire.''' fname = QFileDialog.getOpenFileName(self, 'Choisir un nom de fichier CSV à importer', VideoTracker.csv_dir, 'Fichier CSV (*.csv *.txt)') if fname[0] == "": return with open(fname[0], 'r', encoding="utf8") as F: data = F.readlines() if "VIDEOTRACKER MADE THIS FILE!" not in data[0]: rep = QMessageBox.critical( None, # QMessageBox parent widget 'Erreur', # window bar "Désolé, le fichier CSV <{}> n'a pas été\forgé par VideoTracker..."\ .format(os.path.basename(fname[0])), QMessageBox.Ok) return self.clearPlots() # Extract the meta-data dictionary and fill the field in the Image display: exec("self.imageTab.dico_video="+data[1].split('#')[1].strip()) self.imageTab.parse_meta_data() self.imageTab.setTextInfoVideoGrid() # Extract the unit-scale dictionary and fill the field in the Image display: unit_data = data[2].split('#')[1].strip() exec("self.unit_dict={}".format(unit_data)) print("self.unit_dict:",self.unit_dict) self.imageTab.scale_pixel.setText(str(self.unit_dict["pixels"])) self.imageTab.scale_mm.setText(str(self.unit_dict["mm"])) self.imageTab.scale_XY() self.imageTab.scaleInfoVisible(True) # Extract algo information: algo = data[3].split('#')[1].strip() try: index = ImageDisplay.algo_traj.index(algo) except: rep = QMessageBox.critical( None, # QMessageBox parent widget 'Erreur', # window bar "L'information sur l'algorithme <{}> n'est pas reconnue".format(algo)) return self.imageTab.btn_algo.setCurrentIndex(index) print('index:', index, 'self.imageTab.btn_algo.currentText():', self.imageTab.btn_algo.currentText()) # Extract RGB target color: RGB = data[4].split('#')[1].strip() print("self.target_RGB=np."+RGB) try: exec("self.target_RGB=np."+RGB) except: rep = QMessageBox.critical( None, # QMessageBox parent widget 'Erreur', # window bar "L'information RGB <{}> n'est pas reconnue".format(RGB)) return # Read the CSV file with pandas: self.csv_dataFrame = pandas.read_csv(fname[0], header=5, delimiter=';', encoding="utf8") data = self.csv_dataFrame.values data = [data[:,1], data[:,2], data[:,3]] self.target_pos = np.array(data) self.imageTab.display_plots() # Clear display tab: self.imageTab.btn_algo.clear() self.imageTab.buttonsState(importCSV=True) self.imageTab.img_lbl.setPixmap(QPixmap()) self.twoPlots_VxVy.reset()
app = QApplication(sys.argv) if getattr(sys, 'frozen', False): # running in a bundle imgDir = os.path.join(sys._MEIPASS, 'img') else: # running live imgDir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'img') ### -- style stuff spmtLogo_file = os.path.join(imgDir, 'splashscreen.png') labelstyle = "QLabel { font-size: 14px; color: purple; font-style: italic; text-align: center;}" barStyle = "QProgressBar::chunk {background: QLinearGradient( x1: 0, y1: 0, x2: 1, y2: 0,stop: 0 #372f43,stop: 0.6 #5c4c7a, stop: 0.8 #663399);border-bottom-right-radius: 7px;border-bottom-left-radius: 7px;border-top: 2px solid #8A2BE2;}" splash_pix = QPixmap(spmtLogo_file) splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) progressBar = QProgressBar(splash) progressBar.setGeometry(0, splash_pix.height() - 13, splash_pix.width(), 13) progressBar.setStyleSheet(barStyle) progressBar.setAlignment(Qt.AlignRight) label = QLabel(splash) label.setStyleSheet(labelstyle) label.setGeometry((splash_pix.width() - 500) / 2, splash_pix.height() - 40, 500, 20) label.setAlignment(Qt.AlignCenter) progressText = "loading..."
def __init_view(self): self.setFixedSize(720, 530) self.label_university = QLabel("学校:\t华南理工大学", self) self.label_university.setStyleSheet("font-size:12px") self.label_university.setGeometry(460, 10, 120, 35) self.label_school = QLabel("专业:\t控制科学与工程", self) self.label_school.setStyleSheet("font-size:12px") self.label_school.setGeometry(460, 40, 140, 35) self.label_name = QLabel("姓名:\t***", self) self.label_name.setStyleSheet("font-size:12px") self.label_name.setGeometry(460, 70, 100, 35) self.label_number = QLabel("学号:\t***", self) self.label_number.setStyleSheet("font-size:12px") self.label_number.setGeometry(460, 100, 120, 35) self.label_im = QLabel(self) self.label_im.setGeometry(600, 20, 105, 105) self.label_im.setPixmap(QPixmap("./im_scut.jpg").scaled(105, 105)) self.label_log = QTextEdit(self) self.label_log.setReadOnly(True) # self.label_log.moveCursor(QTextCursor.Down) self.label_log.setStyleSheet( "background:transparent; font-size:15px; font-family:Roman times") # self.label_log.resize(220, 200) self.label_log.setGeometry(460, 140, 245, 220) self.label_log.setFrameStyle(QFrame.Panel | QFrame.Sunken) self.label_log.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) # create a horizontal layout as the main layout of the GUI main_layout = QHBoxLayout(self) # set the distance between widgets to 10px main_layout.setSpacing(10) left_layout = QVBoxLayout() left_layout.setContentsMargins(5, 5, 5, 5) left_layout.addWidget(self.__canvas) path_layout = QHBoxLayout() path_layout.setContentsMargins(5, 5, 5, 5) self.__lab_path = QLabel(self) self.__lab_path.setText("Save Path") self.__lab_path.setFixedHeight(10) path_layout.addWidget(self.__lab_path) left_layout.addLayout(path_layout) self.__txt_path = QLineEdit("./data/1") path_layout.addWidget(self.__txt_path) self.__choose_path = QPushButton("index") self.__choose_path.setParent(self) # self.__choose_path.setShortcut("Ctrl+S") self.__choose_path.clicked.connect(self.btn_save_clicked) path_layout.addWidget(self.__choose_path) btn_layout = QHBoxLayout() btn_layout.setContentsMargins(5, 5, 5, 5) self.__btn_save = QPushButton("Save") self.__btn_save.setParent(self) self.__btn_save.setShortcut("Ctrl+A") self.__btn_save.clicked.connect(self.save_image) btn_layout.addWidget(self.__btn_save) self.__btn_recognize = QPushButton("Predict") self.__btn_recognize.setParent(self) self.__btn_recognize.setShortcut("Ctrl+R") self.__btn_recognize.clicked.connect(self.btn_recog_clicked) btn_layout.addWidget(self.__btn_recognize) self.__btn_clear = QPushButton("Clear") self.__btn_clear.setShortcut("Ctrl+X") self.__btn_clear.setParent(self) self.__btn_clear.clicked.connect(self.btn_clear_clicked) btn_layout.addWidget(self.__btn_clear) self.__btn_exit = QPushButton("EXIT") self.__btn_exit.setParent(self) # self.__btn_exit.setShortcut("Ctrl+Q") self.__btn_exit.clicked.connect(self.btn_exit_clicked) btn_layout.addWidget(self.__btn_exit) left_layout.addLayout(btn_layout) main_layout.addLayout(left_layout) # put canvas in the left GUI # main_layout.addWidget(self.__canvas) # main_layout.addWidget(left_layout) # set the right layout right_layout = QVBoxLayout() # set the space between right contents right_layout.setContentsMargins(5, 5, 5, 14) splitter = QSplitter(self) right_layout.addWidget(splitter) method_layout = QHBoxLayout() self.__lab_method = QLabel(self) self.__lab_method.setText("Recognition Method") self.__lab_method.setFixedHeight(30) method_layout.addWidget(self.__lab_method) self.kernel_list = [ 'NaiveBayesian', 'VoteFisher', 'MultiFisher', 'SklearnFisher', 'CNN' ] self.__box_method = QComboBox(self) self.__box_method.addItems(self.kernel_list) self.__box_method.setCurrentIndex(0) method_layout.addWidget(self.__box_method) right_layout.addLayout(method_layout) show_layout = QHBoxLayout() canv_layout = QVBoxLayout() self.__cbtn_eraser = QCheckBox("Eraser") self.__cbtn_eraser.setParent(self) self.__cbtn_eraser.clicked.connect(self.btn_eraser_clicked) canv_layout.addWidget(self.__cbtn_eraser) pen_size_layout = QHBoxLayout() self.__lab_pen_size = QLabel(self) self.__lab_pen_size.setText("Pen Size") self.__lab_pen_size.setFixedHeight(20) # self.__lab_pen_size.setFixedSize(50, 20) pen_size_layout.addWidget(self.__lab_pen_size) self.__box_pen_size = QSpinBox(self) self.__box_pen_size.setMaximum(40) self.__box_pen_size.setMinimum(20) self.__box_pen_size.setValue(30) self.__box_pen_size.setSingleStep(2) self.__box_pen_size.setFixedSize(50, 20) self.__box_pen_size.valueChanged.connect(self.box_pen_size_change) pen_size_layout.addWidget(self.__box_pen_size) canv_layout.addLayout(pen_size_layout) pen_color_layout = QHBoxLayout() self.__label_pen_color = QLabel(self) self.__label_pen_color.setText("Pen Color") self.__label_pen_color.setFixedHeight(20) pen_color_layout.addWidget(self.__label_pen_color) self.__combo_pen_color = QComboBox(self) self.__combo_pen_color.setFixedSize(50, 20) self.__fillColorList(self.__combo_pen_color) self.__combo_pen_color.currentIndexChanged.connect( self.pen_color_changed) pen_color_layout.addWidget(self.__combo_pen_color) canv_layout.addLayout(pen_color_layout) show_layout.addLayout(canv_layout) self.feature_map = QLabel() self.feature_map.setFixedSize(100, 100) self.feature_map.setText("") self.feature_map.setObjectName('feature map') show_layout.addWidget(self.feature_map) right_layout.addLayout(show_layout) main_layout.addLayout(right_layout)
def __init__(self, x, y): super().__init__() self._transparency = True self._pic = QPixmap(resource_path("PIC/4_0.png")) self._x = x self._y = y
def set_obj_picture(self): pic = get_map(self.city_obj[self.city_obj_now]) qpix = QPixmap() qpix.loadFromData(pic) qpix = qpix.scaled(*IMAGE_SIZE) self.city_obj_pic.setPixmap(qpix)
def __init__(self): super().__init__() self._transparency = True self._pic = QPixmap(resource_path("PIC/0_0.png"))
def paint(self, painter, option, index): QStyledItemDelegate.paint(self, painter, option, index) style = QApplication.style() # Ensure the cover is rendered over any selection rect style.drawItemPixmap(painter, option.rect, Qt.AlignmentFlag.AlignTop|Qt.AlignmentFlag.AlignHCenter, QPixmap(index.data(Qt.ItemDataRole.DecorationRole)))
def load_pixmap(self, data): pmap = QPixmap() pmap.loadFromData(data) pmap.setDevicePixelRatio(QApplication.instance().devicePixelRatio()) return pmap
def __init__(self): self.framesCount = 0 self.animationInterval = 0 self.animationPixmap = QPixmap() self.audioPlayingPixmap = QPixmap() self.audioMutedPixmap = QPixmap()
def __init__(self, parent): self.current_img = QPixmap() self.current_url = QUrl() self.parent = parent self.dialogs = []
def load_file(self): print("load file") fname, _ = QFileDialog.getOpenFileNames( self, '选择图片', '', 'Files(*.jpg *.gif *.png *.mp4)') print(fname) if fname: self.textBrowser.clear() self.selected_labels.clear() self.selected_text = "" self.comboBox.clear() if len(fname) == 1: fname = fname[0] if False: pass else: self.multi_image = False self.image_name = fname.split('/')[-1] image_names = self.image_name.split('.') self.image = cv.imread(fname) print(self.image.shape) if self.image.shape[0] >= self.image.shape[1]: self.image = cv.resize(self.image, (int(440 / self.image.shape[0] * self.image.shape[1]), 440)) self.PaintBoard.setGeometry( QtCore.QRect( self.img_ori.pos().x() + round( (440 - self.image.shape[1]) / 2), self.img_ori.pos().y(), self.image.shape[1], 440)) self.PaintBoard.set_board(self.image.shape[1], self.image.shape[0]) self.PaintBoard2.setGeometry( QtCore.QRect( self.img_rst.pos().x() + round( (440 - self.image.shape[1]) / 2), self.img_rst.pos().y(), self.image.shape[1], 440)) self.PaintBoard2.set_board(self.image.shape[1], self.image.shape[0]) else: print('yes') self.image = cv.resize(self.image, (440, int(440 / self.image.shape[1] * self.image.shape[0]))) self.PaintBoard.setGeometry( QtCore.QRect( self.img_ori.pos().x(), self.img_ori.pos().y() + round( (440 - self.image.shape[0]) / 2), 440, self.image.shape[0])) self.PaintBoard.set_board(self.image.shape[1], self.image.shape[0]) self.PaintBoard2.setGeometry( QtCore.QRect( self.img_rst.pos().x(), self.img_rst.pos().y() + round( (440 - self.image.shape[0]) / 2), 440, self.image.shape[0])) self.PaintBoard2.set_board(self.image.shape[1], self.image.shape[0]) new_image_name = image_names[ 0] + '_resized.' + image_names[1] if not os.path.exists('imgs'): os.mkdir('imgs') new_image_name = 'imgs/' + new_image_name cv.imwrite(new_image_name, self.image) self.image_path = new_image_name self.img_ori.setPixmap(QPixmap(new_image_name)) self.img_ori.setAlignment(Qt.AlignCenter) self.PaintBoard.set_seg() self.PaintBoard2.set_seg() self.pushButton_seg.setEnabled(True) self.go.setEnabled(True) self.Thanos.setEnabled(False) self.comboBox.setEnabled(False) self.pushButton_add_label.setEnabled(False) self.pushButton_clear_label.setEnabled(False) else: print("load cancelled")
def dump(self, items, out_stream, pdf_metadata): opts = self.opts page_size = get_page_size(self.opts) xdpi, ydpi = self.view.logicalDpiX(), self.view.logicalDpiY() def margin(which): val = getattr(opts, 'pdf_page_margin_' + which) if val == 0.0: val = getattr(opts, 'margin_' + which) return val ml, mr, mt, mb = map(margin, 'left right top bottom'.split()) # We cannot set the side margins in the webview as there is no right # margin for the last page (the margins are implemented with # -webkit-column-gap) self.doc = PdfDevice(out_stream, page_size=page_size, left_margin=ml, top_margin=0, right_margin=mr, bottom_margin=0, xdpi=xdpi, ydpi=ydpi, errors=self.log.error, debug=self.log.debug, compress=not opts.uncompressed_pdf, opts=opts, mark_links=opts.pdf_mark_links, page_margins=(ml, mr, mt, mb)) self.footer = opts.pdf_footer_template if self.footer: self.footer = self.footer.strip() if not self.footer and opts.pdf_page_numbers: self.footer = '<p style="text-align:center; text-indent: 0">_PAGENUM_</p>' self.header = opts.pdf_header_template if self.header: self.header = self.header.strip() min_margin = 1.5 * opts._final_base_font_size if self.footer and mb < min_margin: self.log.warn( 'Bottom margin is too small for footer, increasing it to %.1fpts' % min_margin) mb = min_margin if self.header and mt < min_margin: self.log.warn( 'Top margin is too small for header, increasing it to %.1fpts' % min_margin) mt = min_margin self.page.setViewportSize(QSize(self.doc.width(), self.doc.height())) self.render_queue = items self.total_items = len(items) mt, mb = map(self.doc.to_px, (mt, mb)) self.margin_top, self.margin_bottom = map(lambda x: int(floor(x)), (mt, mb)) self.painter = QPainter(self.doc) self.book_language = pdf_metadata.mi.languages[0] self.doc.set_metadata(title=pdf_metadata.title, author=pdf_metadata.author, tags=pdf_metadata.tags, mi=pdf_metadata.mi) self.doc_title = pdf_metadata.title self.doc_author = pdf_metadata.author self.painter.save() try: if self.cover_data is not None: p = QPixmap() try: p.loadFromData(self.cover_data) except TypeError: self.log.warn( 'This ebook does not have a raster cover, cannot generate cover for PDF' '. Cover type: %s' % type(self.cover_data)) if not p.isNull(): self.doc.init_page() draw_image_page(QRect(*self.doc.full_page_rect), self.painter, p, preserve_aspect_ratio=self.opts. preserve_cover_aspect_ratio) self.doc.end_page() finally: self.painter.restore() QTimer.singleShot(0, self.render_book) if self.loop.exec_() == 1: raise Exception('PDF Output failed, see log for details') if self.toc is not None and len(self.toc) > 0: self.doc.add_outline(self.toc) self.painter.end() if self.doc.errors_occurred: raise Exception('PDF Output failed, see log for details')
def process_inpaint(self, image, mask): print(image.shape) if type(mask) == bool: if mask == False: return if self.multi_image == False: image = cv.cvtColor(image, cv.COLOR_BGR2RGB) result, _ = self.model_inpaint.test_img_with_mask(image, mask) result = cv.cvtColor(result, cv.COLOR_BGR2RGB) self.image_result = result.copy() image_names = self.image_name.split('.') new_image_name = image_names[0] + '_result.' + image_names[1] new_image_name = 'imgs/' + new_image_name cv.imwrite(new_image_name, result) self.img_rst.setPixmap(QPixmap(new_image_name)) self.img_rst.setAlignment(Qt.AlignCenter) else: if len(self.selected_labels) == 0: return # for i in range(len(self.images)): # self.masks.append(self.process_segment(self.image_paths[i]).copy()) for i in range(len(self.images)): for l in self.selected_labels: self.masks[i][self.masks[i] == l] = 255 self.masks[i][self.masks[i] != 255] = 0 expand_mask(self.masks[i], 7) result = np.full(self.image.shape, 66, dtype="uint8") for i in range(self.image.shape[0]): for j in range(self.image.shape[1]): for k in range(len(self.masks)): if self.masks[k][i][j] == 0 and mask[i][j] != 255: result[i][j][:] = self.images[k][i][j][:] if mask[i][j] == 255: result[i][j][:] = self.image[i][j][:] mask_add = np.zeros(self.masks[0].shape, dtype="uint8") for i in range(mask_add.shape[0]): for j in range(mask_add.shape[1]): if result[i][j][0] == result[i][j][1] == result[i][j][ 2] == 66 and mask[i][j] != 255: mask_add[i][j] = 255 result = cv.cvtColor(result, cv.COLOR_BGR2RGB) result, _ = self.model_inpaint.test_img_with_mask(result, mask_add) result = cv.cvtColor(result, cv.COLOR_BGR2RGB) image_names = self.image_name.split('.') new_image_name = image_names[0] + '_result.' + image_names[1] new_image_name = 'imgs/' + new_image_name cv.imwrite(new_image_name, result) self.image_result = result.copy() self.img_rst.setPixmap(QPixmap(new_image_name)) self.img_rst.setAlignment(Qt.AlignCenter) self.go.setEnabled(False) self.pushButton_seg.setEnabled(False) torch.cuda.empty_cache() # 有效释放显存 self.pushButton_save.setEnabled(True) self.pushButton_save2.setEnabled(True) print(result.shape) return result
def create_item(self, data): x = data i = QListWidgetItem(QIcon(QPixmap(x['path']).scaled(256, 256, transformMode=Qt.SmoothTransformation)), x['name'], self.images) i.setData(Qt.UserRole, x['fname']) i.setData(Qt.UserRole+1, x['path']) return i
def update_map(self): map_bytes = self.map.get_map_bytes() qpix = QPixmap() qpix.loadFromData(map_bytes) self.mapLabel.setPixmap(qpix)