예제 #1
0
    def update_cache(self, parent=None, timeout=10, force=False,
            suppress_progress=False):
        if self.lock.acquire(False):
            try:
                update_thread = CacheUpdateThread(self.config, self.seralize_books, timeout)
                if not suppress_progress:
                    progress = CacheProgressDialog(parent)
                    progress.set_message(_('Updating MobileRead book cache...'))

                    update_thread.total_changed.connect(progress.set_total)
                    update_thread.update_progress.connect(progress.set_progress)
                    update_thread.update_details.connect(progress.set_details)
                    progress.rejected.connect(update_thread.abort)

                    progress.open()
                    update_thread.start()
                    while update_thread.is_alive() and not progress.canceled:
                        QCoreApplication.processEvents()

                    if progress.isVisible():
                        progress.accept()
                    return not progress.canceled
                else:
                    update_thread.start()
            finally:
                self.lock.release()
예제 #2
0
    def update_cache(self,
                     parent=None,
                     timeout=10,
                     force=False,
                     suppress_progress=False):
        if self.lock.acquire(False):
            try:
                update_thread = CacheUpdateThread(self.cache,
                                                  self.seralize_books, timeout)
                if not suppress_progress:
                    progress = CacheProgressDialog(parent)
                    progress.set_message(
                        _('Updating MobileRead book cache...'))

                    update_thread.total_changed.connect(progress.set_total)
                    update_thread.update_progress.connect(
                        progress.set_progress)
                    update_thread.update_details.connect(progress.set_details)
                    progress.rejected.connect(update_thread.abort)

                    progress.open()
                    update_thread.start()
                    while update_thread.is_alive() and not progress.canceled:
                        QCoreApplication.processEvents()

                    if progress.isVisible():
                        progress.accept()
                    return not progress.canceled
                else:
                    update_thread.start()
            finally:
                self.lock.release()
예제 #3
0
    def emit(self, record):
        """Try to log the message to QGIS if available, otherwise do nothing.

        Args:
            record (): logging record containing whatever info needs to be logged.

        Returns:

        """
        # ToDo:Add the warning/info messages to the form messagebar look at QGIS-master\python\utils.py\showException
        # ??https://gis.stackexchange.com/questions/152730/how-to-add-a-message-bar-to-custom-canvas
        # https://gis.stackexchange.com/questions/135711/why-is-the-display-of-qgsmessagebar-delayed
        # https://gis.stackexchange.com/a/216444
        # Check logging.LogRecord properties for lots of other goodies like line number etc. you can get
        # from the log message.
        try:
            if QgsMessageBar is None:
                return

            if self.lastRec is None or self.lastRec.getMessage(
            ) != record.getMessage():
                QgsMessageLog.logMessage(record.getMessage(), PLUGIN_SHORT,
                                         LOG_MAP[record.levelname]['qgis'])
                self.lastRec = record
            QCoreApplication.processEvents()

        except MemoryError:
            message = 'Due to memory limitations on this machine, PrecisionAg can not handle the full log'
            print(message)
            QgsMessageLog.logMessage(message, PLUGIN_SHORT, 0)
        except IOError:
            pass
        except AttributeError:
            pass
예제 #4
0
 def message(self, msg, ms=2000, sub=False):
     if sub:
         if self._prev_msg:
             msg = ": ".join((self._prev_msg, msg))
     else:
         self._prev_msg = msg
     self.statusBar().showMessage(msg, ms)
     QCoreApplication.processEvents(QEventLoop.ExcludeUserInputEvents)
예제 #5
0
 def message(self, msg, ms=2000, sub=False):
     if sub:
         if self._prev_msg:
             msg = ": ".join((self._prev_msg, msg))
     else:
         self._prev_msg = msg
     self.statusBar().showMessage(msg, ms)
     QCoreApplication.processEvents(QEventLoop.ExcludeUserInputEvents)
예제 #6
0
    def check_library(self):
        from calibre.gui2.dialogs.check_library import CheckLibraryDialog, DBCheck, DBCheckNew

        self.gui.library_view.save_state()
        m = self.gui.library_view.model()
        m.stop_metadata_backup()
        db = m.db
        db.prefs.disable_setting = True

        if hasattr(db, "new_api"):
            d = DBCheckNew(self.gui, db)
        else:
            d = DBCheck(self.gui, db)
        d.start()
        try:
            d.conn.close()
        except:
            pass
        d.break_cycles()
        self.gui.library_moved(db.library_path, call_close=not d.closed_orig_conn)
        if d.rejected:
            return
        if d.error is None:
            if not question_dialog(
                self.gui,
                _("Success"),
                _(
                    "Found no errors in your calibre library database."
                    " Do you want calibre to check if the files in your "
                    " library match the information in the database?"
                ),
            ):
                return
        else:
            return error_dialog(
                self.gui,
                _("Failed"),
                _("Database integrity check failed, click Show details" " for details."),
                show=True,
                det_msg=d.error[1],
            )

        self.gui.status_bar.show_message(_("Starting library scan, this may take a while"))
        try:
            QCoreApplication.processEvents()
            d = CheckLibraryDialog(self.gui, m.db)

            if not d.do_exec():
                info_dialog(
                    self.gui,
                    _("No problems found"),
                    _("The files in your library match the information " "in the database."),
                    show=True,
                )
        finally:
            self.gui.status_bar.clear_message()
