예제 #1
0
def test(scale=0.25):
    from qt.core import QLabel, QPixmap, QMainWindow, QWidget, QScrollArea, QGridLayout
    from calibre.gui2 import Application
    app = Application([])
    mi = Metadata('Unknown', ['Kovid Goyal', 'John & Doe', 'Author'])
    mi.series = 'A series & styles'
    m = QMainWindow()
    sa = QScrollArea(m)
    w = QWidget(m)
    sa.setWidget(w)
    l = QGridLayout(w)
    w.setLayout(l), l.setSpacing(30)
    scale *= w.devicePixelRatioF()
    labels = []
    for r, color in enumerate(sorted(default_color_themes)):
        for c, style in enumerate(sorted(all_styles())):
            mi.series_index = c + 1
            mi.title = 'An algorithmic cover [%s]' % color
            prefs = override_prefs(cprefs, override_color_theme=color, override_style=style)
            scale_cover(prefs, scale)
            img = generate_cover(mi, prefs=prefs, as_qimage=True)
            img.setDevicePixelRatio(w.devicePixelRatioF())
            la = QLabel()
            la.setPixmap(QPixmap.fromImage(img))
            l.addWidget(la, r, c)
            labels.append(la)
    m.setCentralWidget(sa)
    w.resize(w.sizeHint())
    m.show()
    app.exec()
예제 #2
0
def test():
    from qt.core import QMainWindow
    app = QApplication([])
    w = QMainWindow()
    cf = CoverFlow()
    w.resize(cf.size()+QSize(30, 20))
    model = DummyImageList()
    cf.setImages(model)
    cf.setCurrentSlide(39000)
    w.setCentralWidget(cf)

    w.show()
    cf.setFocus(Qt.FocusReason.OtherFocusReason)
    sys.exit(app.exec())
예제 #3
0
def main():
    app = Application([])
    w = QMainWindow()
    sb = w.statusBar()
    la = QLabel(sb)
    sb.addPermanentWidget(la)
    tts = TTSWidget(w)
    tts.show_message.connect(sb.showMessage)
    tts.show_status.connect(la.setText)
    w.setCentralWidget(tts)
    w.show()
    app.exec()
    tts.dispatch_on_main_thread_signal.disconnect()
    tts.mark_changed.disconnect()
    tts.tts.shutdown()
예제 #4
0
        else:
            self._last_reload_at = monotonic()
            self.render_process_restarted.emit()
            prints('Restarting Qt WebEngine')


if __name__ == '__main__':
    from calibre.gui2 import Application
    from calibre.gui2.tweak_book.preview import WebPage
    from qt.core import QMainWindow
    app = Application([])
    view = QWebEngineView()
    page = WebPage(view)
    view.setPage(page)
    w = QMainWindow()
    w.setCentralWidget(view)

    class Test(Bridge):
        s1 = from_js(object)
        j1 = to_js()
    t = Test(view.page())
    t.s1.connect(print)
    w.show()
    view.setHtml('''
<p>hello</p>
    ''')
    app.exec()
    del t
    del page
    del app
예제 #5
0
    w.resize(cf.size()+QSize(30, 20))
    model = DummyImageList()
    cf.setImages(model)
    cf.setCurrentSlide(39000)
    w.setCentralWidget(cf)

    w.show()
    cf.setFocus(Qt.FocusReason.OtherFocusReason)
    sys.exit(app.exec())


def main(args=sys.argv):
    return 0


if __name__ == '__main__':
    from qt.core import QMainWindow
    app = QApplication([])
    w = QMainWindow()
    cf = CoverFlow()
    w.resize(cf.size()+QSize(30, 20))
    path = sys.argv[1]
    model = FileSystemImages(sys.argv[1])
    cf.currentChanged[int].connect(model.currentChanged)
    cf.setImages(model)
    w.setCentralWidget(cf)

    w.show()
    cf.setFocus(Qt.FocusReason.OtherFocusReason)
    sys.exit(app.exec())