def __init__(self, parent, icon, prefs, html=None, page=None, title=""): self.prefs = prefs # QDialog.__init__(self, parent=parent) super(HelpView, self).__init__(parent, "help_dialog") self.setWindowTitle(title) self.setWindowIcon(icon) self.l = QVBoxLayout(self) self.setLayout(self.l) self.wv = QWebView() if html is not None: self.wv.setHtml(html) elif page is not None: self.wv.load(QUrl(page)) self.wv.setMinimumHeight(100) self.wv.setMaximumHeight(16777215) self.wv.setMinimumWidth(400) self.wv.setMaximumWidth(16777215) self.wv.setGeometry(0, 0, 400, 100) self.wv.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.l.addWidget(self.wv) # Sizing sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth()) self.setSizePolicy(sizePolicy) self.resize_dialog()
def _populate_subjects(self): ''' ''' # Setting size policy allows us to match Subjects fields height sp = QSizePolicy() sp.setHorizontalStretch(True) sp.setVerticalStretch(False) sp.setHeightForWidth(False) self.calibre_subjects.setSizePolicy(sp) self.marvin_subjects.setSizePolicy(sp) if 'tags' in self.mismatches: cs = "<b>Subjects:</b> {0}".format(', '.join(self.mismatches['tags']['calibre'])) self.calibre_subjects.setText(self.YELLOW_BG.format(cs)) ms = "<b>Subjects:</b> {0}".format(', '.join(self.mismatches['tags']['Marvin'])) self.marvin_subjects.setText(self.YELLOW_BG.format(ms)) calibre_height = self.calibre_subjects.sizeHint().height() marvin_height = self.marvin_subjects.sizeHint().height() if calibre_height > marvin_height: self.marvin_subjects.setMinimumHeight(calibre_height) self.marvin_subjects.setMaximumHeight(calibre_height) elif marvin_height > calibre_height: self.calibre_subjects.setMinimumHeight(marvin_height) self.calibre_subjects.setMaximumHeight(marvin_height) else: #self._log(repr(self.installed_book.tags)) cs = "<b>Subjects:</b> {0}".format(', '.join(self.installed_book.tags)) #self._log("cs: %s" % repr(cs)) self.calibre_subjects.setText(cs) self.marvin_subjects.setText(cs)
def __init__(self, parent, icon, prefs, html=None, page=None, title=''): self.prefs = prefs #QDialog.__init__(self, parent=parent) super(HelpView, self).__init__(parent, 'help_dialog') self.setWindowTitle(title) self.setWindowIcon(icon) self.l = QVBoxLayout(self) self.setLayout(self.l) self.wv = QWebView() if html is not None: self.wv.setHtml(html) elif page is not None: self.wv.load(QUrl(page)) self.wv.setMinimumHeight(100) self.wv.setMaximumHeight(16777215) self.wv.setMinimumWidth(400) self.wv.setMaximumWidth(16777215) self.wv.setGeometry(0, 0, 400, 100) self.wv.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.l.addWidget(self.wv) # Sizing sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth()) self.setSizePolicy(sizePolicy) self.resize_dialog()
def _populate_subjects(self): ''' ''' # Setting size policy allows us to match Subjects fields height sp = QSizePolicy() sp.setHorizontalStretch(True) sp.setVerticalStretch(False) sp.setHeightForWidth(False) self.calibre_subjects.setSizePolicy(sp) self.marvin_subjects.setSizePolicy(sp) if 'tags' in self.mismatches: cs = "<b>Subjects:</b> {0}".format(', '.join( self.mismatches['tags']['calibre'])) self.calibre_subjects.setText(self.YELLOW_BG.format(cs)) ms = "<b>Subjects:</b> {0}".format(', '.join( self.mismatches['tags']['Marvin'])) self.marvin_subjects.setText(self.YELLOW_BG.format(ms)) calibre_height = self.calibre_subjects.sizeHint().height() marvin_height = self.marvin_subjects.sizeHint().height() if calibre_height > marvin_height: self.marvin_subjects.setMinimumHeight(calibre_height) self.marvin_subjects.setMaximumHeight(calibre_height) elif marvin_height > calibre_height: self.calibre_subjects.setMinimumHeight(marvin_height) self.calibre_subjects.setMaximumHeight(marvin_height) else: #self._log(repr(self.installed_book.tags)) cs = "<b>Subjects:</b> {0}".format(', '.join( self.installed_book.tags)) #self._log("cs: %s" % repr(cs)) self.calibre_subjects.setText(cs) self.marvin_subjects.setText(cs)
def __init__(self, gui, msg, size=100, window_title='Marvin XD', show_cancel=False, on_top=False): flags = Qt.FramelessWindowHint if on_top: flags = Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint QDialog.__init__(self, gui, flags) self._layout = QVBoxLayout() self.setLayout(self._layout) self.cancel_status = 0 self.is_running = False # Add the spinner self.pi = ProgressIndicator(self) self.pi.setDisplaySize(size) self._layout.addSpacing(15) self._layout.addWidget(self.pi, 0, Qt.AlignHCenter) self._layout.addSpacing(15) # Fiddle with the message self.msg = QLabel(msg) #self.msg.setWordWrap(True) self.font = QFont() self.font.setPointSize(self.font.pointSize() + 2) self.msg.setFont(self.font) self._layout.addWidget(self.msg, 0, Qt.AlignHCenter) sp = QSizePolicy() sp.setHorizontalStretch(True) sp.setVerticalStretch(False) sp.setHeightForWidth(False) self.msg.setSizePolicy(sp) self.msg.setMinimumHeight(self.font.pointSize() + 8) self._layout.addSpacing(15) if show_cancel: self.bb = QDialogButtonBox() self.cancel_button = QPushButton(QIcon(I('window-close.png')), 'Cancel') self.bb.addButton(self.cancel_button, self.bb.RejectRole) self.bb.clicked.connect(self.button_handler) self._layout.addWidget(self.bb) self.setWindowTitle(window_title) self.resize(self.sizeHint())
def setupMachinesGUI(self): # sorted by value, i.e., ip for name, ip in sorted(self.machines.items(), key=ip_keys): name64 = b64encode(name) l = QLabel(self.ui.dockWidgetState) l.setObjectName('state_' + name64) sp = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sp.setHorizontalStretch(0) sp.setVerticalStretch(0) sp.setHeightForWidth(l.sizePolicy().hasHeightForWidth()) l.setSizePolicy(sp) l.setPixmap(QPixmap(':/icons/img/icons/25-Red1.png')) l.setScaledContents(True) self.stateLabels[name] = l self.ui.formLayoutState.addRow(ip + ', ' + name + ':', l) self.ping.add(name, ip)
def __init__(self, gui, msg, size=100, window_title="Marvin XD", show_cancel=False, on_top=False): flags = Qt.FramelessWindowHint if on_top: flags = Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint QDialog.__init__(self, gui, flags) self._layout = QVBoxLayout() self.setLayout(self._layout) self.cancel_status = 0 self.is_running = False # Add the spinner self.pi = ProgressIndicator(self) self.pi.setDisplaySize(size) self._layout.addSpacing(15) self._layout.addWidget(self.pi, 0, Qt.AlignHCenter) self._layout.addSpacing(15) # Fiddle with the message self.msg = QLabel(msg) # self.msg.setWordWrap(True) self.font = QFont() self.font.setPointSize(self.font.pointSize() + 2) self.msg.setFont(self.font) self._layout.addWidget(self.msg, 0, Qt.AlignHCenter) sp = QSizePolicy() sp.setHorizontalStretch(True) sp.setVerticalStretch(False) sp.setHeightForWidth(False) self.msg.setSizePolicy(sp) self.msg.setMinimumHeight(self.font.pointSize() + 8) self._layout.addSpacing(15) if show_cancel: self.bb = QDialogButtonBox() self.cancel_button = QPushButton(QIcon(I("window-close.png")), "Cancel") self.bb.addButton(self.cancel_button, self.bb.RejectRole) self.bb.clicked.connect(self.button_handler) self._layout.addWidget(self.bb) self.setWindowTitle(window_title) self.resize(self.sizeHint())