本文整理汇总了Python中PyQt5.QtWidgets.QSplitter.setFocus方法的典型用法代码示例。如果您正苦于以下问题:Python QSplitter.setFocus方法的具体用法?Python QSplitter.setFocus怎么用?Python QSplitter.setFocus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QSplitter
的用法示例。
在下文中一共展示了QSplitter.setFocus方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import setFocus [as 别名]
def __init__(self, parent=None):
super(QMainWindow,self).__init__()
#---------------------------------------------------------------
statusWin = QLabel(self)
#statusWin = QPlainTextEdit(self) # status window
#statusWin.appendHtml("<b>hallo<br>hallo2<br>hallo3</b>")
tabWin = TabWidgets(self) # tabbed window
print('hint status win: {0}'.format(statusWin.sizeHint()))
print('hint_tab win: {0}'.format(tabWin.sizeHint()))
print('hint main win: {0}'.format(self.sizeHint()))
mSize = QFontMetrics(statusWin.font())
rowHt = mSize.lineSpacing()
# fixed height for statusWin needed as the sizeHint of tabWin is very small
#statusWin.setFixedHeight(4*rowHt+4)
# add status window underneath plot Tab Widgets:
spltVMain = QSplitter(QtCore.Qt.Vertical)
spltVMain.addWidget(tabWin)
spltVMain.addWidget(statusWin)
# relative initial sizes of subwidgets, this doesn't work here
# spltVMain.setStretchFactor(4,1)
spltVMain.setSizes([statusWin.sizeHint().height()*2, statusWin.sizeHint().height()*0.05])
spltVMain.setFocus()
# make spltVMain occupy the main area of QMainWindow and set inheritance
self.setCentralWidget(spltVMain)
print('size tabs: {0}'.format(tabWin.size()))
print('size status: {0}'.format(statusWin.size()))
print('size self: {0}'.format(self.size()))
示例2: RGui
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import setFocus [as 别名]
class RGui(QMainWindow):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
# Main window set up
self.setAttribute(Qt.WA_DeleteOnClose)
self.setWindowTitle("RGui")
# File menu
self.fileMenu = self.menuBar().addMenu('&File')
self.fileMenu.addAction('&Open', self.openFile,
Qt.CTRL + Qt.Key_O)
self.fileMenu.addAction('&Save figure', self.saveFigure,
Qt.SHIFT + Qt.CTRL + Qt.Key_S)
# Main widget and its layout
# subWidget is embedded in the right half of mainWidget
self.mainWidget = QSplitter(Qt.Horizontal, self)
self.subWidget = QSplitter(Qt.Vertical, self)
# Plot canvas set up, added to layout
self.canvas = CanvasWidget(self,
width = 10, height = 8, dpi = 100)
# Set up the control panel
self.ctrPane = QTabWidget(self)
self.initCtrPane()
# List widget embedded in Tab widget
self.selectPane = QTabWidget(self.subWidget)
listWidget = QListWidget(self.selectPane)
listWidget.setSelectionMode(QAbstractItemView.ExtendedSelection)
self.selectPane.addTab(listWidget, 'Untitled')
self.firstPlot = True
self.spec = []
# Set up the layouts
self.mainWidget.addWidget(self.canvas)
self.subWidget.addWidget(self.ctrPane)
self.subWidget.addWidget(self.selectPane)
self.mainWidget.addWidget(self.subWidget)
# Set up the MainWindow
self.mainWidget.setFocus()
self.setCentralWidget(self.mainWidget)
self.setGeometry(300, 300, 500, 400)
self.statusBar()
def initCtrPane(self):
# main control set up
mainCtr = QFrame(self.ctrPane)
mainCtr.setFrameShape(QFrame.StyledPanel)
mainCtr.setFrameShadow(QFrame.Sunken)
# buttons and controls
backSubButton = QPushButton('Background Subtraction', mainCtr)
backSubButton.clicked.connect(self.backSub)
plotButton = QPushButton('Plot', mainCtr)
plotButton.clicked.connect(self.updatePlot1)
newTabButton = QPushButton('New tab', mainCtr)
newTabButton.clicked.connect(self.addTab)
self.plotPeak = QCheckBox('Plot fitted peak', mainCtr)
holdPlot = QCheckBox('Hold plot', mainCtr)
holdPlot.stateChanged.connect(self.canvas.toggleHold)
# layout
mainLayout = QGridLayout(mainCtr)
mainLayout.addWidget(backSubButton, 0, 0)
mainLayout.addWidget(plotButton, 0, 1)
mainLayout.addWidget(newTabButton, 1, 0)
mainLayout.addWidget(self.plotPeak, 2, 0)
mainLayout.addWidget(holdPlot, 2, 1)
mainCtr.setLayout(mainLayout)
self.ctrPane.addTab(mainCtr, 'Main Control')
# NMF control set up
NMFCtr = QFrame(self.ctrPane)
NMFCtr.setFrameShape(QFrame.StyledPanel)
NMFCtr.setFrameShadow(QFrame.Sunken)
# input & buttons
self.alphaBox = MyDoubleBox(NMFCtr)
self.l1RatioBox = MyDoubleBox(NMFCtr)
self.loadSettings()
NMFButton = QPushButton('NMF', NMFCtr)
NMFButton.clicked.connect(self.NMF)
# layout
NMFLayout = QGridLayout(NMFCtr)
NMFLayout.addWidget(QLabel('α'), 0, 0)
NMFLayout.addWidget(QLabel('l1 ratio'), 1, 0)
NMFLayout.addWidget(self.alphaBox, 0, 1)
NMFLayout.addWidget(self.l1RatioBox, 1, 1)
NMFLayout.addWidget(NMFButton, 2, 0, 1, 2)
NMFCtr.setLayout(NMFLayout)
self.ctrPane.addTab(NMFCtr, 'NMF Control')
# slots
#.........这里部分代码省略.........