本文整理汇总了Python中spyderlib.qt.QtGui.QApplication类的典型用法代码示例。如果您正苦于以下问题:Python QApplication类的具体用法?Python QApplication怎么用?Python QApplication使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QApplication类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: resize_to_contents
def resize_to_contents(self):
"""Resize cells to contents"""
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
self.resizeColumnsToContents()
self.model().fetch_more(columns=True)
self.resizeColumnsToContents()
QApplication.restoreOverrideCursor()
示例2: test
def test():
from spyderlib.qt.QtGui import QApplication
app = QApplication([])
widget = create_widget()
widget.show()
# Start the application main loop.
app.exec_()
示例3: starting_long_process
def starting_long_process(self, message):
"""
Showing message in main window's status bar
and changing mouse cursor to Qt.WaitCursor
"""
self.show_message(message)
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
QApplication.processEvents()
示例4: ending_long_process
def ending_long_process(self, message=""):
"""
Clearing main window's status bar
and restoring mouse cursor
"""
QApplication.restoreOverrideCursor()
self.show_message(message, timeout=2000)
QApplication.processEvents()
示例5: _post_message
def _post_message(self, message, timeout=60000):
"""
Post a message to the main window status bar with a timeout in ms
"""
if self.editor_widget:
statusbar = self.editor_widget.window().statusBar()
statusbar.showMessage(message, timeout)
QApplication.processEvents()
示例6: write_error
def write_error(self):
if os.name == 'nt':
#---This is apparently necessary only on Windows (not sure though):
# emptying standard output buffer before writing error output
self.process.setReadChannel(QProcess.StandardOutput)
if self.process.waitForReadyRead(1):
self.write_output()
self.shell.write_error(self.get_stderr())
QApplication.processEvents()
示例7: copy_without_prompts
def copy_without_prompts(self):
"""Copy text to clipboard without prompts"""
text = self.get_selected_text()
lines = text.split(os.linesep)
for index, line in enumerate(lines):
if line.startswith('>>> ') or line.startswith('... '):
lines[index] = line[4:]
text = os.linesep.join(lines)
QApplication.clipboard().setText(text)
示例8: mouseMoveEvent
def mouseMoveEvent(self, event):
"""Show Pointing Hand Cursor on error messages"""
text = self.get_line_at(event.pos())
if get_error_match(text):
if not self.__cursor_changed:
QApplication.setOverrideCursor(QCursor(Qt.PointingHandCursor))
self.__cursor_changed = True
event.accept()
return
if self.__cursor_changed:
QApplication.restoreOverrideCursor()
self.__cursor_changed = False
self.QT_CLASS.mouseMoveEvent(self, event)
示例9: save_data
def save_data(self, filename=None):
"""Save data"""
if filename is None:
filename = self.filename
if filename is None:
filename = getcwd()
filename, _selfilter = getsavefilename(self, _("Save data"),
filename,
iofunctions.save_filters)
if filename:
self.filename = filename
else:
return False
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
QApplication.processEvents()
if self.is_internal_shell:
wsfilter = self.get_internal_shell_filter('picklable',
check_all=True)
namespace = wsfilter(self.shellwidget.interpreter.namespace).copy()
error_message = iofunctions.save(namespace, filename)
else:
settings = self.get_view_settings()
error_message = monitor_save_globals(self._get_sock(),
settings, filename)
QApplication.restoreOverrideCursor()
QApplication.processEvents()
if error_message is not None:
QMessageBox.critical(self, _("Save data"),
_("<b>Unable to save current workspace</b>"
"<br><br>Error message:<br>%s") % error_message)
self.save_button.setEnabled(self.filename is not None)
示例10: data
def data(self, index, role=Qt.DisplayRole):
"""Qt Override."""
row = index.row()
if not index.isValid() or not (0 <= row < len(self.shortcuts)):
return to_qvariant()
shortcut = self.shortcuts[row]
key = shortcut.key
column = index.column()
if role == Qt.DisplayRole:
if column == CONTEXT:
return to_qvariant(shortcut.context)
elif column == NAME:
color = self.text_color
if self._parent == QApplication.focusWidget():
if self.current_index().row() == row:
color = self.text_color_highlight
else:
color = self.text_color
text = self.rich_text[row]
text = '<p style="color:{0}">{1}</p>'.format(color, text)
return to_qvariant(text)
elif column == SEQUENCE:
text = QKeySequence(key).toString(QKeySequence.NativeText)
return to_qvariant(text)
elif column == SEARCH_SCORE:
# Treating search scores as a table column simplifies the
# sorting once a score for a specific string in the finder
# has been defined. This column however should always remain
# hidden.
return to_qvariant(self.scores[row])
elif role == Qt.TextAlignmentRole:
return to_qvariant(int(Qt.AlignHCenter | Qt.AlignVCenter))
return to_qvariant()
示例11: mouseMoveEvent
def mouseMoveEvent(self, event):
"""Override Qt method"""
if event.buttons() == Qt.MouseButtons(Qt.LeftButton) and \
(event.pos() - self.__drag_start_pos).manhattanLength() > \
QApplication.startDragDistance():
drag = QDrag(self)
mimeData = QMimeData()
# Converting id's to long to avoid an OverflowError with PySide
if PY2:
ancestor_id = long(id(self.ancestor))
parent_widget_id = long(id(self.parentWidget()))
self_id = long(id(self))
else:
ancestor_id = id(self.ancestor)
parent_widget_id = id(self.parentWidget())
self_id = id(self)
mimeData.setData("parent-id", QByteArray.number(ancestor_id))
mimeData.setData("tabwidget-id",
QByteArray.number(parent_widget_id))
mimeData.setData("tabbar-id", QByteArray.number(self_id))
mimeData.setData("source-index",
QByteArray.number(self.tabAt(self.__drag_start_pos)))
drag.setMimeData(mimeData)
drag.exec_()
QTabBar.mouseMoveEvent(self, event)
示例12: paintEvent
def paintEvent(self, event):
"""Qt Override.
Include a validation icon to the left of the line edit.
"""
super(IconLineEdit, self).paintEvent(event)
painter = QPainter(self)
rect = self.geometry()
space = int((rect.height())/6)
h = rect.height() - space
w = rect.width() - h
if self._icon_visible:
if self._status and self._status_set:
pixmap = self._set_icon.pixmap(h, h)
elif self._status:
pixmap = self._valid_icon.pixmap(h, h)
else:
pixmap = self._invalid_icon.pixmap(h, h)
painter.drawPixmap(w, space, pixmap)
application_style = QApplication.style().objectName()
if self._application_style != application_style:
self._application_style = application_style
self._refresh()
# Small hack to gurantee correct padding on Spyder start
if self._paint_count < 5:
self._paint_count += 1
self._refresh()
示例13: paint
def paint(self, painter, option, index):
options = QStyleOptionViewItem(option)
self.initStyleOption(options, index)
style = (QApplication.style() if options.widget is None
else options.widget.style())
doc = QTextDocument()
doc.setDocumentMargin(self._margin)
doc.setHtml(options.text)
options.text = ""
style.drawControl(QStyle.CE_ItemViewItem, options, painter)
ctx = QAbstractTextDocumentLayout.PaintContext()
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
painter.save()
if style.objectName() == 'oxygen':
painter.translate(textRect.topLeft() + QPoint(5, -9))
else:
painter.translate(textRect.topLeft())
painter.setClipRect(textRect.translated(-textRect.topLeft()))
doc.documentLayout().draw(painter, ctx)
painter.restore()
示例14: copy
def copy(self):
"""Copy text to clipboard"""
if not self.selectedIndexes():
return
(row_min, row_max,
col_min, col_max) = get_idx_rect(self.selectedIndexes())
index = header = False
if col_min == 0:
col_min = 1
index = True
df = self.model().df
if col_max == 0: # To copy indices
contents = '\n'.join(map(str, df.index.tolist()[slice(row_min,
row_max+1)]))
else: # To copy DataFrame
if (col_min == 0 or col_min == 1) and (df.shape[1] == col_max):
header = True
obj = df.iloc[slice(row_min, row_max+1), slice(col_min-1, col_max)]
output = io.StringIO()
obj.to_csv(output, sep='\t', index=index, header=header)
if not PY2:
contents = output.getvalue()
else:
contents = output.getvalue().decode('utf-8')
output.close()
clipboard = QApplication.clipboard()
clipboard.setText(contents)
示例15: data
def data(self, index, role=Qt.DisplayRole):
"""Qt Override"""
if not index.isValid() or \
not (0 <= index.row() < len(self.shortcuts)):
return to_qvariant()
shortcut = self.shortcuts[index.row()]
key = shortcut.key
column = index.column()
if role == Qt.DisplayRole:
if column == CONTEXT:
return to_qvariant(shortcut.context)
elif column == NAME:
color = self.text_color
if self._parent == QApplication.focusWidget():
if self.current_index().row() == index.row():
color = self.text_color_highlight
else:
color = self.text_color
return to_qvariant(self._enrich_text(shortcut.name, color))
elif column == SEQUENCE:
text = QKeySequence(key).toString(QKeySequence.NativeText)
return to_qvariant(text)
elif role == Qt.TextAlignmentRole:
return to_qvariant(int(Qt.AlignHCenter | Qt.AlignVCenter))
return to_qvariant()