예제 #7
0
    def check_library(self):
        from calibre.gui2.dialogs.check_library import CheckLibraryDialog, DBCheck, DBCheckNew
        self.gui.library_view.save_state()
        m = self.gui.library_view.model()
        m.stop_metadata_backup()
        db = m.db
        db.prefs.disable_setting = True

        if hasattr(db, 'new_api'):
            d = DBCheckNew(self.gui, db)
        else:
            d = DBCheck(self.gui, db)
        d.start()
        try:
            d.conn.close()
        except:
            pass
        d.break_cycles()
        self.gui.library_moved(db.library_path,
                               call_close=not d.closed_orig_conn)
        if d.rejected:
            return
        if d.error is None:
            if not question_dialog(
                    self.gui, _('Success'),
                    _('Found no errors in your calibre library database.'
                      ' Do you want calibre to check if the files in your '
                      ' library match the information in the database?')):
                return
        else:
            return error_dialog(
                self.gui,
                _('Failed'),
                _('Database integrity check failed, click Show details'
                  ' for details.'),
                show=True,
                det_msg=d.error[1])

        self.gui.status_bar.show_message(
            _('Starting library scan, this may take a while'))
        try:
            QCoreApplication.processEvents()
            d = CheckLibraryDialog(self.gui, m.db)

            if not d.do_exec():
                info_dialog(
                    self.gui,
                    _('No problems found'),
                    _('The files in your library match the information '
                      'in the database.'),
                    show=True)
        finally:
            self.gui.status_bar.clear_message()
예제 #8
0
def openLogPanel():
    logMessagesPanel = iface.mainWindow().findChild(QDockWidget, 'MessageLog')

    # Check to see if it is already open
    if not logMessagesPanel.isVisible():
        logMessagesPanel.setVisible(True)

    # find and set the active tab
    tabWidget = logMessagesPanel.findChildren(QTabWidget)[0]
    for iTab in range(0, tabWidget.count()):
        if tabWidget.tabText(iTab) == PLUGIN_SHORT:
            tabWidget.setCurrentIndex(iTab)
            break

    QCoreApplication.processEvents()
예제 #9
0
파일: book_info.py 프로젝트: Eksmo/calibre
    def __init__(self, parent, view, row, link_delegate):
        QDialog.__init__(self, parent)
        Ui_BookInfo.__init__(self)
        self.setupUi(self)
        self.gui = parent
        self.cover_pixmap = None
        self.details.sizeHint = self.details_size_hint
        self.details.page().setLinkDelegationPolicy(self.details.page().DelegateAllLinks)
        self.details.linkClicked.connect(self.link_clicked)
        self.css = P('templates/book_details.css', data=True).decode('utf-8')
        self.link_delegate = link_delegate
        self.details.setAttribute(Qt.WA_OpaquePaintEvent, False)
        palette = self.details.palette()
        self.details.setAcceptDrops(False)
        palette.setBrush(QPalette.Base, Qt.transparent)
        self.details.page().setPalette(palette)


        self.view = view
        self.current_row = None
        self.fit_cover.setChecked(dynamic.get('book_info_dialog_fit_cover',
            True))
        self.refresh(row)
        self.connect(self.view.selectionModel(), SIGNAL('currentChanged(QModelIndex,QModelIndex)'), self.slave)
        self.connect(self.next_button, SIGNAL('clicked()'), self.next)
        self.connect(self.previous_button, SIGNAL('clicked()'), self.previous)
        self.fit_cover.stateChanged.connect(self.toggle_cover_fit)
        self.cover.resizeEvent = self.cover_view_resized
        self.cover.cover_changed.connect(self.cover_changed)

        desktop = QCoreApplication.instance().desktop()
        screen_height = desktop.availableGeometry().height() - 100
        self.resize(self.size().width(), screen_height)
예제 #10
0
파일: main.py 프로젝트: Eksmo/calibre
def init_qt(args):
    from calibre.gui2.ui import Main
    parser = option_parser()
    opts, args = parser.parse_args(args)
    if opts.with_library is not None:
        if not os.path.exists(opts.with_library):
            os.makedirs(opts.with_library)
        if os.path.isdir(opts.with_library):
            prefs.set('library_path', os.path.abspath(opts.with_library))
            prints('Using library at', prefs['library_path'])
    QCoreApplication.setOrganizationName(ORG_NAME)
    QCoreApplication.setApplicationName(APP_UID)
    override = 'calibre-gui' if islinux else None
    app = Application(args, override_program_name=override)
    actions = tuple(Main.create_application_menubar())
    app.setWindowIcon(QIcon(I('lt.png')))
    return app, opts, args, actions
예제 #11
0
파일: main.py 프로젝트: IsaacVilela/calibre
def init_qt(args):
    parser = option_parser()
    opts, args = parser.parse_args(args)
    find_portable_library()
    if opts.with_library is not None:
        libpath = os.path.expanduser(opts.with_library)
        if not os.path.exists(libpath):
            os.makedirs(libpath)
        if os.path.isdir(libpath):
            prefs.set('library_path', os.path.abspath(libpath))
            prints('Using library at', prefs['library_path'])
    QCoreApplication.setOrganizationName(ORG_NAME)
    QCoreApplication.setApplicationName(APP_UID)
    override = 'calibre-gui' if islinux else None
    app = Application(args, override_program_name=override)
    app.file_event_hook = EventAccumulator()
    app.setWindowIcon(QIcon(I('lt.png')))
    return app, opts, args
