本文整理汇总了Python中PyQt5.QtWidgets.QScrollArea.setSizePolicy方法的典型用法代码示例。如果您正苦于以下问题:Python QScrollArea.setSizePolicy方法的具体用法?Python QScrollArea.setSizePolicy怎么用?Python QScrollArea.setSizePolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QScrollArea
的用法示例。
在下文中一共展示了QScrollArea.setSizePolicy方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setSizePolicy [as 别名]
class Ui:
def __init__(self, app):
self._app = app
self._layout = QVBoxLayout(app)
self._bottom_layout = QHBoxLayout()
self._top_separator = Separator(parent=app)
self._splitter = QSplitter(app)
if use_mac_theme():
self._splitter.setHandleWidth(0)
# NOTE: 以位置命名的部件应该只用来组织界面布局,不要
# 给其添加任何功能性的函数
self.top_panel = TopPanel(app, app)
self._left_panel_container = QScrollArea(self._app)
self._left_panel_container.setWidgetResizable(True)
self.left_panel = LeftPanel(self._app, self._splitter)
self._left_panel_container.setWidget(self.left_panel)
self.right_panel = RightPanel(self._app, self._splitter)
# alias
self.pc_panel = self.top_panel.pc_panel
self.table_container = self.right_panel.table_container
self.magicbox = MagicBox(self._app)
# 对部件进行一些 UI 层面的初始化
self._splitter.addWidget(self._left_panel_container)
self._splitter.addWidget(self.right_panel)
self.right_panel.setMinimumWidth(780)
self._left_panel_container.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding)
self.right_panel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
if use_mac_theme():
self._layout.addWidget(self.magicbox)
self._layout.addWidget(self._splitter)
self._layout.addWidget(self._top_separator)
self._layout.addWidget(self.top_panel)
else:
self._layout.addWidget(self.top_panel)
self._layout.addWidget(self._top_separator)
self._layout.addWidget(self._splitter)
self._layout.addWidget(self.magicbox)
# self._layout.addLayout(self._bottom_layout)
# self._bottom_layout.addWidget(self.magicbox)
self._layout.setSpacing(0)
self._layout.setContentsMargins(0, 0, 0, 0)
self.top_panel.layout().setSpacing(0)
self.top_panel.layout().setContentsMargins(0, 0, 0, 0)
self.pc_panel.playlist_btn.clicked.connect(self.show_player_playlist)
self._app.hotkey_manager.registe(
[QKeySequence('Ctrl+F'), QKeySequence(':'), QKeySequence('Alt+x')],
self.magicbox.setFocus
)
def show_player_playlist(self):
songs = self._app.playlist.list()
self.table_container.show_player_playlist(songs)
示例2: SquidGui
# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setSizePolicy [as 别名]
class SquidGui( QMainWindow ):
defaults = {}
defaults.update(SquidAxon.defaults)
defaults.update(ClampCircuit.defaults)
defaults.update({'runtime': 50.0,
'simdt': 0.01,
'plotdt': 0.1,
'vclamp.holdingV': 0.0,
'vclamp.holdingT': 10.0,
'vclamp.prepulseV': 0.0,
'vclamp.prepulseT': 0.0,
'vclamp.clampV': 50.0,
'vclamp.clampT': 20.0,
'iclamp.baseI': 0.0,
'iclamp.firstI': 0.1,
'iclamp.firstT': 40.0,
'iclamp.firstD': 5.0,
'iclamp.secondI': 0.0,
'iclamp.secondT': 0.0,
'iclamp.secondD': 0.0
})
def __init__(self, *args):
QMainWindow.__init__(self, *args)
self.squid_setup = SquidSetup()
self._plotdt = SquidGui.defaults['plotdt']
self._plot_dict = defaultdict(list)
self.setWindowTitle('Squid Axon simulation')
self.setDockNestingEnabled(True)
self._createRunControl()
self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self._runControlDock)
self._runControlDock.setFeatures(QDockWidget.AllDockWidgetFeatures)
self._createChannelControl()
self._channelCtrlBox.setWindowTitle('Channel properties')
self._channelControlDock.setFeatures(QDockWidget.AllDockWidgetFeatures)
self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self._channelControlDock)
self._createElectronicsControl()
self._electronicsDock.setFeatures(QDockWidget.AllDockWidgetFeatures)
self._electronicsDock.setWindowTitle('Electronics')
self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self._electronicsDock)
self._createPlotWidget()
self.setCentralWidget(self._plotWidget)
self._createStatePlotWidget()
self._createHelpMessage()
self._helpWindow.setVisible(False)
self._statePlotWidget.setWindowFlags(QtCore.Qt.Window)
self._statePlotWidget.setWindowTitle('State plot')
self._initActions()
self._createRunToolBar()
self._createPlotToolBar()
def getFloatInput(self, widget, name):
try:
return float(str(widget.text()))
except ValueError:
QMessageBox.critical(self, 'Invalid input', 'Please enter a valid number for {}'.format(name))
raise
def _createPlotWidget(self):
self._plotWidget = QWidget()
self._plotFigure = Figure()
self._plotCanvas = FigureCanvas(self._plotFigure)
self._plotCanvas.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self._plotCanvas.updateGeometry()
self._plotCanvas.setParent(self._plotWidget)
self._plotCanvas.mpl_connect('scroll_event', self._onScroll)
self._plotFigure.set_canvas(self._plotCanvas)
# Vm and command voltage go in the same subplot
self._vm_axes = self._plotFigure.add_subplot(2,2,1, title='Membrane potential')
self._vm_axes.set_ylim(-20.0, 120.0)
# Channel conductances go to the same subplot
self._g_axes = self._plotFigure.add_subplot(2,2,2, title='Channel conductance')
self._g_axes.set_ylim(0.0, 0.5)
# Injection current for Vclamp/Iclamp go to the same subplot
self._im_axes = self._plotFigure.add_subplot(2,2,3, title='Injection current')
self._im_axes.set_ylim(-0.5, 0.5)
# Channel currents go to the same subplot
self._i_axes = self._plotFigure.add_subplot(2,2,4, title='Channel current')
self._i_axes.set_ylim(-10, 10)
for axis in self._plotFigure.axes:
axis.set_autoscale_on(False)
layout = QVBoxLayout()
layout.addWidget(self._plotCanvas)
self._plotNavigator = NavigationToolbar(self._plotCanvas, self._plotWidget)
layout.addWidget(self._plotNavigator)
self._plotWidget.setLayout(layout)
def _createStatePlotWidget(self):
self._statePlotWidget = QWidget()
self._statePlotFigure = Figure()
self._statePlotCanvas = FigureCanvas(self._statePlotFigure)
self._statePlotCanvas.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self._statePlotCanvas.updateGeometry()
self._statePlotCanvas.setParent(self._statePlotWidget)
self._statePlotFigure.set_canvas(self._statePlotCanvas)
self._statePlotFigure.subplots_adjust(hspace=0.5)
self._statePlotAxes = self._statePlotFigure.add_subplot(2,1,1, title='State plot')
self._state_plot, = self._statePlotAxes.plot([], [], label='state')
self._activationParamAxes = self._statePlotFigure.add_subplot(2,1,2, title='H-H activation parameters vs time')
self._activationParamAxes.set_xlabel('Time (ms)')
#.........这里部分代码省略.........
示例3: SearchReplaceSlidingWidget
# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setSizePolicy [as 别名]
class SearchReplaceSlidingWidget(QWidget):
"""
Class implementing the search and replace widget with sliding behavior.
@signal searchListChanged() emitted to indicate a change of the search list
"""
searchListChanged = pyqtSignal()
def __init__(self, replace, vm, parent=None):
"""
Constructor
@param replace flag indicating a replace widget is called
@param vm reference to the viewmanager object
@param parent parent widget of this widget (QWidget)
"""
super(SearchReplaceSlidingWidget, self).__init__(parent)
self.__searchReplaceWidget = \
SearchReplaceWidget(replace, vm, self, True)
self.__layout = QHBoxLayout(self)
self.setLayout(self.__layout)
self.__layout.setContentsMargins(0, 0, 0, 0)
self.__layout.setAlignment(Qt.AlignTop)
self.__leftButton = QToolButton(self)
self.__leftButton.setArrowType(Qt.LeftArrow)
self.__leftButton.setSizePolicy(
QSizePolicy.Minimum, QSizePolicy.MinimumExpanding)
self.__leftButton.setAutoRepeat(True)
self.__scroller = QScrollArea(self)
self.__scroller.setWidget(self.__searchReplaceWidget)
self.__scroller.setSizePolicy(
QSizePolicy.Expanding, QSizePolicy.Minimum)
self.__scroller.setFrameShape(QFrame.NoFrame)
self.__scroller.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.__scroller.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.__scroller.setWidgetResizable(False)
self.__rightButton = QToolButton(self)
self.__rightButton.setArrowType(Qt.RightArrow)
self.__rightButton.setSizePolicy(
QSizePolicy.Minimum, QSizePolicy.MinimumExpanding)
self.__rightButton.setAutoRepeat(True)
self.__layout.addWidget(self.__leftButton)
self.__layout.addWidget(self.__scroller)
self.__layout.addWidget(self.__rightButton)
self.setMaximumHeight(self.__searchReplaceWidget.sizeHint().height())
self.adjustSize()
self.__searchReplaceWidget.searchListChanged.connect(
self.searchListChanged)
self.__leftButton.clicked.connect(self.__slideLeft)
self.__rightButton.clicked.connect(self.__slideRight)
def changeEvent(self, evt):
"""
Protected method handling state changes.
@param evt event containing the state change (QEvent)
"""
if evt.type() == QEvent.FontChange:
self.setMaximumHeight(
self.__searchReplaceWidget.sizeHint().height())
self.adjustSize()
def findNext(self):
"""
Public slot to find the next occurrence of text.
"""
self.__searchReplaceWidget.findNext()
def findPrev(self):
"""
Public slot to find the next previous of text.
"""
self.__searchReplaceWidget.findPrev()
def selectionChanged(self):
"""
Public slot tracking changes of selected text.
"""
editor = self.sender()
self.__searchReplaceWidget.updateSelectionCheckBox(editor)
@pyqtSlot(Editor)
def updateSelectionCheckBox(self, editor):
"""
Public slot to update the selection check box.
@param editor reference to the editor (Editor)
"""
self.__searchReplaceWidget.updateSelectionCheckBox(editor)
def show(self, text=''):
"""
#.........这里部分代码省略.........
示例4: MainWindow
# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setSizePolicy [as 别名]
class MainWindow(QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
centralWidget = QWidget()
self.setCentralWidget(centralWidget)
self.glWidget = GLWidget()
self.pixmapLabel = QLabel()
self.glWidgetArea = QScrollArea()
self.glWidgetArea.setWidget(self.glWidget)
self.glWidgetArea.setWidgetResizable(True)
self.glWidgetArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.glWidgetArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.glWidgetArea.setSizePolicy(QSizePolicy.Ignored,
QSizePolicy.Ignored)
self.glWidgetArea.setMinimumSize(50, 50)
self.pixmapLabelArea = QScrollArea()
self.pixmapLabelArea.setWidget(self.pixmapLabel)
self.pixmapLabelArea.setSizePolicy(QSizePolicy.Ignored,
QSizePolicy.Ignored)
self.pixmapLabelArea.setMinimumSize(50, 50)
xSlider = self.createSlider(self.glWidget.xRotationChanged,
self.glWidget.setXRotation)
ySlider = self.createSlider(self.glWidget.yRotationChanged,
self.glWidget.setYRotation)
zSlider = self.createSlider(self.glWidget.zRotationChanged,
self.glWidget.setZRotation)
self.createActions()
self.createMenus()
centralLayout = QGridLayout()
centralLayout.addWidget(self.glWidgetArea, 0, 0)
centralLayout.addWidget(self.pixmapLabelArea, 0, 1)
centralLayout.addWidget(xSlider, 1, 0, 1, 2)
centralLayout.addWidget(ySlider, 2, 0, 1, 2)
centralLayout.addWidget(zSlider, 3, 0, 1, 2)
centralWidget.setLayout(centralLayout)
xSlider.setValue(15 * 16)
ySlider.setValue(345 * 16)
zSlider.setValue(0 * 16)
self.setWindowTitle("Grabber")
self.resize(400, 300)
def grabFrameBuffer(self):
image = self.glWidget.grabFramebuffer()
self.setPixmap(QPixmap.fromImage(image))
def clearPixmap(self):
self.setPixmap(QPixmap())
def about(self):
QMessageBox.about(self, "About Grabber",
"The <b>Grabber</b> example demonstrates two approaches for "
"rendering OpenGL into a Qt pixmap.")
def createActions(self):
self.grabFrameBufferAct = QAction("&Grab Frame Buffer", self,
shortcut="Ctrl+G", triggered=self.grabFrameBuffer)
self.clearPixmapAct = QAction("&Clear Pixmap", self,
shortcut="Ctrl+L", triggered=self.clearPixmap)
self.exitAct = QAction("E&xit", self, shortcut="Ctrl+Q",
triggered=self.close)
self.aboutAct = QAction("&About", self, triggered=self.about)
self.aboutQtAct = QAction("About &Qt", self,
triggered=QApplication.instance().aboutQt)
def createMenus(self):
self.fileMenu = self.menuBar().addMenu("&File")
self.fileMenu.addAction(self.grabFrameBufferAct)
self.fileMenu.addAction(self.clearPixmapAct)
self.fileMenu.addSeparator()
self.fileMenu.addAction(self.exitAct)
self.helpMenu = self.menuBar().addMenu("&Help")
self.helpMenu.addAction(self.aboutAct)
self.helpMenu.addAction(self.aboutQtAct)
def createSlider(self, changedSignal, setterSlot):
slider = QSlider(Qt.Horizontal)
slider.setRange(0, 360 * 16)
slider.setSingleStep(16)
slider.setPageStep(15 * 16)
slider.setTickInterval(15 * 16)
slider.setTickPosition(QSlider.TicksRight)
slider.valueChanged.connect(setterSlot)
changedSignal.connect(slider.setValue)
return slider
#.........这里部分代码省略.........
示例5: UIPreviewer
# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setSizePolicy [as 别名]
class UIPreviewer(E5MainWindow):
"""
Class implementing the UI Previewer main window.
"""
def __init__(self, filename=None, parent=None, name=None):
"""
Constructor
@param filename name of a UI file to load
@param parent parent widget of this window (QWidget)
@param name name of this window (string)
"""
self.mainWidget = None
self.currentFile = QDir.currentPath()
super(UIPreviewer, self).__init__(parent)
if not name:
self.setObjectName("UIPreviewer")
else:
self.setObjectName(name)
self.setStyle(Preferences.getUI("Style"),
Preferences.getUI("StyleSheet"))
self.resize(QSize(600, 480).expandedTo(self.minimumSizeHint()))
self.statusBar()
self.setWindowIcon(UI.PixmapCache.getIcon("eric.png"))
self.setWindowTitle(self.tr("UI Previewer"))
self.cw = QWidget(self)
self.cw.setObjectName("centralWidget")
self.UIPreviewerLayout = QVBoxLayout(self.cw)
self.UIPreviewerLayout.setContentsMargins(6, 6, 6, 6)
self.UIPreviewerLayout.setSpacing(6)
self.UIPreviewerLayout.setObjectName("UIPreviewerLayout")
self.styleLayout = QHBoxLayout()
self.styleLayout.setContentsMargins(0, 0, 0, 0)
self.styleLayout.setSpacing(6)
self.styleLayout.setObjectName("styleLayout")
self.styleLabel = QLabel(self.tr("Select GUI Theme"), self.cw)
self.styleLabel.setObjectName("styleLabel")
self.styleLayout.addWidget(self.styleLabel)
self.styleCombo = QComboBox(self.cw)
self.styleCombo.setObjectName("styleCombo")
self.styleCombo.setEditable(False)
self.styleCombo.setToolTip(self.tr("Select the GUI Theme"))
self.styleLayout.addWidget(self.styleCombo)
self.styleCombo.addItems(sorted(QStyleFactory().keys()))
currentStyle = Preferences.Prefs.settings.value('UIPreviewer/style')
if currentStyle is not None:
self.styleCombo.setCurrentIndex(int(currentStyle))
styleSpacer = QSpacerItem(
40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
self.styleLayout.addItem(styleSpacer)
self.UIPreviewerLayout.addLayout(self.styleLayout)
self.previewSV = QScrollArea(self.cw)
self.previewSV.setObjectName("preview")
self.previewSV.setFrameShape(QFrame.NoFrame)
self.previewSV.setFrameShadow(QFrame.Plain)
self.previewSV.setSizePolicy(
QSizePolicy.Expanding, QSizePolicy.Expanding)
self.UIPreviewerLayout.addWidget(self.previewSV)
self.setCentralWidget(self.cw)
self.styleCombo.activated[str].connect(self.__guiStyleSelected)
self.__initActions()
self.__initMenus()
self.__initToolbars()
self.__updateActions()
# defere loading of a UI file until we are shown
self.fileToLoad = filename
def show(self):
"""
Public slot to show this dialog.
This overloaded slot loads a UI file to be previewed after
the main window has been shown. This way, previewing a dialog
doesn't interfere with showing the main window.
"""
super(UIPreviewer, self).show()
if self.fileToLoad is not None:
fn, self.fileToLoad = (self.fileToLoad, None)
self.__loadFile(fn)
def __initActions(self):
"""
Private method to define the user interface actions.
"""
#.........这里部分代码省略.........
示例6: __init__
# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setSizePolicy [as 别名]
def __init__(self, *args, **kwargs):
super(ShortcutManagerDlg, self).__init__(*args, **kwargs)
self.setWindowTitle("Shortcut Preferences")
self.setMinimumWidth(500)
self.setMinimumHeight(500)
mgr = ShortcutManager() # Singleton
scrollWidget = QWidget(parent=self)
tempLayout = QVBoxLayout(scrollWidget)
scrollWidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
treeWidget = QTreeWidget(parent=scrollWidget)
treeWidget.setHeaderLabels(["Action", "Shortcut"])
treeWidget.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
treeWidget.setColumnWidth(0, 300)
treeWidget.setColumnWidth(1, 50)
action_descriptions = mgr.get_all_action_descriptions()
target_keyseqs = mgr.get_keyseq_reversemap()
# Create a LineEdit for each shortcut,
# and keep track of them in a dict
shortcutEdits = collections.OrderedDict()
for group, targets in list(action_descriptions.items()):
groupItem = QTreeWidgetItem(treeWidget, [group])
for (name, description) in targets:
edit = QLineEdit(target_keyseqs[(group, name)])
shortcutEdits[(group, name)] = edit
item = QTreeWidgetItem(groupItem, [description])
item.setText(0, description)
treeWidget.setItemWidget(item, 1, edit)
tempLayout.addWidget(treeWidget)
# Add ok and cancel buttons
buttonLayout = QHBoxLayout()
cancelButton = QPushButton("Cancel")
cancelButton.clicked.connect(self.reject)
okButton = QPushButton("OK")
okButton.clicked.connect(self.accept)
okButton.setDefault(True)
buttonLayout.addSpacerItem(QSpacerItem(10, 0, QSizePolicy.Expanding))
buttonLayout.addWidget(cancelButton)
buttonLayout.addWidget(okButton)
tempLayout.addLayout(buttonLayout)
scroll = QScrollArea(parent=self)
scroll.setWidget(scrollWidget)
scroll.setWidgetResizable(True)
scroll.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
dlgLayout = QVBoxLayout()
dlgLayout.addWidget(scroll)
self.setLayout(dlgLayout)
# Show the window
result = self.exec_()
# Did the user hit 'cancel'?
if result != QDialog.Accepted:
return
for (group, name), edit in list(shortcutEdits.items()):
oldKey = target_keyseqs[(group, name)]
newKey = str(edit.text())
if oldKey.lower() != newKey.lower() and newKey != "":
mgr.change_keyseq(group, name, oldKey, newKey)
mgr.store_to_preferences()
示例7: MainWindow
# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setSizePolicy [as 别名]
class MainWindow(QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
centralWidget = QWidget()
self.setCentralWidget(centralWidget)
self.glWidget = GLWidget()
self.pixmapLabel = QLabel()
self.glWidgetArea = QScrollArea()
self.glWidgetArea.setWidget(self.glWidget)
self.glWidgetArea.setWidgetResizable(True)
self.glWidgetArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.glWidgetArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.glWidgetArea.setSizePolicy(QSizePolicy.Ignored,
QSizePolicy.Ignored)
self.glWidgetArea.setMinimumSize(50, 50)
self.pixmapLabelArea = QScrollArea()
self.pixmapLabelArea.setWidget(self.pixmapLabel)
self.pixmapLabelArea.setSizePolicy(QSizePolicy.Ignored,
QSizePolicy.Ignored)
self.pixmapLabelArea.setMinimumSize(50, 50)
xSlider = self.createSlider(self.glWidget.xRotationChanged,
self.glWidget.setXRotation)
ySlider = self.createSlider(self.glWidget.yRotationChanged,
self.glWidget.setYRotation)
zSlider = self.createSlider(self.glWidget.zRotationChanged,
self.glWidget.setZRotation)
self.createActions()
self.createMenus()
centralLayout = QGridLayout()
centralLayout.addWidget(self.glWidgetArea, 0, 0)
centralLayout.addWidget(self.pixmapLabelArea, 0, 1)
centralLayout.addWidget(xSlider, 1, 0, 1, 2)
centralLayout.addWidget(ySlider, 2, 0, 1, 2)
centralLayout.addWidget(zSlider, 3, 0, 1, 2)
centralWidget.setLayout(centralLayout)
xSlider.setValue(15 * 16)
ySlider.setValue(345 * 16)
zSlider.setValue(0 * 16)
self.setWindowTitle("Grabber")
self.resize(400, 300)
def renderIntoPixmap(self):
size = self.getSize()
if size.isValid():
pixmap = self.glWidget.renderPixmap(size.width(), size.height())
self.setPixmap(pixmap)
def grabFrameBuffer(self):
image = self.glWidget.grabFrameBuffer()
self.setPixmap(QPixmap.fromImage(image))
def clearPixmap(self):
self.setPixmap(QPixmap())
def about(self):
QMessageBox.about(self, "About Grabber",
"The <b>Grabber</b> example demonstrates two approaches for "
"rendering OpenGL into a Qt pixmap.")
def createActions(self):
self.renderIntoPixmapAct = QAction("&Render into Pixmap...",
self, shortcut="Ctrl+R", triggered=self.renderIntoPixmap)
self.grabFrameBufferAct = QAction("&Grab Frame Buffer", self,
shortcut="Ctrl+G", triggered=self.grabFrameBuffer)
self.clearPixmapAct = QAction("&Clear Pixmap", self,
shortcut="Ctrl+L", triggered=self.clearPixmap)
self.exitAct = QAction("E&xit", self, shortcut="Ctrl+Q",
triggered=self.close)
self.aboutAct = QAction("&About", self, triggered=self.about)
self.aboutQtAct = QAction("About &Qt", self,
triggered=QApplication.instance().aboutQt)
def createMenus(self):
self.fileMenu = self.menuBar().addMenu("&File")
self.fileMenu.addAction(self.renderIntoPixmapAct)
self.fileMenu.addAction(self.grabFrameBufferAct)
self.fileMenu.addAction(self.clearPixmapAct)
self.fileMenu.addSeparator()
self.fileMenu.addAction(self.exitAct)
self.helpMenu = self.menuBar().addMenu("&Help")
self.helpMenu.addAction(self.aboutAct)
self.helpMenu.addAction(self.aboutQtAct)
def createSlider(self, changedSignal, setterSlot):
#.........这里部分代码省略.........
示例8: __initUI__
# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setSizePolicy [as 别名]
#.........这里部分代码省略.........
self.QRAS_max = QDoubleSpinBox(40)
self.QRAS_max.setRange(0, 999)
# Runoff coefficient (Cro) :
self.CRO_min = QDoubleSpinBox(0.1, 3)
self.CRO_min.setRange(0, 1)
self.CRO_max = QDoubleSpinBox(0.3, 3)
self.CRO_max.setRange(0, 1)
# Snowmelt parameters :
# units=' °C'
self._Tmelt = QDoubleSpinBox(0, 1)
self._Tmelt.setRange(-25, 25)
# units=' mm/°C'
self._CM = QDoubleSpinBox(4, 1, 0.1, )
self._CM.setRange(0.1, 100)
# units=' days'
self._deltaT = QDoubleSpinBox(0, 0, )
self._deltaT.setRange(0, 999)
class QLabelCentered(QLabel):
def __init__(self, text):
super(QLabelCentered, self).__init__(text)
self.setAlignment(Qt.AlignCenter)
# ---- Parameters
params_group = QFrameLayout()
params_group.setContentsMargins(10, 5, 10, 0) # (L, T, R, B)
params_group.setObjectName("viewport")
params_group.setStyleSheet("#viewport {background-color:transparent;}")
row = 0
params_group.addWidget(QLabel('Sy :'), row, 0)
params_group.addWidget(self.QSy_min, row, 1)
params_group.addWidget(QLabelCentered('to'), row, 2)
params_group.addWidget(self.QSy_max, row, 3)
row += 1
params_group.addWidget(QLabel('RAS<sub>max</sub> :'), row, 0)
params_group.addWidget(self.QRAS_min, row, 1)
params_group.addWidget(QLabelCentered('to'), row, 2)
params_group.addWidget(self.QRAS_max, row, 3)
params_group.addWidget(QLabel('mm'), row, 4)
row += 1
params_group.addWidget(QLabel('Cro :'), row, 0)
params_group.addWidget(self.CRO_min, row, 1)
params_group.addWidget(QLabelCentered('to'), row, 2)
params_group.addWidget(self.CRO_max, row, 3)
row += 1
params_group.setRowMinimumHeight(row, 10)
row += 1
params_group.addWidget(QLabel('Tmelt :'), row, 0)
params_group.addWidget(self._Tmelt, row, 1)
params_group.addWidget(QLabel('°C'), row, 2, 1, 3)
row += 1
params_group.addWidget(QLabel('CM :'), row, 0)
params_group.addWidget(self._CM, row, 1)
params_group.addWidget(QLabel('mm/°C'), row, 2, 1, 3)
row += 1
params_group.addWidget(QLabel('deltaT :'), row, 0)
params_group.addWidget(self._deltaT, row, 1)
params_group.addWidget(QLabel('days'), row, 2, 1, 3)
row += 1
params_group.setRowStretch(row, 100)
params_group.setColumnStretch(5, 100)
# ---- Layout ----
qtitle = QLabel('Parameter Range')
qtitle.setAlignment(Qt.AlignCenter)
sa = QScrollArea()
sa.setWidget(params_group)
sa.setWidgetResizable(True)
sa.setFrameStyle(0)
sa.setStyleSheet("QScrollArea {background-color:transparent;}")
sa.setSizePolicy(QSizePolicy(QSizePolicy.Ignored,
QSizePolicy.Preferred))
# ---- Main Layout
self.addWidget(qtitle, 0, 0)
self.addWidget(HSep(), 1, 0)
self.addWidget(sa, 2, 0)
self.addWidget(HSep(), 3, 0)
self.setRowMinimumHeight(4, 5)
self.addWidget(self.setup_toolbar(), 5, 0)
self.setRowStretch(2, 100)
self.setVerticalSpacing(5)
self.setContentsMargins(0, 0, 0, 10) # (L, T, R, B)