def setup_ui(self): self.l = l = QGridLayout(self) self.bb = QDialogButtonBox(self) self.bb.setStandardButtons(self.bb.Cancel) self.bb.rejected.connect(self.reject) self.la1 = la = QLabel('<h2>' + self.title) l.addWidget(la, 0, 0, 1, -1) self.la2 = la = QLabel(_('Total:')) l.addWidget(la, l.rowCount(), 0) self.overall = p = QProgressBar(self) p.setMinimum(0), p.setValue(0), p.setMaximum(0) p.setMinimumWidth(450) l.addWidget(p, l.rowCount() - 1, 1) self.omsg = la = QLabel(self) la.setMaximumWidth(450) l.addWidget(la, l.rowCount(), 1) self.la3 = la = QLabel(_('Current:')) l.addWidget(la, l.rowCount(), 0) self.current = p = QProgressBar(self) p.setMinimum(0), p.setValue(0), p.setMaximum(0) l.addWidget(p, l.rowCount() - 1, 1) self.cmsg = la = QLabel(self) la.setMaximumWidth(450) l.addWidget(la, l.rowCount(), 1) l.addWidget(self.bb, l.rowCount(), 0, 1, -1) self.update_current_signal.connect( self.update_current, type=Qt.ConnectionType.QueuedConnection) self.update_overall_signal.connect( self.update_overall, type=Qt.ConnectionType.QueuedConnection) self.finish_signal.connect(self.finish_processing, type=Qt.ConnectionType.QueuedConnection)
def build_ui(self): self.setWindowTitle("Filesystem Analyzer") settings_action = QAction(QIcon("res/settings.svg"), "Settings", self) settings_action.setShortcut("Ctrl+S") settings_action.triggered.connect(self.settings_action_handler) set_path_action = QAction(QIcon("res/directory-submission-symbol.svg"), "Set path", self) set_path_action.setShortcut("Ctrl+N") set_path_action.triggered.connect(self.set_path_action_handler) refresh_action = QAction(QIcon("res/reload.svg"), "Refresh", self) refresh_action.setShortcut("Ctrl+R") refresh_action.triggered.connect(self.refresh_action_handler) menu_bar = self.menuBar() action_menu = menu_bar.addMenu("&Action") action_menu.addAction(settings_action) action_menu.addAction(set_path_action) action_menu.addAction(refresh_action) toolbar = self.addToolBar("Exit") toolbar.addAction(settings_action) toolbar.addAction(set_path_action) toolbar.addAction(refresh_action) self.progressbar = QProgressBar(self) self.progressbar.hide() self.progressbar.setRange(0, 100) cancel_button = QPushButton(QIcon("res/cancel-button.svg"), "Cancel", self) cancel_button.clicked.connect(self.set_path_cancel) self.statusBar().addPermanentWidget(self.progressbar) self.statusBar().addPermanentWidget(cancel_button) self.tab_widget = QTabWidget(self) self.file_tree_widget = FSFileTreeWidget() self.file_tree_model = FSFileTreeModel() self.file_tree_widget.setModel(self.file_tree_model) self.movie_table_widget = FSMovieTableWidget() self.movie_table_widget.setShowGrid(False) self.movie_table_widget.setAlternatingRowColors(True) self.movie_table_widget.verticalHeader().setVisible(False) self.movie_table_widget.setSelectionBehavior(QTableView.SelectRows) self.movie_table_model = FSMovieTableModel() self.movie_table_widget.setModel(self.movie_table_model) self.tab_widget.addTab(self.file_tree_widget, "General") self.tab_widget.addTab(self.movie_table_widget, "Movies") self.setCentralWidget(self.tab_widget) last_tab_index = self.app.load_setting("last_tab_index") if last_tab_index: self.tab_widget.setCurrentIndex(int(last_tab_index)) self.tab_widget.currentChanged.connect(self.tab_widget_changed) self.show()
def setup_ui(self): self.pb = pb = QProgressBar(self) pb.setTextVisible(True) pb.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) pb.setRange(0, 0) self.w = w = QWidget(self) self.w.l = l = QVBoxLayout(w) l.addStretch(), l.addWidget(pb) self.w.la = la = QLabel(_('Checking external links, please wait...')) la.setStyleSheet('QLabel { font-size: 20px; font-weight: bold }') l.addWidget(la, 0, Qt.AlignCenter), l.addStretch() self.l = l = QVBoxLayout(self) self.results = QTextBrowser(self) self.results.setOpenLinks(False) self.results.anchorClicked.connect(self.anchor_clicked) self.stack = s = QStackedWidget(self) s.addWidget(w), s.addWidget(self.results) l.addWidget(s) self.bh = h = QHBoxLayout() self.check_anchors = ca = QCheckBox(_('Check &anchors')) ca.setToolTip( _('Check HTML anchors in links (the part after the #).\n' ' This can be a little slow, since it requires downloading and parsing all the HTML pages.' )) ca.setChecked(tprefs.get('check_external_link_anchors', True)) ca.stateChanged.connect(self.anchors_changed) h.addWidget(ca), h.addStretch(100), h.addWidget(self.bb) l.addLayout(h) self.bb.setStandardButtons(self.bb.Close) self.rb = b = self.bb.addButton(_('&Refresh'), self.bb.ActionRole) b.setIcon(QIcon(I('view-refresh.png'))) b.clicked.connect(self.refresh)
def __init__(self, url, fname, parent): QDialog.__init__(self, parent) self.setWindowTitle(_('Download %s')%fname) self.l = QVBoxLayout(self) self.purl = urlparse(url) self.msg = QLabel(_('Downloading <b>%(fname)s</b> from %(url)s')%dict( fname=fname, url=self.purl.netloc)) self.msg.setWordWrap(True) self.l.addWidget(self.msg) self.pb = QProgressBar(self) self.pb.setMinimum(0) self.pb.setMaximum(0) self.l.addWidget(self.pb) self.bb = QDialogButtonBox(QDialogButtonBox.Cancel, Qt.Horizontal, self) self.l.addWidget(self.bb) self.bb.rejected.connect(self.reject) sz = self.sizeHint() self.resize(max(sz.width(), 400), sz.height()) fpath = PersistentTemporaryFile(os.path.splitext(fname)[1]) fpath.close() self.fpath = fpath.name self.worker = Worker(url, self.fpath, Queue()) self.rejected = False
def update_log(self, book_id, msg): if book_id in self.book_log_map: index = self.book_log_map[book_id] else: index = self.log.rowCount() self.book_log_map[book_id] = index self.log.insertRow(index) title = self.db.get_proxy_metadata(book_id).title title_item = QTableWidgetItem(title) title_item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemNeverHasChildren) self.log.setItem(index, 0, title_item) progress = QProgressBar() progress.setMaximum(0) self.log.setCellWidget(index, 1, progress) self.book_progress_map[book_id] = progress if not msg is None: del (self.book_progress_map[book_id]) self.log.setCellWidget(index, 1, None) msg_item = QTableWidgetItem(msg) msg_item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemNeverHasChildren) self.log.setItem(index, 1, msg_item)
def __init__(self, parent=None, max_items=100, window_title='Progress Bar', label='', on_top=False): if on_top: QDialog.__init__(self, parent=parent, flags=Qt.WindowStaysOnTopHint) else: QDialog.__init__(self, parent=parent) self.application = Application self.setWindowTitle(window_title) self.l = QVBoxLayout(self) self.setLayout(self.l) self.label = QLabel(label) self.label.setAlignment(Qt.AlignHCenter) self.l.addWidget(self.label) self.progressBar = QProgressBar(self) self.progressBar.setRange(0, max_items) self.progressBar.setValue(0) self.l.addWidget(self.progressBar)
def _setup_ui(self): self.setStyleSheet(self._default) self.setWindowFlags( Qt.Window | Qt.WindowTitleHint | Qt.CustomizeWindowHint ) self.setStyleSheet(self._default) layout = make_layout( horizon=False, margin=24, spacing=24 ) self._progress_bar = QProgressBar() self._progress_bar.setRange(0, self._total_progress) self._progress_bar.setTextVisible(True) self._progress_bar.setFormat(r'%p% (%v/%m)') self._progress_bar.setValue(0) layout.addWidget( self._progress_bar ) self.setLayout(layout) move_center(self)
def __init__(self, parent=None): QWidget.__init__(self, parent) self.l = l = QVBoxLayout(self) self.view = v = QWebEngineView(self) v.loadStarted.connect(self.load_started) v.loadProgress.connect(self.load_progress) v.loadFinished.connect(self.load_finished) l.addWidget(v) self.h = h = QHBoxLayout() l.addLayout(h) self.download_progress = d = DownloadProgress(self) h.addWidget(d) self.home_button = b = QPushButton(_('Home')) b.clicked.connect(self.home) h.addWidget(b) self.back_button = b = QPushButton(_('Back')) b.clicked.connect(v.back) h.addWidget(b) self.forward_button = b = QPushButton(_('Forward')) b.clicked.connect(v.forward) h.addWidget(b) self.progress_bar = b = QProgressBar(self) h.addWidget(b) self.reload_button = b = QPushButton(_('Reload')) b.clicked.connect(v.reload) h.addWidget(b)
def __init__(self, __images_dir, parent=None): QDialog.__init__(self, parent=parent) self.__thread = None # l'objet QThread qui fera le calcul self.__images_dir = __images_dir # le dossier des images self.__images_list = None # la liste des images *.png à traiter self.__vMin = None # la valeur min de la barre self.__vMax = None # la valeur max de la barre self.title = QLabel("",self) self.pbar = QProgressBar(self) self.pbar.setGeometry(30, 40, 250, 25) self.btnOk = QPushButton('OK', self) self.btnOk.clicked.connect(self.close) self.btnOk.setEnabled(False) self.btnCancel = QPushButton('Cancel', self) self.btnCancel.clicked.connect(self.Cancel) self.btnCancel.setEnabled(True) vbox = QVBoxLayout() vbox.addWidget(self.title) vbox.addWidget(self.pbar) hbox = QHBoxLayout() hbox.addWidget(self.btnOk) hbox.addWidget(self.btnCancel) vbox.addLayout(hbox) self.setLayout(vbox) self.setModal(True) self.setWindowModality(Qt.ApplicationModal) self.show()
def __init__(self, parent, library_path, wait_time=2): QDialog.__init__(self, parent) self.l = QVBoxLayout() self.setLayout(self.l) self.l1 = QLabel('<b>'+_('Restoring database from backups, do not' ' interrupt, this will happen in three stages')+'...') self.setWindowTitle(_('Restoring database')) self.l.addWidget(self.l1) self.pb = QProgressBar(self) self.l.addWidget(self.pb) self.pb.setMaximum(0) self.pb.setMinimum(0) self.msg = QLabel('') self.l.addWidget(self.msg) self.msg.setWordWrap(True) self.bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Cancel) self.l.addWidget(self.bb) self.bb.rejected.connect(self.confirm_cancel) self.resize(self.sizeHint() + QSize(100, 50)) self.error = None self.rejected = False self.library_path = library_path self.update_signal.connect(self.do_update, type=Qt.ConnectionType.QueuedConnection) from calibre.db.restore import Restore self.restorer = Restore(library_path, self) self.restorer.daemon = True # Give the metadata backup thread time to stop QTimer.singleShot(wait_time * 1000, self.start)
def initUI(self): self.resize(400, 180) self.setWindowTitle("Ticket Analysis") self.setWindowIcon(QIcon('Keyword_Analysis')) CsvUploadBtn = QPushButton("CSV Upload", self) CsvUploadBtn.resize(CsvUploadBtn.sizeHint()) CsvUploadBtn.clicked.connect(self.Browse) CsvUploadBtn.move(10, 10) self.FilePathLbl = QLabel(self) self.FilePathLbl.move(100, 15) AnalyseBtn = QPushButton("Analyse", self) AnalyseBtn.move(10, 40) AnalyseBtn.clicked.connect(self.Analyse) self.ProgressBar = QProgressBar(self) self.ProgressBar.move(100, 41) self.ProgressBar.hide() self.ProgressBar.setProperty("value", 1) self.ProgressBar.setMinimumWidth(300) ConfirmationLbl = QLabel("Ticket analysis done", self) ConfirmationLbl.move(10, 110) ConfirmationLbl2 = QLabel("Please check the folder in the directory", self) ConfirmationLbl2.move(10, 130) OpenDirectory = QPushButton("Open Directory", self) OpenDirectory.move(285, 125) OpenDirectory.clicked.connect(self.OpenDir) self.show()
def __init__(self): QSplashScreen.__init__(self, QtGui.QPixmap(), QtCore.Qt.WindowStaysOnTopHint) self.rootDir = Path(__file__).parent # default values self.image = None self.version = "Version: 3.x" # pixmap.height - ? self.progress_y = 68 # pixmap.width - ? self.vx = 24 # pixmap.height - ? self.vy = 32 # message font size self.msize = 12 self.cv = OpenCVLib() self.progressBar = QProgressBar(self) self.progressBar.setMinimum(0) self.progressBar.setValue(0) self.progressBar.setMaximum(100) self.progressBar.setTextVisible(False) self.setPositionProgressBar() self.message = QLabel(self) self.message.setFont(QFont("Arial", self.msize)) self.message.setStyleSheet("QLabel { color : #000000; }") self.message.setAlignment(Qt.AlignCenter) # Shadow Effekt effect = QGraphicsDropShadowEffect(self) effect.setBlurRadius(5) effect.setColor(QColor("#ffffff")) effect.setOffset(1, 1) self.message.setGraphicsEffect(effect) self.setPositionMessage() # self.message.hide() # CSS Styling self.setStyleSheet(""" QProgressBar{ border: 1px solid #eeeeee; text-align: center; padding: 0; margin-top: 10px; } QProgressBar::chunk{ background-color: #3daee9; width: 0.34em; margin: 0 1px; } """)
def __init__(self, download_id, filename, parent=None): QWidget.__init__(self, parent) self.l = l = QHBoxLayout(self) self.la = la = QLabel('{}:\xa0'.format(filename)) la.setMaximumWidth(400) l.addWidget(la) self.pb = pb = QProgressBar(self) pb.setRange(0, 0) l.addWidget(pb) self.download_id = download_id
def __call__(self, resources): self.url_map = {} self.labels = [] for url in resources: p = self.url_map[url] = QProgressBar(self.w) p.setRange(0, 0) self.l.addWidget(p, self.l.rowCount(), 0) la = QLabel('\xa0' + url) self.labels.append(la) self.l.addWidget(la, self.l.rowCount() - 1, 1) self.l.addWidget(QLabel('')) self.l.setRowStretch(self.l.rowCount() - 1, 10)
def set_stats_one(self, nombre): self.label_nombre_1 = QLabel(nombre, self) self.label_nombre_1.setGeometry(N + 50, 10, 150, 30) self.labels_vidas_1 = [] if CANT_VIDAS > 3: self.label_nvidas_1 = QLabel(str(CANT_VIDAS), self) self.label_nvidas_1.setGeometry(N + 30, 60, 40, 30) pixmap = QPixmap("assets/vida.png") currentx = N + 100 tope = (min(CANT_VIDAS, 10)) for i in range(tope): label = QLabel("", self) label.setGeometry(currentx, 60, 30, 30) label.setPixmap(pixmap.scaled( 30, 30, Qt.KeepAspectRatio, Qt.FastTransformation)) self.labels_vidas_1.append(label) currentx += 150 / tope self.label_power_bombas_1 = QLabel("", self) self.label_power_bombas_1.setGeometry(N + 125, 100, 50, 50) self.label_power_bombas_1.setScaledContents(True) self.label_power_bombas_1.setPixmap( QPixmap("assets/mas_bombas.png")) self.label_bombas_1 = QLabel("", self) self.label_bombas_1.setGeometry(N + 75, 100, 50, 50) self.label_power_bombas_1.hide() self.label_power_velocidad_1 = QLabel("", self) self.label_power_velocidad_1.setGeometry(N + 50, 180, 50, 50) self.label_power_velocidad_1.setScaledContents(True) self.label_power_velocidad_1.setPixmap( QPixmap("assets/velocidad.png")) self.label_power_velocidad_1.hide() self.label_power_super_1 = QLabel("", self) self.label_power_super_1.setGeometry(N + 125, 180, 50, 50) self.label_power_super_1.setScaledContents(True) self.label_power_super_1.setPixmap( QPixmap("assets/supervelocidad.png")) self.label_power_super_1.hide() self.label_power_jugger_1 = QLabel("", self) self.label_power_jugger_1.setGeometry(N + 200, 180, 50, 50) self.label_power_jugger_1.setScaledContents(True) self.label_power_jugger_1.setPixmap( QPixmap("assets/juggernaut.png")) self.label_power_jugger_1.hide() self.score_bar_1 = QProgressBar(self) self.score_bar_1.setRange(0, AUMENTO_DIFICULTAD) self.score_bar_1.setGeometry(100, N + 10, N/2 - 150, 30) self.score_bar_1.setValue(0) self.label_score_1 = QLabel("Score P1", self) self.label_score_1.setGeometry(30, N + 10, 80, 30)
def set_qpb_list_item(self, channel_id, lbp): item = QListWidgetItem(self.qpb_list_widget) item.setSizeHint(QSize(400, 80)) widget = QWidget(self.qpb_list_widget) v_layout = QVBoxLayout() label = QLabel(channel_id + "==>>>等待出包...") v_layout.addWidget(label) lbp['label'] = label qpb = QProgressBar(self.qpb_list_widget) v_layout.addWidget(qpb) lbp['qpb'] = qpb widget.setLayout(v_layout) self.qpb_list_widget.addItem(item) self.qpb_list_widget.setItemWidget(item, widget)
def __init__(self, title, msg='\u00a0', min=0, max=99, parent=None, cancelable=True, icon=None): QDialog.__init__(self, parent) if icon is None: self.l = l = QVBoxLayout(self) else: self.h = h = QHBoxLayout(self) self.icon = i = QLabel(self) if not isinstance(icon, QIcon): icon = QIcon(I(icon)) i.setPixmap(icon.pixmap(64)) h.addWidget(i, alignment=Qt.AlignTop | Qt.AlignHCenter) self.l = l = QVBoxLayout() h.addLayout(l) self.setWindowIcon(icon) self.title_label = t = QLabel(title) self.setWindowTitle(title) t.setStyleSheet('QLabel { font-weight: bold }'), t.setAlignment( Qt.AlignCenter), t.setTextFormat(Qt.PlainText) l.addWidget(t) self.bar = b = QProgressBar(self) b.setMinimum(min), b.setMaximum(max), b.setValue(min) l.addWidget(b) self.message = m = QLabel(self) fm = QFontMetrics(self.font()) m.setAlignment(Qt.AlignCenter), m.setMinimumWidth( fm.averageCharWidth() * 80), m.setTextFormat(Qt.PlainText) l.addWidget(m) self.msg = msg self.button_box = bb = QDialogButtonBox(QDialogButtonBox.Abort, self) bb.rejected.connect(self._canceled) l.addWidget(bb) self.setWindowModality(Qt.ApplicationModal) self.canceled = False if not cancelable: bb.setVisible(False) self.cancelable = cancelable self.resize(self.sizeHint())
def create_state_labels(self, state_name): """ Generate 4 QLabel and 1 QProgressBar and store them in "state_data" QLabels are: state_icon | state_text | state_number | state_diff QProgressBar get value of percent. All are added on one row define by "row" value :param state_name: name of the state to be stored :type state_name: str """ # Icon icon = QPixmap(get_image_path(state_name)) state_icon = QLabel() state_icon.setFixedSize(16, 16) state_icon.setScaledContents(True) state_icon.setPixmap(icon) # Initialize Labels state_text = QLabel(self.define_label(state_name)) state_number = QLabel() state_diff = QLabel() # QProgressBar progress_bar = QProgressBar() progress_bar.setValue(0) progress_bar.setFixedHeight(20) progress_bar.setObjectName(state_name) # Layout self.main_layout.addWidget(state_icon, self.row, 0) self.main_layout.addWidget(state_text, self.row, 1) self.main_layout.addWidget(state_number, self.row, 2) self.main_layout.setAlignment(state_number, Qt.AlignCenter) self.main_layout.addWidget(state_diff, self.row, 3) self.main_layout.addWidget(progress_bar, self.row, 4) # Store state self.state_data[state_name] = { 'icon': state_icon, 'state_number': state_number, 'diff': state_diff, 'progress_bar': progress_bar } # Increment vertically position for next widget self.row += 1
def setup_ui(self): self.setWindowIcon(QIcon(I('compress-image.png'))) self.setCursor(Qt.CursorShape.BusyCursor) self.setMinimumWidth(350) self.l = l = QVBoxLayout(self) self.la = la = QLabel(_('Compressing images, please wait...')) la.setStyleSheet('QLabel { font-weight: bold }'), la.setAlignment(Qt.AlignmentFlag.AlignCenter), la.setTextFormat(Qt.TextFormat.PlainText) l.addWidget(la) self.progress = p = QProgressBar(self) p.setMinimum(0), p.setMaximum(0) l.addWidget(p) self.msg = la = QLabel('\xa0') la.setAlignment(Qt.AlignmentFlag.AlignCenter), la.setTextFormat(Qt.TextFormat.PlainText) l.addWidget(la) self.bb.setStandardButtons(QDialogButtonBox.StandardButton.Cancel) l.addWidget(self.bb)
def __init__(self, wav_files, output_directory, network_location): QMainWindow.__init__(self) self.wav_files = wav_files self.output_directory = output_directory self.network_location = network_location self.setMinimumSize(QSize(900, 500)) self.setWindowTitle("Diarization - Diarize Files (Step 2 of 2)") centralWidget = QWidget(self) self.setCentralWidget(centralWidget) gridLayout = QGridLayout(self) centralWidget.setLayout(gridLayout) title = QLabel("Please Wait While The .wav Files Are Annotated", self) title.setAlignment(QtCore.Qt.AlignCenter) self._all_files_progress = QProgressBar(self) self._all_files_progress.setMinimum(1) self._all_files_progress.setMaximum(len(wav_files)) self._file_name_lbl = QLabel("File: ", self) self._file_name_lbl.setAlignment(QtCore.Qt.AlignCenter) self._file_progress_lbl = QLabel("0%", self) self._file_progress_lbl.setAlignment(QtCore.Qt.AlignCenter) gridLayout.setRowStretch(0, 0) gridLayout.addWidget(title, 1, 0) gridLayout.setRowStretch(2, 0) gridLayout.addWidget(self._all_files_progress, 3, 0) gridLayout.addWidget(self._file_name_lbl, 4, 0) gridLayout.addWidget(self._file_progress_lbl, 5, 0) gridLayout.setRowStretch(49, 0) gridLayout.setRowStretch(50, 0) thread = Thread(target=self.exe_controler, args=()) thread.start()
def __init__(self): QDialog.__init__(self) layout = QVBoxLayout() self.url = QLineEdit() self.url.setPlaceholderText("URL") self.save_location = QLineEdit("File save location") self.progressbar = QProgressBar() download = QPushButton("Download") self.progressbar.setValue(0) self.progressbar.setAlignment(Qt.AlignHCenter) layout.addWidget(self.url) layout.addWidget(self.save_location) layout.addWidget(self.progressbar) layout.addWidget(download) self.setLayout(layout) self.setWindowTitle("Python Downloader using PyQt5") self.setFocus() download.clicked.connect(self.download)
def __init__(self, gui, icon, do_user_config): QDialog.__init__(self, gui) self.gui = gui self.do_user_config = do_user_config self.db = gui.current_db self.l = QVBoxLayout() self.setLayout(self.l) self.label = QLabel( "This plugin helps download last issues from fluter.de") self.l.addWidget(self.label) self.setWindowTitle("Unofficial fluter. Downloader") self.setWindowIcon(icon) self.progress_bar = QProgressBar(self) self.l.addWidget(self.progress_bar) self.progress_label = QLabel("Waiting to start") self.l.addWidget(self.progress_label) self.add_button = QPushButton("Download new fluter. issues", self) self.add_button.clicked.connect(self.add_fluter) self.l.addWidget(self.add_button) self.conf_button = QPushButton("Configure", self) self.conf_button.clicked.connect(self.config) self.l.addWidget(self.conf_button) self.about_button = QPushButton("About", self) self.about_button.clicked.connect(self.about) self.l.addWidget(self.about_button) self.resize(self.sizeHint())
def setup_ui(self): self.pb = pb = QProgressBar(self) pb.setTextVisible(True) pb.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) pb.setRange(0, 0) self.w = w = QWidget(self) self.w.l = l = QVBoxLayout(w) l.addStretch(), l.addWidget(pb) self.w.la = la = QLabel(_('Checking external links, please wait...')) la.setStyleSheet('QLabel { font-size: 20px; font-weight: bold }') l.addWidget(la, 0, Qt.AlignCenter), l.addStretch() self.l = l = QVBoxLayout(self) self.results = QTextBrowser(self) self.results.setOpenLinks(False) self.results.anchorClicked.connect(self.anchor_clicked) self.stack = s = QStackedWidget(self) s.addWidget(w), s.addWidget(self.results) l.addWidget(s) l.addWidget(self.bb) self.bb.setStandardButtons(self.bb.Close) self.rb = b = self.bb.addButton(_('&Refresh'), self.bb.ActionRole) b.setIcon(QIcon(I('view-refresh.png'))) b.clicked.connect(self.refresh)
def __init__(self, parent=None): super(WebTab, self).__init__(parent) self.current = {'title': "[EMPTY]", 'address': ""} # address bar self.address_bar = AddressBar(parent=self) # webkit (the actual "web engine") self.webkit = WebView(parent=self) # set_prefix: app defined, carries str self.webkit.set_prefix.connect(self.address_bar.set_model) # CFG02 # javascript_state: app defined, carries bool self.webkit.javascript_state.connect(self.address_bar.set_bgcolor) # small label displaying instance ID and pending tab operations info_label = QLabel(parent=self) info_label.setText('?') # CFG02 # webkit_info: app defined, carries str self.webkit.attr.webkit_info.connect(info_label.setText) def update_address(qurl): """ The 'connect' gives a QUrl and setText receives a string; can't just connect setText Required because a 3XX HTTP redirection will change the address, and without updating, the address bar will be left stale AB02 AB03 """ self.current['address'] = qurl.toString() self.address_bar.setText(self.current['address']) # urlChanged carries QUrl; loadStarted carries nothing; # loadFinished carries bool; titleChanged carries str; # loadProgress carries int self.webkit.urlChanged.connect(update_address) self.webkit.loadStarted.connect(self.load_started) self.webkit.loadFinished.connect(self.load_finished) self.webkit.titleChanged.connect(self.save_title) self.webkit.loadProgress.connect(self.load_progress) def fill_notifier(message, request): """ sends a message to be displayed by the notifier """ notify(message + " " + request.url().toString()) # downloadRequested carries QNetworkRequest self.webkit.page().downloadRequested.connect( partial(fill_notifier, "download")) # unsupportedContent carries QNetworkReply self.webkit.page().unsupportedContent.connect( partial(fill_notifier, "unsupported")) # input area for access-key navigation self.nav_bar = NavigateInput(parent=self) # editingFinished carries nothing self.nav_bar.editingFinished.connect(self.webkit.clear_labels) # textEdited carries str self.nav_bar.textEdited.connect(self.webkit.akeynav) # nonvalid_tag (app defined) carries nothing self.webkit.nonvalid_tag.connect(self.nav_bar.clear) # 'corner' message and notification label, not on timer, smaller self.message_label = MessageLabel(self.webkit) def handle_hovered(link, title, content): """ When hovered, if ALT is pressed, show message label; hide otherwise """ if ((QApplication.keyboardModifiers() & Qt.AltModifier) and (link or title or content)): # ugly hack to ensure proper resizing; find a better way? self.message_label.hide() self.message_label.setText(link + " " + title + " " + content) self.message_label.show() else: self.message_label.hide() # linkHovered carries str, str, str self.webkit.page().linkHovered.connect(handle_hovered) def handle_signaled(title): """ We received a string through a signal; display it on the message label """ # if title: self.message_label.hide() self.message_label.setText(title) self.message_label.show() # show_message (app defined) carries str self.webkit.show_message.connect(handle_signaled) # loadStarted carries nothing self.webkit.loadStarted.connect(self.message_label.hide) # At the time navigation is requested load_requested is sent, and the # requested url is set as text in grey at the address bar. Once the # urlChanged signal is received, the actual url is set in black. # load_requested (app defined) carries str self.webkit.load_requested.connect( partial(self.address_bar.set_txt_color, color=QColor(128, 128, 128))) def hide_message_label(*_): """ WARNING scrollRequested carries int, int, QRect; star swallows all """ self.message_label.hide() self.webkit.page().scrollRequested.connect(hide_message_label) # focus_webkit (app defined) carries nothing self.webkit.hide_overlay.connect(self.message_label.hide) self.webkit.focus_webkit.connect(self.address_bar.restore) # progress bar self.pbar = QProgressBar(self) self.pbar.setRange(0, 100) self.pbar.setTextVisible(False) self.pbar.setVisible(False) self.pbar.setMaximumHeight(7) # search in page self.search_frame = SearchFrame(parent=self) # NAV20 # textChanged carries str self.search_frame.search_line.textChanged.connect(self.do_search) # layout grid = QGridLayout(self) grid.setSpacing(0) grid.setVerticalSpacing(0) grid.setContentsMargins(0, 0, 0, 0) grid.setRowStretch(1, 1) grid.addWidget(info_label, 0, 0, 1, 1) grid.addWidget(self.address_bar, 0, 1, 1, 1) grid.addWidget(self.nav_bar, 0, 2, 1, 1) grid.addWidget(self.webkit, 1, 0, 1, 3) grid.addWidget(self.search_frame, 2, 0, 1, 3) grid.addWidget(self.pbar, 3, 0, 1, 3) def show_search(): """ One-time callback for QShortcut NAV20 """ self.search_frame.setVisible(True) self.search_frame.search_line.setFocus() def hide_search(): """ One-time callback for QShortcut NAV20 """ self.search_frame.setVisible(False) self.webkit.findText("") self.webkit.setFocus() def navigate_completion(key=Qt.Key_Down): """ Sends an "arrow press" to the completion popup to navigate results. Not the best way to do this. It would be better to find out what function is being called by that arrow press. AB01 """ event = QKeyEvent(QEvent.KeyPress, key, Qt.NoModifier) self.address_bar.completer().popup().keyPressEvent(event) # the star swallows all arguments that aren't named 'store' def reset_addressbar(*, store=False): """ Restore the address bar to its original address and color (it could have changed because of a hover event). Optionally, store the original address in the clipboard. AB03 """ if self.current['address']: self.address_bar.set_txt_color(self.current['address'], color=QColor(0, 0, 0)) if store: clipboard(self.current['address']) # urlChanged carries QUrl (ignored) self.webkit.urlChanged.connect(reset_addressbar) def enter_address_bar(clear=True): """ do not try entering the address bar if a load is in progress; do an 'stop' first AB00 """ if 'in_page_load' not in self.webkit.attr: if clear: self.address_bar.clear_and_focus() else: self.address_bar.setFocus() def cancel(): """ if we're in the middle of loading the document, stop loading. Otherwise, hide the message label. The general concept is to reach a basic state. """ if 'in_page_load' not in self.webkit.attr: self.message_label.hide() self.webkit.update() else: self.webkit.stop() set_shortcuts([ # search NAV20 ("G", self.webkit, show_search), ("Escape", self.search_frame, hide_search), ("Return", self.search_frame, self.do_search), ("Ctrl+J", self.search_frame, self.do_search), # go to page AB00 ("Ctrl+J", self.address_bar, partial(self.webkit.navigate, self.address_bar)), ("Return", self.address_bar, partial(self.webkit.navigate, self.address_bar)), # address bar interaction ("A", self.webkit, cancel), ("Ctrl+L", self.webkit, enter_address_bar), # AB00 ("Ctrl+Shift+L", self.webkit, partial(enter_address_bar, clear=False)), ("Escape", self.address_bar, self.webkit.setFocus), # AB00 ("Ctrl+I", self.address_bar, navigate_completion), # AB01 ("Ctrl+P", self.address_bar, partial(navigate_completion, Qt.Key_Up)), # in-page element navigation ("Ñ", self, self.enter_nav), # NAV11 (";", self, self.enter_nav), # DOM01 ("Ctrl+Ñ", self, partial(self.enter_nav, target="titles")), # toggle ("Q", self.webkit, self.toggle_script), # TOG01 # clipboard ("E", self, partial(reset_addressbar, store=True)) # CB05 ])
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..." label.setText(progressText) splash.show()
def prince_convert(self): ''' Call the actual Prince command to convert to PDF ''' from os import makedirs from os.path import dirname, join, exists from calibre.ptempfile import PersistentTemporaryFile from calibre.constants import DEBUG from shlex import split as shsplit # All files are relative to the OPF location opf_dir = dirname(self.opf) base_dir = dirname(self.pdf_file) base_dir = join(opf_dir, base_dir) try: makedirs(base_dir) except BaseException: if not exists(base_dir): raise # Create a temporary CSS file with the box contents custom_CSS = PersistentTemporaryFile(mode='w+') custom_CSS.write(unicode(self.css1.toPlainText())) custom_CSS.close() # Create a temporary file with the list of input files file_list = PersistentTemporaryFile(mode='w+') for item in self.oeb.spine: file_list.write(item.href + "\n") file_list.close() # Build the command line command = prefs['prince_exe'] args = ['-v'] if self.prince_file: args.append('-s') args.append(self.prince_file) args.append('-s') args.append(custom_CSS.name) args.append('-l') args.append(file_list.name) args.append('-o') args.append(self.pdf_file) # Additional command-line arguments args.extend(shsplit(self.args.text())) # Hide the convert button and show a busy indicator self.convert.setEnabled(False) self.progress_bar = QProgressBar() self.progress_bar.setRange(0, 0) self.progress_bar.setValue(0) self.l.addWidget(self.progress_bar) # Run the command and return the path to the PDF file if DEBUG: print(_('Converting book...')) process = QProcess(self) process.setWorkingDirectory(opf_dir) process.setProcessChannelMode(QProcess.MergedChannels) process.error.connect(self.error) process.finished.connect(self.end) self.process = process if DEBUG: from subprocess import list2cmdline line = list2cmdline([command] + args) print(_('Command line: %s') % line) process.start(command, args)
def create_gui(self): """ Layout arrangement for the dialog and its input widgets. """ self.layout = QVBoxLayout() self.layout.setSpacing(20) self.setLayout(self.layout) # Create an editable box for user to input Comic Vine API Key. self.api_layout = QHBoxLayout() self.api_msg = QLineEdit(self) self.api_msg.setFixedWidth(350) self.api_msg.setText(prefs["comic_vine_api_key"]) self.api_label = QLabel("Comic Vine API Key") self.api_label.setBuddy(self.api_msg) self.api_layout.addWidget(self.api_label) self.api_layout.addWidget(self.api_msg) # Create an editable box for user to input Tags to add to all books. self.tags_layout = QHBoxLayout() self.tags_msg = QLineEdit(self) self.tags_msg.setText(prefs["tags_to_add"]) self.tags_label = QLabel("Tags To Add") self.tags_label.setBuddy(self.tags_msg) self.tags_layout.addWidget(self.tags_label) self.tags_layout.addWidget(self.tags_msg) # Add the fields to the main layout. self.layout.addLayout(self.api_layout) self.layout.addLayout(self.tags_layout) # Option to keep current tags. self.keep_tags_cb = QCheckBox("Keep existing tags while adding new.", self) self.layout.addWidget(self.keep_tags_cb) # Separate the buttons from the input. self.btn_sep = QFrame() self.btn_sep.setFrameShape(QFrame.HLine) self.btn_sep.setFrameShadow(QFrame.Sunken) self.layout.addWidget(self.btn_sep) # Create a start button to kick off the processing with title. self.title_start = QPushButton("Using Title - Hover For Details", self) self.title_start.setToolTip( "This expects the title of a book to have a " "specific formatted string containing volume " "ID and issue#. e.g." + os.linesep + "Desired " "Title --- v1234 n0124" + os.linesep + "Where " "--- is required and the number after v " "matches Comic Vine's volume ID. The number " "after n is the issue number.") self.title_start.clicked.connect(self.title_process) self.layout.addWidget(self.title_start) # Create a start button to kick off the processing with series. self.series_start = QPushButton("Using Series - Hover For Details", self) self.series_start.setToolTip( "This expects the series name to match the " "Comic Vine volume ID and the series number " "equals issue number.") self.series_start.clicked.connect(self.series_process) self.layout.addWidget(self.series_start) # Create a start button to kick off the processing with CV IDs. self.ids_start = QPushButton("Using IDs - Hover For Details", self) self.ids_start.setToolTip( "This expects two custom columns with lookup " "comicvineissueid and comicvinevolumeid. " "These must match Comic Vine's IDs for the " "issue and the volume.") self.ids_start.clicked.connect(self.ids_process) self.layout.addWidget(self.ids_start) # Separate the progress and results. self.result_sep = QFrame() self.result_sep.setFrameShape(QFrame.HLine) self.result_sep.setFrameShadow(QFrame.Sunken) self.layout.addWidget(self.result_sep) # Create progress bar. self.progress_bar = QProgressBar() self.progress_bar.setRange(0, 100) self.progress_bar.setMinimumWidth(485) self.layout.addWidget(self.progress_bar) # Create results text area. self.result_box = QGroupBox() self.result_box.setTitle("Results") self.result_text = QLabel("Run Comicalibre to see results.") self.result_scroll = QScrollArea() self.result_scroll.setWidget(self.result_text) self.result_scroll.setWidgetResizable(True) self.result_layout = QVBoxLayout() self.result_layout.addWidget(self.result_scroll) self.result_box.setLayout(self.result_layout) self.layout.addWidget(self.result_box) self.setWindowTitle("Comicalibre") self.setWindowIcon(self.icon) self.resize(self.sizeHint())