本文整理汇总了Python中PyQt5.QtWidgets.QTextBrowser.setSizePolicy方法的典型用法代码示例。如果您正苦于以下问题:Python QTextBrowser.setSizePolicy方法的具体用法?Python QTextBrowser.setSizePolicy怎么用?Python QTextBrowser.setSizePolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QTextBrowser
的用法示例。
在下文中一共展示了QTextBrowser.setSizePolicy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Window
# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import setSizePolicy [as 别名]
class Window(QWidget):
def __init__(self, parent=None):
super(Window, self).__init__(parent)
model = FileListModel(self)
model.setDirPath(QLibraryInfo.location(QLibraryInfo.PrefixPath))
label = QLabel("Directory")
lineEdit = QLineEdit()
label.setBuddy(lineEdit)
view = QListView()
view.setModel(model)
self.logViewer = QTextBrowser()
self.logViewer.setSizePolicy(QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
lineEdit.textChanged.connect(model.setDirPath)
lineEdit.textChanged.connect(self.logViewer.clear)
model.numberPopulated.connect(self.updateLog)
layout = QGridLayout()
layout.addWidget(label, 0, 0)
layout.addWidget(lineEdit, 0, 1)
layout.addWidget(view, 1, 0, 1, 2)
layout.addWidget(self.logViewer, 2, 0, 1, 2)
self.setLayout(layout)
self.setWindowTitle("Fetch More Example")
def updateLog(self, number):
self.logViewer.append("%d items added." % number)
示例2: add_text
# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import setSizePolicy [as 别名]
def add_text(self):
self.process_text()
text = QTextBrowser()
text.setHtml(self.text)
text.setOpenLinks(False)
# text.moveCursor(QTextCursor.End)
text.setMinimumWidth(500)
text.setMaximumWidth(500)
text.document().setTextWidth(500)
text.setMinimumHeight((text.document().size().height())+5)
text.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
text.anchorClicked.connect(self.link_clicked)
self.lay.addWidget(text, 1, 1, 1, 3)
示例3: Article
# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import setSizePolicy [as 别名]
class Article(QDialog):
def __init__(self, listIndexArticle, articleList, parentW=None, shuffle_=False):
super(Article, self).__init__()
self.parentW = parentW
self.articleList = articleList
if shuffle_ == True:
shuffle(self.articleList)
self.articleId = self.articleList[listIndexArticle]
self.listIndexArticle = listIndexArticle
self.selectArticle(self.articleId)
self.setWindowTitle("Article id: " + str(self.articleId))
self.initUI()
def initUI(self):
self.setGeometry(1030, 220, 400, 700)
mainLayout = QVBoxLayout()
self.createNavigationWidget()
self.createTitleBox()
self.createAuthorBox()
self.createDateBox()
self.createContentBrowser()
self.createEntitiesBox()
mainLayout.addWidget(self.titleBox)
mainLayout.addWidget(self.authorBox)
mainLayout.addWidget(self.dateBox)
mainLayout.addWidget(self.contentBrowser)
mainLayout.addWidget(self.entityBox)
mainLayout.addWidget(self.navigationWidget)
self.setLayout(mainLayout)
self.show()
def createNavigationWidget(self):
previousButton = QPushButton("<")
previousButton.setFocusPolicy(Qt.NoFocus)
previousButton.clicked.connect(self.previousArticle)
nextButton = QPushButton(">")
nextButton.setFocusPolicy(Qt.NoFocus)
nextButton.clicked.connect(self.nextArticle)
layout = QHBoxLayout()
layout.addWidget(previousButton)
layout.addWidget(nextButton)
self.navigationWidget = QWidget()
self.navigationWidget.setLayout(layout)
def createTitleBox(self):
self.titleLabel = QLabel(self.articleTitle)
self.titleLabel.setWordWrap(True)
layout = QHBoxLayout()
layout.addWidget(self.titleLabel)
self.titleBox = QGroupBox("Title")
self.titleBox.setLayout(layout)
def createAuthorBox(self):
self.authorLabel = QLabel(self.articleAuthor)
layout = QHBoxLayout()
layout.addWidget(self.authorLabel)
self.authorBox = QGroupBox("Author")
self.authorBox.setLayout(layout)
def createDateBox(self):
self.dateLabel = QLabel(str(self.articleDate))
layout = QHBoxLayout()
layout.addWidget(self.dateLabel)
self.dateBox = QGroupBox("Date")
self.dateBox.setLayout(layout)
def createContentBrowser(self):
self.contentBrowser = QTextBrowser(self)
self.contentBrowser.setPlainText(self.articleContent)
self.contentBrowser.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
def createEntitiesBox(self):
layout = self.createEntityGridLayout()
self.entityBox = QGroupBox("Entities - Opinions")
self.entityBox.setLayout(layout)
if len(self.entities) == 0:
self.entityBox.setVisible(False)
else:
self.entityBox.setVisible(True)
#.........这里部分代码省略.........
示例4: SquidGui
# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser 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)')
#.........这里部分代码省略.........