本文整理汇总了Python中PySide.QtGui.QComboBox.setSizePolicy方法的典型用法代码示例。如果您正苦于以下问题:Python QComboBox.setSizePolicy方法的具体用法?Python QComboBox.setSizePolicy怎么用?Python QComboBox.setSizePolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QComboBox
的用法示例。
在下文中一共展示了QComboBox.setSizePolicy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ExposureControl
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setSizePolicy [as 别名]
class ExposureControl(QWidget):
class Mode(Enum):
AUTO = 1
TV = 2
AV = 4
MANUAL = 8
def __or__(self, other):
return self.value | other.value
def __init__(self, camera):
super(ExposureControl, self).__init__()
self.camera = camera
self.initUI()
def initUI(self):
layout = QGridLayout()
title = QLabel("Exposure")
title.setAlignment(Qt.AlignCenter)
layout.addWidget(title, 0, 0, 1, 4)
btnAuto = OptionButton()
btnAuto.setText("Full Auto")
_safelyConnect(btnAuto.clicked, self.camera.setAutoExposure)
btnAuto.setChecked(True)
layout.addWidget(btnAuto, 1, 0)
btnTV = OptionButton()
btnTV.setText("Tv")
_safelyConnect(btnTV.clicked, self.camera.setShutterPriority)
layout.addWidget(btnTV, 1, 1)
btnAV = OptionButton()
btnAV.setText("Av")
_safelyConnect(btnAV.clicked, self.camera.setAperturePriority)
layout.addWidget(btnAV, 1, 2)
btnManual = OptionButton()
btnManual.setText("M")
_safelyConnect(btnManual.clicked, self.camera.setManualExposure)
layout.addWidget(btnManual, 1, 3)
layout.addWidget(QLabel("Aperture"), 2, 0)
self.aperture = QComboBox(self)
for a in list(Aperture):
self.aperture.addItem(a.label, userData=a)
self.aperture.currentIndexChanged.connect(self.setAperture)
self.aperture.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.aperture.setEnabled(False)
layout.addWidget(self.aperture, 2, 1, 1, 3)
layout.addWidget(QLabel("Shutter"), 3, 0)
self.shutter = QComboBox(self)
for s in list(Shutter):
self.shutter.addItem(s.label, userData=s)
self.shutter.currentIndexChanged.connect(self.setShutter)
self.shutter.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.shutter.setEnabled(False)
layout.addWidget(self.shutter, 3, 1, 1, 3)
layout.addWidget(QLabel("Gain"), 4, 0)
self.gain = QComboBox(self)
for g in list(Gain):
self.gain.addItem(g.label, userData=g)
self.gain.currentIndexChanged.connect(self.setGain)
self.gain.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.gain.setEnabled(False)
layout.addWidget(self.gain, 4, 1, 1, 3)
self.exposureButtons = QButtonGroup()
self.exposureButtons.addButton(btnAuto, self.Mode.AUTO.value)
self.exposureButtons.addButton(btnTV, self.Mode.TV.value)
self.exposureButtons.addButton(btnAV, self.Mode.AV.value)
self.exposureButtons.addButton(btnManual, self.Mode.MANUAL.value)
self.exposureButtons.buttonClicked.connect(self.onExposureMethodSelected)
layout.setRowStretch(0, 0)
layout.setRowStretch(1, 1)
layout.setRowStretch(2, 1)
layout.setRowStretch(3, 1)
layout.setRowStretch(4, 1)
self.setLayout(layout)
def onExposureMethodSelected(self):
checked = self.exposureButtons.checkedId()
self.aperture.setEnabled(checked & (self.Mode.MANUAL | self.Mode.AV))
#.........这里部分代码省略.........
示例2: ConsoleWidget
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setSizePolicy [as 别名]
class ConsoleWidget(QMainWindow):
def __init__(self):
super(ConsoleWidget, self).__init__()
self.setWindowTitle('1c query')
self._connection = None
self._home = os.path.expanduser('~/%s' % QApplication.applicationName())
if not os.path.isdir(self._home):
os.mkdir(self._home)
self.queryToolBar = self.addToolBar('Query')
self.queryAction = self.queryToolBar.addAction('Run', self.executeQuery)
self.queryAction.setDisabled(True)
uri_history = list()
path = os.path.join(self._home, 'uri_history.txt')
if os.path.isfile(path):
uri_history = open(path, 'r').read().split('\n')
self.connectionToolBar = self.addToolBar('Connection')
self.connectionUriCombo = QComboBox(self)
self.connectionUriCombo.setEditable(True)
if not uri_history:
self.connectionUriCombo.addItem('File="";usr="";pwd="";')
self.connectionUriCombo.addItem('Srvr="{host}";Ref="{ref}";Usr="{user}";Pwd="{password}";')
else:
self.connectionUriCombo.addItems(uri_history)
self.connectionUriCombo.setCurrentIndex(len(uri_history) - 1)
self.connectionUriCombo.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Maximum)
self.connectionToolBar.addWidget(self.connectionUriCombo)
self.onesVersionCombo = QComboBox(self)
self.onesVersionCombo.addItems(['8.3', '8.2', '8.1', '8.0'])
self.onesVersionCombo.setCurrentIndex(0)
self.connectionToolBar.addWidget(self.onesVersionCombo)
self.connectAction = self.connectionToolBar.addAction('Connect', self.connectOneS)
self.disconnectAction = self.connectionToolBar.addAction('Disconnect', self.disconnectOneS)
self.disconnectAction.setDisabled(True)
self.logEdit = QPlainTextEdit(self)
self.logDock = QDockWidget('Log', self)
self.logDock.setWidget(self.logEdit)
self.addDockWidget(Qt.BottomDockWidgetArea, self.logDock, Qt.Horizontal)
self.splitter = QSplitter(Qt.Vertical, self)
self.setCentralWidget(self.splitter)
self.sqlEdit = QTextEdit(self)
self.sqlEdit.setLineWrapMode(QTextEdit.NoWrap)
path = os.path.join(self._home, 'last-sql.txt')
if os.path.isfile(path):
sql = open(path, 'r').read()
self.sqlEdit.setText(sql)
self.model = QStandardItemModel(self)
self.tableView = QTableView(self)
self.tableView.setModel(self.model)
self.splitter.addWidget(self.sqlEdit)
self.splitter.addWidget(self.tableView)
self.splitter.setStretchFactor(0, 3)
self.splitter.setStretchFactor(1, 2)
def query(self, sql):
if not self._connection:
self.logEdit.appendPlainText('No connection')
return None
try:
query = self._connection.NewObject('Query', sql)
result = query.Execute()
except Exception as e:
self.logEdit.appendPlainText(str(e))
return None
return result
def refresh(self, result):
self.model.clear()
columns = list()
result_columns = result.Columns
for index in range(result_columns.Count()):
name = result_columns.Get(index).Name
columns.append(name)
self.model.setColumnCount(len(columns))
for section, name in enumerate(columns):
self.model.setHeaderData(section, Qt.Horizontal, name)
select = result.Choose()
self.logEdit.appendPlainText('Selected %d records' % select.Count())
while select.Next():
items = list()
for index in range(len(columns)):
value = select.Get(index)
item = QStandardItem('')
#.........这里部分代码省略.........