本文整理汇总了Python中PyQt5.QtWidgets.QTextBrowser.viewport方法的典型用法代码示例。如果您正苦于以下问题:Python QTextBrowser.viewport方法的具体用法?Python QTextBrowser.viewport怎么用?Python QTextBrowser.viewport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QTextBrowser
的用法示例。
在下文中一共展示了QTextBrowser.viewport方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OWCSVFileImport
# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import viewport [as 别名]
class OWCSVFileImport(widget.OWWidget):
name = "CSV File Import"
description = "Import a data table from a CSV formatted file."
icon = "icons/CSVFile.svg"
outputs = [
widget.OutputSignal(
name="Data",
type=Orange.data.Table,
doc="Loaded data set."),
widget.OutputSignal(
name="Data Frame",
type=pd.DataFrame,
doc=""
)
]
class Error(widget.OWWidget.Error):
error = widget.Msg(
"Unexpected error"
)
encoding_error = widget.Msg(
"Encoding error\n"
"The file might be encoded in an unsupported encoding or it "
"might be binary"
)
#: Paths and options of files accessed in a 'session'
_session_items = settings.Setting(
[], schema_only=True) # type: List[Tuple[str, dict]]
#: Saved dialog state (last directory and selected filter)
dialog_state = settings.Setting({
"directory": "",
"filter": ""
}) # type: Dict[str, str]
MaxHistorySize = 50
want_main_area = False
buttons_area_orientation = None
def __init__(self, *args, **kwargs):
super().__init__(self, *args, **kwargs)
self.__committimer = QTimer(self, singleShot=True)
self.__committimer.timeout.connect(self.commit)
self.__executor = qconcurrent.ThreadExecutor()
self.__watcher = None # type: Optional[qconcurrent.FutureWatcher]
self.controlArea.layout().setSpacing(-1) # reset spacing
grid = QGridLayout()
grid.addWidget(QLabel("File:", self), 0, 0, 1, 1)
self.import_items_model = QStandardItemModel(self)
self.recent_combo = QComboBox(
self, objectName="recent-combo", toolTip="Recent files.",
sizeAdjustPolicy=QComboBox.AdjustToMinimumContentsLengthWithIcon,
minimumContentsLength=16,
)
self.recent_combo.setModel(self.import_items_model)
self.recent_combo.activated.connect(self.activate_recent)
self.recent_combo.setSizePolicy(
QSizePolicy.MinimumExpanding, QSizePolicy.Fixed)
self.browse_button = QPushButton(
"…", icon=self.style().standardIcon(QStyle.SP_DirOpenIcon),
toolTip="Browse filesystem", autoDefault=False,
)
self.browse_button.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
self.browse_button.clicked.connect(self.browse)
grid.addWidget(self.recent_combo, 0, 1, 1, 1)
grid.addWidget(self.browse_button, 0, 2, 1, 1)
self.controlArea.layout().addLayout(grid)
###########
# Info text
###########
box = gui.widgetBox(self.controlArea, "Info", addSpace=False)
self.summary_text = QTextBrowser(
verticalScrollBarPolicy=Qt.ScrollBarAsNeeded,
readOnly=True,
)
self.summary_text.viewport().setBackgroundRole(QPalette.NoRole)
self.summary_text.setFrameStyle(QTextBrowser.NoFrame)
self.summary_text.setMinimumHeight(self.fontMetrics().ascent() * 2 + 4)
self.summary_text.viewport().setAutoFillBackground(False)
box.layout().addWidget(self.summary_text)
button_box = QDialogButtonBox(
orientation=Qt.Horizontal,
standardButtons=QDialogButtonBox.Cancel | QDialogButtonBox.Retry
)
self.load_button = b = button_box.button(QDialogButtonBox.Retry)
b.setText("Load")
b.clicked.connect(self.__committimer.start)
b.setEnabled(False)
b.setDefault(True)
self.cancel_button = b = button_box.button(QDialogButtonBox.Cancel)
b.clicked.connect(self.cancel)
#.........这里部分代码省略.........