예제 #12
0
def init_qt(args):
    parser = option_parser()
    opts, args = parser.parse_args(args)
    find_portable_library()
    if opts.with_library is not None:
        libpath = os.path.expanduser(opts.with_library)
        if not os.path.exists(libpath):
            os.makedirs(libpath)
        if os.path.isdir(libpath):
            prefs.set('library_path', os.path.abspath(libpath))
            prints('Using library at', prefs['library_path'])
    QCoreApplication.setOrganizationName(ORG_NAME)
    QCoreApplication.setApplicationName(APP_UID)
    override = 'calibre-gui' if islinux else None
    app = Application(args, override_program_name=override)
    app.file_event_hook = EventAccumulator()
    app.setWindowIcon(QIcon(I('lt.png')))
    return app, opts, args
예제 #13
0
 def __init__(self, *args, **kwargs):
     QDialog.__init__(self, *args)
     self.setupUi(self)
     desktop = QCoreApplication.instance().desktop()
     geom = desktop.availableGeometry(self)
     nh, nw = geom.height() - 25, geom.width() - 10
     if nh < 0:
         nh = max(800, self.height())
     if nw < 0:
         nw = max(600, self.height())
     nh = min(self.height(), nh)
     nw = min(self.width(), nw)
     self.resize(nw, nh)
예제 #14
0
 def __init__(self, *args, **kwargs):
     QDialog.__init__(self, *args)
     self.setupUi(self)
     desktop = QCoreApplication.instance().desktop()
     geom = desktop.availableGeometry(self)
     nh, nw = geom.height()-25, geom.width()-10
     if nh < 0:
         nh = max(800, self.height())
     if nw < 0:
         nw = max(600, self.height())
     nh = min(self.height(), nh)
     nw = min(self.width(), nw)
     self.resize(nw, nh)
예제 #15
0
    def config_widget(cls):
        from PyQt4.Qt import QCoreApplication
        from PyQt4.Qt import QScrollArea

        cw = super(KOBOTOUCHEXTENDED, cls).config_widget()
        qsa = QScrollArea()
        qsa.setWidgetResizable(True)
        qsa.setWidget(cw)
        qsa.validate = cw.validate
        desktop_geom = QCoreApplication.instance().desktop().availableGeometry()
        if desktop_geom.height() < 800:
            qsa.setBaseSize(qsa.size().width(), desktop_geom.height() - 100)
        return qsa
예제 #16
0
파일: main.py 프로젝트: warunanc/hotspotter
def initQtApp():
    # Attach to QtConsole's QApplication if able
    from PyQt4.Qt import QCoreApplication, QApplication
    app = QCoreApplication.instance()
    isRootApp = app is None
    if isRootApp:  # if not in qtconsole
        # configure matplotlib
        import matplotlib
        print('Configuring matplotlib for Qt4')
        matplotlib.use('Qt4Agg')
        # Run new root application
        print('Starting new QApplication')
        app = QApplication(sys.argv)
    else:
        print('Running using parent QApplication')
    return app, isRootApp
예제 #17
0
    def __init__(self, parent, view, row, link_delegate):
        QDialog.__init__(self, parent)
        Ui_BookInfo.__init__(self)
        self.setupUi(self)
        self.gui = parent
        self.cover_pixmap = None
        self.details.sizeHint = self.details_size_hint
        self.details.page().setLinkDelegationPolicy(self.details.page().DelegateAllLinks)
        self.details.linkClicked.connect(self.link_clicked)
        self.css = P('templates/book_details.css', data=True).decode('utf-8')
        self.link_delegate = link_delegate
        self.details.setAttribute(Qt.WA_OpaquePaintEvent, False)
        palette = self.details.palette()
        self.details.setAcceptDrops(False)
        palette.setBrush(QPalette.Base, Qt.transparent)
        self.details.page().setPalette(palette)


        self.view = view
        self.current_row = None
        self.fit_cover.setChecked(dynamic.get('book_info_dialog_fit_cover',
            True))
        self.refresh(row)
        self.connect(self.view.selectionModel(), SIGNAL('currentChanged(QModelIndex,QModelIndex)'), self.slave)
        self.connect(self.next_button, SIGNAL('clicked()'), self.next)
        self.connect(self.previous_button, SIGNAL('clicked()'), self.previous)
        self.fit_cover.stateChanged.connect(self.toggle_cover_fit)
        self.cover.resizeEvent = self.cover_view_resized
        self.cover.cover_changed.connect(self.cover_changed)
        self.ns = QShortcut(QKeySequence('Alt+Right'), self)
        self.ns.activated.connect(self.next)
        self.ps = QShortcut(QKeySequence('Alt+Left'), self)
        self.ps.activated.connect(self.previous)
        self.next_button.setToolTip(_('Next [%s]')%
                unicode(self.ns.key().toString(QKeySequence.NativeText)))
        self.previous_button.setToolTip(_('Previous [%s]')%
                unicode(self.ps.key().toString(QKeySequence.NativeText)))

        desktop = QCoreApplication.instance().desktop()
        screen_height = desktop.availableGeometry().height() - 100
        self.resize(self.size().width(), screen_height)
