本文整理汇总了Python中PyQt4.Qwt5.QwtPlot.sizePolicy方法的典型用法代码示例。如果您正苦于以下问题:Python QwtPlot.sizePolicy方法的具体用法?Python QwtPlot.sizePolicy怎么用?Python QwtPlot.sizePolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qwt5.QwtPlot
的用法示例。
在下文中一共展示了QwtPlot.sizePolicy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ValueWidget
# 需要导入模块: from PyQt4.Qwt5 import QwtPlot [as 别名]
# 或者: from PyQt4.Qwt5.QwtPlot import sizePolicy [as 别名]
class ValueWidget(QWidget, Ui_Widget):
def __init__(self, iface):
self.hasqwt=hasqwt
self.hasmpl=hasmpl
self.layerMap=dict()
self.statsChecked=False
self.ymin=0
self.ymax=250
self.iface=iface
self.canvas=self.iface.mapCanvas()
self.legend=self.iface.legendInterface()
self.logger = logging.getLogger('.'.join((__name__,
self.__class__.__name__)))
QWidget.__init__(self)
self.setupUi(self)
self.setupUi_extra()
QObject.connect(self.cbxActive,SIGNAL("stateChanged(int)"),self.changeActive)
QObject.connect(self.cbxGraph,SIGNAL("stateChanged(int)"),self.changePage)
QObject.connect(self.canvas, SIGNAL( "keyPressed( QKeyEvent * )" ), self.pauseDisplay )
QObject.connect(self.plotSelector, SIGNAL( "currentIndexChanged ( int )" ), self.changePlot )
def setupUi_extra(self):
# checkboxes
#self.changeActive(Qt.Checked)
#set inactive by default - should save last state in user config
self.cbxActive.setCheckState(Qt.Unchecked)
# plot
self.plotSelector.setVisible( False )
self.cbxStats.setVisible( False )
self.graphControls.setVisible( False )
if self.hasqwt:
self.plotSelector.addItem( 'Qwt' )
if self.hasmpl:
self.plotSelector.addItem( 'mpl' )
self.plotSelector.setCurrentIndex( 0 );
if (not self.hasqwt or not self.hasmpl):
#self.plotSelector.setVisible(False)
self.plotSelector.setEnabled(False)
# Page 2 - qwt
if self.hasqwt:
self.qwtPlot = QwtPlot(self.stackedWidget)
self.qwtPlot.setAutoFillBackground(False)
self.qwtPlot.setObjectName("qwtPlot")
self.curve = QwtPlotCurve()
self.curve.setSymbol(
QwtSymbol(QwtSymbol.Ellipse,
QBrush(Qt.white),
QPen(Qt.red, 2),
QSize(9, 9)))
self.curve.attach(self.qwtPlot)
self.qwtPlot.setVisible(False)
else:
self.qwtPlot = QtGui.QLabel("Need Qwt >= 5.0 or matplotlib >= 1.0 !")
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.qwtPlot.sizePolicy().hasHeightForWidth())
self.qwtPlot.setSizePolicy(sizePolicy)
self.qwtPlot.setObjectName("qwtPlot")
self.qwtPlot.updateGeometry()
self.stackedWidget.addWidget(self.qwtPlot)
#Page 3 - matplotlib
self.mplLine = None #make sure to invalidate when layers change
if self.hasmpl:
# mpl stuff
# should make figure light gray
self.mplBackground = None #http://www.scipy.org/Cookbook/Matplotlib/Animations
self.mplFig = plt.Figure(facecolor='w', edgecolor='w')
self.mplFig.subplots_adjust(left=0.1, right=0.975, bottom=0.13, top=0.95)
self.mplPlt = self.mplFig.add_subplot(111)
self.mplPlt.tick_params(axis='both', which='major', labelsize=12)
self.mplPlt.tick_params(axis='both', which='minor', labelsize=10)
# qt stuff
self.pltCanvas = FigureCanvasQTAgg(self.mplFig)
self.pltCanvas.setParent(self.stackedWidget)
self.pltCanvas.setAutoFillBackground(False)
self.pltCanvas.setObjectName("mplPlot")
self.mplPlot = self.pltCanvas
self.mplPlot.setVisible(False)
else:
self.mplPlot = QtGui.QLabel("Need Qwt >= 5.0 or matplotlib >= 1.0 !")
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.mplPlot.sizePolicy().hasHeightForWidth())
self.mplPlot.setSizePolicy(sizePolicy)
self.qwtPlot.setObjectName("qwtPlot")
self.mplPlot.updateGeometry()
self.stackedWidget.addWidget(self.mplPlot)
#.........这里部分代码省略.........
示例2: ValueWidget
# 需要导入模块: from PyQt4.Qwt5 import QwtPlot [as 别名]
# 或者: from PyQt4.Qwt5.QwtPlot import sizePolicy [as 别名]
class ValueWidget(QWidget, Ui_Widget):
def __init__(self, iface):
self.hasqwt=hasqwt
self.hasmpl=hasmpl
self.layerMap=dict()
self.statsChecked=False
self.ymin=0
self.ymax=250
self.isActive=False
# Statistics (>=1.9)
self.statsSampleSize = 2500000
self.stats = {} # stats per layer
self.layersSelected=[]
self.layerBands=dict()
self.iface=iface
self.canvas=self.iface.mapCanvas
self.legend=self.iface.legendInterface()
self.logger = logging.getLogger('.'.join((__name__,
self.__class__.__name__)))
QWidget.__init__(self)
self.setupUi(self)
self.tabWidget.setEnabled(False)
self.cbxClick.setChecked( QSettings().value('plugins/valuetool/mouseClick', False, type=bool ) )
#self.setupUi_plot()
#don't setup plot until Plot tab is clicked - workaround for bug #7450
#qgis will still crash in some cases, but at least the tool can be used in Table mode
self.qwtPlot = None
self.mplPlot = None
self.mplLine = None
QObject.connect(self.plotSelector, SIGNAL( "currentIndexChanged ( int )" ), self.changePlot )
QObject.connect(self.tabWidget, SIGNAL( "currentChanged ( int )" ), self.tabWidgetChanged )
QObject.connect(self.cbxLayers, SIGNAL( "currentIndexChanged ( int )" ), self.updateLayers )
QObject.connect(self.cbxBands, SIGNAL( "currentIndexChanged ( int )" ), self.updateLayers )
QObject.connect(self.tableWidget2, SIGNAL("cellChanged ( int , int )"), self.layerSelected)
def setupUi_plot(self):
# plot
self.plotSelector.setVisible( False )
self.cbxStats.setVisible( False )
# stats by default because estimated are fast
self.cbxStats.setChecked( True )
self.plotSelector.addItem( 'Qwt' )
self.plotSelector.addItem( 'mpl' )
# Page 2 - qwt
if self.hasqwt:
self.qwtPlot = QwtPlot(self.stackedWidget)
self.qwtPlot.setAutoFillBackground(False)
self.qwtPlot.setObjectName("qwtPlot")
self.curve = QwtPlotCurve()
self.curve.setSymbol(
QwtSymbol(QwtSymbol.Ellipse,
QBrush(Qt.white),
QPen(Qt.red, 2),
QSize(9, 9)))
self.curve.attach(self.qwtPlot)
else:
self.qwtPlot = QtGui.QLabel("Need Qwt >= 5.0 or matplotlib >= 1.0 !")
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.qwtPlot.sizePolicy().hasHeightForWidth())
self.qwtPlot.setSizePolicy(sizePolicy)
self.qwtPlot.updateGeometry()
self.stackedWidget.addWidget(self.qwtPlot)
#Page 3 - matplotlib
self.mplLine = None #make sure to invalidate when layers change
if self.hasmpl:
# mpl stuff
# should make figure light gray
self.mplBackground = None #http://www.scipy.org/Cookbook/Matplotlib/Animations
self.mplFig = plt.Figure(facecolor='w', edgecolor='w')
self.mplFig.subplots_adjust(left=0.1, right=0.975, bottom=0.13, top=0.95)
self.mplPlt = self.mplFig.add_subplot(111)
self.mplPlt.tick_params(axis='both', which='major', labelsize=12)
self.mplPlt.tick_params(axis='both', which='minor', labelsize=10)
# qt stuff
self.pltCanvas = FigureCanvasQTAgg(self.mplFig)
self.pltCanvas.setParent(self.stackedWidget)
self.pltCanvas.setAutoFillBackground(False)
self.pltCanvas.setObjectName("mplPlot")
self.mplPlot = self.pltCanvas
else:
self.mplPlot = QtGui.QLabel("Need Qwt >= 5.0 or matplotlib >= 1.0 !")
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.mplPlot.sizePolicy().hasHeightForWidth())
#.........这里部分代码省略.........