本文整理汇总了Python中AnyQt.QtWidgets.QLineEdit类的典型用法代码示例。如果您正苦于以下问题:Python QLineEdit类的具体用法?Python QLineEdit怎么用?Python QLineEdit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QLineEdit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DiscreteFeatureEditor
class DiscreteFeatureEditor(FeatureEditor):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.valuesedit = QLineEdit()
self.valuesedit.textChanged.connect(self._invalidate)
layout = self.layout()
layout.addRow(self.tr("Values"), self.valuesedit)
def setEditorData(self, data, domain):
self.valuesedit.setText(
", ".join(v.replace(",", r"\,") for v in data.values))
super().setEditorData(data, domain)
def editorData(self):
values = self.valuesedit.text()
values = re.split(r"(?<!\\),", values)
values = tuple(filter(None, [v.replace(r"\,", ",").strip() for v in values]))
return DiscreteDescriptor(
name=self.nameedit.text(),
values=values,
base_value=-1,
ordered=False,
expression=self.expressionedit.text()
)
示例2: __init__
def __init__(self, tree, dataset, master, parent=None):
QLineEdit.__init__(self, parent)
Control.__init__(self, tree, dataset, master)
if hasattr(tree, "regexp"):
self.setValidator(QRegExpValidator(QRegExp(tree.regexp), self))
if hasattr(tree, "defaultValue"):
self.setText(tree.defaultValue)
示例3: __init__
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
layout = QFormLayout(
fieldGrowthPolicy=QFormLayout.ExpandingFieldsGrow
)
layout.setContentsMargins(0, 0, 0, 0)
self.nameedit = QLineEdit(
placeholderText="Name...",
sizePolicy=QSizePolicy(QSizePolicy.Minimum,
QSizePolicy.Fixed)
)
self.expressionedit = QLineEdit(
placeholderText="Expression..."
)
self.attrs_model = itemmodels.VariableListModel(
["Select Feature"], parent=self)
self.attributescb = QComboBox(
minimumContentsLength=16,
sizeAdjustPolicy=QComboBox.AdjustToMinimumContentsLengthWithIcon,
sizePolicy=QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
)
self.attributescb.setModel(self.attrs_model)
sorted_funcs = sorted(self.FUNCTIONS)
self.funcs_model = itemmodels.PyListModelTooltip()
self.funcs_model.setParent(self)
self.funcs_model[:] = chain(["Select Function"], sorted_funcs)
self.funcs_model.tooltips[:] = chain(
[''],
[self.FUNCTIONS[func].__doc__ for func in sorted_funcs])
self.functionscb = QComboBox(
minimumContentsLength=16,
sizeAdjustPolicy=QComboBox.AdjustToMinimumContentsLengthWithIcon,
sizePolicy=QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum))
self.functionscb.setModel(self.funcs_model)
hbox = QHBoxLayout()
hbox.addWidget(self.attributescb)
hbox.addWidget(self.functionscb)
layout.addRow(self.nameedit, self.expressionedit)
layout.addRow(self.tr(""), hbox)
self.setLayout(layout)
self.nameedit.editingFinished.connect(self._invalidate)
self.expressionedit.textChanged.connect(self._invalidate)
self.attributescb.currentIndexChanged.connect(self.on_attrs_changed)
self.functionscb.currentIndexChanged.connect(self.on_funcs_changed)
self._modified = False
示例4: __run_add_package_dialog
def __run_add_package_dialog(self):
self.__add_package_by_name_dialog = dlg = QDialog(
self, windowTitle="Add add-on by name",
)
dlg.setAttribute(Qt.WA_DeleteOnClose)
vlayout = QVBoxLayout()
form = QFormLayout()
form.setContentsMargins(0, 0, 0, 0)
nameentry = QLineEdit(
placeholderText="Package name",
toolTip="Enter a package name as displayed on "
"PyPI (capitalization is not important)")
nameentry.setMinimumWidth(250)
form.addRow("Name:", nameentry)
vlayout.addLayout(form)
buttons = QDialogButtonBox(
standardButtons=QDialogButtonBox.Ok | QDialogButtonBox.Cancel
)
okb = buttons.button(QDialogButtonBox.Ok)
okb.setEnabled(False)
okb.setText("Add")
def changed(name):
okb.setEnabled(bool(name))
nameentry.textChanged.connect(changed)
vlayout.addWidget(buttons)
vlayout.setSizeConstraint(QVBoxLayout.SetFixedSize)
dlg.setLayout(vlayout)
f = None
def query():
nonlocal f
name = nameentry.text()
def query_pypi(name):
# type: (str) -> _QueryResult
res = pypi_json_query_project_meta([name])
assert len(res) == 1
r = res[0]
if r is not None:
r = installable_from_json_response(r)
return _QueryResult(queryname=name, installable=r)
f = self.__executor.submit(query_pypi, name)
okb.setDisabled(True)
f.add_done_callback(
method_queued(self.__on_add_single_query_finish, (object,))
)
buttons.accepted.connect(query)
buttons.rejected.connect(dlg.reject)
dlg.exec_()
示例5: removeActionAt
def removeActionAt(self, position):
"""
Remove the action at position.
"""
self._checkPosition(position)
slot = self.__actions[position - 1]
self.__actions[position - 1] = None
slot.button.hide()
slot.button.deleteLater()
QLineEdit.removeAction(self, slot.action)
self.__layoutActions()
示例6: __init__
def __init__(self, parent):
QFrame.__init__(self, parent)
self.setContentsMargins(0, 0, 0, 0)
layout = QVBoxLayout()
layout.setContentsMargins(0, 0, 0, 0)
layout.setSpacing(1)
self._setNameLineEdit = QLineEdit(self)
layout.addWidget(self._setNameLineEdit)
self._setListView = QListView(self)
self._listModel = QStandardItemModel(self)
self._proxyModel = QSortFilterProxyModel(self)
self._proxyModel.setSourceModel(self._listModel)
self._setListView.setModel(self._proxyModel)
self._setListView.setItemDelegate(ListItemDelegate(self))
self._setNameLineEdit.textChanged.connect(
self._proxyModel.setFilterFixedString)
self._completer = QCompleter(self._listModel, self)
self._setNameLineEdit.setCompleter(self._completer)
self._listModel.itemChanged.connect(self._onSetNameChange)
layout.addWidget(self._setListView)
buttonLayout = QHBoxLayout()
self._addAction = QAction(
"+", self, toolTip="Add a new sort key")
self._updateAction = QAction(
"Update", self, toolTip="Update/save current selection")
self._removeAction = QAction(
"\u2212", self, toolTip="Remove selected sort key.")
self._addToolButton = QToolButton(self)
self._updateToolButton = QToolButton(self)
self._removeToolButton = QToolButton(self)
self._updateToolButton.setSizePolicy(
QSizePolicy.MinimumExpanding, QSizePolicy.Minimum)
self._addToolButton.setDefaultAction(self._addAction)
self._updateToolButton.setDefaultAction(self._updateAction)
self._removeToolButton.setDefaultAction(self._removeAction)
buttonLayout.addWidget(self._addToolButton)
buttonLayout.addWidget(self._updateToolButton)
buttonLayout.addWidget(self._removeToolButton)
layout.addLayout(buttonLayout)
self.setLayout(layout)
self._addAction.triggered.connect(self.addCurrentSelection)
self._updateAction.triggered.connect(self.updateSelectedSelection)
self._removeAction.triggered.connect(self.removeSelectedSelection)
self._setListView.selectionModel().selectionChanged.connect(
self._onListViewSelectionChanged)
self.selectionModel = None
self._selections = []
示例7: paintEvent
def paintEvent(self, event):
QLineEdit.paintEvent(self, event)
if not self.text() and self.placeholderText() and \
not self.hasFocus():
p = QStylePainter(self)
font = self.font()
metrics = QFontMetrics(font)
p.setFont(font)
color = self.palette().color(QPalette.Mid)
p.setPen(color)
left, top, right, bottom = self.getTextMargins()
contents = self.contentsRect()
contents = contents.adjusted(left, top, -right, -bottom)
text = metrics.elidedText(self.placeholderText(),
Qt.ElideMiddle,
contents.width())
p.drawText(contents, Qt.AlignLeft | Qt.AlignVCenter, text)
示例8: __init__
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.__searchline = QLineEdit(self, visible=False, frame=False)
self.__searchline.setAttribute(Qt.WA_MacShowFocusRect, False)
self.__searchline.setFocusProxy(self)
self.__popup = None # type: Optional[QAbstractItemModel]
self.__proxy = None # type: Optional[QSortFilterProxyModel]
self.__popupTimer = QElapsedTimer()
self.setFocusPolicy(Qt.ClickFocus | Qt.TabFocus)
示例9: __init__
def __init__(self, master):
"""Initialize the attributes and set up the interface"""
QDialog.__init__(self, master, windowTitle=self.captionTitle)
WidgetMessagesMixin.__init__(self)
self.setLayout(QVBoxLayout())
self.insert_message_bar()
self.layout().insertWidget(0, self.message_bar)
self.master = master
self.keep_running = False
self.scheduled_call = None
self.saved_state = None
self.saved_progress = 0
self.scores = []
self.add_to_model = queue.Queue()
self.update_timer = QTimer(self)
self.update_timer.timeout.connect(self._update)
self.update_timer.setInterval(200)
self._thread = None
self._worker = None
self.filter = QLineEdit()
self.filter.setPlaceholderText("Filter ...")
self.filter.textChanged.connect(self.filter_changed)
self.layout().addWidget(self.filter)
# Remove focus from line edit
self.setFocus(Qt.ActiveWindowFocusReason)
self.rank_model = QStandardItemModel(self)
self.model_proxy = QSortFilterProxyModel(
self, filterCaseSensitivity=False)
self.model_proxy.setSourceModel(self.rank_model)
self.rank_table = view = QTableView(
selectionBehavior=QTableView.SelectRows,
selectionMode=QTableView.SingleSelection,
showGrid=False,
editTriggers=gui.TableView.NoEditTriggers)
if self._has_bars:
view.setItemDelegate(TableBarItem())
else:
view.setItemDelegate(HorizontalGridDelegate())
view.setModel(self.model_proxy)
view.selectionModel().selectionChanged.connect(
self.on_selection_changed)
view.horizontalHeader().setStretchLastSection(True)
view.horizontalHeader().hide()
self.layout().addWidget(view)
self.button = gui.button(
self, self, "Start", callback=self.toggle, default=True)
示例10: setAction
def setAction(self, action, position=LeftPosition):
"""
Set `action` to be displayed at `position`. Existing action
(if present) will be removed.
Parameters
----------
action : :class:`QAction`
position : int
Position where to set the action (default: ``LeftPosition``).
"""
curr = self.actionAt(position)
if curr is not None:
self.removeAction(position)
# Add the action using QWidget.addAction (for shortcuts)
QLineEdit.addAction(self, action)
button = LineEditButton(self)
button.setToolButtonStyle(Qt.ToolButtonIconOnly)
button.setDefaultAction(action)
button.setVisible(self.isVisible())
button.show()
button.setCursor(Qt.ArrowCursor)
button.triggered.connect(self.triggered)
button.triggered.connect(self.__onTriggered)
slot = _ActionSlot(position, action, button, False)
self.__actions[position - 1] = slot
if not self.testAttribute(Qt.WA_Resized):
# Need some sensible height to do the layout.
self.adjustSize()
self.__layoutActions()
示例11: __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)
示例12: __init__
def __init__(self, parent=None, signalManager=None,
name="Databases update"):
OWWidget.__init__(self, parent, signalManager, name,
wantMainArea=False)
self.searchString = ""
fbox = gui.widgetBox(self.controlArea, "Filter")
self.completer = TokenListCompleter(
self, caseSensitivity=Qt.CaseInsensitive)
self.lineEditFilter = QLineEdit(textChanged=self.SearchUpdate)
self.lineEditFilter.setCompleter(self.completer)
fbox.layout().addWidget(self.lineEditFilter)
box = gui.widgetBox(self.controlArea, "Files")
self.filesView = QTreeWidget(self)
self.filesView.setHeaderLabels(
["", "Data Source", "Update", "Last Updated", "Size"])
self.filesView.setRootIsDecorated(False)
self.filesView.setUniformRowHeights(True)
self.filesView.setSelectionMode(QAbstractItemView.NoSelection)
self.filesView.setSortingEnabled(True)
self.filesView.sortItems(1, Qt.AscendingOrder)
self.filesView.setItemDelegateForColumn(
0, UpdateOptionsItemDelegate(self.filesView))
self.filesView.model().layoutChanged.connect(self.SearchUpdate)
box.layout().addWidget(self.filesView)
box = gui.widgetBox(self.controlArea, orientation="horizontal")
self.updateButton = gui.button(
box, self, "Update all",
callback=self.UpdateAll,
tooltip="Update all updatable files",
)
self.downloadButton = gui.button(
box, self, "Download all",
callback=self.DownloadFiltered,
tooltip="Download all filtered files shown"
)
self.cancelButton = gui.button(
box, self, "Cancel", callback=self.Cancel,
tooltip="Cancel scheduled downloads/updates."
)
self.retryButton = gui.button(
box, self, "Reconnect", callback=self.RetrieveFilesList
)
self.retryButton.hide()
gui.rubber(box)
self.warning(0)
box = gui.widgetBox(self.controlArea, orientation="horizontal")
gui.rubber(box)
self.infoLabel = QLabel()
self.infoLabel.setAlignment(Qt.AlignCenter)
self.controlArea.layout().addWidget(self.infoLabel)
self.infoLabel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self.updateItems = []
self.resize(800, 600)
self.progress = ProgressState(self, maximum=3)
self.progress.valueChanged.connect(self._updateProgress)
self.progress.rangeChanged.connect(self._updateProgress)
self.executor = ThreadExecutor(
threadPool=QThreadPool(maxThreadCount=2)
)
task = Task(self, function=self.RetrieveFilesList)
task.exceptionReady.connect(self.HandleError)
task.start()
self._tasks = []
self._haveProgress = False
示例13: OWDatabasesUpdate
class OWDatabasesUpdate(OWWidget):
name = "Databases Update"
description = "Update local systems biology databases."
icon = "../widgets/icons/Databases.svg"
priority = 10
inputs = []
outputs = []
want_main_area = False
def __init__(self, parent=None, signalManager=None,
name="Databases update"):
OWWidget.__init__(self, parent, signalManager, name,
wantMainArea=False)
self.searchString = ""
fbox = gui.widgetBox(self.controlArea, "Filter")
self.completer = TokenListCompleter(
self, caseSensitivity=Qt.CaseInsensitive)
self.lineEditFilter = QLineEdit(textChanged=self.SearchUpdate)
self.lineEditFilter.setCompleter(self.completer)
fbox.layout().addWidget(self.lineEditFilter)
box = gui.widgetBox(self.controlArea, "Files")
self.filesView = QTreeWidget(self)
self.filesView.setHeaderLabels(
["", "Data Source", "Update", "Last Updated", "Size"])
self.filesView.setRootIsDecorated(False)
self.filesView.setUniformRowHeights(True)
self.filesView.setSelectionMode(QAbstractItemView.NoSelection)
self.filesView.setSortingEnabled(True)
self.filesView.sortItems(1, Qt.AscendingOrder)
self.filesView.setItemDelegateForColumn(
0, UpdateOptionsItemDelegate(self.filesView))
self.filesView.model().layoutChanged.connect(self.SearchUpdate)
box.layout().addWidget(self.filesView)
box = gui.widgetBox(self.controlArea, orientation="horizontal")
self.updateButton = gui.button(
box, self, "Update all",
callback=self.UpdateAll,
tooltip="Update all updatable files",
)
self.downloadButton = gui.button(
box, self, "Download all",
callback=self.DownloadFiltered,
tooltip="Download all filtered files shown"
)
self.cancelButton = gui.button(
box, self, "Cancel", callback=self.Cancel,
tooltip="Cancel scheduled downloads/updates."
)
self.retryButton = gui.button(
box, self, "Reconnect", callback=self.RetrieveFilesList
)
self.retryButton.hide()
gui.rubber(box)
self.warning(0)
box = gui.widgetBox(self.controlArea, orientation="horizontal")
gui.rubber(box)
self.infoLabel = QLabel()
self.infoLabel.setAlignment(Qt.AlignCenter)
self.controlArea.layout().addWidget(self.infoLabel)
self.infoLabel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self.updateItems = []
self.resize(800, 600)
self.progress = ProgressState(self, maximum=3)
self.progress.valueChanged.connect(self._updateProgress)
self.progress.rangeChanged.connect(self._updateProgress)
self.executor = ThreadExecutor(
threadPool=QThreadPool(maxThreadCount=2)
)
task = Task(self, function=self.RetrieveFilesList)
task.exceptionReady.connect(self.HandleError)
task.start()
self._tasks = []
self._haveProgress = False
def RetrieveFilesList(self):
self.retryButton.hide()
#.........这里部分代码省略.........
示例14: __init__
def __init__(self):
super().__init__()
self.data = None
self._pca = None
self._transformed = None
self._variance_ratio = None
self._cumulative = None
self._line = False
self._init_projector()
# Components Selection
box = gui.vBox(self.controlArea, "Components Selection")
form = QFormLayout()
box.layout().addLayout(form)
self.components_spin = gui.spin(
box, self, "ncomponents", 1, MAX_COMPONENTS,
callback=self._update_selection_component_spin,
keyboardTracking=False
)
self.components_spin.setSpecialValueText("All")
self.variance_spin = gui.spin(
box, self, "variance_covered", 1, 100,
callback=self._update_selection_variance_spin,
keyboardTracking=False
)
self.variance_spin.setSuffix("%")
form.addRow("Components:", self.components_spin)
form.addRow("Variance covered:", self.variance_spin)
# Incremental learning
self.sampling_box = gui.vBox(self.controlArea, "Incremental learning")
self.addresstext = QLineEdit(box)
self.addresstext.setPlaceholderText('Remote server')
if self.address:
self.addresstext.setText(self.address)
self.sampling_box.layout().addWidget(self.addresstext)
form = QFormLayout()
self.sampling_box.layout().addLayout(form)
self.batch_spin = gui.spin(
self.sampling_box, self, "batch_size", 50, 100000, step=50,
keyboardTracking=False)
form.addRow("Batch size ~ ", self.batch_spin)
self.start_button = gui.button(
self.sampling_box, self, "Start remote computation",
callback=self.start, autoDefault=False,
tooltip="Start/abort computation on the server")
self.start_button.setEnabled(False)
gui.checkBox(self.sampling_box, self, "auto_update",
"Periodically fetch model", callback=self.update_model)
self.__timer = QTimer(self, interval=2000)
self.__timer.timeout.connect(self.get_model)
self.sampling_box.setVisible(remotely)
# Decomposition
self.decomposition_box = gui.radioButtons(
self.controlArea, self,
"decomposition_idx", [d.name for d in DECOMPOSITIONS],
box="Decomposition", callback=self._update_decomposition
)
# Options
self.options_box = gui.vBox(self.controlArea, "Options")
self.normalize_box = gui.checkBox(
self.options_box, self, "normalize",
"Normalize data", callback=self._update_normalize
)
self.maxp_spin = gui.spin(
self.options_box, self, "maxp", 1, MAX_COMPONENTS,
label="Show only first", callback=self._setup_plot,
keyboardTracking=False
)
self.controlArea.layout().addStretch()
gui.auto_commit(self.controlArea, self, "auto_commit", "Apply",
checkbox_label="Apply automatically")
self.plot = pg.PlotWidget(background="w")
axis = self.plot.getAxis("bottom")
axis.setLabel("Principal Components")
axis = self.plot.getAxis("left")
axis.setLabel("Proportion of variance")
self.plot_horlabels = []
self.plot_horlines = []
self.plot.getViewBox().setMenuEnabled(False)
self.plot.getViewBox().setMouseEnabled(False, False)
self.plot.showGrid(True, True, alpha=0.5)
self.plot.setRange(xRange=(0.0, 1.0), yRange=(0.0, 1.0))
#.........这里部分代码省略.........
示例15: OWPCA
class OWPCA(widget.OWWidget):
name = "PCA"
description = "Principal component analysis with a scree-diagram."
icon = "icons/PCA.svg"
priority = 3050
keywords = ["principal component analysis", "linear transformation"]
class Inputs:
data = Input("Data", Table)
class Outputs:
transformed_data = Output("Transformed data", Table)
components = Output("Components", Table)
pca = Output("PCA", PCA, dynamic=False)
preprocessor = Output("Preprocessor", Preprocess)
settingsHandler = settings.DomainContextHandler()
ncomponents = settings.Setting(2)
variance_covered = settings.Setting(100)
batch_size = settings.Setting(100)
address = settings.Setting('')
auto_update = settings.Setting(True)
auto_commit = settings.Setting(True)
normalize = settings.ContextSetting(True)
decomposition_idx = settings.ContextSetting(0)
maxp = settings.Setting(20)
axis_labels = settings.Setting(10)
graph_name = "plot.plotItem"
class Warning(widget.OWWidget.Warning):
trivial_components = widget.Msg(
"All components of the PCA are trivial (explain 0 variance). "
"Input data is constant (or near constant).")
class Error(widget.OWWidget.Error):
no_features = widget.Msg("At least 1 feature is required")
no_instances = widget.Msg("At least 1 data instance is required")
sparse_data = widget.Msg("Sparse data is not supported")
def __init__(self):
super().__init__()
self.data = None
self._pca = None
self._transformed = None
self._variance_ratio = None
self._cumulative = None
self._line = False
self._init_projector()
# Components Selection
box = gui.vBox(self.controlArea, "Components Selection")
form = QFormLayout()
box.layout().addLayout(form)
self.components_spin = gui.spin(
box, self, "ncomponents", 1, MAX_COMPONENTS,
callback=self._update_selection_component_spin,
keyboardTracking=False
)
self.components_spin.setSpecialValueText("All")
self.variance_spin = gui.spin(
box, self, "variance_covered", 1, 100,
callback=self._update_selection_variance_spin,
keyboardTracking=False
)
self.variance_spin.setSuffix("%")
form.addRow("Components:", self.components_spin)
form.addRow("Variance covered:", self.variance_spin)
# Incremental learning
self.sampling_box = gui.vBox(self.controlArea, "Incremental learning")
self.addresstext = QLineEdit(box)
self.addresstext.setPlaceholderText('Remote server')
if self.address:
self.addresstext.setText(self.address)
self.sampling_box.layout().addWidget(self.addresstext)
form = QFormLayout()
self.sampling_box.layout().addLayout(form)
self.batch_spin = gui.spin(
self.sampling_box, self, "batch_size", 50, 100000, step=50,
keyboardTracking=False)
form.addRow("Batch size ~ ", self.batch_spin)
self.start_button = gui.button(
self.sampling_box, self, "Start remote computation",
callback=self.start, autoDefault=False,
tooltip="Start/abort computation on the server")
self.start_button.setEnabled(False)
gui.checkBox(self.sampling_box, self, "auto_update",
"Periodically fetch model", callback=self.update_model)
self.__timer = QTimer(self, interval=2000)
self.__timer.timeout.connect(self.get_model)
#.........这里部分代码省略.........