예제 #18
0
파일: SimplePlot.py 프로젝트: PyQwt/PyQwt3D
    def __init__(self, *args):
        SurfacePlot.__init__(self, *args)
        # fonts
        family = QCoreApplication.instance().font().family()
        if 'Verdana' in QFontDatabase().families():
            family = 'Verdana'
        family = 'Courier'
            
        self.coordinates().setLabelFont(family, 14)
        self.coordinates().setNumberFont(family, 12)
            
        self.setTitle('A Simple SurfacePlot Demonstration');
        self.setTitleFont(family, 16, QFont.Bold)
        self.setBackgroundColor(RGBA(1.0, 1.0, 0.6))

        rosenbrock = Rosenbrock(self)

        rosenbrock.setMesh(41, 31)
        rosenbrock.setDomain(-1.73, 1.5, -1.5, 1.5)
        rosenbrock.setMinZ(-10)
        
        rosenbrock.create()

        self.setRotation(30, 0, 15)
        self.setScale(1, 1, 1)
        self.setShift(0.15, 0, 0)
        self.setZoom(0.9)

        axes = self.coordinates().axes # alias
        for axis in axes:
            axis.setMajors(7)
            axis.setMinors(4)
            
        axes[X1].setLabelString('x-axis')
        axes[Y1].setLabelString('y-axis')
        axes[Z1].setLabelString('z-axis')

        self.setCoordinateStyle(BOX);

        self.updateData();
        self.updateGL();
예제 #19
0
파일: AutoSwitch.py 프로젝트: PyQwt/PyQwt3D
    def __init__(self, parent, updateinterval):
        SurfacePlot.__init__(self, parent)
        # fonts
        family = QCoreApplication.instance().font().family()
        if 'Verdana' in QFontDatabase().families():
            family = 'Verdana'
        family = 'Courier'

        self.setTitleFont(family, 16, QFont.Bold)
            
        self.setRotation(30, 0, 15)
        self.setShift(0.1, 0, 0)
        self.setZoom(0.8)

        self.coordinates().setNumberFont(family, 8)
        
        axes = self.coordinates().axes # alias
        for axis in axes:
            axis.setMajors(7)
            axis.setMinors(4)

        axes[X1].setLabelString("x")
        axes[Y1].setLabelString("y")
        axes[Z1].setLabelString("z")
        axes[X2].setLabelString("x")
        axes[Y2].setLabelString("y")
        axes[Z2].setLabelString("z")
        axes[X3].setLabelString("x")
        axes[Y3].setLabelString("y")
        axes[Z3].setLabelString("z")
        axes[X4].setLabelString("x")
        axes[Y4].setLabelString("y")
        axes[Z4].setLabelString("z")

        timer = QTimer(self)
        self.connect(timer, SIGNAL('timeout()'), self.rotate)
        timer.start(updateinterval)
예제 #20
0
    def __init__(self, parent, view, row, link_delegate):
        QDialog.__init__(self, parent)
        self.normal_brush = QBrush(Qt.white)
        self.marked_brush = QBrush(Qt.lightGray)
        self.marked = None
        self.gui = parent
        self.splitter = QSplitter(self)
        self._l = l = QVBoxLayout(self)
        self.setLayout(l)
        l.addWidget(self.splitter)

        self.cover = CoverView(self)
        self.cover.resizeEvent = self.cover_view_resized
        self.cover.cover_changed.connect(self.cover_changed)
        self.cover_pixmap = None
        self.cover.sizeHint = self.details_size_hint
        self.splitter.addWidget(self.cover)

        self.details = QWebView(self)
        self.details.sizeHint = self.details_size_hint
        self.details.page().setLinkDelegationPolicy(
            self.details.page().DelegateAllLinks)
        self.details.linkClicked.connect(self.link_clicked)
        self.css = css()
        self.link_delegate = link_delegate
        self.details.setAttribute(Qt.WA_OpaquePaintEvent, False)
        palette = self.details.palette()
        self.details.setAcceptDrops(False)
        palette.setBrush(QPalette.Base, Qt.transparent)
        self.details.page().setPalette(palette)

        self.c = QWidget(self)
        self.c.l = l2 = QGridLayout(self.c)
        self.c.setLayout(l2)
        l2.addWidget(self.details, 0, 0, 1, -1)
        self.splitter.addWidget(self.c)

        self.fit_cover = QCheckBox(_('Fit &cover within view'), self)
        self.fit_cover.setChecked(
            gprefs.get('book_info_dialog_fit_cover', True))
        l2.addWidget(self.fit_cover, l2.rowCount(), 0, 1, -1)
        self.previous_button = QPushButton(QIcon(I('previous.png')),
                                           _('&Previous'), self)
        self.previous_button.clicked.connect(self.previous)
        l2.addWidget(self.previous_button, l2.rowCount(), 0)
        self.next_button = QPushButton(QIcon(I('next.png')), _('&Next'), self)
        self.next_button.clicked.connect(self.next)
        l2.addWidget(self.next_button, l2.rowCount() - 1, 1)

        self.view = view
        self.current_row = None
        self.refresh(row)
        self.view.selectionModel().currentChanged.connect(self.slave)
        self.fit_cover.stateChanged.connect(self.toggle_cover_fit)
        self.ns = QShortcut(QKeySequence('Alt+Right'), self)
        self.ns.activated.connect(self.next)
        self.ps = QShortcut(QKeySequence('Alt+Left'), self)
        self.ps.activated.connect(self.previous)
        self.next_button.setToolTip(
            _('Next [%s]') %
            unicode(self.ns.key().toString(QKeySequence.NativeText)))
        self.previous_button.setToolTip(
            _('Previous [%s]') %
            unicode(self.ps.key().toString(QKeySequence.NativeText)))

        geom = QCoreApplication.instance().desktop().availableGeometry(self)
        screen_height = geom.height() - 100
        screen_width = geom.width() - 100
        self.resize(max(int(screen_width / 2), 700), screen_height)
        saved_layout = gprefs.get('book_info_dialog_layout', None)
        if saved_layout is not None:
            try:
                self.restoreGeometry(saved_layout[0])
                self.splitter.restoreState(saved_layout[1])
            except Exception:
                pass
