本文整理汇总了Python中PyQt5.Qt.QCoreApplication类的典型用法代码示例。如果您正苦于以下问题:Python QCoreApplication类的具体用法?Python QCoreApplication怎么用?Python QCoreApplication使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QCoreApplication类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start_import_data
def start_import_data(self):
config = self.getCurrentConfig()
dest_dir = config.get('hdf5', 'dir')
if not os.path.exists(dest_dir) or not os.path.isdir(dest_dir):
print("错误:", '指定的目标数据存放目录不存在!')
sys.exit(-1)
#return
if config.getboolean('tdx', 'enable') \
and (not os.path.exists(config['tdx']['dir']
or os.path.isdir(config['tdx']['dir']))):
print("错误:", "请确认通达信安装目录是否正确!")
sys.exit(-1)
#return
self.import_running = True
print("正在启动任务....")
QCoreApplication.processEvents()
if config.getboolean('tdx', 'enable'):
self.hdf5_import_thread = UseTdxImportToH5Thread(config)
else:
self.hdf5_import_thread = UsePytdxImportToH5Thread(config)
self.hdf5_import_thread.message.connect(self.on_message_from_thread)
self.hdf5_import_thread.start()
self.escape_time = 0.0
self.escape_time_thread = EscapetimeThread()
self.escape_time_thread.message.connect(self.on_message_from_thread)
self.escape_time_thread.start()
示例2: update_cache
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: show_shutdown_message
def show_shutdown_message(self, message):
smw = self.shutdown_message_widget
smw.setVisible(True)
txt = smw.text()
txt += '\n' + message
smw.setText(txt)
# Force processing the events needed to show the message
QCoreApplication.processEvents()
示例4: show_shutdown_message
def show_shutdown_message(self, message=''):
smw = self.shutdown_message_widget
smw.setGeometry(0, 0, self.width(), self.height())
smw.setVisible(True)
smw.raise_()
smw.setText(_('<h2>Shutting down</h2><div>') + message)
# Force processing the events needed to show the message
QCoreApplication.processEvents()
示例5: chapter_rendered
def chapter_rendered(self, num):
if num > 0:
self.progress_bar.setMinimum(0)
self.progress_bar.setMaximum(num)
self.progress_bar.setValue(0)
self.progress_label.setText('Laying out '+ self.document_title)
else:
self.progress_bar.setValue(self.progress_bar.value()+1)
QCoreApplication.processEvents()
示例6: check_library
def check_library(self):
from calibre.gui2.dialogs.check_library import CheckLibraryDialog, DBCheck
self.gui.library_view.save_state()
m = self.gui.library_view.model()
m.stop_metadata_backup()
db = m.db
db.prefs.disable_setting = True
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: downloadOpdsCatalog
def downloadOpdsCatalog(self, gui, opdsCatalogUrl):
print "downloading catalog: %s" % opdsCatalogUrl
opdsCatalogFeed = parse(opdsCatalogUrl)
self.books = self.makeMetadataFromParsedOpds(opdsCatalogFeed.entries)
self.filterBooks()
QCoreApplication.processEvents()
nextUrl = self.findNextUrl(opdsCatalogFeed.feed)
while nextUrl is not None:
nextFeed = parse(nextUrl)
self.books = self.books + self.makeMetadataFromParsedOpds(nextFeed.entries)
self.filterBooks()
QCoreApplication.processEvents()
nextUrl = self.findNextUrl(nextFeed.feed)
示例8: show_browser
def show_browser(self):
'''
Show the currently loaded web page in a window. Useful for debugging.
'''
if getattr(QCoreApplication.instance(), 'headless', False):
raise RuntimeError('Cannot show browser when running in a headless Qt application')
view = BrowserView(self.page)
view.exec_()
示例9: init_qt
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
示例10: __init__
def __init__(self, *args, **kwargs):
QDialog.__init__(self, *args)
self.setupUi(self)
desktop = QCoreApplication.instance().desktop()
geom = desktop.availableGeometry(self)
nh, nw = max(550, geom.height()-25), max(700, geom.width()-10)
nh = min(self.height(), nh)
nw = min(self.width(), nw)
self.resize(nw, nh)
示例11: parsed
def parsed(self):
if not self.renderer.aborted and self.renderer.lrf is not None:
width, height = self.renderer.lrf.device_info.width, self.renderer.lrf.device_info.height
hdelta = self.tool_bar.height() + 3
s = QScrollBar(self)
scrollbar_adjust = min(s.width(), s.height())
self.graphics_view.resize_for(width + scrollbar_adjust, height + scrollbar_adjust)
desktop = QCoreApplication.instance().desktop()
screen_height = desktop.availableGeometry(self).height() - 25
height = min(screen_height, height + hdelta + scrollbar_adjust)
self.resize(width + scrollbar_adjust, height)
self.setWindowTitle(self.renderer.lrf.metadata.title + " - " + __appname__)
self.document_title = self.renderer.lrf.metadata.title
if self.opts.profile:
import cProfile
lrf = self.renderer.lrf
cProfile.runctx("self.document.render(lrf)", globals(), locals(), lrf.metadata.title + ".stats")
print "Stats written to", self.renderer.lrf.metadata.title + ".stats"
else:
start = time.time()
self.document.render(self.renderer.lrf)
print "Layout time:", time.time() - start, "seconds"
self.renderer.lrf = None
self.graphics_view.setScene(self.document)
self.graphics_view.show()
self.spin_box.setRange(1, self.document.num_of_pages)
self.slider.setRange(1, self.document.num_of_pages)
self.spin_box.setSuffix(" of %d" % (self.document.num_of_pages,))
self.spin_box.updateGeometry()
self.stack.setCurrentIndex(0)
self.graphics_view.setFocus(Qt.OtherFocusReason)
elif self.renderer.exception is not None:
exception = self.renderer.exception
print >> sys.stderr, "Error rendering document"
print >> sys.stderr, exception
print >> sys.stderr, self.renderer.formatted_traceback
msg = (
u"<p><b>%s</b>: " % (exception.__class__.__name__,)
+ unicode(str(exception), "utf8", "replace")
+ u"</p>"
)
msg += u"<p>Failed to render document</p>"
msg += u"<p>Detailed <b>traceback</b>:<pre>"
msg += self.renderer.formatted_traceback + "</pre>"
d = ConversionErrorDialog(self, "Error while rendering file", msg)
d.exec_()
示例12: main
def main(args=sys.argv, logger=None):
parser = option_parser()
opts, args = parser.parse_args(args)
if hasattr(opts, 'help'):
parser.print_help()
return 1
pid = os.fork() if (islinux or isbsd) else -1
if pid <= 0:
override = 'calibre-lrf-viewer' if islinux else None
app = Application(args, override_program_name=override)
app.setWindowIcon(QIcon(I('viewer.png')))
QCoreApplication.setOrganizationName(ORG_NAME)
QCoreApplication.setApplicationName(APP_UID)
opts = normalize_settings(parser, opts)
stream = open(args[1], 'rb') if len(args) > 1 else None
main = file_renderer(stream, opts, logger=logger)
sys.excepthook = main.unhandled_exception
main.show()
main.render()
main.activateWindow()
main.raise_()
return app.exec_()
return 0
示例13: parsed
def parsed(self):
if not self.renderer.aborted and self.renderer.lrf is not None:
width, height = self.renderer.lrf.device_info.width, \
self.renderer.lrf.device_info.height
hdelta = self.tool_bar.height()+3
s = QScrollBar(self)
scrollbar_adjust = min(s.width(), s.height())
self.graphics_view.resize_for(width+scrollbar_adjust, height+scrollbar_adjust)
desktop = QCoreApplication.instance().desktop()
screen_height = desktop.availableGeometry(self).height() - 25
height = min(screen_height, height+hdelta+scrollbar_adjust)
self.resize(width+scrollbar_adjust, height)
self.setWindowTitle(self.renderer.lrf.metadata.title + ' - ' + __appname__)
self.document_title = self.renderer.lrf.metadata.title
if self.opts.profile:
import cProfile
lrf = self.renderer.lrf
cProfile.runctx('self.document.render(lrf)', globals(), locals(), lrf.metadata.title+'.stats')
print('Stats written to', self.renderer.lrf.metadata.title+'.stats')
else:
start = time.time()
self.document.render(self.renderer.lrf)
print('Layout time:', time.time()-start, 'seconds')
self.renderer.lrf = None
self.graphics_view.setScene(self.document)
self.graphics_view.show()
self.spin_box.setRange(1, self.document.num_of_pages)
self.slider.setRange(1, self.document.num_of_pages)
self.spin_box.setSuffix(' of %d'%(self.document.num_of_pages,))
self.spin_box.updateGeometry()
self.stack.setCurrentIndex(0)
self.graphics_view.setFocus(Qt.OtherFocusReason)
elif self.renderer.exception is not None:
exception = self.renderer.exception
print('Error rendering document', file=sys.stderr)
print(exception, file=sys.stderr)
print(self.renderer.formatted_traceback, file=sys.stderr)
msg = u'<p><b>%s</b>: '%(exception.__class__.__name__,) + as_unicode(exception) + u'</p>'
msg += u'<p>Failed to render document</p>'
msg += u'<p>Detailed <b>traceback</b>:<pre>'
msg += self.renderer.formatted_traceback + '</pre>'
d = ConversionErrorDialog(self, 'Error while rendering file', msg)
d.exec_()
示例14: __init__
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 = Details(parent.book_details.book_info, self)
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.model().new_bookdisplay_data.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
示例15: no_more_jobs
def no_more_jobs(self):
if self.is_running:
self.stop()
QCoreApplication.instance().alert(self, 5000)