def __init__(self, parent):
super(LCAResultsTab, self).__init__(parent)
self.panel = parent # e.g. right panel
self.visible = False
self.scroll_area = QtWidgets.QScrollArea()
self.scroll_widget = QtWidgets.QWidget()
self.scroll_widget_layout = QtWidgets.QVBoxLayout()
self.scroll_widget.setLayout(self.scroll_widget_layout)
self.scroll_area.setWidget(self.scroll_widget)
self.scroll_area.setWidgetResizable(True)
self.layout = QtWidgets.QVBoxLayout()
self.setLayout(self.layout)
self.connect_signals()
python类QScrollArea()的实例源码
def __init__(self, parent=None, frame=QtWidgets.QFrame.Box):
super(FIRSTUI.ScrollWidget, self).__init__()
# Container Widget
widget = QtWidgets.QWidget()
# Layout of Container Widget
self.layout = QtWidgets.QVBoxLayout(self)
self.layout.setContentsMargins(0, 0, 0, 0)
widget.setLayout(self.layout)
# Scroll Area Properties
scroll = QtWidgets.QScrollArea()
scroll.setFrameShape(frame)
scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
scroll.setWidgetResizable(True)
scroll.setWidget(widget)
# Scroll Area Layer add
scroll_layout = QtWidgets.QVBoxLayout(self)
scroll_layout.addWidget(scroll)
scroll_layout.setContentsMargins(0, 0, 0, 0)
self.setLayout(scroll_layout)
def __init__(self, message, *args, **kwargs):
super().__init__(*args, **kwargs)
ui_dir_path = os.path.dirname(__file__)
ui_file_path = os.path.join(ui_dir_path, 'report_detail.ui')
uic.loadUi(ui_file_path, self)
# self.message = eval(message)
scroll_area = QScrollArea()
message_label = QLabel()
# message_label.setWordWrap(True)
# message_label_text = ''
# for key, value in self.message.items():
# message_label_text += "{} :\n{}\n".format(key, value)
# message_label.setText(message_label_text)
message_label.setText(message)
scroll_area.setWidget(message_label)
self.main_layout.addWidget(scroll_area)
def __init__(self):
super().__init__()
self.vbox_l2 = QtWidgets.QVBoxLayout()
self.scroll_area_w3 = QtWidgets.QScrollArea()
self.scroll_area_w3.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
self.scroll_area_w3.setWidgetResizable(True)
self.scroll_area_w3.verticalScrollBar().rangeChanged.connect(self.move_scrollbar_to_bottom)
self.scroll_list_widget_w4 = QtWidgets.QWidget()
self.scroll_list_widget_w4.setObjectName(MY_WIDGET_NAME_STR)
self.scroll_list_widget_w4.setStyleSheet("#" + MY_WIDGET_NAME_STR
+ "{" + "background-image:url(\"" + wbd.wbd_global.background_image_path
+ "\"); background-position:center; background-repeat:no-repeat" + "}")
self.scroll_list_vbox_l5 = QtWidgets.QVBoxLayout()
self.scroll_list_widget_w4.setLayout(self.scroll_list_vbox_l5)
self.scroll_area_w3.setWidget(self.scroll_list_widget_w4)
self.vbox_l2.addWidget(self.scroll_area_w3)
self.setLayout(self.vbox_l2)
def setupUi(self, corpusManager):
corpusManager.setObjectName("corpusManager")
corpusManager.resize(800, 600)
self.verticalLayout = QtWidgets.QVBoxLayout(corpusManager)
self.verticalLayout.setObjectName("verticalLayout")
self.list_corpora = QtWidgets.QScrollArea(corpusManager)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.list_corpora.sizePolicy().hasHeightForWidth())
self.list_corpora.setSizePolicy(sizePolicy)
self.list_corpora.setFrameShape(QtWidgets.QFrame.NoFrame)
self.list_corpora.setWidgetResizable(True)
self.list_corpora.setObjectName("list_corpora")
self.list_content = QtWidgets.QWidget()
self.list_content.setGeometry(QtCore.QRect(0, 0, 792, 592))
self.list_content.setObjectName("list_content")
self.list_layout = QtWidgets.QVBoxLayout(self.list_content)
self.list_layout.setContentsMargins(0, 0, 0, 0)
self.list_layout.setSpacing(0)
self.list_layout.setObjectName("list_layout")
self.list_corpora.setWidget(self.list_content)
self.verticalLayout.addWidget(self.list_corpora)
self.retranslateUi(corpusManager)
QtCore.QMetaObject.connectSlotsByName(corpusManager)
def setupUi(self, DownloadWindow):
DownloadWindow.setObjectName("DownloadWindow")
DownloadWindow.resize(314, 284)
self.centralwidget = QtWidgets.QWidget(DownloadWindow)
self.centralwidget.setObjectName("centralwidget")
self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setSpacing(0)
self.verticalLayout.setObjectName("verticalLayout")
self.list = QtWidgets.QScrollArea(self.centralwidget)
self.list.setFrameShape(QtWidgets.QFrame.NoFrame)
self.list.setFrameShadow(QtWidgets.QFrame.Plain)
self.list.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.list.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContents)
self.list.setWidgetResizable(True)
self.list.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
self.list.setObjectName("list")
self.scrollAreaWidgetContents = QtWidgets.QWidget()
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 314, 284))
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
self.layout = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents)
self.layout.setSizeConstraint(QtWidgets.QLayout.SetMinAndMaxSize)
self.layout.setContentsMargins(4, 4, 4, 4)
self.layout.setSpacing(4)
self.layout.setObjectName("layout")
self.list.setWidget(self.scrollAreaWidgetContents)
self.verticalLayout.addWidget(self.list)
DownloadWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(DownloadWindow)
QtCore.QMetaObject.connectSlotsByName(DownloadWindow)
def paintEvent(self, event):
painter = QtGui.QPainter(self)
painter.setRenderHint(QtGui.QPainter.Antialiasing, True)
painter.drawRoundedRect(
0, 0, self.width() - 1, self.height() - 1, 5, 5)
super(Bubble, self).paintEvent(event)
# class MainWindow(QtWidgets.QMainWindow):
# def __init__(self, text, parent=None):
# super(MainWindow, self).__init__(parent)
# self.mainArea = QtWidgets.QScrollArea(self)
# self.mainArea.setWidgetResizable(True)
# widget = QtWidgets.QWidget(self.mainArea)
# widget.setMinimumWidth(50)
# layout = FlowLayoutWidget(widget)
# self.words = []
# for word in text.split():
# label = Bubble(word)
# label.setFont(QtGui.QFont('SblHebrew', 18))
# label.setFixedWidth(label.sizeHint().width())
# self.words.append(label)
# layout.addWidget(label)
# self.mainArea.setWidget(widget)
# self.setCentralWidget(self.mainArea)
#
# if __name__ == '__main__':
#
# app = QtWidgets.QApplication(sys.argv)
# window = MainWindow('Harry Potter is a series of fantasy literature')
# window.show()
# sys.exit(app.exec_())
def setupUi(self, GroupDialog):
GroupDialog.setObjectName("GroupDialog")
GroupDialog.resize(640, 480)
self.verticalLayout = QtWidgets.QGridLayout(GroupDialog)
self.verticalLayout.setObjectName("verticalLayout")
self.buttonBox = QtWidgets.QDialogButtonBox(GroupDialog)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
self.verticalLayout.addWidget(self.buttonBox, 3, 1, 1, 1)
self.label_3 = QtWidgets.QLabel(GroupDialog)
self.label_3.setObjectName("label_3")
self.verticalLayout.addWidget(self.label_3, 2, 0, 1, 1)
self.label = QtWidgets.QLabel(GroupDialog)
self.label.setObjectName("label")
self.verticalLayout.addWidget(self.label, 0, 0, 1, 1)
self.widget_selection = CoqListSelect(GroupDialog)
self.widget_selection.setObjectName("widget_selection")
self.verticalLayout.addWidget(self.widget_selection, 1, 1, 1, 1)
self.label_2 = QtWidgets.QLabel(GroupDialog)
self.label_2.setObjectName("label_2")
self.verticalLayout.addWidget(self.label_2, 1, 0, 1, 1)
self.edit_label = QtWidgets.QLineEdit(GroupDialog)
self.edit_label.setText("")
self.edit_label.setObjectName("edit_label")
self.verticalLayout.addWidget(self.edit_label, 0, 1, 1, 1)
self.scroll_area = QtWidgets.QScrollArea(GroupDialog)
self.scroll_area.setWidgetResizable(True)
self.scroll_area.setObjectName("scroll_area")
self.scroll_content = QtWidgets.QWidget()
self.scroll_content.setGeometry(QtCore.QRect(0, 0, 535, 265))
self.scroll_content.setObjectName("scroll_content")
self.scroll_layout = QtWidgets.QVBoxLayout(self.scroll_content)
self.scroll_layout.setContentsMargins(0, 0, 0, 0)
self.scroll_layout.setSpacing(0)
self.scroll_layout.setObjectName("scroll_layout")
self.scroll_area.setWidget(self.scroll_content)
self.verticalLayout.addWidget(self.scroll_area, 2, 1, 1, 1)
self.verticalLayout.setRowStretch(1, 1)
self.verticalLayout.setRowStretch(2, 2)
self.label_3.setBuddy(self.scroll_content)
self.label.setBuddy(self.edit_label)
self.label_2.setBuddy(self.widget_selection)
self.retranslateUi(GroupDialog)
self.buttonBox.accepted.connect(GroupDialog.accept)
self.buttonBox.rejected.connect(GroupDialog.reject)
QtCore.QMetaObject.connectSlotsByName(GroupDialog)
def setupUi(self, logfileDialog):
logfileDialog.setObjectName("logfileDialog")
logfileDialog.resize(640, 480)
self.verticalLayout = QtWidgets.QVBoxLayout(logfileDialog)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setSpacing(10)
self.verticalLayout.setObjectName("verticalLayout")
self.scrollArea = QtWidgets.QScrollArea(logfileDialog)
self.scrollArea.setFrameShape(QtWidgets.QFrame.NoFrame)
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName("scrollArea")
self.scrollAreaWidgetContents = QtWidgets.QWidget()
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 640, 480))
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents)
self.verticalLayout_2.setContentsMargins(0, 0, 0, 0)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.label = QtWidgets.QLabel(self.scrollAreaWidgetContents)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth())
self.label.setSizePolicy(sizePolicy)
self.label.setObjectName("label")
self.horizontalLayout.addWidget(self.label)
self.check_errors = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.check_errors.setObjectName("check_errors")
self.horizontalLayout.addWidget(self.check_errors)
self.check_warnings = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.check_warnings.setObjectName("check_warnings")
self.horizontalLayout.addWidget(self.check_warnings)
self.check_info = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.check_info.setObjectName("check_info")
self.horizontalLayout.addWidget(self.check_info)
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
self.verticalLayout_2.addLayout(self.horizontalLayout)
self.log_table = QtWidgets.QTableView(self.scrollAreaWidgetContents)
self.log_table.setHorizontalScrollMode(QtWidgets.QAbstractItemView.ScrollPerPixel)
self.log_table.setObjectName("log_table")
self.log_table.horizontalHeader().setStretchLastSection(True)
self.log_table.verticalHeader().setVisible(False)
self.verticalLayout_2.addWidget(self.log_table)
self.scrollArea.setWidget(self.scrollAreaWidgetContents)
self.verticalLayout.addWidget(self.scrollArea)
self.retranslateUi(logfileDialog)
QtCore.QMetaObject.connectSlotsByName(logfileDialog)
def setupUi(self, TabMapSpecific):
TabMapSpecific.setObjectName("TabMapSpecific")
TabMapSpecific.resize(445, 534)
self.gridLayout = QtWidgets.QGridLayout(TabMapSpecific)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setSpacing(0)
self.gridLayout.setObjectName("gridLayout")
self.scrollArea_2 = QtWidgets.QScrollArea(TabMapSpecific)
self.scrollArea_2.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.scrollArea_2.setWidgetResizable(True)
self.scrollArea_2.setObjectName("scrollArea_2")
self.scrollAreaWidgetContents_2 = QtWidgets.QWidget()
self.scrollAreaWidgetContents_2.setGeometry(QtCore.QRect(0, 0, 443, 532))
self.scrollAreaWidgetContents_2.setObjectName("scrollAreaWidgetContents_2")
self.verticalLayout = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents_2)
self.verticalLayout.setContentsMargins(6, 6, 6, 6)
self.verticalLayout.setSpacing(6)
self.verticalLayout.setObjectName("verticalLayout")
self.selectedMap = QtWidgets.QComboBox(self.scrollAreaWidgetContents_2)
self.selectedMap.setObjectName("selectedMap")
self.verticalLayout.addWidget(self.selectedMap)
self.frame = QtWidgets.QFrame(self.scrollAreaWidgetContents_2)
self.frame.setFrameShape(QtWidgets.QFrame.NoFrame)
self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame.setObjectName("frame")
self.gridLayout_4 = QtWidgets.QGridLayout(self.frame)
self.gridLayout_4.setContentsMargins(0, 0, 0, 0)
self.gridLayout_4.setSpacing(0)
self.gridLayout_4.setObjectName("gridLayout_4")
self.mapSpecificOptionsPosition = QtWidgets.QGridLayout()
self.mapSpecificOptionsPosition.setSpacing(0)
self.mapSpecificOptionsPosition.setObjectName("mapSpecificOptionsPosition")
self.gridLayout_4.addLayout(self.mapSpecificOptionsPosition, 0, 0, 1, 1)
self.verticalLayout.addWidget(self.frame)
spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.verticalLayout.addItem(spacerItem)
self.scrollArea_2.setWidget(self.scrollAreaWidgetContents_2)
self.gridLayout.addWidget(self.scrollArea_2, 0, 0, 1, 1)
self.retranslateUi(TabMapSpecific)
QtCore.QMetaObject.connectSlotsByName(TabMapSpecific)
TabMapSpecific.setTabOrder(self.scrollArea_2, self.selectedMap)
def __init__(self, parent=None, title='', animation_duration=300):
"""
References:
# Adapted from c++ version
http://stackoverflow.com/questions/32476006/how-to-make-an-expandable-collapsable-section-widget-in-qt
"""
super(GroupWidget, self).__init__(parent=parent)
self.animation_duration = animation_duration
self.toggle_animation = QParallelAnimationGroup()
self.content_area = QScrollArea()
self.header_line = QFrame()
self.toggle_button = QToolButton()
self.main_layout = QGridLayout()
toggle_button = self.toggle_button
toggle_button.setStyleSheet("QToolButton { border: none; }")
toggle_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
toggle_button.setArrowType(Qt.RightArrow)
toggle_button.setText(str(title))
toggle_button.setCheckable(True)
toggle_button.setChecked(False)
header_line = self.header_line
header_line.setFrameShape(QFrame.HLine)
header_line.setFrameShadow(QFrame.Sunken)
header_line.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)
self.content_area.setStyleSheet("QScrollArea { background-color: white; border: none; }")
self.content_area.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
# start out collapsed
self.content_area.setMaximumHeight(0)
self.content_area.setMinimumHeight(0)
# let the entire widget grow and shrink with its content
toggle_animation = self.toggle_animation
toggle_animation.addAnimation(QPropertyAnimation(self, bytes("minimumHeight", "utf-8")))
toggle_animation.addAnimation(QPropertyAnimation(self, bytes("maximumHeight", "utf-8")))
toggle_animation.addAnimation(QPropertyAnimation(self.content_area, bytes("maximumHeight", "utf-8")))
# don't waste space
main_layout = self.main_layout
main_layout.setVerticalSpacing(0)
main_layout.setContentsMargins(0, 0, 0, 0)
row = 0
main_layout.addWidget(self.toggle_button, row, 0, 1, 1, Qt.AlignLeft)
main_layout.addWidget(self.header_line, row, 2, 1, 1)
row += 1
main_layout.addWidget(self.content_area, row, 0, 1, 3)
self.setLayout(self.main_layout)
def start_animation(checked):
arrow_type = Qt.DownArrow if checked else Qt.RightArrow
direction = QAbstractAnimation.Forward if checked else QAbstractAnimation.Backward
toggle_button.setArrowType(arrow_type)
self.toggle_animation.setDirection(direction)
self.toggle_animation.start()
self.toggle_button.clicked.connect(start_animation)
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(550, 130)
self.verticalLayout_2 = QtWidgets.QVBoxLayout(Form)
self.verticalLayout_2.setContentsMargins(3, 3, 3, 3)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.label = QtWidgets.QLabel(Form)
self.label.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label.setObjectName("label")
self.horizontalLayout.addWidget(self.label)
self.label_type = QtWidgets.QLabel(Form)
self.label_type.setText("")
self.label_type.setObjectName("label_type")
self.horizontalLayout.addWidget(self.label_type)
self.button_more = QtWidgets.QPushButton(Form)
self.button_more.setObjectName("button_more")
self.horizontalLayout.addWidget(self.button_more)
self.button_less = QtWidgets.QPushButton(Form)
self.button_less.setObjectName("button_less")
self.horizontalLayout.addWidget(self.button_less)
self.button_edit = QtWidgets.QPushButton(Form)
self.button_edit.setObjectName("button_edit")
self.horizontalLayout.addWidget(self.button_edit)
self.button_delete = QtWidgets.QPushButton(Form)
self.button_delete.setMaximumSize(QtCore.QSize(30, 16777215))
self.button_delete.setText("")
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap("../logos/logo_cross.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.button_delete.setIcon(icon)
self.button_delete.setObjectName("button_delete")
self.horizontalLayout.addWidget(self.button_delete)
self.verticalLayout_2.addLayout(self.horizontalLayout)
self.line = QtWidgets.QFrame(Form)
self.line.setFrameShape(QtWidgets.QFrame.HLine)
self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line.setObjectName("line")
self.verticalLayout_2.addWidget(self.line)
self.scrollArea = QtWidgets.QScrollArea(Form)
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName("scrollArea")
self.scroll_widget = QtWidgets.QWidget()
self.scroll_widget.setGeometry(QtCore.QRect(0, 0, 542, 81))
self.scroll_widget.setObjectName("scroll_widget")
self.layout_depend_depend = QtWidgets.QVBoxLayout(self.scroll_widget)
self.layout_depend_depend.setContentsMargins(0, 0, 0, 0)
self.layout_depend_depend.setSpacing(6)
self.layout_depend_depend.setObjectName("layout_depend_depend")
spacerItem = QtWidgets.QSpacerItem(20, 265, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.layout_depend_depend.addItem(spacerItem)
self.scrollArea.setWidget(self.scroll_widget)
self.verticalLayout_2.addWidget(self.scrollArea)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)