예제 #21
0
    def updateGraph(self):
        #         try:
        #             self.graph.clear()
        #             print 'yes'
        #         except AttributeError:
        #             print "error"
        #         else:
        #             pass
        #         QtGui.QWidget.__init__(self)
        #         self.canvas = MplCanvas()
        #         #We instantiate the Matplotlib canvas object.
        #         self.vbl = QtGui.QVBoxLayout()
        #         #Here, we create a layout manager (in this case a vertical box).
        #         self.vbl.addWidget(self.canvas)
        #         # We add the Matplotlib canvas to the layout manager.
        #         self.graph.setLayout(self.vbl)
        #         # a figure instance to plot on
        self.figure = plt.figure()
        # this is the Canvas Widget that displays the `figure`
        # it takes the `figure` instance as a parameter to __init__
        self.canvas = FigureCanvas(self.figure)

        #         self.canvas.clf()
        # this is the Navigation widget
        # it takes the Canvas widget and a parent
        self.toolbar = NavigationToolbar(self.canvas, self)

        #         self.layout.reLayout()
        if self.hasLayOUT == True:
            self.clearLayout()
        if self.hasLayOUT == False:
            self.layout = QtGui.QVBoxLayout()
        self.hasLayOUT = True
        self.layout.addWidget(self.toolbar)
        self.layout.addWidget(self.canvas)
        #         self.graph.layout().deleteLater()
        self.graph.setLayout(self.layout)
        self.ControlButton.setVisible(False)
        pos = {}
        for nm, ob in self.provisionals.iteritems():
            x = ob.x
            y = ob.y
            pos[nm] = (x, y)
        for nm, ob in self.control.iteritems():
            x = ob.x
            y = ob.y
            pos[nm] = (x, y)
        nx.draw_networkx_nodes(self.N,
                               pos,
                               node_color='y',
                               node_size=800,
                               alpha=1)
        nx.draw_networkx_nodes(self.N,
                               pos,
                               nodelist=self.control,
                               node_color='r',
                               node_size=800,
                               alpha=1)

        #         ellipse = mpl.patches.Ellipse(xy=(58305,49663), width=1000, height=1000)
        #         fig,ax = plt.subplots()
        # #         self.figure.add_artist(ellipse)
        #         nx.draw_networkx_nodes(ellipse, xy=(self.control['SUR09'].x,self.control['SUR09'].y))
        edges = {}
        for v, u, d in self.N.edges(data=True):
            if d.has_key("distance") and d.has_key('direction'):
                edges[v, u] = 'b'
#         fig = figure()
#         ax = fig.add_subplot(111, aspect='equal')
#         e=(Ellipse((self.control['SUR09'].x,self.control['SUR09'].y), width=100, height=5, angle=45))
#         ax.add_artist(e)
#         plt.plot(self.control['SUR09'].x,self.control['SUR09'].y,'g.', markersize=100.0)                  #([e], [e], 'g.', markersize=20.0)

        nx.draw(self.N, pos)
        nx.draw_networkx_edges(self.N,
                               pos,
                               edgelist=edges,
                               width=8,
                               alpha=0.5,
                               edge_color='b')
        #         nx.draw(Ellipse((self.control['SUR09'].x,self.control['SUR09'].y), width=100, height=5, angle=45,edgecolor=('green')))

        plt.axis('scaled')
        #         nx.set_aspect('auto')

        #         forceAspect(nx,aspect=1)
        #         plt.show()
        #         nx.draw(ellipse)
        #         nx.add_artist(ellipse)
        #     matplotlib.pyplot.ion()
        #     plt.draw()
        #         self.canvas.addAction(ellipse)
        QCoreApplication.processEvents()
        self.canvas.draw()
예제 #22
0
 def initialization_failed(self):
     print 'Catastrophic failure initializing GUI, bailing out...'
     QCoreApplication.exit(1)
     raise SystemExit(1)
예제 #23
0
파일: main.py 프로젝트: Pipeliner/calibre
 def initialization_failed(self):
     print 'Catastrophic failure initializing GUI, bailing out...'
     QCoreApplication.exit(1)
     raise SystemExit(1)
예제 #24
0
파일: jobs.py 프로젝트: 089git/calibre
 def no_more_jobs(self):
     if self.is_running:
         self.stop()
         QCoreApplication.instance().alert(self, 5000)
예제 #25
0
def available_width():
    desktop = QCoreApplication.instance().desktop()
    return desktop.availableGeometry().width()
예제 #26
0
def available_width():
    desktop       = QCoreApplication.instance().desktop()
    return desktop.availableGeometry().width()
예제 #27
0
def available_heights():
    desktop  = QCoreApplication.instance().desktop()
    return map(lambda x: x.height(), map(desktop.availableGeometry, range(desktop.numScreens())))
