本文整理汇总了Python中PyQt5.QtWidgets.QVBoxLayout.replaceWidget方法的典型用法代码示例。如果您正苦于以下问题:Python QVBoxLayout.replaceWidget方法的具体用法?Python QVBoxLayout.replaceWidget怎么用?Python QVBoxLayout.replaceWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QVBoxLayout
的用法示例。
在下文中一共展示了QVBoxLayout.replaceWidget方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SongsTable_Container
# 需要导入模块: from PyQt5.QtWidgets import QVBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QVBoxLayout import replaceWidget [as 别名]
class SongsTable_Container(FFrame):
def __init__(self, app, parent=None):
super().__init__(parent)
self._app = app
self.songs_table = None
self.table_control = TableControl(self._app)
self._layout = QVBoxLayout(self)
self.setup_ui()
def setup_ui(self):
self._layout.setContentsMargins(0, 0, 0, 0)
self._layout.setSpacing(0)
self._layout.addWidget(self.table_control)
def set_table(self, songs_table):
if self.songs_table:
self._layout.replaceWidget(self.songs_table, songs_table)
self.songs_table.close()
del self.songs_table
else:
self._layout.addWidget(songs_table)
self._layout.addSpacing(10)
self.songs_table = songs_table
示例2: VariantInfoWidget
# 需要导入模块: from PyQt5.QtWidgets import QVBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QVBoxLayout import replaceWidget [as 别名]
#.........这里部分代码省略.........
# headline
description = QLabel(QApplication.translate("VariantInfoWidget", "Break even line for"))
layout.addSpacing(10)
layout.addWidget(description)
# show legend for all plotted curves
for curve in self.curves:
layout.addSpacing(6)
vertical = QHBoxLayout()
vertical.setContentsMargins(0, 0, 0, 0)
line = ColorLine(curve)
line.farbeDef = curve.data(TreeModel.ColorRole)
line.colorChanged.connect(self.updateColor)
vertical.addWidget(line)
vertical.addSpacing(10)
vertical.addWidget(QLabel(
curve.parent().data(TreeModel.IdentificationRole) +
" " + QApplication.translate("VariantInfoWidget", "and") + " " +
curve.data(TreeModel.IdentificationRole)))
layout.addLayout(vertical)
result = QHBoxLayout()
result.setContentsMargins(0, 0, 0, 0)
result.addSpacing(35)
# check, if the plant count is smaller than the calculation
point = curve.data(TreeModel.ResultRole) * self.model.projectData("length")
resultText = QApplication.translate("VariantInfoWidget", "The costs are equal")
if self.model.projectData("count") < point:
resultText = QApplication.translate("VariantInfoWidget", "Tree shelter is profitable")
elif self.model.projectData("count") > point:
resultText = QApplication.translate("VariantInfoWidget", "Fence is profitable")
result.addWidget(QLabel("<i>" + resultText + "</i>"))
layout.addLayout(result)
# show the color hint
layout.addSpacing(10)
layout.addWidget(QLabel("(" + QApplication.translate("VariantInfoWidget", "to change the color click on the symbol") + ")", wordWrap=True))
layout.addSpacing(10)
helpSymbol = QLabel(pixmap=QPixmap(os.path.join(self._OXYGEN_PATH_22, "system-help.png")))
helpText = ClickableLabel("<a href='#'>" + QApplication.translate("VariantInfoWidget", "Explanation of calculation") + "</a>")
helpText.clicked.connect(self.showHelp)
helpLayout = QHBoxLayout()
helpLayout.setContentsMargins(0, 0, 0, 0)
helpLayout.setSpacing(8)
helpLayout.addWidget(helpSymbol, alignment=Qt.AlignVCenter)
helpLayout.addWidget(helpText, alignment=Qt.AlignVCenter)
helpLayout.addStretch()
layout.addLayout(helpLayout)
# add hints
separator = QFrame(frameShadow=QFrame.Sunken, frameShape=QFrame.HLine)
# not the best solution but it works
# this is very tricky!
hintTitle = QLabel("<b>" + QApplication.translate("VariantInfoWidget", "Relevant information:") + "</b>")
hintArrow = QLabel("<ul style='list-style-type: square; margin-left: -25px;'>" +
"<li>" + QApplication.translate("VariantInfoWidget", "the orange arrow displays the result of the calculation") + "</li></ul>", wordWrap=True) # orangener Pfeil zeigt das Ergebnis der Kalkulation
hintLines = QLabel("<ul style='list-style-type: square; margin-left: -25px;'>" +
"<li>" + QApplication.translate("VariantInfoWidget", "the auxiliary lines for fence length and number of plants are moveable") + "</li></ul>", wordWrap=True) # Hilfslinien für Zaunlänge und Pflanzenzahl sind beweglich
layout.addSpacing(30)
layout.addWidget(separator)
layout.addWidget(hintTitle)
layout.addSpacing(10)
layout.addWidget(hintArrow)
layout.addSpacing(6)
layout.addWidget(hintLines)
layout.addStretch()
else:
# no curve was plotted
# there is no result available
layout.addSpacing(10)
layout.addWidget(QLabel(QApplication.translate("VariantInfoWidget", "No results available!")))
layout.addStretch()
new.setLayout(layout)
self.layout.replaceWidget(self.results, new)
self.results.deleteLater()
self.results = new
def showHelp(self):
# create the documentation path with
# the current locale settings
docFile = os.path.join("doc", "documentation_" +
self.locale().name()[:2] + ".pdf")
# on every platfrom a different
# start operation is needed
if sys.platform == "win32":
os.startfile(docFile)
elif sys.platform == "darwin":
subprocess.call(("open", docFile))
elif sys.platform.startswith("linux"):
subprocess.call(("xdg-open", docFile))
示例3: SongsTable_Container
# 需要导入模块: from PyQt5.QtWidgets import QVBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QVBoxLayout import replaceWidget [as 别名]
class SongsTable_Container(FFrame):
def __init__(self, app, parent=None):
super().__init__(parent)
self._app = app
self.songs_table = None
self.img_label = CoverImgLabel(self._app)
self.desc_container = DescriptionContainer(self._app)
self.info_container = FFrame(parent=self)
self.table_control = TableControl(self._app)
self._layout = QVBoxLayout(self)
self._info_layout = QHBoxLayout(self.info_container)
self.setup_ui()
def setup_ui(self):
self._layout.setContentsMargins(0, 0, 0, 0)
self._layout.setSpacing(0)
self._info_layout.setContentsMargins(0, 0, 0, 0)
self._info_layout.setSpacing(0)
self._info_layout.addWidget(self.img_label)
self._info_layout.addSpacing(20)
self._info_layout.addWidget(self.desc_container)
self._layout.addSpacing(10)
self._layout.addWidget(self.info_container)
self._layout.addSpacing(10)
self._layout.addWidget(self.table_control)
def set_table(self, songs_table):
if self.songs_table:
self._layout.replaceWidget(self.songs_table, songs_table)
self.songs_table.deleteLater()
else:
self._layout.addWidget(songs_table)
self._layout.addSpacing(10)
self.songs_table = songs_table
def load_img(self, img_url, img_name):
self.info_container.show()
event_loop = asyncio.get_event_loop()
future = event_loop.create_task(
self._app.img_ctl.get(img_url, img_name))
future.add_done_callback(self.set_img)
def set_img(self, future):
content = future.result()
img = QImage()
img.loadFromData(content)
pixmap = QPixmap(img)
if pixmap.isNull():
return None
self.img_label.setPixmap(
pixmap.scaledToWidth(self.img_label.width(),
mode=Qt.SmoothTransformation))
def set_desc(self, desc):
self.desc_container.set_html(desc)
def hide_info_container(self):
self.info_container.hide()