本文整理汇总了Python中PyQt4.Qt.QCoreApplication类的典型用法代码示例。如果您正苦于以下问题:Python QCoreApplication类的具体用法?Python QCoreApplication怎么用?Python QCoreApplication使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QCoreApplication类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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.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: message
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)
示例3: check_library
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()
示例4: __init__
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)
示例5: init_qt
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
示例6: 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
示例7: config_widget
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
示例8: __init__
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)
示例9: __init__
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();
示例10: __init__
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)
示例11: __init__
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)
示例12: available_width
def available_width():
desktop = QCoreApplication.instance().desktop()
return desktop.availableGeometry().width()
示例13: available_height
def available_height():
desktop = QCoreApplication.instance().desktop()
return desktop.availableGeometry().height()
示例14: available_heights
def available_heights():
desktop = QCoreApplication.instance().desktop()
return map(lambda x: x.height(), map(desktop.availableGeometry, range(desktop.numScreens())))
示例15: initialization_failed
def initialization_failed(self):
print 'Catastrophic failure initializing GUI, bailing out...'
QCoreApplication.exit(1)
raise SystemExit(1)