예제 #28
0
    def __init__(self, gui, view, row):
        QDialog.__init__(self, gui, flags=Qt.Window)
        Ui_Quickview.__init__(self)
        self.setupUi(self)
        self.isClosed = False

        self.books_table_column_widths = None
        try:
            self.books_table_column_widths = \
                        gprefs.get('quickview_dialog_books_table_widths', None)
            geom = gprefs.get('quickview_dialog_geometry', bytearray(''))
            self.restoreGeometry(QByteArray(geom))
        except:
            pass

        # Remove the help button from the window title bar
        icon = self.windowIcon()
        self.setWindowFlags(self.windowFlags()
                            & (~Qt.WindowContextHelpButtonHint))
        self.setWindowIcon(icon)

        self.db = view.model().db
        self.view = view
        self.gui = gui
        self.is_closed = False
        self.current_book_id = None
        self.current_key = None
        self.last_search = None
        self.current_column = None
        self.current_item = None
        self.no_valid_items = False

        self.items.setSelectionMode(QAbstractItemView.SingleSelection)
        self.items.currentTextChanged.connect(self.item_selected)

        # Set up the books table columns
        self.books_table.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.books_table.setSelectionMode(QAbstractItemView.SingleSelection)
        self.books_table.setColumnCount(3)
        t = QTableWidgetItem(_('Title'))
        self.books_table.setHorizontalHeaderItem(0, t)
        t = QTableWidgetItem(_('Authors'))
        self.books_table.setHorizontalHeaderItem(1, t)
        t = QTableWidgetItem(_('Series'))
        self.books_table.setHorizontalHeaderItem(2, t)
        self.books_table_header_height = self.books_table.height()
        self.books_table.cellDoubleClicked.connect(self.book_doubleclicked)
        self.books_table.sortByColumn(0, Qt.AscendingOrder)

        # get the standard table row height. Do this here because calling
        # resizeRowsToContents can word wrap long cell contents, creating
        # double-high rows
        self.books_table.setRowCount(1)
        self.books_table.setItem(0, 0, TableItem('A', ''))
        self.books_table.resizeRowsToContents()
        self.books_table_row_height = self.books_table.rowHeight(0)
        self.books_table.setRowCount(0)

        # Add the data
        self.refresh(row)

        self.view.clicked.connect(self.slave)
        QCoreApplication.instance().aboutToQuit.connect(self.save_state)
        self.search_button.clicked.connect(self.do_search)
        view.model().new_bookdisplay_data.connect(self.book_was_changed)
예제 #29
0
파일: iqt.py 프로젝트: gyenney/Tools
"""iqt

Provides control over PyQt and PyQwt widgets from the command line interpreter.
"""

# Import GNU readline, so that readline can do its work in Python scripts.
# _iqt falls back on a different method when there is no GNU readline.
try:
    import readline
except ImportError:
    pass

from PyQt4.Qt import QApplication, QCoreApplication, PYQT_VERSION

if QCoreApplication.instance() is None:
    _a = QApplication([])

if PYQT_VERSION < 0x40300:
    import _iqt

# Local Variables: ***
# mode: python ***
# End: ***
예제 #30
0
def available_heights():
    desktop = QCoreApplication.instance().desktop()
    return map(lambda x: x.height(),
               map(desktop.availableGeometry, range(desktop.numScreens())))
예제 #31
0
파일: jobs.py 프로젝트: sss/calibre
 def no_more_jobs(self):
     if self.is_running:
         self.stop()
         QCoreApplication.instance().alert(self, 5000)
예제 #32
0
def available_height():
    desktop  = QCoreApplication.instance().desktop()
    return desktop.availableGeometry().height()
예제 #33
0
    def __init__(self, gui, view, row):
        QDialog.__init__(self, gui, flags=Qt.Window)
        Ui_Quickview.__init__(self)
        self.setupUi(self)
        self.isClosed = False

        self.books_table_column_widths = None
        try:
            self.books_table_column_widths = gprefs.get("quickview_dialog_books_table_widths", None)
            geom = gprefs.get("quickview_dialog_geometry", bytearray(""))
            self.restoreGeometry(QByteArray(geom))
        except:
            pass

        # Remove the help button from the window title bar
        icon = self.windowIcon()
        self.setWindowFlags(self.windowFlags() & (~Qt.WindowContextHelpButtonHint))
        self.setWindowFlags(self.windowFlags() | Qt.WindowStaysOnTopHint)
        self.setWindowIcon(icon)

        self.db = view.model().db
        self.view = view
        self.gui = gui
        self.is_closed = False
        self.current_book_id = None
        self.current_key = None
        self.last_search = None
        self.current_column = None
        self.current_item = None
        self.no_valid_items = False

        column_positions = self.view.get_state()["column_positions"]
        column_order = ["title", "authors", "series"]
        column_order.sort(key=lambda col: column_positions[col])
        self.title_column = column_order.index("title")
        self.author_column = column_order.index("authors")
        self.series_column = column_order.index("series")

        self.items.setSelectionMode(QAbstractItemView.SingleSelection)
        self.items.currentTextChanged.connect(self.item_selected)

        # Set up the books table columns
        self.books_table.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.books_table.setSelectionMode(QAbstractItemView.SingleSelection)
        self.books_table.setColumnCount(3)
        t = QTableWidgetItem(_("Title"))
        self.books_table.setHorizontalHeaderItem(self.title_column, t)
        t = QTableWidgetItem(_("Authors"))
        self.books_table.setHorizontalHeaderItem(self.author_column, t)
        t = QTableWidgetItem(_("Series"))
        self.books_table.setHorizontalHeaderItem(self.series_column, t)
        self.books_table_header_height = self.books_table.height()
        self.books_table.cellDoubleClicked.connect(self.book_doubleclicked)
        self.books_table.sortByColumn(self.title_column, Qt.AscendingOrder)

        # get the standard table row height. Do this here because calling
        # resizeRowsToContents can word wrap long cell contents, creating
        # double-high rows
        self.books_table.setRowCount(1)
        self.books_table.setItem(0, 0, TableItem("A", ""))
        self.books_table.resizeRowsToContents()
        self.books_table_row_height = self.books_table.rowHeight(0)
        self.books_table.setRowCount(0)

        # Add the data
        self.refresh(row)

        self.view.clicked.connect(self.slave)
        self.change_quickview_column.connect(self.slave)
        QCoreApplication.instance().aboutToQuit.connect(self.save_state)
        self.search_button.clicked.connect(self.do_search)
        view.model().new_bookdisplay_data.connect(self.book_was_changed)

        close_button = self.buttonBox.button(QDialogButtonBox.Close)
        close_button.setAutoDefault(False)
