本文整理汇总了Python中AnyQt.QtWidgets.QSplitter类的典型用法代码示例。如果您正苦于以下问题:Python QSplitter类的具体用法?Python QSplitter怎么用?Python QSplitter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QSplitter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
super().__init__()
dbox = gui.widgetBox(self.controlArea, "Image values")
rbox = gui.radioButtons(
dbox, self, "value_type", callback=self._change_integration)
gui.appendRadioButton(rbox, "From spectra")
self.box_values_spectra = gui.indentedBox(rbox)
gui.comboBox(
self.box_values_spectra, self, "integration_method", valueType=int,
items=(a.name for a in self.integration_methods),
callback=self._change_integral_type)
gui.rubber(self.controlArea)
gui.appendRadioButton(rbox, "Use feature")
self.box_values_feature = gui.indentedBox(rbox)
self.feature_value_model = DomainModel(DomainModel.METAS | DomainModel.CLASSES,
valid_types=DomainModel.PRIMITIVE)
self.feature_value = gui.comboBox(
self.box_values_feature, self, "attr_value",
callback=self.update_feature_value, model=self.feature_value_model,
sendSelectedValue=True, valueType=str)
splitter = QSplitter(self)
splitter.setOrientation(Qt.Vertical)
self.imageplot = ImagePlot(self)
self.imageplot.selection_changed.connect(self.output_image_selection)
self.curveplot = CurvePlotHyper(self, select=SELECTONE)
self.curveplot.selection_changed.connect(self.redraw_data)
self.curveplot.plot.vb.x_padding = 0.005 # pad view so that lines are not hidden
splitter.addWidget(self.imageplot)
splitter.addWidget(self.curveplot)
self.mainArea.layout().addWidget(splitter)
self.line1 = MovableVline(position=self.lowlim, label="", report=self.curveplot)
self.line1.sigMoved.connect(lambda v: setattr(self, "lowlim", v))
self.line2 = MovableVline(position=self.highlim, label="", report=self.curveplot)
self.line2.sigMoved.connect(lambda v: setattr(self, "highlim", v))
self.line3 = MovableVline(position=self.choose, label="", report=self.curveplot)
self.line3.sigMoved.connect(lambda v: setattr(self, "choose", v))
for line in [self.line1, self.line2, self.line3]:
line.sigMoveFinished.connect(self.changed_integral_range)
self.curveplot.add_marking(line)
line.hide()
self.data = None
self.disable_integral_range = False
self.resize(900, 700)
self._update_integration_type()
# prepare interface according to the new context
self.contextAboutToBeOpened.connect(lambda x: self.init_interface_data(x[0]))
示例2: __setupUi
def __setupUi(self):
layout = QVBoxLayout()
layout.setContentsMargins(0, 0, 0, 0)
layout.setSpacing(0)
self.toolbox = WidgetToolBox()
self.help = QuickHelpWidget(objectName="quick-help")
self.__splitter = QSplitter()
self.__splitter.setOrientation(Qt.Vertical)
self.__splitter.addWidget(self.toolbox)
self.__splitter.addWidget(self.help)
self.toolbar = DynamicResizeToolBar()
self.toolbar.setMovable(False)
self.toolbar.setFloatable(False)
self.toolbar.setSizePolicy(QSizePolicy.Ignored,
QSizePolicy.Preferred)
layout.addWidget(self.__splitter, 10)
layout.addWidget(self.toolbar)
self.setLayout(layout)
self.__splitterResizer = SplitterResizer(self)
self.__splitterResizer.setSplitterAndWidget(self.__splitter, self.help)
示例3: test_dock
def test_dock(self):
reg = global_registry()
reg = QtWidgetRegistry(reg, parent=self.app)
toolbox = WidgetToolBox()
toolbox.setObjectName("widgets-toolbox")
toolbox.setModel(reg.model())
text = QTextEdit()
splitter = QSplitter()
splitter.setOrientation(Qt.Vertical)
splitter.addWidget(toolbox)
splitter.addWidget(text)
dock = CollapsibleDockWidget()
dock.setExpandedWidget(splitter)
toolbar = QToolBar()
toolbar.addAction("1")
toolbar.setOrientation(Qt.Vertical)
toolbar.setMovable(False)
toolbar.setFloatable(False)
dock.setCollapsedWidget(toolbar)
dock.show()
self.app.exec_()
示例4: CanvasToolDock
class CanvasToolDock(QWidget):
"""Canvas dock widget with widget toolbox, quick help and
canvas actions.
"""
def __init__(self, parent=None, **kwargs):
super().__init__(parent, **kwargs)
self.__setupUi()
def __setupUi(self):
layout = QVBoxLayout()
layout.setContentsMargins(0, 0, 0, 0)
layout.setSpacing(0)
self.toolbox = WidgetToolBox()
self.help = QuickHelpWidget(objectName="quick-help")
self.__splitter = QSplitter()
self.__splitter.setOrientation(Qt.Vertical)
self.__splitter.addWidget(self.toolbox)
self.__splitter.addWidget(self.help)
self.toolbar = DynamicResizeToolBar()
self.toolbar.setMovable(False)
self.toolbar.setFloatable(False)
self.toolbar.setSizePolicy(QSizePolicy.Ignored,
QSizePolicy.Preferred)
layout.addWidget(self.__splitter, 10)
layout.addWidget(self.toolbar)
self.setLayout(layout)
self.__splitterResizer = SplitterResizer(self)
self.__splitterResizer.setSplitterAndWidget(self.__splitter, self.help)
def setQuickHelpVisible(self, state):
"""Set the quick help box visibility status.
"""
self.__splitterResizer.setExpanded(state)
def quickHelpVisible(self):
return self.__splitterResizer.expanded()
def setQuickHelpAnimationEnabled(self, enabled):
"""Enable/disable the quick help animation.
"""
self.__splitterResizer.setAnimationEnabled(enabled)
def toogleQuickHelpAction(self):
"""Return a checkable QAction for help show/hide.
"""
return self.__splitterResizer.toogleExpandedAction()
示例5: test_splitter_resizer
def test_splitter_resizer(self):
w = QSplitter(orientation=Qt.Vertical)
w.addWidget(QWidget())
text = QTextEdit()
w.addWidget(text)
resizer = SplitterResizer(w)
resizer.setSplitterAndWidget(w, text)
def toogle():
if resizer.size() == 0:
resizer.open()
else:
resizer.close()
self.singleShot(1000, toogle)
w.show()
self.singleShot(0, toogle)
self.app.exec_()
示例6: test_splitter_resizer
def test_splitter_resizer(self):
w = QSplitter(orientation=Qt.Vertical)
w.addWidget(QWidget())
text = QTextEdit()
w.addWidget(text)
resizer = SplitterResizer(parent=None)
resizer.setSplitterAndWidget(w, text)
def toogle():
if resizer.size() == 0:
resizer.open()
else:
resizer.close()
w.show()
timer = QTimer(resizer, interval=1000)
timer.timeout.connect(toogle)
timer.start()
self.app.exec_()
示例7: OWPythonScript
#.........这里部分代码省略.........
action.triggered.connect(self.onRemoveScript)
w.addAction(action)
action = QAction("Update", self)
action.setToolTip("Save changes in the editor to library")
action.setShortcut(QKeySequence(QKeySequence.Save))
action.triggered.connect(self.commitChangesToLibrary)
w.addAction(action)
action = QAction("More", self, toolTip="More actions")
new_from_file = QAction("Import Script from File", self)
save_to_file = QAction("Save Selected Script to File", self)
save_to_file.setShortcut(QKeySequence(QKeySequence.SaveAs))
new_from_file.triggered.connect(self.onAddScriptFromFile)
save_to_file.triggered.connect(self.saveScript)
menu = QMenu(w)
menu.addAction(new_from_file)
menu.addAction(save_to_file)
action.setMenu(menu)
button = w.addAction(action)
button.setPopupMode(QToolButton.InstantPopup)
w.layout().setSpacing(1)
self.controlBox.layout().addWidget(w)
self.execute_button = gui.auto_commit(
self.controlArea, self, "auto_execute", "Execute",
auto_label="Auto Execute")
self.splitCanvas = QSplitter(Qt.Vertical, self.mainArea)
self.mainArea.layout().addWidget(self.splitCanvas)
self.defaultFont = defaultFont = \
"Monaco" if sys.platform == "darwin" else "Courier"
self.textBox = gui.vBox(self, 'Python Script')
self.splitCanvas.addWidget(self.textBox)
self.text = PythonScriptEditor(self)
self.textBox.layout().addWidget(self.text)
self.textBox.setAlignment(Qt.AlignVCenter)
self.text.setTabStopWidth(4)
self.text.modificationChanged[bool].connect(self.onModificationChanged)
self.saveAction = action = QAction("&Save", self.text)
action.setToolTip("Save script to file")
action.setShortcut(QKeySequence(QKeySequence.Save))
action.setShortcutContext(Qt.WidgetWithChildrenShortcut)
action.triggered.connect(self.saveScript)
self.consoleBox = gui.vBox(self, 'Console')
self.splitCanvas.addWidget(self.consoleBox)
self.console = PythonConsole({}, self)
self.consoleBox.layout().addWidget(self.console)
self.console.document().setDefaultFont(QFont(defaultFont))
self.consoleBox.setAlignment(Qt.AlignBottom)
self.console.setTabStopWidth(4)
select_row(self.libraryView, self.currentScriptIndex)
self.splitCanvas.setSizes([2, 1])
示例8: __init__
def __init__(self):
super().__init__()
#: Input data table
self.data = None # type: Optional[Orange.data.Table]
#: A dict mapping input ids to PredictorSlot
self.predictors = OrderedDict() # type: Dict[object, PredictorSlot]
#: A class variable (prediction target)
self.class_var = None # type: Optional[Orange.data.Variable]
#: List of (discrete) class variable's values
self.class_values = [] # type: List[str]
box = gui.vBox(self.controlArea, "Info")
self.infolabel = gui.widgetLabel(
box, "No data on input.\nPredictors: 0\nTask: N/A")
self.infolabel.setMinimumWidth(150)
gui.button(box, self, "Restore Original Order",
callback=self._reset_order,
tooltip="Show rows in the original order")
self.classification_options = box = gui.vBox(
self.controlArea, "Options (classification)", spacing=-1,
addSpace=False)
gui.checkBox(box, self, "show_predictions", "Show predicted class",
callback=self._update_prediction_delegate)
b = gui.checkBox(box, self, "show_probabilities",
"Show predicted probabilities",
callback=self._update_prediction_delegate)
ibox = gui.indentedBox(box, sep=gui.checkButtonOffsetHint(b),
addSpace=False)
gui.listBox(ibox, self, "selected_classes", "class_values",
callback=self._update_prediction_delegate,
selectionMode=QListWidget.MultiSelection,
addSpace=False)
gui.checkBox(box, self, "draw_dist", "Draw distribution bars",
callback=self._update_prediction_delegate)
box = gui.vBox(self.controlArea, "Data View")
gui.checkBox(box, self, "show_attrs", "Show full data set",
callback=self._update_column_visibility)
box = gui.vBox(self.controlArea, "Output", spacing=-1)
self.checkbox_class = gui.checkBox(
box, self, "output_attrs", "Original data",
callback=self.commit)
self.checkbox_class = gui.checkBox(
box, self, "output_predictions", "Predictions",
callback=self.commit)
self.checkbox_prob = gui.checkBox(
box, self, "output_probabilities", "Probabilities",
callback=self.commit)
gui.rubber(self.controlArea)
self.splitter = QSplitter(
orientation=Qt.Horizontal,
childrenCollapsible=False,
handleWidth=2,
)
self.dataview = TableView(
verticalScrollBarPolicy=Qt.ScrollBarAlwaysOn,
horizontalScrollBarPolicy=Qt.ScrollBarAlwaysOn,
horizontalScrollMode=QTableView.ScrollPerPixel,
selectionMode=QTableView.NoSelection,
focusPolicy=Qt.StrongFocus
)
self.predictionsview = TableView(
verticalScrollBarPolicy=Qt.ScrollBarAlwaysOff,
horizontalScrollBarPolicy=Qt.ScrollBarAlwaysOn,
horizontalScrollMode=QTableView.ScrollPerPixel,
selectionMode=QTableView.NoSelection,
focusPolicy=Qt.StrongFocus,
sortingEnabled=True,
)
self.predictionsview.setItemDelegate(PredictionsItemDelegate())
self.dataview.verticalHeader().hide()
dsbar = self.dataview.verticalScrollBar()
psbar = self.predictionsview.verticalScrollBar()
psbar.valueChanged.connect(dsbar.setValue)
dsbar.valueChanged.connect(psbar.setValue)
self.dataview.verticalHeader().setDefaultSectionSize(22)
self.predictionsview.verticalHeader().setDefaultSectionSize(22)
self.dataview.verticalHeader().sectionResized.connect(
lambda index, _, size:
self.predictionsview.verticalHeader()
.resizeSection(index, size)
)
self.splitter.addWidget(self.predictionsview)
self.splitter.addWidget(self.dataview)
self.mainArea.layout().addWidget(self.splitter)
示例9: OWPredictions
class OWPredictions(widget.OWWidget):
name = "Predictions"
icon = "icons/Predictions.svg"
priority = 200
description = "Display the predictions of models for an input data set."
inputs = [("Data", Orange.data.Table, "set_data"),
("Predictors", Model,
"set_predictor", widget.Multiple)]
outputs = [("Predictions", Orange.data.Table),
("Evaluation Results", Orange.evaluation.Results)]
settingsHandler = settings.ClassValuesContextHandler()
#: Display the full input dataset or only the target variable columns (if
#: available)
show_attrs = settings.Setting(True)
#: Show predicted values (for discrete target variable)
show_predictions = settings.Setting(True)
#: Show predictions probabilities (for discrete target variable)
show_probabilities = settings.Setting(True)
#: List of selected class value indices in the "Show probabilities" list
selected_classes = settings.ContextSetting([])
#: Draw colored distribution bars
draw_dist = settings.Setting(True)
output_attrs = settings.Setting(True)
output_predictions = settings.Setting(True)
output_probabilities = settings.Setting(True)
def __init__(self):
super().__init__()
#: Input data table
self.data = None # type: Optional[Orange.data.Table]
#: A dict mapping input ids to PredictorSlot
self.predictors = OrderedDict() # type: Dict[object, PredictorSlot]
#: A class variable (prediction target)
self.class_var = None # type: Optional[Orange.data.Variable]
#: List of (discrete) class variable's values
self.class_values = [] # type: List[str]
box = gui.vBox(self.controlArea, "Info")
self.infolabel = gui.widgetLabel(
box, "No data on input.\nPredictors: 0\nTask: N/A")
self.infolabel.setMinimumWidth(150)
gui.button(box, self, "Restore Original Order",
callback=self._reset_order,
tooltip="Show rows in the original order")
self.classification_options = box = gui.vBox(
self.controlArea, "Options (classification)", spacing=-1,
addSpace=False)
gui.checkBox(box, self, "show_predictions", "Show predicted class",
callback=self._update_prediction_delegate)
b = gui.checkBox(box, self, "show_probabilities",
"Show predicted probabilities",
callback=self._update_prediction_delegate)
ibox = gui.indentedBox(box, sep=gui.checkButtonOffsetHint(b),
addSpace=False)
gui.listBox(ibox, self, "selected_classes", "class_values",
callback=self._update_prediction_delegate,
selectionMode=QListWidget.MultiSelection,
addSpace=False)
gui.checkBox(box, self, "draw_dist", "Draw distribution bars",
callback=self._update_prediction_delegate)
box = gui.vBox(self.controlArea, "Data View")
gui.checkBox(box, self, "show_attrs", "Show full data set",
callback=self._update_column_visibility)
box = gui.vBox(self.controlArea, "Output", spacing=-1)
self.checkbox_class = gui.checkBox(
box, self, "output_attrs", "Original data",
callback=self.commit)
self.checkbox_class = gui.checkBox(
box, self, "output_predictions", "Predictions",
callback=self.commit)
self.checkbox_prob = gui.checkBox(
box, self, "output_probabilities", "Probabilities",
callback=self.commit)
gui.rubber(self.controlArea)
self.splitter = QSplitter(
orientation=Qt.Horizontal,
childrenCollapsible=False,
handleWidth=2,
)
self.dataview = TableView(
verticalScrollBarPolicy=Qt.ScrollBarAlwaysOn,
horizontalScrollBarPolicy=Qt.ScrollBarAlwaysOn,
horizontalScrollMode=QTableView.ScrollPerPixel,
selectionMode=QTableView.NoSelection,
focusPolicy=Qt.StrongFocus
)
self.predictionsview = TableView(
verticalScrollBarPolicy=Qt.ScrollBarAlwaysOff,
horizontalScrollBarPolicy=Qt.ScrollBarAlwaysOn,
horizontalScrollMode=QTableView.ScrollPerPixel,
selectionMode=QTableView.NoSelection,
#.........这里部分代码省略.........
示例10: OWPythonScript
#.........这里部分代码省略.........
w.addAction(action)
action = QAction("Update", self)
action.setToolTip("Save changes in the editor to library")
action.setShortcut(QKeySequence(QKeySequence.Save))
action.triggered.connect(self.commitChangesToLibrary)
w.addAction(action)
action = QAction("More", self, toolTip="More actions")
new_from_file = QAction("Import Script from File", self)
save_to_file = QAction("Save Selected Script to File", self)
restore_saved = QAction("Undo Changes to Selected Script", self)
save_to_file.setShortcut(QKeySequence(QKeySequence.SaveAs))
new_from_file.triggered.connect(self.onAddScriptFromFile)
save_to_file.triggered.connect(self.saveScript)
restore_saved.triggered.connect(self.restoreSaved)
menu = QMenu(w)
menu.addAction(new_from_file)
menu.addAction(save_to_file)
menu.addAction(restore_saved)
action.setMenu(menu)
button = w.addAction(action)
button.setPopupMode(QToolButton.InstantPopup)
w.layout().setSpacing(1)
self.controlBox.layout().addWidget(w)
self.execute_button = gui.button(self.controlArea, self, 'Run', callback=self.commit)
self.splitCanvas = QSplitter(Qt.Vertical, self.mainArea)
self.mainArea.layout().addWidget(self.splitCanvas)
self.defaultFont = defaultFont = \
"Monaco" if sys.platform == "darwin" else "Courier"
self.textBox = gui.vBox(self, 'Python Script')
self.splitCanvas.addWidget(self.textBox)
self.text = PythonScriptEditor(self)
self.textBox.layout().addWidget(self.text)
self.textBox.setAlignment(Qt.AlignVCenter)
self.text.setTabStopWidth(4)
self.text.modificationChanged[bool].connect(self.onModificationChanged)
self.saveAction = action = QAction("&Save", self.text)
action.setToolTip("Save script to file")
action.setShortcut(QKeySequence(QKeySequence.Save))
action.setShortcutContext(Qt.WidgetWithChildrenShortcut)
action.triggered.connect(self.saveScript)
self.consoleBox = gui.vBox(self, 'Console')
self.splitCanvas.addWidget(self.consoleBox)
self.console = PythonConsole({}, self)
self.consoleBox.layout().addWidget(self.console)
self.console.document().setDefaultFont(QFont(defaultFont))
self.consoleBox.setAlignment(Qt.AlignBottom)
self.console.setTabStopWidth(4)
select_row(self.libraryView, self.currentScriptIndex)
self.restoreScriptText()
示例11: __init__
def __init__(self, parent=None):
super().__init__(parent)
self.organismCodes = []
self._changedFlag = False
self.__invalidated = False
self.__runstate = OWKEGGPathwayBrowser.Initializing
self.__in_setProgress = False
self.controlArea.setMaximumWidth(250)
box = gui.widgetBox(self.controlArea, "Info")
self.infoLabel = gui.widgetLabel(box, "No data on input\n")
# Organism selection.
box = gui.widgetBox(self.controlArea, "Organism")
self.organismComboBox = gui.comboBox(
box,
self,
"organismIndex",
items=[],
callback=self.Update,
addSpace=True,
tooltip="Select the organism of the input genes",
)
# Selection of genes attribute
box = gui.widgetBox(self.controlArea, "Gene attribute")
self.geneAttrCandidates = itemmodels.VariableListModel(parent=self)
self.geneAttrCombo = gui.comboBox(box, self, "geneAttrIndex", callback=self.Update)
self.geneAttrCombo.setModel(self.geneAttrCandidates)
gui.checkBox(
box, self, "useAttrNames", "Use variable names", disables=[(-1, self.geneAttrCombo)], callback=self.Update
)
self.geneAttrCombo.setDisabled(bool(self.useAttrNames))
gui.separator(self.controlArea)
gui.checkBox(self.controlArea, self, "useReference", "From signal", box="Reference", callback=self.Update)
gui.separator(self.controlArea)
gui.checkBox(
self.controlArea,
self,
"showOrthology",
"Show pathways in full orthology",
box="Orthology",
callback=self.UpdateListView,
)
gui.checkBox(
self.controlArea, self, "autoResize", "Resize to fit", box="Image", callback=self.UpdatePathwayViewTransform
)
box = gui.widgetBox(self.controlArea, "Cache Control")
gui.button(
box,
self,
"Clear cache",
callback=self.ClearCache,
tooltip="Clear all locally cached KEGG data.",
default=False,
autoDefault=False,
)
gui.separator(self.controlArea)
gui.auto_commit(self.controlArea, self, "autoCommit", "Commit")
gui.rubber(self.controlArea)
spliter = QSplitter(Qt.Vertical, self.mainArea)
self.pathwayView = PathwayView(self, spliter)
self.pathwayView.scene().selectionChanged.connect(self._onSelectionChanged)
self.mainArea.layout().addWidget(spliter)
self.listView = QTreeWidget(
allColumnsShowFocus=True, selectionMode=QTreeWidget.SingleSelection, sortingEnabled=True, maximumHeight=200
)
spliter.addWidget(self.listView)
self.listView.setColumnCount(4)
self.listView.setHeaderLabels(["Pathway", "P value", "Genes", "Reference"])
self.listView.itemSelectionChanged.connect(self.UpdatePathwayView)
select = QAction("Select All", self, shortcut=QKeySequence.SelectAll)
select.triggered.connect(self.selectAll)
self.addAction(select)
self.data = None
self.refData = None
self._executor = concurrent.ThreadExecutor()
self.setEnabled(False)
self.setBlocking(True)
#.........这里部分代码省略.........
示例12: __init__
def __init__(self):
super().__init__()
self.corpus = None # Corpus
self.corpus_docs = None # Documents generated from Corpus
self.output_mask = [] # Output corpus indices
self.doc_webview = None # WebView for showing content
self.search_features = [] # two copies are needed since Display allows drag & drop
self.display_features = []
# Info attributes
self.update_info()
info_box = gui.widgetBox(self.controlArea, 'Info')
gui.label(info_box, self, 'Documents: %(n_documents)s')
gui.label(info_box, self, 'Preprocessed: %(is_preprocessed)s')
gui.label(info_box, self, ' ◦ Tokens: %(n_tokens)s')
gui.label(info_box, self, ' ◦ Types: %(n_types)s')
gui.label(info_box, self, 'POS tagged: %(is_pos_tagged)s')
gui.label(info_box, self, 'N-grams range: %(ngram_range)s')
gui.label(info_box, self, 'Matching: %(n_matching)s')
# Search features
self.search_listbox = gui.listBox(
self.controlArea, self, 'search_indices', 'search_features',
selectionMode=QListView.ExtendedSelection,
box='Search features', callback=self.regenerate_docs,)
# Display features
display_box = gui.widgetBox(self.controlArea, 'Display features')
self.display_listbox = gui.listBox(
display_box, self, 'display_indices', 'display_features',
selectionMode=QListView.ExtendedSelection,
callback=self.show_docs, enableDragDrop=True)
self.show_tokens_checkbox = gui.checkBox(display_box, self, 'show_tokens',
'Show Tokens && Tags', callback=self.show_docs)
# Auto-commit box
gui.auto_commit(self.controlArea, self, 'autocommit', 'Send data', 'Auto send is on')
# Search
self.filter_input = gui.lineEdit(self.mainArea, self, '',
orientation=Qt.Horizontal,
sizePolicy=QSizePolicy(QSizePolicy.MinimumExpanding,
QSizePolicy.Fixed),
label='RegExp Filter:')
self.filter_input.textChanged.connect(self.refresh_search)
# Main area
self.splitter = QSplitter(
orientation=Qt.Horizontal,
childrenCollapsible=False,
)
# Document list
self.doc_list = QTableView()
self.doc_list.setSelectionBehavior(QTableView.SelectRows)
self.doc_list.setSelectionMode(QTableView.ExtendedSelection)
self.doc_list.setEditTriggers(QAbstractItemView.NoEditTriggers)
self.doc_list.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
self.doc_list.horizontalHeader().setVisible(False)
self.splitter.addWidget(self.doc_list)
self.doc_list_model = QStandardItemModel(self)
self.doc_list.setModel(self.doc_list_model)
self.doc_list.selectionModel().selectionChanged.connect(self.show_docs)
# Document contents
# For PyQt5 WebEngine's setHtml grabs the focus and makes typing hard
# More info: http://stackoverflow.com/questions/36609489
# To bypass the annoying behaviour disable the widget for WebEngine
self.doc_webview = gui.WebviewWidget(self.splitter, self,
debug=True, enabled=HAVE_WEBKIT)
self.mainArea.layout().addWidget(self.splitter)
示例13: OWCorpusViewer
class OWCorpusViewer(OWWidget):
name = "Corpus Viewer"
description = "Display corpus contents."
icon = "icons/CorpusViewer.svg"
priority = 70
inputs = [(IO.DATA, Table, 'set_data')]
outputs = [(IO.MATCHED, Corpus, widget.Default), (IO.UNMATCHED, Corpus)]
search_indices = ContextSetting([0]) # features included in search
display_indices = ContextSetting([0]) # features for display
show_tokens = Setting(False)
autocommit = Setting(True)
class Warning(OWWidget.Warning):
no_feats_search = Msg('No features included in search.')
no_feats_display = Msg('No features selected for display.')
def __init__(self):
super().__init__()
self.corpus = None # Corpus
self.corpus_docs = None # Documents generated from Corpus
self.output_mask = [] # Output corpus indices
self.doc_webview = None # WebView for showing content
self.search_features = [] # two copies are needed since Display allows drag & drop
self.display_features = []
# Info attributes
self.update_info()
info_box = gui.widgetBox(self.controlArea, 'Info')
gui.label(info_box, self, 'Documents: %(n_documents)s')
gui.label(info_box, self, 'Preprocessed: %(is_preprocessed)s')
gui.label(info_box, self, ' ◦ Tokens: %(n_tokens)s')
gui.label(info_box, self, ' ◦ Types: %(n_types)s')
gui.label(info_box, self, 'POS tagged: %(is_pos_tagged)s')
gui.label(info_box, self, 'N-grams range: %(ngram_range)s')
gui.label(info_box, self, 'Matching: %(n_matching)s')
# Search features
self.search_listbox = gui.listBox(
self.controlArea, self, 'search_indices', 'search_features',
selectionMode=QListView.ExtendedSelection,
box='Search features', callback=self.regenerate_docs,)
# Display features
display_box = gui.widgetBox(self.controlArea, 'Display features')
self.display_listbox = gui.listBox(
display_box, self, 'display_indices', 'display_features',
selectionMode=QListView.ExtendedSelection,
callback=self.show_docs, enableDragDrop=True)
self.show_tokens_checkbox = gui.checkBox(display_box, self, 'show_tokens',
'Show Tokens && Tags', callback=self.show_docs)
# Auto-commit box
gui.auto_commit(self.controlArea, self, 'autocommit', 'Send data', 'Auto send is on')
# Search
self.filter_input = gui.lineEdit(self.mainArea, self, '',
orientation=Qt.Horizontal,
sizePolicy=QSizePolicy(QSizePolicy.MinimumExpanding,
QSizePolicy.Fixed),
label='RegExp Filter:')
self.filter_input.textChanged.connect(self.refresh_search)
# Main area
self.splitter = QSplitter(
orientation=Qt.Horizontal,
childrenCollapsible=False,
)
# Document list
self.doc_list = QTableView()
self.doc_list.setSelectionBehavior(QTableView.SelectRows)
self.doc_list.setSelectionMode(QTableView.ExtendedSelection)
self.doc_list.setEditTriggers(QAbstractItemView.NoEditTriggers)
self.doc_list.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
self.doc_list.horizontalHeader().setVisible(False)
self.splitter.addWidget(self.doc_list)
self.doc_list_model = QStandardItemModel(self)
self.doc_list.setModel(self.doc_list_model)
self.doc_list.selectionModel().selectionChanged.connect(self.show_docs)
# Document contents
# For PyQt5 WebEngine's setHtml grabs the focus and makes typing hard
# More info: http://stackoverflow.com/questions/36609489
# To bypass the annoying behaviour disable the widget for WebEngine
self.doc_webview = gui.WebviewWidget(self.splitter, self,
debug=True, enabled=HAVE_WEBKIT)
self.mainArea.layout().addWidget(self.splitter)
def copy_to_clipboard(self):
text = self.doc_webview.selectedText()
QApplication.clipboard().setText(text)
def set_data(self, data=None):
self.reset_widget()
self.corpus = data
#.........这里部分代码省略.........
示例14: OWCorpusViewer
class OWCorpusViewer(OWWidget):
name = "Corpus Viewer"
description = "Display corpus contents."
icon = "icons/CorpusViewer.svg"
priority = 500
class Inputs:
corpus = Input("Corpus", Corpus, replaces=["Data"])
class Outputs:
matching_docs = Output("Matching Docs", Corpus, default=True)
other_docs = Output("Other Docs", Corpus)
settingsHandler = PerfectDomainContextHandler(
match_values = PerfectDomainContextHandler.MATCH_VALUES_ALL
)
search_indices = ContextSetting([], exclude_metas=False) # features included in search
display_indices = ContextSetting([], exclude_metas=False) # features for display
display_features = ContextSetting([], exclude_metas=False)
regexp_filter = ContextSetting("")
selection = [0] # TODO: DataHashContextHandler
show_tokens = Setting(False)
autocommit = Setting(True)
class Warning(OWWidget.Warning):
no_feats_search = Msg('No features included in search.')
no_feats_display = Msg('No features selected for display.')
def __init__(self):
super().__init__()
self.corpus = None # Corpus
self.corpus_docs = None # Documents generated from Corpus
self.output_mask = [] # Output corpus indices
self.doc_webview = None # WebView for showing content
self.search_features = [] # two copies are needed since Display allows drag & drop
self.display_list_indices = [0]
# Info attributes
self.update_info()
info_box = gui.widgetBox(self.controlArea, 'Info')
gui.label(info_box, self, 'Documents: %(n_documents)s')
gui.label(info_box, self, 'Preprocessed: %(is_preprocessed)s')
gui.label(info_box, self, ' ◦ Tokens: %(n_tokens)s')
gui.label(info_box, self, ' ◦ Types: %(n_types)s')
gui.label(info_box, self, 'POS tagged: %(is_pos_tagged)s')
gui.label(info_box, self, 'N-grams range: %(ngram_range)s')
gui.label(info_box, self, 'Matching: %(n_matching)s')
# Search features
self.search_listbox = gui.listBox(
self.controlArea, self, 'search_indices', 'search_features',
selectionMode=QListView.ExtendedSelection,
box='Search features', callback=self.search_features_changed)
# Display features
display_box = gui.widgetBox(self.controlArea, 'Display features')
self.display_listbox = gui.listBox(
display_box, self, 'display_list_indices', 'display_features',
selectionMode=QListView.ExtendedSelection,
callback=self.show_docs, enableDragDrop=True)
self.show_tokens_checkbox = gui.checkBox(display_box, self, 'show_tokens',
'Show Tokens && Tags', callback=self.show_docs)
# Auto-commit box
gui.auto_commit(self.controlArea, self, 'autocommit', 'Send data', 'Auto send is on')
# Search
self.filter_input = gui.lineEdit(self.mainArea, self, 'regexp_filter',
orientation=Qt.Horizontal,
sizePolicy=QSizePolicy(QSizePolicy.MinimumExpanding,
QSizePolicy.Fixed),
label='RegExp Filter:')
self.filter_input.textChanged.connect(self.refresh_search)
# Main area
self.splitter = QSplitter(
orientation=Qt.Horizontal,
childrenCollapsible=False,
)
# Document list
self.doc_list = QTableView()
self.doc_list.setSelectionBehavior(QTableView.SelectRows)
self.doc_list.setSelectionMode(QTableView.ExtendedSelection)
self.doc_list.setEditTriggers(QAbstractItemView.NoEditTriggers)
self.doc_list.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
self.doc_list.horizontalHeader().setVisible(False)
self.splitter.addWidget(self.doc_list)
self.doc_list_model = QStandardItemModel(self)
self.doc_list.setModel(self.doc_list_model)
self.doc_list.selectionModel().selectionChanged.connect(self.show_docs)
# Document contents
self.doc_webview = gui.WebviewWidget(self.splitter, debug=False)
#.........这里部分代码省略.........
示例15: __init__
def __init__(self):
super().__init__()
self.local_cache_path = os.path.join(data_dir(), self.DATASET_DIR)
self.__awaiting_state = None # type: Optional[_FetchState]
box = gui.widgetBox(self.controlArea, "Info")
self.infolabel = QLabel(text="Initializing...\n\n")
box.layout().addWidget(self.infolabel)
gui.widgetLabel(self.mainArea, "Filter")
self.filterLineEdit = QLineEdit(
textChanged=self.filter
)
self.mainArea.layout().addWidget(self.filterLineEdit)
self.splitter = QSplitter(orientation=Qt.Vertical)
self.view = QTreeView(
sortingEnabled=True,
selectionMode=QTreeView.SingleSelection,
alternatingRowColors=True,
rootIsDecorated=False,
editTriggers=QTreeView.NoEditTriggers,
)
box = gui.widgetBox(self.splitter, "Description", addToLayout=False)
self.descriptionlabel = QLabel(
wordWrap=True,
textFormat=Qt.RichText,
)
self.descriptionlabel = QTextBrowser(
openExternalLinks=True,
textInteractionFlags=(Qt.TextSelectableByMouse |
Qt.LinksAccessibleByMouse)
)
self.descriptionlabel.setFrameStyle(QTextBrowser.NoFrame)
# no (white) text background
self.descriptionlabel.viewport().setAutoFillBackground(False)
box.layout().addWidget(self.descriptionlabel)
self.splitter.addWidget(self.view)
self.splitter.addWidget(box)
self.splitter.setSizes([300, 200])
self.splitter.splitterMoved.connect(
lambda:
setattr(self, "splitter_state", bytes(self.splitter.saveState()))
)
self.mainArea.layout().addWidget(self.splitter)
self.controlArea.layout().addStretch(10)
gui.auto_commit(self.controlArea, self, "auto_commit", "Send Data")
model = QStandardItemModel(self)
model.setHorizontalHeaderLabels(HEADER)
proxy = QSortFilterProxyModel()
proxy.setSourceModel(model)
proxy.setFilterKeyColumn(-1)
proxy.setFilterCaseSensitivity(False)
self.view.setModel(proxy)
if self.splitter_state:
self.splitter.restoreState(self.splitter_state)
self.view.setItemDelegateForColumn(
Header.Size, SizeDelegate(self))
self.view.setItemDelegateForColumn(
Header.Local, gui.IndicatorItemDelegate(self, role=Qt.DisplayRole))
self.view.setItemDelegateForColumn(
Header.Instances, NumericalDelegate(self))
self.view.setItemDelegateForColumn(
Header.Variables, NumericalDelegate(self))
self.view.resizeColumnToContents(Header.Local)
if self.header_state:
self.view.header().restoreState(self.header_state)
self.setBlocking(True)
self.setStatusMessage("Initializing")
self._executor = ThreadPoolExecutor(max_workers=1)
f = self._executor.submit(self.list_remote)
w = FutureWatcher(f, parent=self)
w.done.connect(self.__set_index)