本文整理汇总了Python中qwt.qt.QtGui.QApplication类的典型用法代码示例。如果您正苦于以下问题:Python QApplication类的具体用法?Python QApplication怎么用?Python QApplication使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QApplication类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, max_n, parent=None, **kwargs):
super(BMDemo, self).__init__(parent=parent)
self.setWindowTitle('Curve styles')
tabs = QTabWidget()
self.resize(1000, 800)
# Force window to show up and refresh (for test purpose only)
self.show()
QApplication.processEvents()
self.setCentralWidget(tabs)
pts = 1000
for points, symbols in zip((pts/10, pts/10, pts, pts),
(True, False)*2):
t0 = time.time()
widget = CSWidget(points, symbols)
symtext = "with%s symbols" % ("" if symbols else "out")
title = '%d points, %s' % (points, symtext)
tabs.addTab(widget, title)
tabs.setCurrentWidget(widget)
# Force widget to refresh (for test purpose only)
QApplication.processEvents()
time_str = "Elapsed time: %d ms" % ((time.time()-t0)*1000)
widget.text.setText(time_str)
tabs.setCurrentIndex(0)
示例2: __init__
def __init__(self, max_n, parent=None, **kwargs):
super(BMDemo, self).__init__(parent=parent)
self.setWindowTitle('Curve benchmark')
tabs = QTabWidget()
self.setCentralWidget(tabs)
contents = BMText()
tabs.addTab(contents, 'Contents')
self.resize(1000, 600)
# Force window to show up and refresh (for test purpose only)
self.show()
QApplication.processEvents()
t0g = time.time()
for idx in range(4, -1, -1):
points = max_n/10**idx
t0 = time.time()
widget = BMWidget(points)
title = '%d points' % points
tabs.addTab(widget, title)
tabs.setCurrentWidget(widget)
# Force widget to refresh (for test purpose only)
QApplication.processEvents()
time_str = "Elapsed time: %d ms" % ((time.time()-t0)*1000)
widget.text.setText(time_str)
contents.append("<br><i>%s:</i><br>%s" % (title, time_str))
dt = time.time()-t0g
contents.append("<br><br><u>Total elapsed time</u>: %d ms" % (dt*1000))
tabs.setCurrentIndex(0)
示例3: process_iteration
def process_iteration(self, title, description, widget, t0):
self.tabs.addTab(widget, title)
self.tabs.setCurrentWidget(widget)
# Force widget to refresh (for test purpose only)
QApplication.processEvents()
time_str = "Elapsed time: %d ms" % ((time.time()-t0)*1000)
widget.text.setText(time_str)
self.text.append("<br><i>%s:</i><br>%s" % (description, time_str))
示例4: eventFilter
def eventFilter(self, object_, event):
if object_ is self.__data.view.contentsWidget:
if event.type() == QEvent.ChildRemoved:
ce = event #TODO: cast to QChildEvent
if ce.child().isWidgetType():
w = ce.child() #TODO: cast to QWidget
self.__data.itemMap.removeWidget(w)
elif event.type() == QEvent.LayoutRequest:
self.__data.view.layoutContents()
if self.parentWidget() and self.parentWidget().layout() is None:
QApplication.postEvent(self.parentWidget(),
QEvent(QEvent.LayoutRequest))
return QwtAbstractLegend.eventFilter(self, object_, event)
示例5: eventFilter
def eventFilter(self, object, event):
if event.type() == QEvent.FocusIn:
self.__showCursor(True)
if event.type() == QEvent.FocusOut:
self.__showCursor(False)
if event.type() == QEvent.Paint:
QApplication.postEvent(self, QEvent(QEvent.User))
elif event.type() == QEvent.MouseButtonPress:
self.__select(event.pos())
return True
elif event.type() == QEvent.MouseMove:
self.__move(event.pos())
return True
if event.type() == QEvent.KeyPress:
delta = 5
key = event.key()
if key == Qt.Key_Up:
self.__shiftCurveCursor(True)
return True
elif key == Qt.Key_Down:
self.__shiftCurveCursor(False)
return True
elif key == Qt.Key_Right or key == Qt.Key_Plus:
if self.__selectedCurve:
self.__shiftPointCursor(True)
else:
self.__shiftCurveCursor(True)
return True
elif key == Qt.Key_Left or key == Qt.Key_Minus:
if self.__selectedCurve:
self.__shiftPointCursor(False)
else:
self.__shiftCurveCursor(True)
return True
if key == Qt.Key_1:
self.__moveBy(-delta, delta)
elif key == Qt.Key_2:
self.__moveBy(0, delta)
elif key == Qt.Key_3:
self.__moveBy(delta, delta)
elif key == Qt.Key_4:
self.__moveBy(-delta, 0)
elif key == Qt.Key_6:
self.__moveBy(delta, 0)
elif key == Qt.Key_7:
self.__moveBy(-delta, -delta)
elif key == Qt.Key_8:
self.__moveBy(0, -delta)
elif key == Qt.Key_9:
self.__moveBy(delta, -delta)
return QwtPlot.eventFilter(self.__plot, object, event)
示例6: replot
def replot(self):
doAutoReplot = self.autoReplot()
self.setAutoReplot(False)
self.updateAxes()
QApplication.sendPostedEvents(self, QEvent.LayoutRequest)
if self.__data.canvas:
try:
self.__data.canvas.replot()
except (AttributeError, TypeError):
self.__data.canvas.update(self.__data.canvas.contentsRect())
self.setAutoReplot(doAutoReplot)
示例7: sizeHint
def sizeHint(self):
sz = QwtTextLabel.sizeHint(self)
sz.setHeight(max([sz.height(), self.__data.icon.height()+4]))
if self.__data.itemMode != QwtLegendData.ReadOnly:
sz += buttonShift(self)
sz = sz.expandedTo(QApplication.globalStrut())
return sz
示例8: qwtScreenResolution
def qwtScreenResolution():
screenResolution = QSize()
if not screenResolution.isValid():
desktop = QApplication.desktop()
if desktop is not None:
screenResolution.setWidth(desktop.logicalDpiX())
screenResolution.setHeight(desktop.logicalDpiY())
return screenResolution
示例9: _desktopwidget
def _desktopwidget(self):
"""
Property used to store the Application Desktop Widget to avoid calling
the `QApplication.desktop()" function more than necessary as its
calling time is not negligible.
"""
if self.__desktopwidget is None:
self.__desktopwidget = QApplication.desktop()
return self.__desktopwidget
示例10: qwtUnscaleFont
def qwtUnscaleFont(painter):
if painter.font().pixelSize() >= 0:
return
screenResolution = qwtScreenResolution()
pd = painter.device()
if pd.logicalDpiX() != screenResolution.width() or\
pd.logicalDpiY() != screenResolution.height():
pixelFont = QFont(painter.font(), QApplication.desktop())
pixelFont.setPixelSize(QFontInfo(pixelFont).pixelSize())
painter.setFont(pixelFont)
示例11: eventFilter
def eventFilter(self, object_, event):
"""
Handle QEvent.ChildRemoved andQEvent.LayoutRequest events
for the contentsWidget().
:param QObject object: Object to be filtered
:param QEvent event: Event
:return: Forwarded to QwtAbstractLegend.eventFilter()
"""
if object_ is self.__data.view.contentsWidget:
if event.type() == QEvent.ChildRemoved:
ce = event #TODO: cast to QChildEvent
if ce.child().isWidgetType():
w = ce.child() #TODO: cast to QWidget
self.__data.itemMap.removeWidget(w)
elif event.type() == QEvent.LayoutRequest:
self.__data.view.layoutContents()
if self.parentWidget() and self.parentWidget().layout() is None:
QApplication.postEvent(self.parentWidget(),
QEvent(QEvent.LayoutRequest))
return QwtAbstractLegend.eventFilter(self, object_, event)
示例12: __init__
def __init__(self, max_n, parent=None, **kwargs):
super(BMDemo, self).__init__(parent=parent)
title = self.TITLE
if kwargs.get('only_lines', False):
title = '%s (%s)' % (title, 'only lines')
self.setWindowTitle(title)
self.tabs = QTabWidget()
self.setCentralWidget(self.tabs)
self.text = BMText(self)
self.tabs.addTab(self.text, 'Contents')
self.resize(*self.SIZE)
# Force window to show up and refresh (for test purpose only)
self.show()
QApplication.processEvents()
t0g = time.time()
self.run_benchmark(max_n, **kwargs)
dt = time.time()-t0g
self.text.append("<br><br><u>Total elapsed time</u>: %d ms" % (dt*1e3))
self.tabs.setCurrentIndex(0)
示例13: showInfo
def showInfo(self, text=""):
self.statusBar().showMessage(text)
def moved(self, point):
info = "Freq=%g, Ampl=%g, Phase=%g" % (
self.plot.invTransform(QwtPlot.xBottom, point.x()),
self.plot.invTransform(QwtPlot.yLeft, point.y()),
self.plot.invTransform(QwtPlot.yRight, point.y()))
self.showInfo(info)
def selected(self, _):
self.showInfo()
def make():
demo = BodeDemo()
demo.resize(540, 400)
demo.show()
return demo
if __name__ == '__main__':
app = QApplication(sys.argv)
fonts = QFontDatabase()
for name in ('Verdana', 'STIXGeneral'):
if name in fonts.families():
app.setFont(QFont(name))
break
demo = make()
sys.exit(app.exec_())
示例14: make
self.phase = 0.0
# y moves from left to right:
# shift y array right and assign new value y[0]
self.y = np.concatenate((self.y[:1], self.y[:-1]), 1)
self.y[0] = np.sin(self.phase) * (-1.0 + 2.0*random.random())
# z moves from right to left:
# Shift z array left and assign new value to z[n-1].
self.z = np.concatenate((self.z[1:], self.z[:1]), 1)
self.z[-1] = 0.8 - (2.0 * self.phase/np.pi) + 0.4*random.random()
self.curveR.setData(self.x, self.y)
self.curveL.setData(self.x, self.z)
self.replot()
self.phase += np.pi*0.02
def make():
demo = DataPlot()
demo.resize(500, 300)
demo.show()
return demo
if __name__ == '__main__':
app = QApplication(sys.argv)
demo = make()
sys.exit(app.exec_())
示例15: QApplication
# -*- coding: utf-8 -*-
__author__ = 'Valeriy'
from qwt.qt.QtGui import QApplication
from qwt import QwtPlot, QwtPlotCurve
import numpy as np
app = QApplication([])
# x = [1,2,3,4,5,6,7,8,9]
# y1 = [3.2, 5.1 ,7.0, 4.24, 4.41, 8.34, 2.21, 5.657, 6.1]
x = []
y1 = []
my_plot = QwtPlot("Two curves")
curve1 = QwtPlotCurve("Curve 1")
my_plot.resize(600, 300)
curve1.setData(x, y1)
curve1.attach(my_plot)
# my_plot.replot()
my_plot.show()
app.exec_()
# SELECT PrepData FROM= Pdata WHERE ((PNameId=2) AND (SNameId = 14) AND (YearId=2012))