예제 #34
0
파일: book_info.py 프로젝트: 089git/calibre
    def __init__(self, parent, view, row, link_delegate):
        QDialog.__init__(self, parent)
        self.normal_brush = QBrush(Qt.white)
        self.marked_brush = QBrush(Qt.lightGray)
        self.marked = None
        self.gui = parent
        self.splitter = QSplitter(self)
        self._l = l = QVBoxLayout(self)
        self.setLayout(l)
        l.addWidget(self.splitter)

        self.cover = CoverView(self)
        self.cover.resizeEvent = self.cover_view_resized
        self.cover.cover_changed.connect(self.cover_changed)
        self.cover_pixmap = None
        self.cover.sizeHint = self.details_size_hint
        self.splitter.addWidget(self.cover)

        self.details = QWebView(self)
        self.details.sizeHint = self.details_size_hint
        self.details.page().setLinkDelegationPolicy(self.details.page().DelegateAllLinks)
        self.details.linkClicked.connect(self.link_clicked)
        s = self.details.page().settings()
        s.setAttribute(s.JavascriptEnabled, False)
        self.css = css()
        self.link_delegate = link_delegate
        self.details.setAttribute(Qt.WA_OpaquePaintEvent, False)
        palette = self.details.palette()
        self.details.setAcceptDrops(False)
        palette.setBrush(QPalette.Base, Qt.transparent)
        self.details.page().setPalette(palette)

        self.c = QWidget(self)
        self.c.l = l2 = QGridLayout(self.c)
        self.c.setLayout(l2)
        l2.addWidget(self.details, 0, 0, 1, -1)
        self.splitter.addWidget(self.c)

        self.fit_cover = QCheckBox(_('Fit &cover within view'), self)
        self.fit_cover.setChecked(gprefs.get('book_info_dialog_fit_cover', True))
        l2.addWidget(self.fit_cover, l2.rowCount(), 0, 1, -1)
        self.previous_button = QPushButton(QIcon(I('previous.png')), _('&Previous'), self)
        self.previous_button.clicked.connect(self.previous)
        l2.addWidget(self.previous_button, l2.rowCount(), 0)
        self.next_button = QPushButton(QIcon(I('next.png')), _('&Next'), self)
        self.next_button.clicked.connect(self.next)
        l2.addWidget(self.next_button, l2.rowCount() - 1, 1)

        self.view = view
        self.current_row = None
        self.refresh(row)
        self.view.selectionModel().currentChanged.connect(self.slave)
        self.fit_cover.stateChanged.connect(self.toggle_cover_fit)
        self.ns = QShortcut(QKeySequence('Alt+Right'), self)
        self.ns.activated.connect(self.next)
        self.ps = QShortcut(QKeySequence('Alt+Left'), self)
        self.ps.activated.connect(self.previous)
        self.next_button.setToolTip(_('Next [%s]')%
                unicode(self.ns.key().toString(QKeySequence.NativeText)))
        self.previous_button.setToolTip(_('Previous [%s]')%
                unicode(self.ps.key().toString(QKeySequence.NativeText)))

        geom = QCoreApplication.instance().desktop().availableGeometry(self)
        screen_height = geom.height() - 100
        screen_width = geom.width() - 100
        self.resize(max(int(screen_width/2), 700), screen_height)
        saved_layout = gprefs.get('book_info_dialog_layout', None)
        if saved_layout is not None:
            try:
                self.restoreGeometry(saved_layout[0])
                self.splitter.restoreState(saved_layout[1])
            except Exception:
                pass
예제 #35
0
def available_height():
    desktop = QCoreApplication.instance().desktop()
    return desktop.availableGeometry().height()
예제 #36
0
    def updateGraph(self):
#         try:
#             self.graph.clear()
#             print 'yes'
#         except AttributeError:
#             print "error"
#         else:
#             pass
#         QtGui.QWidget.__init__(self)
#         self.canvas = MplCanvas()
#         #We instantiate the Matplotlib canvas object.
#         self.vbl = QtGui.QVBoxLayout()
#         #Here, we create a layout manager (in this case a vertical box).
#         self.vbl.addWidget(self.canvas)
#         # We add the Matplotlib canvas to the layout manager.
#         self.graph.setLayout(self.vbl)
#         # a figure instance to plot on
        self.figure = plt.figure()
        # this is the Canvas Widget that displays the `figure`
        # it takes the `figure` instance as a parameter to __init__
        self.canvas = FigureCanvas(self.figure)

#         self.canvas.clf()
        # this is the Navigation widget
        # it takes the Canvas widget and a parent
        self.toolbar = NavigationToolbar(self.canvas, self)
        
#         self.layout.reLayout()
        if self.hasLayOUT==True:
            self.clearLayout()
        if self.hasLayOUT==False:
            self.layout = QtGui.QVBoxLayout()
        self.hasLayOUT=True
        self.layout.addWidget(self.toolbar)
        self.layout.addWidget(self.canvas)
#         self.graph.layout().deleteLater()
        self.graph.setLayout(self.layout)
        self.ControlButton.setVisible(False)
        pos={}
        for nm,ob in self.provisionals.iteritems():
            x=ob.x
            y=ob.y
            pos[nm]=  (x,y)         
        for nm,ob in self.control.iteritems():
            x=ob.x
            y=ob.y
            pos[nm]=  (x,y)
        nx.draw_networkx_nodes(self.N,pos,
                           node_color='y',
                           node_size=800,
                           alpha=1)
        nx.draw_networkx_nodes(self.N,pos,
                       nodelist=self.control,
                       node_color='r',
                       node_size=800,
                       alpha=1)
        
#         ellipse = mpl.patches.Ellipse(xy=(58305,49663), width=1000, height=1000)
#         fig,ax = plt.subplots()
# #         self.figure.add_artist(ellipse) 
#         nx.draw_networkx_nodes(ellipse, xy=(self.control['SUR09'].x,self.control['SUR09'].y))
        edges={}
        for v,u,d in self.N.edges(data=True):
            if d.has_key("distance") and d.has_key('direction'):
                edges[v,u]='b'
#         fig = figure()
#         ax = fig.add_subplot(111, aspect='equal')
#         e=(Ellipse((self.control['SUR09'].x,self.control['SUR09'].y), width=100, height=5, angle=45))    
#         ax.add_artist(e)
#         plt.plot(self.control['SUR09'].x,self.control['SUR09'].y,'g.', markersize=100.0)                  #([e], [e], 'g.', markersize=20.0) 
          
        nx.draw(self.N,pos)
        nx.draw_networkx_edges(self.N,pos,
                       edgelist=edges,
                       width=8,alpha=0.5,edge_color='b')
#         nx.draw(Ellipse((self.control['SUR09'].x,self.control['SUR09'].y), width=100, height=5, angle=45,edgecolor=('green')))
        
        plt.axis('scaled')
#         nx.set_aspect('auto')
        
#         forceAspect(nx,aspect=1)
#         plt.show()
#         nx.draw(ellipse)
#         nx.add_artist(ellipse)
    #     matplotlib.pyplot.ion()
    #     plt.draw()
#         self.canvas.addAction(ellipse)
        QCoreApplication.processEvents()
        self.canvas.draw()
예제 #37
0
파일: quickview.py 프로젝트: Eksmo/calibre
    def __init__(self, gui, view, row):
        QDialog.__init__(self, gui, flags=Qt.Window)
        Ui_Quickview.__init__(self)
        self.setupUi(self)
        self.isClosed = False

        self.books_table_column_widths = None
        try:
            self.books_table_column_widths = \
                        gprefs.get('quickview_dialog_books_table_widths', None)
            geom = gprefs.get('quickview_dialog_geometry', bytearray(''))
            self.restoreGeometry(QByteArray(geom))
        except:
            pass

        # Remove the help button from the window title bar
        icon = self.windowIcon()
        self.setWindowFlags(self.windowFlags()&(~Qt.WindowContextHelpButtonHint))
        self.setWindowIcon(icon)

        self.db = view.model().db
        self.view = view
        self.gui = gui
        self.is_closed = False
        self.current_book_id = None
        self.current_key = None
        self.last_search = None
        self.current_column = None
        self.current_item = None
        self.no_valid_items = False

        self.items.setSelectionMode(QAbstractItemView.SingleSelection)
        self.items.currentTextChanged.connect(self.item_selected)

        # Set up the books table columns
        self.books_table.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.books_table.setSelectionMode(QAbstractItemView.SingleSelection)
        self.books_table.setColumnCount(3)
        t = QTableWidgetItem(_('Title'))
        self.books_table.setHorizontalHeaderItem(0, t)
        t = QTableWidgetItem(_('Authors'))
        self.books_table.setHorizontalHeaderItem(1, t)
        t = QTableWidgetItem(_('Series'))
        self.books_table.setHorizontalHeaderItem(2, t)
        self.books_table_header_height = self.books_table.height()
        self.books_table.cellDoubleClicked.connect(self.book_doubleclicked)
        self.books_table.sortByColumn(0, Qt.AscendingOrder)

        # get the standard table row height. Do this here because calling
        # resizeRowsToContents can word wrap long cell contents, creating
        # double-high rows
        self.books_table.setRowCount(1)
        self.books_table.setItem(0, 0, TableItem('A', ''))
        self.books_table.resizeRowsToContents()
        self.books_table_row_height = self.books_table.rowHeight(0)
        self.books_table.setRowCount(0)

        # Add the data
        self.refresh(row)

        self.view.clicked.connect(self.slave)
        QCoreApplication.instance().aboutToQuit.connect(self.save_state)
        self.search_button.clicked.connect(self.do_search)
        view.model().new_bookdisplay_data.connect(self.book_was_changed)