def __init__(self): self.setFixedWidth(400) self.setFixedHeight(220) left_box_1 = ShadowGui.widgetBox(self.controlArea, "Loop Management", addSpace=True, orientation="vertical", width=370, height=100) ShadowGui.lineEdit(left_box_1, self, "number_of_new_beams", "Number of new Beams", labelWidth=250, valueType=int, orientation="horizontal") self.le_current_new_beam = ShadowGui.lineEdit(left_box_1, self, "current_new_beam", "Current New Beam", labelWidth=250, valueType=int, orientation="horizontal") self.le_current_new_beam.setReadOnly(True) font = QtGui.QFont(self.le_current_new_beam.font()) font.setBold(True) self.le_current_new_beam.setFont(font) palette = QtGui.QPalette(self.le_current_new_beam.palette()) # make a copy of the palette palette.setColor(QtGui.QPalette.Text, QtGui.QColor('dark blue')) palette.setColor(QtGui.QPalette.Base, QtGui.QColor(243, 240, 160)) self.le_current_new_beam.setPalette(palette) button_box = gui.widgetBox(self.controlArea, "", addSpace=True, orientation="horizontal") self.start_button = gui.button(button_box, self, "Start Loop", callback=self.startLoop) self.start_button.setFixedHeight(45) stop_button = gui.button(button_box, self, "Interrupt", callback=self.stopLoop) stop_button.setFixedHeight(45) font = QtGui.QFont(stop_button.font()) font.setBold(True) stop_button.setFont(font) palette = QtGui.QPalette(stop_button.palette()) # make a copy of the palette palette.setColor(QtGui.QPalette.ButtonText, QtGui.QColor('red')) stop_button.setPalette(palette) # assign new palette gui.rubber(self.controlArea)
def __init__(self): super().__init__() self.data = None self.file_att = None # attribute with image file names self.origin = None # origin of image files box = gui.widgetBox(self.controlArea, "Info") self.info_a = gui.widgetLabel(box, "No data on input.") self.info_b = gui.widgetLabel(box, "") box = gui.widgetBox(self.controlArea, "Server Token") gui.lineEdit(box, self, "token", "Token: ", controlWidth=250, orientation=Qt.Horizontal, enterPlaceholder=True, callback=self.token_name_changed) gui.button( box, self, "Get Token", callback=self.open_server_token_page, autoDefault=False ) self.controlArea.setMinimumWidth(self.controlArea.sizeHint().width()) self.layout().setSizeConstraint(QtGui.QLayout.SetFixedSize) self.commit_box = gui.auto_commit( self.controlArea, self, "auto_commit", label="Commit", checkbox_label="Commit on change" ) self.commit_box.setEnabled(False) self.profiler = ImageProfiler(token=self.token) if self.token: self.profiler.set_token(self.token) self.set_info()
def __init__(self): super().__init__() RecentPathsWComboMixin.__init__(self) self.loaded_file = "" vbox = gui.vBox(self.controlArea, "Distance File", addSpace=True) box = gui.hBox(vbox) self.file_combo.setMinimumWidth(300) box.layout().addWidget(self.file_combo) self.file_combo.activated[int].connect(self.select_file) button = gui.button(box, self, '...', callback=self.browse_file) button.setIcon(self.style().standardIcon(QtGui.QStyle.SP_DirOpenIcon)) button.setSizePolicy( QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed) button = gui.button( box, self, "Reload", callback=self.reload, default=True) button.setIcon(self.style().standardIcon(QtGui.QStyle.SP_BrowserReload)) button.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) box = gui.vBox(self.controlArea, "Info", addSpace=True) self.infoa = gui.widgetLabel(box, 'No data loaded.') self.warnings = gui.widgetLabel(box, ' ') #Set word wrap, so long warnings won't expand the widget self.warnings.setWordWrap(True) self.warnings.setSizePolicy( QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.MinimumExpanding) self.set_file_list() QtCore.QTimer.singleShot(0, self.open_file)
def __init__(self, parent=None, signalManager=None, stored_settings=None): super(OWSql, self).__init__(parent=parent, signalManager=signalManager, stored_settings=stored_settings) self._connection = None vbox = gui.widgetBox(self.controlArea, "Server", addSpace=True) box = gui.widgetBox(vbox) self.servertext = QtGui.QLineEdit(box) self.servertext.setPlaceholderText('Server') if self.host: self.servertext.setText(self.host) box.layout().addWidget(self.servertext) self.databasetext = QtGui.QLineEdit(box) self.databasetext.setPlaceholderText('Database') if self.database: self.databasetext.setText(self.database) box.layout().addWidget(self.databasetext) self.usernametext = QtGui.QLineEdit(box) self.usernametext.setPlaceholderText('Username') if self.username: self.usernametext.setText(self.username) box.layout().addWidget(self.usernametext) self.passwordtext = QtGui.QLineEdit(box) self.passwordtext.setPlaceholderText('Password') self.passwordtext.setEchoMode(QtGui.QLineEdit.Password) if self.password: self.passwordtext.setText(self.password) box.layout().addWidget(self.passwordtext) tables = gui.widgetBox(box, orientation='horizontal') self.tablecombo = QtGui.QComboBox(tables) choices = ['Select a table'] + self.tables + ['Custom SQL'] for i, item in enumerate(choices): self.tablecombo.addItem(item) if item == self.table: self.tablecombo.setCurrentIndex(i) tables.layout().addWidget(self.tablecombo) self.tablecombo.activated[int].connect(self.select_table) self.connectbutton = gui.button( tables, self, '↻', callback=self.connect) self.connectbutton.setSizePolicy( QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) tables.layout().addWidget(self.connectbutton) self.custom_sql = gui.widgetBox(box, orientation='vertical') self.custom_sql.setVisible(False) self.sqltext = QtGui.QTextEdit(self.custom_sql) self.sqltext.setPlainText(self.sql) self.custom_sql.layout().addWidget(self.sqltext) self.executebtn = gui.button( self.custom_sql, self, 'Execute', callback=self.execute_sql) box.layout().addWidget(self.custom_sql) if self.table: self.open_table()
def __init__(self): super().__init__() box = gui.widgetBox(self.controlArea, "Movie Selection (from %d)" % len(movielens.get_all_movie_names())) methodbox = gui.radioButtons(box, self, "method", callback=self._on_method_changed) gui.appendRadioButton(methodbox, "Fraction of movies") percent = gui.hSlider( gui.indentedBox(methodbox), self, "percent", minValue=1, maxValue=100, step=1, ticks=10, labelFormat="%d %%" ) gui.appendRadioButton(methodbox, "Time period:") ibox = gui.indentedBox(methodbox) start = gui.spin(ibox, self, "start", 1907, 2015, 1, label="Starting year: ") end = gui.spin(ibox, self, "end", 1907, 2015, 1, label="Ending year: ") self.method_params = [percent, start, end] gui.button(self.controlArea, self, "&Apply", callback=self.send_output, default=True) self.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)) self.setMinimumWidth(250) self.setMaximumWidth(250) self._on_method_changed() self.send_output()
def __init__(self, parent=None, signalManager=None, settings=None, data=None, file_formats=None): super().__init__(self, parent, signalManager, settings, "Save") self.data = None self.filename = "" self.format_index = 0 self.file_formats = FileFormats.writers if file_formats: self.file_formats = file_formats self.formats = tuple((FileFormats.names[ext], ext) for ext in self.file_formats) self.comboBoxFormat = gui.comboBox( self.controlArea, self, value='format_index', items=['{} (*{})'.format(*x) for x in self.formats], box='File Format', callback=self.reset_filename) box = gui.widgetBox(self.controlArea) self.save = gui.button(box, self, "Save", callback=self.save_file, default=True, disabled=True) gui.separator(box) self.saveAs = gui.button(box, self, "Save as ...", callback=self.save_file_as, disabled=True) self.setMinimumWidth(320) self.adjustSize() if data: self.dataset(data)
def __init__(self, data=None, file_formats=None): super().__init__() self.data = None self.filename = "" self.format_index = 0 self.file_formats = file_formats or FileFormat.writers self.formats = [ (f.DESCRIPTION, f.EXTENSIONS) for f in sorted(set(self.file_formats.values()), key=lambda f: f.OWSAVE_PRIORITY) ] self.comboBoxFormat = gui.comboBox( self.controlArea, self, value="format_index", items=["{} (*{})".format(x[0], " *".join(x[1])) for x in self.formats], box="File Format", ) box = gui.widgetBox(self.controlArea) self.save = gui.button(box, self, "Save", callback=self.save_file, default=True, disabled=True) gui.separator(box) self.saveAs = gui.button(box, self, "Save as ...", callback=self.save_file_as, disabled=True) self.setMinimumWidth(320) self.adjustSize() if data: self.dataset(data)
def __init__(self): super().__init__() self.data = None """The LazyTable that will be send.""" # GUI: as simple as possible for now box = gui.widgetBox(self.controlArea, "SAMP Info") self.infoa = gui.widgetLabel(widget=box, label='SAMP status unknown.') box_input_catalog = gui.widgetBox(box, orientation=0) self.input_catalog_text = gui.widgetLabel(widget=box_input_catalog , label='Catalog') self.input_catalog = gui.lineEdit(widget=box_input_catalog , master=self, value='catalog_of_interest') #self.resize(100,50) self.button_disconnect = gui.button(self.controlArea, self, "&Disconnect", callback=self.disconnect_samp, default=False) self.button_connect = gui.button(self.controlArea, self, "&Connect", callback=self.connect_samp, default=False) self.button_disconnect.setHidden(True) #gui.button(self.controlArea, self, "&Pull Rows", callback=self.pull_rows, default=False) gui.button(self.controlArea, self, "&Set Table", callback=self.we_have_a_new_table, default=False) # Create a SAMP client and connect to HUB. # Do not make the client in __init__ because this does not allow # the client to disconnect and reconnect again. self.samp_client = None self.connect_samp()
def __init__(self, parent=None): super().__init__(parent) self.data = None self.preprocessors = None box = gui.widgetBox(self.controlArea, "Learner/Classifier Name") gui.lineEdit(box, self, "learner_name") box = gui.widgetBox(self.controlArea, "Neighbors") gui.spin(box, self, "n_neighbors", 1, 100, label="Number of neighbors") box = gui.widgetBox(box, "Metric") box.setFlat(True) gui.comboBox(box, self, "metric_index", items=["Euclidean", "Manhattan", "Maximal", "Mahalanobis"]) self.metrics = ["euclidean", "manhattan", "chebyshev", "mahalanobis"] gui.button(self.controlArea, self, "Apply", callback=self.apply, default=True) self.setMinimumWidth(250) layout = self.layout() self.layout().setSizeConstraint(layout.SetFixedSize) self.apply()
def __init__(self): super().__init__() self.data = None self.preprocessors = None box = gui.widgetBox(self.controlArea, self.tr("Name")) gui.lineEdit(box, self, "learner_name") box = gui.widgetBox(self.controlArea, box=True) gui.comboBox(box, self, "penalty_type", label="Regularization type: ", items=self.penalty_types, orientation="horizontal", addSpace=4) gui.widgetLabel(box, "Strength:") box2 = gui.widgetBox(gui.indentedBox(box), orientation="horizontal") gui.widgetLabel(box2, "Weak").setStyleSheet("margin-top:6px") gui.hSlider(box2, self, "C_index", minValue=0, maxValue=len(self.C_s) - 1, callback=self.set_c, createLabel=False) gui.widgetLabel(box2, "Strong").setStyleSheet("margin-top:6px") box2 = gui.widgetBox(box, orientation="horizontal") box2.layout().setAlignment(Qt.AlignCenter) self.c_label = gui.widgetLabel(box2) box = gui.widgetBox(self.controlArea, orientation="horizontal", margin=0) box.layout().addWidget(self.report_button) gui.button(box, self, "&Apply", callback=self.apply, default=True) self.set_c() self.apply()
def __init__(self, parent, caption="Color Palette", callback=None): super().__init__(parent) self.setCaption(caption) self.setLayout(QVBoxLayout(self)) self.layout().setMargin(4) self.callback = callback self.contPaletteNames = [] self.exContPaletteNames = [] self.discPaletteNames = [] self.colorButtonNames = [] self.colorSchemas = [] self.selectedSchemaIndex = 0 self.mainArea = gui.widgetBox(self, spacing=4) self.layout().addWidget(self.mainArea) self.schemaCombo = gui.comboBox( self.mainArea, self, "selectedSchemaIndex", box="Saved Profiles", callback=self.paletteSelected) self.hbox = gui.widgetBox(self, orientation="horizontal") self.okButton = gui.button(self.hbox, self, "OK", self.acceptChanges) self.cancelButton = gui.button(self.hbox, self, "Cancel", self.reject) self.setMinimumWidth(230) self.resize(350, 200)
def __init__(self, parent=None): super().__init__(parent) self.train_data = None self.test_data = None #: An Ordered dictionary with current inputs and their testing #: results. self.learners = OrderedDict() sbox = gui.widgetBox(self.controlArea, "Sampling") rbox = gui.radioButtons( sbox, self, "resampling", callback=self._param_changed ) gui.appendRadioButton(rbox, "Cross validation") ibox = gui.indentedBox(rbox) gui.spin(ibox, self, "k_folds", 2, 50, label="Number of folds:", callback=self.kfold_changed) gui.appendRadioButton(rbox, "Leave one out") gui.appendRadioButton(rbox, "Random sampling") ibox = gui.indentedBox(rbox) gui.spin(ibox, self, "n_repeat", 2, 50, label="Repeat train/test", callback=self.bootstrap_changed) gui.widgetLabel(ibox, "Relative training set size:") gui.hSlider(ibox, self, "sample_p", minValue=1, maxValue=100, ticks=20, vertical=False, labelFormat="%d %%", callback=self.bootstrap_changed) gui.appendRadioButton(rbox, "Test on train data") gui.appendRadioButton(rbox, "Test on test data") rbox.layout().addSpacing(5) gui.button(rbox, self, "Apply", callback=self.apply) self.cbox = gui.widgetBox(self.controlArea, "Target class") self.class_selection_combo = gui.comboBox(self.cbox, self, "class_selection", items=[], callback=self._select_class, sendSelectedValue=True, valueType=str) gui.rubber(self.controlArea) self.view = QTreeView( rootIsDecorated=False, uniformRowHeights=True, wordWrap=True, editTriggers=QTreeView.NoEditTriggers ) header = self.view.header() header.setResizeMode(QHeaderView.ResizeToContents) header.setDefaultAlignment(Qt.AlignCenter) header.setStretchLastSection(False) self.result_model = QStandardItemModel() self.view.setModel(self.result_model) self.view.setItemDelegate(ItemDelegate()) self._update_header() box = gui.widgetBox(self.mainArea, "Evaluation Results") box.layout().addWidget(self.view)
def __init__(self): super().__init__() # The main label of the Control's GUI. # gui.label(self.controlArea, self, "Spark Context") # Create parameters Box. box = gui.widgetBox(self.controlArea, "Spark SQL Table", addSpace = True) self.gui_parameters = OrderedDict() if self.hc: self.databases = [i.result for i in self.hc.sql("show databases").collect()] default_value = self.saved_gui_params.get('database', 'default') if default_value not in self.databases: self.databases.append(default_value) self.database = default_value self.refresh_databases_btn = gui.button(box, self, label = 'Refresh databases', callback = self.fill_database_list) self.gui_parameters['database'] = GuiParam(parent_widget = box, list_values = self.databases, label = 'Database', default_value = default_value, callback_func = self.refresh_database) default_value = self.saved_gui_params.get('table', '') self.gui_parameters['table'] = GuiParam(parent_widget = box, label = 'Table', default_value = default_value, list_values = [default_value]) self.refresh_database(self.gui_parameters['database'].get_value()) action_box = gui.widgetBox(box) # Action Button self.create_sc_btn = gui.button(action_box, self, label = 'Submit', callback = self.submit)
def __init__(self): super().__init__() self.selectedIndex = -1 #: input model/classifier self.model = None box = gui.widgetBox(self.controlArea, self.tr("File"), orientation=QtGui.QHBoxLayout()) self.filesCB = gui.comboBox(box, self, "selectedIndex", callback=self._on_recent) self.filesCB.setMinimumContentsLength(20) self.filesCB.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength) button = gui.button(box, self, "...", callback=self.browse, default=True) button.setIcon(self.style().standardIcon(QtGui.QStyle.SP_DirOpenIcon)) button.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed) self.savebutton = gui.button(self.controlArea, self, "Save", callback=self.savecurrent, default=True) self.savebutton.setEnabled(False) # filter valid existing filenames self.history = list(filter(os.path.isfile, self.history))[:20] for filename in self.history: self.filesCB.addItem(os.path.basename(filename), userData=filename) # restore the current selection if the filename is # in the history list if self.filename in self.history: self.selectedIndex = self.history.index(self.filename) else: self.selectedIndex = -1 self.filename = None
def __init__(self): super().__init__() # options box self.options_box = gui.widgetBox(self.controlArea, "Data") opts = dict( widget=self.options_box, master=self, orientation=Qt.Horizontal, callback=self.restart, sendSelectedValue=True, maximumContentsLength=15) self.cbx = gui.comboBox(value='attr_x', label='X: ', **opts) self.cby = gui.comboBox(value='attr_y', label='Y: ', **opts) self.centroids_box = gui.widgetBox(self.controlArea, "Centroids") self.centroid_numbers_spinner = gui.spin( self.centroids_box, self, 'number_of_clusters', minv=1, maxv=10, step=1, label='Number of centroids:', alignment=Qt.AlignRight, callback=self.number_of_clusters_change) self.restart_button = gui.button( self.centroids_box, self, "Randomize Positions", callback=self.restart) gui.separator(self.centroids_box) self.lines_checkbox = gui.checkBox( self.centroids_box, self, 'lines_to_centroids', 'Show membership lines', callback=self.complete_replot) # control box gui.separator(self.controlArea, 20, 20) self.step_box = gui.widgetBox(self.controlArea, "Manually step through") self.step_button = gui.button( self.step_box, self, self.STEP_BUTTONS[1], callback=self.step) self.step_back_button = gui.button( self.step_box, self, "Step Back", callback=self.step_back) self.run_box = gui.widgetBox(self.controlArea, "Run") self.auto_play_speed_spinner = gui.hSlider( self.run_box, self, 'auto_play_speed', label='Speed:', minValue=0, maxValue=1.91, step=0.1, intOnly=False, createLabel=False) self.auto_play_button = gui.button( self.run_box, self, self.AUTOPLAY_BUTTONS[0], callback=self.auto_play) gui.rubber(self.controlArea) # disable until data loaded self.set_disabled_all(True) # graph in mainArea self.scatter = Scatterplot( click_callback=self.graph_clicked, drop_callback=self.centroid_dropped, xAxis_gridLineWidth=0, yAxis_gridLineWidth=0, tooltip_enabled=False, debug=False) # Just render an empty chart so it shows a nice 'No data to display' self.scatter.chart() self.mainArea.layout().addWidget(self.scatter)
def __init__(self): super().__init__() self.data = None self.input_features = None self.attrs = [] self.attr_box = gui.hBox(self.mainArea) model = VariableListModel() model.wrap(self.attrs) self.attrXCombo = gui.comboBox( self.attr_box, self, value="attrX", contentsLength=12, callback=self.change_attr, sendSelectedValue=True, valueType=str) self.attrXCombo.setModel(model) gui.widgetLabel(self.attr_box, "\u2715").\ setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.attrYCombo = gui.comboBox( self.attr_box, self, value="attrY", contentsLength=12, callback=self.change_attr, sendSelectedValue=True, valueType=str) self.attrYCombo.setModel(model) self.canvas = QGraphicsScene() self.canvasView = _ViewWithPress(self.canvas, self.mainArea, handler=self.reset_selection) self.mainArea.layout().addWidget(self.canvasView) self.canvasView.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.canvasView.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) box = gui.hBox(self.mainArea) gui.button(box, None, "&Save Graph", callback=self.save_graph, autoDefault=False) gui.button(box, None, "&Report", callback=self.show_report, autoDefault=False)
def __init__(self): super().__init__() self.data = None self.input_vars = () self._invalidated = False box = gui.vBox(self.controlArea, "Domain Features") self.domain_model = itemmodels.VariableListModel() self.domain_view = QListView( selectionMode=QListView.SingleSelection ) self.domain_view.setModel(self.domain_model) self.domain_view.selectionModel().selectionChanged.connect( self._on_selection_changed) box.layout().addWidget(self.domain_view) box = gui.hBox(self.controlArea) gui.button(box, self, "Reset Selected", callback=self.reset_selected) gui.button(box, self, "Reset All", callback=self.reset_all) gui.auto_commit(self.controlArea, self, "autocommit", "Apply") box = gui.vBox(self.mainArea, "Edit") self.editor_stack = QStackedWidget() self.editor_stack.addWidget(DiscreteVariableEditor()) self.editor_stack.addWidget(ContinuousVariableEditor()) self.editor_stack.addWidget(VariableEditor()) box.layout().addWidget(self.editor_stack)
def __init__(self, parent=None): super().__init__(parent) self.data = None self.preprocessors = None box = gui.widgetBox(self.controlArea, "Learner/Predictor Name") gui.lineEdit(box, self, "learner_name") box = gui.widgetBox(self.controlArea, "Options") box = gui.radioButtons(box, self, "reg_type", callback=self._reg_type_changed) gui.appendRadioButton(box, "Ordinary linear regression") gui.appendRadioButton(box, "Ridge regression") ibox = gui.indentedBox(box) gui.doubleSpin(ibox, self, "ridgealpha", 0.0, 1000.0, label="alpha:") self.ridge_box = ibox gui.appendRadioButton(box, "Lasso regression") ibox = gui.indentedBox(box) gui.doubleSpin(ibox, self, "lassoalpha", 0.0, 1000.0, label="alpha") self.lasso_box = ibox gui.button(self.controlArea, self, "Apply", callback=self.apply, default=True) self.layout().setSizeConstraint(QLayout.SetFixedSize) self.ridge_box.setEnabled(self.reg_type == self.Ridge) self.lasso_box.setEnabled(self.reg_type == self.Lasso) self.apply()
def _create_layout(self): self._new_webview() box = gui.widgetBox(self.controlArea, 'Info') self.topic_info = gui.label(box, self, '%(n_topic_words)d words in a topic') gui.label(box, self, '%(documents_info_str)s') box = gui.widgetBox(self.controlArea, 'Cloud preferences') gui.checkBox(box, self, 'words_color', 'Color words', callback=self.on_cloud_pref_change) TILT_VALUES = ('no', 'slight', 'more', 'full') gui.valueSlider(box, self, 'words_tilt', label='Words tilt:', values=list(range(len(TILT_VALUES))), callback=self.on_cloud_pref_change, labelFormat=lambda x: TILT_VALUES[x]) gui.button(box, None, 'Regenerate word cloud', callback=self.on_cloud_pref_change) box = gui.widgetBox(self.controlArea, 'Words && weights') self.table = gui.TableWidget(box, col_labels=['Weight', 'Word'], multi_selection=True, select_rows=True) def _selection_changed(selected, deselected): for index in deselected.indexes(): data = self.table.rowData(index.row()) self.selected_words.remove(data) for index in selected.indexes(): data = self.table.rowData(index.row()) self.selected_words.add(data) self.cloud_reselect() self.table.selectionChanged = _selection_changed
def __init__(self): super().__init__() self.corpus = None self.preprocessor = None self.normalization = None # Pre-processing info. pp_info_box = gui.widgetBox(self.controlArea, "Pre-processing info") pp_info = "Includes punctuation: {}\n" \ "Lowercase: {}\n" \ "Transformation: {}\n" \ "Stop words removed: {}\n" \ "TF-IDF performed: {}\n" \ "Normalization: {}"\ .format(False, False, None, None, self.use_tfidf, self.normalization) self.pp_info_label = gui.label(pp_info_box, self, pp_info) # TF-IDF. tfidf_box = gui.widgetBox(self.controlArea, "TF-IDF", addSpace=False) self.tfidf_chbox = gui.checkBox(tfidf_box, self, "use_tfidf", "Use TF-IDF") self.tfidf_chbox.stateChanged.connect(self._tfidf_changed) ibox = gui.indentedBox(tfidf_box) self.norm_combo = gui.comboBox(ibox, self, 'normalization_type', items=self._normalization_options, label="Normalization:") self.norm_combo.activated[int].connect(self._select_normalization) self.norm_combo.setEnabled(self.use_tfidf) gui.button(self.controlArea, self, "&Apply", callback=self.apply, default=True)
def __init__(self): super().__init__() self.data = None grid = QGridLayout() gui.widgetBox(self.controlArea, orientation=grid) grid.addWidget( gui.checkBox( None, self, "add_type_annotations", "Add type annotations to header", tooltip= "Some formats (Tab-delimited, Comma-separated) can include \n" "additional information about variables types in header rows.", callback=self._update_messages), 0, 0, 1, 2) grid.setRowMinimumHeight(1, 8) grid.addWidget( gui.checkBox( None, self, "auto_save", "Autosave when receiving new data", callback=self._update_messages), 2, 0, 1, 2) grid.setRowMinimumHeight(3, 8) self.bt_save = gui.button(None, self, "Save", callback=self.save_file) grid.addWidget(self.bt_save, 4, 0) grid.addWidget( gui.button(None, self, "Save as ...", callback=self.save_file_as), 4, 1) self.adjustSize() self._update_messages()
def __init__(self, parent=None, signalManager=None, stored_settings=None): super(OWSql, self).__init__(parent=parent, signalManager=signalManager, stored_settings=stored_settings) self._connection = None vbox = gui.widgetBox(self.controlArea, "Server", addSpace=True) box = gui.widgetBox(vbox) self.servertext = QtGui.QLineEdit(box) self.servertext.setPlaceholderText('Server') if self.host: self.servertext.setText(self.host if not self.port else '{}:{}'.format(self.host, self.port)) box.layout().addWidget(self.servertext) self.databasetext = QtGui.QLineEdit(box) self.databasetext.setPlaceholderText('Database') if self.database: self.databasetext.setText(self.database) box.layout().addWidget(self.databasetext) self.usernametext = QtGui.QLineEdit(box) self.usernametext.setPlaceholderText('Username') if self.username: self.usernametext.setText(self.username) box.layout().addWidget(self.usernametext) self.passwordtext = QtGui.QLineEdit(box) self.passwordtext.setPlaceholderText('Password') self.passwordtext.setEchoMode(QtGui.QLineEdit.Password) if self.password: self.passwordtext.setText(self.password) box.layout().addWidget(self.passwordtext) tables = gui.widgetBox(box, orientation='horizontal') self.tablecombo = QtGui.QComboBox(tables) tables.layout().addWidget(self.tablecombo) self.tablecombo.activated[int].connect(self.select_table) self.connectbutton = gui.button( tables, self, '↻', callback=self.connect) self.connectbutton.setSizePolicy( QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) tables.layout().addWidget(self.connectbutton) self.custom_sql = gui.widgetBox(box, orientation='vertical') self.custom_sql.setVisible(False) self.sqltext = QtGui.QTextEdit(self.custom_sql) self.sqltext.setPlainText(self.sql) self.custom_sql.layout().addWidget(self.sqltext) self.executebtn = gui.button( self.custom_sql, self, 'Execute', callback=self.open_table) box.layout().addWidget(self.custom_sql) gui.checkBox(box, self, "guess_values", "Auto-discover discrete variables.", callback=self.open_table) self.connect() if self.table: self.open_table()
def __init__(self): super().__init__() self.preprocessors = None self.data = None box = gui.widgetBox(self.controlArea, "Learner/Model Name") gui.lineEdit(box, self, "learner_name") box = gui.widgetBox(self.controlArea, "Neighbors") gui.spin(box, self, "n_neighbors", 1, 100, label="Number of neighbors") box = gui.widgetBox(box, "Metric") box.setFlat(True) box.layout().setContentsMargins(0, 0, 0, 0) gui.comboBox(box, self, "metric_index", items=["Euclidean", "Manhattan", "Maximal", "Mahalanobis"]) self.metrics = ["euclidean", "manhattan", "chebyshev", "mahalanobis"] gui.button(self.controlArea, self, "Apply", callback=self.apply, default=True) self.controlArea.layout().addWidget(self.report_button) layout = self.layout() self.layout().setSizeConstraint(layout.SetFixedSize) self.apply()
def __init__(self, parent, windowTitle="Color Palette"): super().__init__(parent, windowTitle=windowTitle) if PYQT_VERSION < 0x50000: gui.OWComponent.__init__(self, None) self.setLayout(QVBoxLayout()) self.layout().setContentsMargins(4, 4, 4, 4) self.contPaletteNames = [] self.exContPaletteNames = [] self.discPaletteNames = [] self.colorButtonNames = [] self.colorSchemas = [] self.selectedSchemaIndex = 0 self.mainArea = gui.vBox(self, spacing=4) self.layout().addWidget(self.mainArea) self.schemaCombo = gui.comboBox( self.mainArea, self, "selectedSchemaIndex", box="Saved Profiles", callback=self.paletteSelected) self.hbox = gui.hBox(self) self.okButton = gui.button(self.hbox, self, "OK", self.acceptChanges) self.cancelButton = gui.button(self.hbox, self, "Cancel", self.reject) self.setMinimumWidth(230) self.resize(350, 200)
def __init__(self): super().__init__() self.relation = None form = QtGui.QGridLayout() methodbox = gui.radioButtonsInBox( self.controlArea, self, "method", [], box=self.tr("Sampling method"), orientation=form) rows = gui.appendRadioButton(methodbox, "Rows", addToLayout=False) form.addWidget(rows, 0, 0, Qt.AlignLeft) cols = gui.appendRadioButton(methodbox, "Columns", addToLayout=False) form.addWidget(cols, 0, 1, Qt.AlignLeft) rows_and_cols = gui.appendRadioButton(methodbox, "Rows and columns", addToLayout=False) form.addWidget(rows_and_cols, 1, 0, Qt.AlignLeft) entries = gui.appendRadioButton(methodbox, "Entries", addToLayout=False) form.addWidget(entries, 1, 1, Qt.AlignLeft) sample_size = gui.widgetBox(self.controlArea, "Proportion of data in the sample") percent = gui.hSlider( sample_size, self, 'percent', minValue=1, maxValue=100, step=5, ticks=10, labelFormat=" %d%%") gui.button(self.controlArea, self, "&Apply", callback=self.send_output, default=True) self.setSizePolicy( QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)) self.setMinimumWidth(250) self.send_output()
def __init__(self): super().__init__() gui.label(self.controlArea, self, "Spark DataFrame") self.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum) self.allSQLSelectWidgets.append(self) # set default settings self.domain = None self.queryFile = None self.query = '' self.lastQuery = None # self.loadSettings() if self.lastQuery is not None: self.query = self.lastQuery # query self.splitCanvas = QSplitter(QtCore.Qt.Vertical, self.mainArea) self.mainArea.layout().addWidget(self.splitCanvas) self.textBox = gui.widgetBox(self, 'SparkSQL') self.splitCanvas.addWidget(self.textBox) self.queryTextEdit = QPlainTextEdit(self.query, self) self.textBox.layout().addWidget(self.queryTextEdit) self.selectBox = gui.widgetBox(self.controlArea, "Select statement") self.selectBox.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) gui.button(self.selectBox, self, 'format SQL!', callback = self.format_sql, disabled = 0) gui.button(self.selectBox, self, 'execute!', callback = self.executeQuery, disabled = 0) # info self.infoBox = gui.widgetBox(self.controlArea, "Info") self.info = [] self.info.append(gui.label(self.infoBox, self, 'No data loaded.')) self.info.append(gui.label(self.infoBox, self, '')) self.resize(300, 300)
def __init__(self): super().__init__() self.data = {} # key: id, value: ExampleTable self.dist_color = QtGui.QColor(*self.dist_color_RGB) self.locale = QtCore.QLocale() info_box = gui.widgetBox(self.controlArea, "Info") self.info_ex = gui.widgetLabel(info_box, 'No data on input.', ) self.info_ex.setWordWrap(True) self.info_attr = gui.widgetLabel(info_box, ' ') self.info_attr.setWordWrap(True) self.info_class = gui.widgetLabel(info_box, ' ') self.info_class.setWordWrap(True) self.info_meta = gui.widgetLabel(info_box, ' ') self.info_meta.setWordWrap(True) gui.separator(info_box) gui.button(info_box, self, "Restore Original Order", callback=self.reset_sort_clicked, tooltip="Show rows in the original order") info_box.setMinimumWidth(200) gui.separator(self.controlArea) box = gui.widgetBox(self.controlArea, "Variables") self.c_show_attribute_labels = gui.checkBox( box, self, "show_attribute_labels", "Show variable labels (if present)", callback=self.c_show_attribute_labels_clicked) self.c_show_attribute_labels.setEnabled(True) gui.checkBox(box, self, "show_distributions", 'Visualize continuous values', callback=self.cb_show_distributions) gui.checkBox(box, self, "color_by_class", 'Color by instance classes', callback=self.cb_show_distributions) gui.button(box, self, "Set colors", self.set_colors, tooltip="Set the background color and color palette") gui.separator(self.controlArea) selection_box = gui.widgetBox(self.controlArea, "Selection") self.send_button = gui.button(selection_box, self, "Send selections", self.commit, default=True) cb = gui.checkBox(selection_box, self, "auto_commit", "Commit on any change", callback=self.commit_if) gui.setStopper(self, self.send_button, cb, "selectionChangedFlag", self.commit) gui.rubber(self.controlArea) dlg = self.create_color_dialog() self.discPalette = dlg.getDiscretePalette("discPalette") # GUI with tabs self.tabs = gui.tabWidget(self.mainArea) self.tabs.sizeHint = lambda: QtCore.QSize(600,500) self.id2table = {} # key: widget id, value: table self.table2id = {} # key: table, value: widget id self.tabs.currentChanged.connect(self.tab_clicked) self.selectionChangedFlag = False
def __init__(self): super().__init__() self.data = None self.groups = None self.CVSettings = (self.stratified, self.numberOfFolds) infoBox = gui.widgetBox(self.controlArea, "Information") self.dataInfoLabel = gui.widgetLabel(infoBox, 'No data on input.') self.outputInfoLabel = gui.widgetLabel(infoBox, ' ') optionsBox = gui.widgetBox(self.controlArea, "Options") le = gui.lineEdit(optionsBox, self, "randomSeed", "Random seed: ", orientation=0, controlWidth=60, validator=QtGui.QIntValidator()) s = le.sizeHint().height() - 2 b = gui.toolButton(le.box, self, width=s, height=s, callback=lambda: le.setText("")) b.setIcon(b.style().standardIcon(b.style().SP_DialogCancelButton)) gui.rubber(le.box) gui.checkBox(optionsBox, self, "stratified", "Stratified, if possible") sampling = gui.radioButtons( self.controlArea, self, "samplingType", box="Sampling type", addSpace=True) gui.appendRadioButton(sampling, "Random Sampling:") indRndSmpl = gui.indentedBox(sampling) sizeType = gui.radioButtons( indRndSmpl, self, "sampleSizeType", callback=lambda: self.chooseSampling(0)) gui.appendRadioButton(sizeType, "Sample size:", insertInto=indRndSmpl) self.sampleSizeSpin = gui.spin( gui.indentedBox(indRndSmpl), self, "sampleSizeNumber", 1, 1000000000, callback=[lambda: self.chooseSampling(0), lambda: self.chooseSizeType(0)]) gui.appendRadioButton(sizeType, "Sample proportions:", insertInto=indRndSmpl) gui.hSlider(gui.indentedBox(indRndSmpl), self, "sampleSizePercentage", minValue=1, maxValue=100, ticks=10, labelFormat="%d%%", callback=[lambda: self.chooseSampling(0), lambda: self.chooseSizeType(1)]) gui.appendRadioButton(sampling, "Cross Validation:") crossValidIndent = gui.indentedBox(sampling) gui.spin( crossValidIndent, self, "numberOfFolds", 2, 100, label="Number of folds:", callback=[self.updateSelectedFoldSpin, lambda: self.chooseSampling(1)]) self.selectedFoldSpin = gui.spin( crossValidIndent, self, "selectedFold", 1, 100, label="Selected fold:", callback=[self.updateSelectedFoldSpin, lambda: self.chooseSampling(1)]) gui.button(self.controlArea, self, "Sample Data", callback=self.sendData)
def __init__(self, parent=None): super().__init__(parent) self.inputs = OrderedDict() self.dist_color = QtGui.QColor(*self.dist_color_RGB) info_box = gui.widgetBox(self.controlArea, "Info") self.info_ex = gui.widgetLabel(info_box, 'No data on input.', ) self.info_ex.setWordWrap(True) self.info_attr = gui.widgetLabel(info_box, ' ') self.info_attr.setWordWrap(True) self.info_class = gui.widgetLabel(info_box, ' ') self.info_class.setWordWrap(True) self.info_meta = gui.widgetLabel(info_box, ' ') self.info_meta.setWordWrap(True) gui.separator(info_box) gui.button(info_box, self, "Restore Original Order", callback=self.restore_order, tooltip="Show rows in the original order", autoDefault=False) info_box.setMinimumWidth(200) gui.separator(self.controlArea) box = gui.widgetBox(self.controlArea, "Variables") self.c_show_attribute_labels = gui.checkBox( box, self, "show_attribute_labels", "Show variable labels (if present)", callback=self._on_show_variable_labels_changed) gui.checkBox(box, self, "show_distributions", 'Visualize continuous values', callback=self._on_distribution_color_changed) gui.checkBox(box, self, "color_by_class", 'Color by instance classes', callback=self._on_distribution_color_changed) gui.button(box, self, "Set colors", self.set_colors, autoDefault=False, tooltip="Set the background color and color palette") box = gui.widgetBox(self.controlArea, "Selection") gui.checkBox(box, self, "select_rows", "Select full rows", callback=self._on_select_rows_changed) gui.rubber(self.controlArea) gui.auto_commit(self.controlArea, self, "auto_commit", "Send Selected Rows", "Auto send is on") dlg = self.create_color_dialog() self.discPalette = dlg.getDiscretePalette("discPalette") # GUI with tabs self.tabs = gui.tabWidget(self.mainArea) self.tabs.currentChanged.connect(self._on_current_tab_changed) copy = QtGui.QAction("Copy", self, shortcut=QtGui.QKeySequence.Copy, triggered=self.copy) self.addAction(copy)
def setup_layout(self): super().setup_layout() self._task = None # type: Optional[Task] self._executor = ThreadExecutor() # just a test cancel button gui.button(self.apply_button, self, "Cancel", callback=self.cancel)
def __init__(self): """Widget creator.""" super().__init__() # Other attributes... self.segmentation = None self.createdInputs = list() self.titleSeg = None self.filteredTitleSeg = None self.filterValues = dict() self.base_url = \ u"http://www.eighteenthcenturypoetry.org/works/#genres" self.document_base_url = \ u"http://www.eighteenthcenturypoetry.org/works/#genres" # Next two instructions are helpers from TextableUtils. Corresponding # interface elements are declared here and actually drawn below (at # their position in the UI)... self.infoBox = InfoBox(widget=self.controlArea) self.sendButton = SendButton( widget=self.controlArea, master=self, callback=self.sendData, infoBoxAttribute="infoBox", sendIfPreCallback=self.updateGUI, ) # The AdvancedSettings class, also from TextableUtils, facilitates # the management of basic vs. advanced interface. An object from this # class (here assigned to self.advancedSettings) contains two lists # (basicWidgets and advancedWidgets), to which the corresponding # widgetBoxes must be added. self.advancedSettings = AdvancedSettings( widget=self.controlArea, master=self, callback=self.updateFilterValueList, ) # User interface... # Advanced settings checkbox (basic/advanced interface will appear # immediately after it... self.advancedSettings.draw() # Filter box (advanced settings only) filterBox = gui.widgetBox( widget=self.controlArea, box="Filter", orientation="vertical", ) filterCriterionCombo = gui.comboBox( widget=filterBox, master=self, value="filterCriterion", items=["author"], sendSelectedValue=True, orientation="horizontal", label="Criterion:", labelWidth=120, callback=self.updateFilterValueList, # OK tooltip=( "Please select a criterion for searching the title list." ), ) filterCriterionCombo.setMinimumWidth(120) gui.separator(widget=filterBox, height=3) self.filterValueCombo = gui.comboBox( widget=filterBox, master=self, value="filterValue", sendSelectedValue=True, orientation="horizontal", label="Value:", labelWidth=120, callback=self.updateTitleList, # OK tooltip=("Please select a value for the chosen criterion."), ) gui.separator(widget=filterBox, height=3) # The following lines add filterBox (and a vertical separator) to the # advanced interface... self.advancedSettings.advancedWidgets.append(filterBox) self.advancedSettings.advancedWidgetsAppendSeparator() # Title box titleBox = gui.widgetBox( widget=self.controlArea, box="Works", orientation="vertical", ) self.titleListbox = gui.listBox( widget=titleBox, master=self, value="selectedTitles", # setting (list) labels="titleLabels", # setting (list) # callback=self.sendButton.settingsChanged, # renvoyer vers bouton "add to basket" # tooltip="The list of titles whose content will be imported.", ) self.titleListbox.setMinimumHeight(150) self.titleListbox.setSelectionMode(3) gui.separator(widget=titleBox, height=3) gui.button( widget=titleBox, master=self, label="Refresh", callback=self.refreshTitleSeg, # OK tooltip="Connect to EighteenthCenturyPoetry website and refresh list.", ) gui.separator(widget=titleBox, height=3) # bouton ajouter au panier gui.button( widget=titleBox, master=self, label="Add to basket", # callback=self.refreshTitleSeg, # changer fonction pour ajouter au panier # tooltip="Add selected items of this box to basket.", ) gui.separator(widget=self.controlArea, height=3) # Basket box basketBox = gui.widgetBox( widget=self.controlArea, box="Basket", orientation="vertical", ) self.titleListbox = gui.listBox( widget=basketBox, master=self, # changer pour panier value="selectedTitles", # setting (list) labels="titleLabels", # setting (list) # # selectionner pour bouton delete callback=self.sendButton.settingsChanged, # tooltip="The list of titles whose content will be imported.", ) gui.separator(widget=basketBox, height=3) #bouton pour supprimer elements selectionnes gui.button( widget=basketBox, master=self, label="Delete", # changer fonction pour supprimer elements selectionnes callback=self.refreshTitleSeg, # tooltip="Delete selected item(s)", ) gui.separator(widget=basketBox, height=3) #bouton pour supprimer tous les elements gui.button( widget=basketBox, master=self, label="Clear all", # changer fonction pour tout supprimer callback=self.refreshTitleSeg, # tooltip="Delete all item(s)", ) gui.separator(widget=self.controlArea, height=3) gui.rubber(self.controlArea) # Now Info box and Send button must be drawn... self.sendButton.draw() self.infoBox.draw() # This initialization step needs to be done after infoBox has been # drawn (because getTitleSeg may need to display an error message). self.getTitleSeg() # Send data if autoSend. self.sendButton.sendIf() self.setMinimumWidth(350) self.adjustSizeWithTimer()
def insertLayout(self): def createPixmapWidget(self, parent, iconName): w = QLabel(parent) parent.layout().addWidget(w) w.setFixedSize(16, 16) w.hide() if os.path.exists(iconName): w.setPixmap(QPixmap(iconName)) return w self.setLayout(QVBoxLayout()) self.layout().setMargin(2) self.warning_bar = gui.widgetBox(self, orientation="horizontal", margin=0, spacing=0) self.warning_icon = gui.widgetLabel(self.warning_bar, "") self.warning_label = gui.widgetLabel(self.warning_bar, "") self.warning_label.setStyleSheet("padding-top: 5px") self.warning_bar.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Maximum) gui.rubber(self.warning_bar) self.warning_bar.setVisible(False) self.want_main_area = self.graph_name is not None or self.want_main_area splitter = self.Splitter(Qt.Horizontal, self) self.layout().addWidget(splitter) if self.want_control_area: self.controlArea = gui.widgetBox(splitter, orientation="vertical", margin=0) splitter.setSizes([1]) # Results in smallest size allowed by policy if self.graph_name is not None or hasattr(self, "send_report"): leftSide = self.controlArea self.controlArea = gui.widgetBox(leftSide, margin=0) if self.graph_name is not None: self.graphButton = gui.button(leftSide, None, "&Save Graph") self.graphButton.clicked.connect(self.save_graph) self.graphButton.setAutoDefault(0) if hasattr(self, "send_report"): self.report_button = gui.button(leftSide, None, "&Report", callback=self.show_report) self.report_button.setAutoDefault(0) if self.want_main_area: self.controlArea.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.MinimumExpanding) self.controlArea.layout().setContentsMargins(4, 4, 0 if self.want_main_area else 4, 4) if self.want_main_area: self.mainArea = gui.widgetBox(splitter, orientation="vertical", margin=4, sizePolicy=QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) splitter.setCollapsible(1, False) self.mainArea.layout().setContentsMargins(0 if self.want_control_area else 4, 4, 4, 4) if self.want_status_bar: self.widgetStatusArea = QFrame(self) self.statusBarIconArea = QFrame(self) self.widgetStatusBar = QStatusBar(self) self.layout().addWidget(self.widgetStatusArea) self.widgetStatusArea.setLayout(QHBoxLayout(self.widgetStatusArea)) self.widgetStatusArea.layout().addWidget(self.statusBarIconArea) self.widgetStatusArea.layout().addWidget(self.widgetStatusBar) self.widgetStatusArea.layout().setMargin(0) self.widgetStatusArea.setFrameShape(QFrame.StyledPanel) self.statusBarIconArea.setLayout(QHBoxLayout()) self.widgetStatusBar.setSizeGripEnabled(0) self.statusBarIconArea.hide() self._warningWidget = createPixmapWidget( self.statusBarIconArea, gui.resource_filename("icons/triangle-orange.png")) self._errorWidget = createPixmapWidget( self.statusBarIconArea, gui.resource_filename("icons/triangle-red.png")) if not self.resizing_enabled: self.layout().setSizeConstraint(QVBoxLayout.SetFixedSize)
def __init__(self, parent=None): super().__init__(self, parent) self.clusterDataset = None self.referenceDataset = None self.ontology = None self.annotations = None self.loadedAnnotationCode = None self.treeStructRootKey = None self.probFunctions = [stats.Binomial(), stats.Hypergeometric()] self.selectedTerms = [] self.selectionChanging = 0 self.__state = State.Ready self.__scheduletimer = QTimer(self, singleShot=True) self.__scheduletimer.timeout.connect(self.__update) ############# ## GUI ############# self.tabs = gui.tabWidget(self.controlArea) ## Input tab self.inputTab = gui.createTabPage(self.tabs, "Input") box = gui.widgetBox(self.inputTab, "Info") self.infoLabel = gui.widgetLabel(box, "No data on input\n") gui.button( box, self, "Ontology/Annotation Info", callback=self.ShowInfo, tooltip="Show information on loaded ontology and annotations") box = gui.widgetBox(self.inputTab, "Organism") self.annotationComboBox = gui.comboBox( box, self, "annotationIndex", items=[], callback=self.__invalidateAnnotations, tooltip="Select organism") genebox = gui.widgetBox(self.inputTab, "Gene Names") self.geneAttrIndexCombo = gui.comboBox( genebox, self, "geneAttrIndex", callback=self.__invalidate, tooltip="Use this attribute to extract gene names from input data") self.geneAttrIndexCombo.setDisabled(self.useAttrNames) cb = gui.checkBox(genebox, self, "useAttrNames", "Use column names", tooltip="Use column names for gene names", callback=self.__invalidate) cb.toggled[bool].connect(self.geneAttrIndexCombo.setDisabled) gui.button(genebox, self, "Gene matcher settings", callback=self.UpdateGeneMatcher, tooltip="Open gene matching settings dialog") self.referenceRadioBox = gui.radioButtonsInBox( self.inputTab, self, "useReferenceDataset", ["Entire genome", "Reference set (input)"], tooltips=[ "Use entire genome for reference", "Use genes from Referece Examples input signal as reference" ], box="Reference", callback=self.__invalidate) self.referenceRadioBox.buttons[1].setDisabled(True) gui.radioButtonsInBox( self.inputTab, self, "aspectIndex", ["Biological process", "Cellular component", "Molecular function"], box="Aspect", callback=self.__invalidate) ## Filter tab self.filterTab = gui.createTabPage(self.tabs, "Filter") box = gui.widgetBox(self.filterTab, "Filter GO Term Nodes") gui.checkBox( box, self, "filterByNumOfInstances", "Genes", callback=self.FilterAndDisplayGraph, tooltip="Filter by number of input genes mapped to a term") ibox = gui.indentedBox(box) gui.spin(ibox, self, 'minNumOfInstances', 1, 100, step=1, label='#:', labelWidth=15, callback=self.FilterAndDisplayGraph, callbackOnReturn=True, tooltip="Min. number of input genes mapped to a term") gui.checkBox(box, self, "filterByPValue_nofdr", "p-value", callback=self.FilterAndDisplayGraph, tooltip="Filter by term p-value") gui.doubleSpin(gui.indentedBox(box), self, 'maxPValue_nofdr', 1e-8, 1, step=1e-8, label='p:', labelWidth=15, callback=self.FilterAndDisplayGraph, callbackOnReturn=True, tooltip="Max term p-value") #use filterByPValue for FDR, as it was the default in prior versions gui.checkBox(box, self, "filterByPValue", "FDR", callback=self.FilterAndDisplayGraph, tooltip="Filter by term FDR") gui.doubleSpin(gui.indentedBox(box), self, 'maxPValue', 1e-8, 1, step=1e-8, label='p:', labelWidth=15, callback=self.FilterAndDisplayGraph, callbackOnReturn=True, tooltip="Max term p-value") box = gui.widgetBox(box, "Significance test") gui.radioButtonsInBox( box, self, "probFunc", ["Binomial", "Hypergeometric"], tooltips=[ "Use binomial distribution test", "Use hypergeometric distribution test" ], callback=self.__invalidate) # TODO: only update the p values box = gui.widgetBox(self.filterTab, "Evidence codes in annotation", addSpace=True) self.evidenceCheckBoxDict = {} for etype in go.evidenceTypesOrdered: ecb = QCheckBox(etype, toolTip=go.evidenceTypes[etype], checked=self.useEvidenceType[etype]) ecb.toggled.connect(self.__on_evidenceChanged) box.layout().addWidget(ecb) self.evidenceCheckBoxDict[etype] = ecb ## Select tab self.selectTab = gui.createTabPage(self.tabs, "Select") box = gui.radioButtonsInBox(self.selectTab, self, "selectionDirectAnnotation", ["Directly or Indirectly", "Directly"], box="Annotated genes", callback=self.ExampleSelection) box = gui.widgetBox(self.selectTab, "Output", addSpace=True) gui.radioButtonsInBox( box, self, "selectionDisjoint", btnLabels=[ "All selected genes", "Term-specific genes", "Common term genes" ], tooltips=[ "Outputs genes annotated to all selected GO terms", "Outputs genes that appear in only one of selected GO terms", "Outputs genes common to all selected GO terms" ], callback=[self.ExampleSelection, self.UpdateAddClassButton]) self.addClassCB = gui.checkBox(box, self, "selectionAddTermAsClass", "Add GO Term as class", callback=self.ExampleSelection) # ListView for DAG, and table for significant GOIDs self.DAGcolumns = [ 'GO term', 'Cluster', 'Reference', 'p-value', 'FDR', 'Genes', 'Enrichment' ] self.splitter = QSplitter(Qt.Vertical, self.mainArea) self.mainArea.layout().addWidget(self.splitter) # list view self.listView = GOTreeWidget(self.splitter) self.listView.setSelectionMode(QTreeView.ExtendedSelection) self.listView.setAllColumnsShowFocus(1) self.listView.setColumnCount(len(self.DAGcolumns)) self.listView.setHeaderLabels(self.DAGcolumns) self.listView.header().setSectionsClickable(True) self.listView.header().setSortIndicatorShown(True) self.listView.setSortingEnabled(True) self.listView.setItemDelegateForColumn( 6, EnrichmentColumnItemDelegate(self)) self.listView.setRootIsDecorated(True) self.listView.itemSelectionChanged.connect(self.ViewSelectionChanged) # table of significant GO terms self.sigTerms = QTreeWidget(self.splitter) self.sigTerms.setColumnCount(len(self.DAGcolumns)) self.sigTerms.setHeaderLabels(self.DAGcolumns) self.sigTerms.setSortingEnabled(True) self.sigTerms.setSelectionMode(QTreeView.ExtendedSelection) self.sigTerms.setItemDelegateForColumn( 6, EnrichmentColumnItemDelegate(self)) self.sigTerms.itemSelectionChanged.connect(self.TableSelectionChanged) self.sigTableTermsSorted = [] self.graph = {} self.originalGraph = None self.inputTab.layout().addStretch(1) self.filterTab.layout().addStretch(1) self.selectTab.layout().addStretch(1) class AnnotationSlot(SimpleNamespace): taxid = ... # type: str name = ... # type: str orgcode = ... # type: str filename = ... # type:str available_annotations = [ AnnotationSlot(taxid=taxid, name=taxonomy.common_taxid_to_name(taxid), orgcode=go.from_taxid(taxid), filename="gene_association.{}.tar.gz".format( go.from_taxid(taxid))) for taxid in taxonomy.common_taxids() if go.from_taxid(taxid) ] self.availableAnnotations = sorted(available_annotations, key=lambda a: a.name) self.annotationComboBox.clear() for a in self.availableAnnotations: self.annotationComboBox.addItem(a.name) self.annotationComboBox.setCurrentIndex(self.annotationIndex) self.annotationIndex = self.annotationComboBox.currentIndex() self._executor = ThreadExecutor()
def _create_layout(self): self._new_webview() box = gui.widgetBox(self.controlArea, 'Info') self.topic_info = gui.label(box, self, '%(n_topic_words)d words in a topic') gui.label(box, self, '%(documents_info_str)s') box = gui.widgetBox(self.controlArea, 'Cloud preferences') gui.checkBox(box, self, 'words_color', 'Color words', callback=self.on_cloud_pref_change) TILT_VALUES = ('no', '30°', '45°', '60°') gui.valueSlider(box, self, 'words_tilt', label='Words tilt:', values=list(range(len(TILT_VALUES))), callback=self.on_cloud_pref_change, labelFormat=lambda x: TILT_VALUES[x]) gui.button(box, None, 'Regenerate word cloud', callback=self.on_cloud_pref_change) box = gui.widgetBox(self.controlArea, 'Words && weights') class TableView(gui.TableView): def __init__(self, parent): super().__init__(parent) self._parent = parent self.__nope = False def setModel(self, model): """Otherwise QTableView.setModel() calls QAbstractItemView.setSelectionModel() which resets selection, calling selectionChanged() and overwriting any selected_words setting that may have been saved.""" self.__nope = True super().setModel(model) self.__nope = False def selectionChanged(self, selected, deselected): nonlocal model, proxymodel super().selectionChanged(selected, deselected) if not self.__nope: words = { model[proxymodel.mapToSource(index).row()][1] for index in self.selectionModel().selectedIndexes() } self._parent.update_selection(words, self) def update_selection(self, words): nonlocal model, proxymodel selection = QItemSelection() for i, (_, word) in enumerate(model): if word in words: index = proxymodel.mapFromSource(model.index(i, 1)) selection.select(index, index) self.__nope = True self.clearSelection() self.selectionModel().select( selection, QItemSelectionModel.Select | QItemSelectionModel.Rows) self.__nope = False view = self.tableview = TableView(self) model = self.tablemodel = PyTableModel(parent=self) proxymodel = QSortFilterProxyModel( self, dynamicSortFilter=True, sortCaseSensitivity=Qt.CaseInsensitive, sortRole=Qt.EditRole) proxymodel.setSourceModel(model) model.setHorizontalHeaderLabels(['Weight', 'Word']) view.setModel(proxymodel) box.layout().addWidget(view)
def _init_ui(self): # implement your user interface here (for setting hyperparameters) gui.separator(self.controlArea) box = gui.widgetBox(self.controlArea, "Hyperparameter") gui.separator(self.controlArea) gui.lineEdit(box, self, 'window_size', label='The window dimension. (IntVariable)', callback=None) # return_subseq_inds = Setting(False) gui.checkBox(box, self, "return_subseq_inds", label='If return subsequence index.', callback=None) # use_semantic_types = Setting(False) gui.checkBox(box, self, "use_semantic_types", label='Mannally select columns if active.', callback=None) # use_columns = Setting(()) gui.lineEdit( box, self, "use_columns_buf", label= 'Column index to use when use_semantic_types is activated. Tuple, e.g. (0,1,2)', validator=None, callback=self._use_columns_callback) # exclude_columns = Setting(()) gui.lineEdit( box, self, "exclude_columns_buf", label= 'Column index to exclude when use_semantic_types is activated. Tuple, e.g. (0,1,2)', validator=None, callback=self._exclude_columns_callback) # return_result = Setting(['append', 'replace', 'new']) gui.comboBox( box, self, "return_result", sendSelectedValue=True, label='Output results.', items=['new', 'append', 'replace'], ) # add_index_columns = Setting(False) gui.checkBox(box, self, "add_index_columns", label='Keep index in the outputs.', callback=None) # error_on_no_input = Setting(True) gui.checkBox(box, self, "error_on_no_input", label='Error on no input.', callback=None) # return_semantic_type = Setting(['https://metadata.datadrivendiscovery.org/types/Attribute', # 'https://metadata.datadrivendiscovery.org/types/ConstructedAttribute']) gui.comboBox( box, self, "return_semantic_type", sendSelectedValue=True, label='Semantic type attach with results.', items=[ 'https://metadata.datadrivendiscovery.org/types/Attribute', 'https://metadata.datadrivendiscovery.org/types/ConstructedAttribute' ], ) # Only for test gui.button(box, self, "Print Hyperparameters", callback=self._print_hyperparameter) gui.auto_apply(box, self, "autosend", box=False) self.data = None self.info.set_input_summary(self.info.NoInput) self.info.set_output_summary(self.info.NoOutput)
def __init__(self): super().__init__() self.data = None self.results = None self.learners = [] self.headers = [] self.learners_box = gui.listBox(self.controlArea, self, "selected_learner", "learners", box=True, callback=self._learner_changed) self.outputbox = gui.vBox(self.controlArea, "输出") box = gui.hBox(self.outputbox) gui.checkBox(box, self, "append_predictions", "预测", callback=self._invalidate) gui.checkBox(box, self, "append_probabilities", "可能性", callback=self._invalidate) gui.auto_commit(self.outputbox, self, "autocommit", "选中发送", "自动发送", box=False) self.mainArea.layout().setContentsMargins(0, 0, 0, 0) box = gui.vBox(self.mainArea, box=True) sbox = gui.hBox(box) gui.rubber(sbox) gui.comboBox(sbox, self, "selected_quantity", items=self.quantities, label="显示: ", orientation=Qt.Horizontal, callback=self._update) self.tablemodel = QStandardItemModel(self) view = self.tableview = QTableView( editTriggers=QTableView.NoEditTriggers) view.setModel(self.tablemodel) view.horizontalHeader().hide() view.verticalHeader().hide() view.horizontalHeader().setMinimumSectionSize(60) view.selectionModel().selectionChanged.connect(self._invalidate) view.setShowGrid(False) view.setItemDelegate(BorderedItemDelegate(Qt.white)) view.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) view.clicked.connect(self.cell_clicked) box.layout().addWidget(view) selbox = gui.hBox(box) gui.button(selbox, self, "选择正确", callback=self.select_correct, autoDefault=False) gui.button(selbox, self, "选择错误分类", callback=self.select_wrong, autoDefault=False) gui.button(selbox, self, "清除选择", callback=self.select_none, autoDefault=False)
def __init__(self): super().__init__() RecentPathsWComboMixin.__init__(self) self.domain = None self.data = None self.loaded_file = "" self.reader = None readers = [ f for f in FileFormat.formats if getattr(f, 'read', None) and getattr(f, "EXTENSIONS", None) ] def group_readers_per_addon_key(w): # readers from Orange.data.io should go first def package(w): package = w.qualified_name().split(".")[:-1] package = package[:2] if ".".join(package) == "Orange.data": return ["0"] # force "Orange" to come first return package return package(w), w.DESCRIPTION self.available_readers = sorted(set(readers), key=group_readers_per_addon_key) layout = QGridLayout() layout.setSpacing(4) gui.widgetBox(self.controlArea, orientation=layout, box='Source') vbox = gui.radioButtons(None, self, "source", box=True, callback=self.load_data, addToLayout=False) rb_button = gui.appendRadioButton(vbox, "File:", addToLayout=False) layout.addWidget(rb_button, 0, 0, Qt.AlignVCenter) box = gui.hBox(None, addToLayout=False, margin=0) box.setSizePolicy(Policy.Expanding, Policy.Fixed) self.file_combo.setSizePolicy(Policy.Expanding, Policy.Fixed) self.file_combo.setMinimumSize(QSize(100, 1)) self.file_combo.activated[int].connect(self.select_file) box.layout().addWidget(self.file_combo) layout.addWidget(box, 0, 1) file_button = gui.button(None, self, '...', callback=self.browse_file, autoDefault=False) file_button.setIcon(self.style().standardIcon(QStyle.SP_DirOpenIcon)) file_button.setSizePolicy(Policy.Maximum, Policy.Fixed) layout.addWidget(file_button, 0, 2) reload_button = gui.button(None, self, "Reload", callback=self.load_data, autoDefault=False) reload_button.setIcon(self.style().standardIcon( QStyle.SP_BrowserReload)) reload_button.setSizePolicy(Policy.Fixed, Policy.Fixed) layout.addWidget(reload_button, 0, 3) self.sheet_box = gui.hBox(None, addToLayout=False, margin=0) self.sheet_combo = QComboBox() self.sheet_combo.textActivated.connect(self.select_sheet) self.sheet_combo.setSizePolicy(Policy.Expanding, Policy.Fixed) self.sheet_combo.setMinimumSize(QSize(50, 1)) self.sheet_label = QLabel() self.sheet_label.setText('Sheet') self.sheet_label.setSizePolicy(Policy.MinimumExpanding, Policy.Fixed) self.sheet_box.layout().addWidget(self.sheet_label, Qt.AlignLeft) self.sheet_box.layout().addWidget(self.sheet_combo, Qt.AlignVCenter) layout.addWidget(self.sheet_box, 2, 1) self.sheet_box.hide() rb_button = gui.appendRadioButton(vbox, "URL:", addToLayout=False) layout.addWidget(rb_button, 3, 0, Qt.AlignVCenter) self.url_combo = url_combo = QComboBox() url_model = NamedURLModel(self.sheet_names) url_model.wrap(self.recent_urls) url_combo.setLineEdit(LineEditSelectOnFocus()) url_combo.setModel(url_model) url_combo.setSizePolicy(Policy.Ignored, Policy.Fixed) url_combo.setEditable(True) url_combo.setInsertPolicy(url_combo.InsertAtTop) url_edit = url_combo.lineEdit() margins = url_edit.textMargins() l, t, r, b = margins.left(), margins.top(), margins.right( ), margins.bottom() url_edit.setTextMargins(l + 5, t, r, b) layout.addWidget(url_combo, 3, 1, 1, 3) url_combo.activated.connect(self._url_set) # whit completer we set that combo box is case sensitive when # matching the history completer = QCompleter() completer.setCaseSensitivity(Qt.CaseSensitive) url_combo.setCompleter(completer) layout = QGridLayout() layout.setSpacing(4) gui.widgetBox(self.controlArea, orientation=layout, box='File Type') box = gui.hBox(None, addToLayout=False, margin=0) box.setSizePolicy(Policy.Expanding, Policy.Fixed) self.reader_combo = QComboBox(self) self.reader_combo.setSizePolicy(Policy.Expanding, Policy.Fixed) self.reader_combo.setMinimumSize(QSize(100, 1)) self.reader_combo.activated[int].connect(self.select_reader) box.layout().addWidget(self.reader_combo) layout.addWidget(box, 0, 1) box = gui.vBox(self.controlArea, "Info") self.infolabel = gui.widgetLabel(box, 'No data loaded.') box = gui.widgetBox(self.controlArea, "Columns (Double click to edit)") self.domain_editor = DomainEditor(self) self.editor_model = self.domain_editor.model() box.layout().addWidget(self.domain_editor) box = gui.hBox(box) gui.button(box, self, "Reset", callback=self.reset_domain_edit, autoDefault=False) gui.rubber(box) self.apply_button = gui.button(box, self, "Apply", callback=self.apply_domain_edit) self.apply_button.setEnabled(False) self.apply_button.setFixedWidth(170) self.editor_model.dataChanged.connect( lambda: self.apply_button.setEnabled(True)) hBox = gui.hBox(self.controlArea) gui.rubber(hBox) gui.button(hBox, self, "Browse documentation datasets", callback=lambda: self.browse_file(True), autoDefault=False) gui.rubber(hBox) self.set_file_list() # Must not call open_file from within __init__. open_file # explicitly re-enters the event loop (by a progress bar) self.setAcceptDrops(True) if self.source == self.LOCAL_FILE: last_path = self.last_path() if last_path and os.path.exists(last_path) and \ os.path.getsize(last_path) > self.SIZE_LIMIT: self.Warning.file_too_big() return QTimer.singleShot(0, self.load_data)
def __init__(self): """Widget creator.""" super().__init__() # NONE BASIC SETTING self.inputData = None self.system = os.name self.user = os.environ.get("USER") self.langues = list() self.created_inputs = list() self.language = 0 self.check_firt_use = False self.createdInputs = list() self.compteur = 0 self.NoLink = True # liste des langues possible self.langues_possibles = { "French": ["french.par", "french-abbreviations"], "English": ["english-utf8.par", "english-abbreviations"], "German": ["german-utf8.par", "german-abbreviations"], "Italian": ["italian-utf8.par", "italian-abbreviations"], "Swahili": ["swahili.par", "swahili-abbreviations"], "Portuguese": ["portuguese.par", "portuguese-abbreviations"], "Russian": ["russian.par", "russian-abbreviations"], "Spanish": ["spanish-utf8.par", "spanish-abbreviations", "spanish-mwls"], "Slovenian": ["slovenian-utf8.par"], "Slovak": ["slovak2-utf8.par"], "Romanian": ["romanian.par"], "Polish": ["polish-utf8.par"], "Mongolian": ["mongolian.par"], "Latin": ["latin.par"], "Galician": ["galician.par"], "Finnish": ["finnish-utf8.par"], "Estonian": ["estonian.par"], "Bulgarian": ["bulgarian-utf8.par"], "Spoken French": ["spoken-french.par", "french-abbreviations"] } # Next two instructions are helpers from TextableUtils. Corresponding # interface elements are declared here and actually drawn below (at # their position in the UI)... self.infoBox = InfoBox(widget=self.controlArea) self.sendButton = SendButton(widget=self.controlArea, master=self, callback=self.sendData, infoBoxAttribute=u"infoBox", sendIfPreCallback=self.updateGUI) # The AdvancedSettings class, also from TextableUtils, facilitates # the management of basic vs. advanced interface. An object from this # class (here assigned to self.advancedSettings) contains two lists # (basicWidgets and advancedWidgets), to which the corresponding # widgetBoxes must be added. # User interface... # OPTION BOX gui.separator(widget=self.controlArea, height=5) self.infoBox1 = gui.widgetBox(self.controlArea, u"Option", addSpace=True) # definir la langue self.langueBox = gui.comboBox(widget=self.infoBox1, master=self, value="language", items=self.langues, orientation=u"horizontal", label="Select text language :", callback=self.settings_changed) self.langueBox.setMaximumWidth(100) gui.separator(widget=self.controlArea, height=3) # Checkbox pour activer output avec code xml self.choix_xml = gui.checkBox(widget=self.infoBox1, master=self, value="activer_xml", label=" Output with XML code", callback=self.settings_changed) # Checkbox pour afficher unknown si le mot est inconnu self.choix_unknown = gui.checkBox(widget=self.infoBox1, master=self, value="unknown", label=" Output without '[unknown]'", callback=self.settings_changed) # The following lines: # Bouton pour aller cherche le lien vers treetagger... self.treetagger_box = gui.widgetBox( self.controlArea, u"Please, enter a correct path to TreeTagger :", addSpace=True) gui.button(widget=self.treetagger_box, master=self, label="Browse", callback=self.treetagger_search) gui.separator(widget=self.treetagger_box, height=3) gui.rubber(self.controlArea) # Now Info box and Send button must be drawn... self.sendButton.draw() self.infoBox.draw() # Send data if autoSend. self.sendButton.sendIf() # ajuster taille widjet self.adjustSizeWithTimer() # verifie lien treetagger self.treetagger_check()
def __init__(self, parent=None, signalManager=None, settings=None): super().__init__(self, parent, signalManager, settings, "Heat map") controlBox = gui.widgetBox(self.controlArea) self.labelDataInput = gui.widgetLabel(controlBox, 'No data input yet') self.labelOutput = gui.widgetLabel(controlBox, '') self.icons = gui.attributeIconDict self.comboBoxAttributesX = gui.comboBox(self.controlArea, self, value='X_attributes_select', box='X Attribute', callback=self.attrChanged) self.comboBoxAttributesY = gui.comboBox(self.controlArea, self, value='Y_attributes_select', box='Y Attribute', callback=self.attrChanged) self.comboBoxClassvars = gui.comboBox(self.controlArea, self, value='classvar_select', box='Color by', callback=self.attrChanged) self.checkBoxesColorsShownBox = gui.widgetBox(self.controlArea, box='Colors shown') self.checkBoxesColorsShown = [] self.checkBoxesColorsShownAttributeList = [] self.mouseBehaviourBox = gui.radioButtons( self.controlArea, self, value='radio_mouse_behaviour', btnLabels=('Drag', 'Select'), box='Mouse left button behaviour', callback=self.mouseBehaviourChanged) self.displayBox = gui.widgetBox(self.controlArea, box='Display') self.checkBoxUseCache = gui.checkBox(self.displayBox, self, label='Use cache', value='check_use_cache') self.buttonDisplay = gui.button(self.displayBox, self, label='Display heatmap', callback=self.buttonDisplayClick) gui.rubber(self.controlArea) self.image_width = self.image_height = self.default_image_width self.hmi = None self.plot = pg.PlotWidget() self.plot.setBackground((255, 255, 255)) pg.setConfigOption('foreground', (0, 0, 0)) self.mainArea.layout().addWidget(self.plot) self.mainArea.setMinimumWidth(self.image_width + 100) self.mainArea.setMinimumHeight(self.image_height + 100) self.sharpeningRegion = False # flag is set when sharpening a region, not the whole heatmap self.regionSharpened = False # flag is set when first region has been sharpened self.cachedHeatmaps = {} np.set_printoptions(precision=2)
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)) self.mainArea.layout().addWidget(self.plot) self._update_normalize()
def __init__(self): super().__init__() self.libraryListSource = [] for name in self.signal_names: setattr(self, name, {}) self._cachedDocuments = {} self.infoBox = gui.vBox(self.controlArea, 'Info') gui.label( self.infoBox, self, "<p>Execute python script.</p><p>Input variables:<ul><li> " + "<li>".join(map("in_{0}, in_{0}s".format, self.signal_names)) + "</ul></p><p>Output variables:<ul><li>" + "<li>".join(map("out_{0}".format, self.signal_names)) + "</ul></p>" ) self.libraryList = itemmodels.PyListModel( [], self, flags=Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable) self.libraryList.wrap(self.libraryListSource) self.controlBox = gui.vBox(self.controlArea, 'Library') self.controlBox.layout().setSpacing(1) self.libraryView = QListView( editTriggers=QListView.DoubleClicked | QListView.EditKeyPressed, sizePolicy=QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Preferred) ) self.libraryView.setItemDelegate(ScriptItemDelegate(self)) self.libraryView.setModel(self.libraryList) self.libraryView.selectionModel().selectionChanged.connect( self.onSelectedScriptChanged ) self.controlBox.layout().addWidget(self.libraryView) w = itemmodels.ModelActionsWidget() self.addNewScriptAction = action = QAction("+", self) action.setToolTip("Add a new script to the library") action.triggered.connect(self.onAddScript) w.addAction(action) action = QAction(unicodedata.lookup("MINUS SIGN"), self) action.setToolTip("Remove script from library") 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) 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) run = QAction("Run script", self, triggered=self.commit, shortcut=QKeySequence(Qt.ControlModifier | Qt.Key_R)) self.addAction(run) 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) self.splitCanvas.setSizes([2, 1]) self.setAcceptDrops(True) self.controlArea.layout().addStretch(10) self._restoreState() self.settingsAboutToBePacked.connect(self._saveState)
def __init__(self, parent=None): super().__init__(self, parent) self.dataset = None self.z_values = [] self._root = None self._displayed_root = None self._item = None self._cache = {} self.colors = colorpalette.ColorPaletteGenerator(10) self.sampling_box = box = gui.widgetBox(self.controlArea, "Sampling") sampling_options =\ self.sample_times_captions + self.sample_percentages_captions gui.comboBox(box, self, 'sample_level', items=sampling_options, callback=self.update_sample) gui.button(box, self, "Sharpen", self.sharpen) box = gui.widgetBox(self.controlArea, "Input") self.labelDataInput = gui.widgetLabel(box, 'No data on input') self.labelDataInput.setTextFormat(Qt.PlainText) self.labelOutput = gui.widgetLabel(box, '') self.x_var_model = itemmodels.VariableListModel() self.comboBoxAttributesX = gui.comboBox(self.controlArea, self, value='x_var_index', box='X Attribute', callback=self.replot) self.comboBoxAttributesX.setModel(self.x_var_model) self.y_var_model = itemmodels.VariableListModel() self.comboBoxAttributesY = gui.comboBox(self.controlArea, self, value='y_var_index', box='Y Attribute', callback=self.replot) self.comboBoxAttributesY.setModel(self.y_var_model) box = gui.widgetBox(self.controlArea, "Color by") self.z_var_model = itemmodels.VariableListModel() self.comboBoxClassvars = gui.comboBox(box, self, value='z_var_index', callback=self._on_z_var_changed) self.comboBoxClassvars.setModel(self.z_var_model) box1 = gui.widgetBox(box, 'Colors displayed', margin=0) box1.setFlat(True) self.z_values_view = gui.listBox( box1, self, "selected_z_values", "z_values", callback=self._on_z_values_selection_changed, selectionMode=QtGui.QListView.MultiSelection, addSpace=False) box1 = gui.widgetBox(box, "Color Scale", margin=0) box1.setFlat(True) gui.comboBox(box1, self, "color_scale", items=["Linear", "Square root", "Logarithmic"], callback=self._on_color_scale_changed) self.mouseBehaviourBox = gui.radioButtons( self.controlArea, self, value='mouse_mode', btnLabels=('Drag', 'Select'), box='Mouse left button behavior', callback=self._update_mouse_mode) gui.rubber(self.controlArea) self.plot = pg.PlotWidget(background="w") self.plot.setMenuEnabled(False) self.plot.setFrameStyle(QtGui.QFrame.StyledPanel) self.plot.setMinimumSize(500, 500) def font_resize(font, factor, minsize=None, maxsize=None): font = QtGui.QFont(font) fontinfo = QtGui.QFontInfo(font) size = fontinfo.pointSizeF() * factor if minsize is not None: size = max(size, minsize) if maxsize is not None: size = min(size, maxsize) font.setPointSizeF(size) return font axisfont = font_resize(self.font(), 0.8, minsize=11) axispen = QtGui.QPen(self.palette().color(QtGui.QPalette.Text)) axis = self.plot.getAxis("bottom") axis.setTickFont(axisfont) axis.setPen(axispen) axis = self.plot.getAxis("left") axis.setTickFont(axisfont) axis.setPen(axispen) self.plot.getViewBox().sigTransformChanged.connect( self._on_transform_changed) self.mainArea.layout().addWidget(self.plot)
def _init_ui(self): # implement your user interface here (for setting hyperparameters) gui.separator(self.controlArea) box = gui.widgetBox(self.controlArea, "Hyperparameter") gui.separator(self.controlArea) gui.lineEdit(box, self, 'stop_epochs', label='Number of epochs to train. (IntVariable)', callback=None) gui.lineEdit(box, self, 'lr_d', label='The learn rate of the discriminator. (Float)', callback=None) gui.lineEdit(box, self, 'lr_g', label='The learn rate of the generator. (Float)', callback=None) gui.lineEdit(box, self, 'k', label='The number of sub generators.. (IntVariable)', callback=None) gui.lineEdit(box, self, 'decay', label='The decay parameter for SGD.. (Float)', callback=None) gui.lineEdit(box, self, 'momentum', label='The momentum parameter for SGD. (Float)', callback=None) gui.doubleSpin( box, self, "contamination", minv=0., maxv=1., step=0.001, label="Input contamination, float in (0,0.5].", # callbackOnReturn = True, # checked = "BoundedFloat" ) # return_subseq_inds = Setting(False) gui.checkBox(box, self, "return_subseq_inds", label='If return subsequence index.', callback=None) # use_semantic_types = Setting(False) gui.checkBox(box, self, "use_semantic_types", label='Mannally select columns if active.', callback=None) # use_columns = Setting(()) gui.lineEdit( box, self, "use_columns_buf", label= 'Column index to use when use_semantic_types is activated. Tuple, e.g. (0,1,2)', validator=None, callback=self._use_columns_callback) # exclude_columns = Setting(()) gui.lineEdit( box, self, "exclude_columns_buf", label= 'Column index to exclude when use_semantic_types is activated. Tuple, e.g. (0,1,2)', validator=None, callback=self._exclude_columns_callback) # return_result = Setting(['append', 'replace', 'new']) gui.comboBox( box, self, "return_result", sendSelectedValue=True, label='Output results.', items=['new', 'append', 'replace'], ) # add_index_columns = Setting(False) gui.checkBox(box, self, "add_index_columns", label='Keep index in the outputs.', callback=None) # error_on_no_input = Setting(True) gui.checkBox(box, self, "error_on_no_input", label='Error on no input.', callback=None) # return_semantic_type = Setting(['https://metadata.datadrivendiscovery.org/types/Attribute', # 'https://metadata.datadrivendiscovery.org/types/ConstructedAttribute']) gui.comboBox( box, self, "return_semantic_type", sendSelectedValue=True, label='Semantic type attach with results.', items=[ 'https://metadata.datadrivendiscovery.org/types/Attribute', 'https://metadata.datadrivendiscovery.org/types/ConstructedAttribute' ], ) # Only for test gui.button(box, self, "Print Hyperparameters", callback=self._print_hyperparameter) gui.auto_apply(box, self, "autosend", box=False) self.data = None self.info.set_input_summary(self.info.NoInput) self.info.set_output_summary(self.info.NoOutput)
def __init__(self): super().__init__() self.data = None self.data_subset = None self.plotdata = None box = gui.widgetBox(self.controlArea, "Optimization", spacing=10) form = QtGui.QFormLayout( labelAlignment=Qt.AlignLeft, formAlignment=Qt.AlignLeft, fieldGrowthPolicy=QtGui.QFormLayout.AllNonFixedFieldsGrow, verticalSpacing=10 ) form.addRow( "Force law", gui.comboBox(box, self, "force_law", items=[text for text, _ in OWFreeViz.ForceLaw], callback=self.__reset_update_interval) ) form.addRow( "Max iterations", gui.spin(box, self, "maxiter", 10, 10 ** 4) ) form.addRow( "Initialization", gui.comboBox(box, self, "initialization", items=["Circular", "Random"], callback=self.__reset_initialization) ) form.addRow( "Replot", gui.comboBox(box, self, "replot_interval", items=[text for text, _ in OWFreeViz.ReplotIntervals], callback=self.__reset_update_interval) ) box.layout().addLayout(form) self.start_button = gui.button( box, self, "Optimize", self._toogle_start) self.color_varmodel = itemmodels.VariableListModel(parent=self) self.shape_varmodel = itemmodels.VariableListModel(parent=self) self.size_varmodel = itemmodels.VariableListModel(parent=self) self.label_varmodel = itemmodels.VariableListModel(parent=self) box = gui.widgetBox(self.controlArea, "Plot") form = QtGui.QFormLayout( formAlignment=Qt.AlignLeft, labelAlignment=Qt.AlignLeft, fieldGrowthPolicy=QtGui.QFormLayout.AllNonFixedFieldsGrow, spacing=8, ) box.layout().addLayout(form) color_cb = gui.comboBox( box, self, "color_var", sendSelectedValue=True, emptyString="(Same color)", contentsLength=10, callback=self._update_color) color_cb.setModel(self.color_varmodel) form.addRow("Color", color_cb) opacity_slider = gui.hSlider( box, self, "opacity", minValue=50, maxValue=255, ticks=True, createLabel=False, callback=self._update_color) opacity_slider.setTickInterval(0) opacity_slider.setPageStep(10) form.addRow("Opacity", opacity_slider) shape_cb = gui.comboBox( box, self, "shape_var", contentsLength=10, sendSelectedValue=True, emptyString="(Same shape)", callback=self._update_shape) shape_cb.setModel(self.shape_varmodel) form.addRow("Shape", shape_cb) size_cb = gui.comboBox( box, self, "size_var", contentsLength=10, sendSelectedValue=True, emptyString="(Same size)", callback=self._update_size) size_cb.setModel(self.size_varmodel) form.addRow("Size", size_cb) size_slider = gui.hSlider( box, self, "point_size", minValue=3, maxValue=20, ticks=True, createLabel=False, callback=self._update_size) form.addRow(None, size_slider) label_cb = gui.comboBox( box, self, "label_var", contentsLength=10, sendSelectedValue=True, emptyString="(No labels)", callback=self._update_labels) label_cb.setModel(self.label_varmodel) form.addRow("Label", label_cb) form.addRow( "Jitter", gui.comboBox(box, self, "jitter", items=[text for text, _ in self.JitterAmount], callback=self._update_xy) ) self.class_density_cb = gui.checkBox( box, self, "class_density", "", callback=self._update_density) form.addRow("Class density", self.class_density_cb) box = gui.widgetBox(self.controlArea, "Hide anchors") rslider = gui.hSlider( box, self, "min_anchor_radius", minValue=0, maxValue=100, step=5, label="Hide radius", createLabel=False, ticks=True, callback=self._update_anchor_visibility) rslider.setTickInterval(0) rslider.setPageStep(10) box = gui.widgetBox(self.controlArea, "Zoom/Select") hlayout = QtGui.QHBoxLayout() box.layout().addLayout(hlayout) toolbox = PlotToolBox(self) hlayout.addWidget(toolbox.button(PlotToolBox.SelectTool)) hlayout.addWidget(toolbox.button(PlotToolBox.ZoomTool)) hlayout.addWidget(toolbox.button(PlotToolBox.PanTool)) hlayout.addSpacing(2) hlayout.addWidget(toolbox.button(PlotToolBox.ZoomReset)) toolbox.standardAction(PlotToolBox.ZoomReset).triggered.connect( lambda: self.plot.setRange(QtCore.QRectF(-1.05, -1.05, 2.1, 2.1)) ) toolbox.standardAction(PlotToolBox.ZoomIn).triggered.connect( lambda: self.plot.getViewBox().scaleBy((1.25, 1.25)) ) toolbox.standardAction(PlotToolBox.ZoomIn).triggered.connect( lambda: self.plot.getViewBox().scaleBy((1 / 1.25, 1 / 1.25)) ) selecttool = toolbox.plotTool(PlotToolBox.SelectTool) selecttool.selectionFinished.connect(self.__select_area) self.addActions(toolbox.actions()) self.controlArea.layout().addStretch(1) box = gui.widgetBox(self.controlArea, "Output") gui.comboBox(box, self, "embedding_domain_role", items=["Original features only", "Coordinates as features", "Coordinates as meta attributes"]) gui.auto_commit(box, self, "autocommit", "Commit", box=False, callback=self.commit) self.plot = pg.PlotWidget(enableMouse=False, enableMenu=False) self.plot.setFrameStyle(QtGui.QFrame.StyledPanel) self.plot.plotItem.hideAxis("bottom") self.plot.plotItem.hideAxis("left") self.plot.plotItem.hideButtons() self.plot.setAspectLocked(True) self.plot.scene().installEventFilter(self) self.legend = linproj.LegendItem() self.legend.setParentItem(self.plot.getViewBox()) self.legend.anchor((1, 0), (1, 0)) self.plot.setRenderHint(QtGui.QPainter.Antialiasing, True) self.mainArea.layout().addWidget(self.plot) viewbox = self.plot.getViewBox() viewbox.grabGesture(Qt.PinchGesture) pinchtool = linproj.PlotPinchZoomTool(parent=self) pinchtool.setViewBox(viewbox) toolbox.setViewBox(viewbox) self._loop = AsyncUpdateLoop(parent=self) self._loop.yielded.connect(self.__set_projection) self._loop.finished.connect(self.__freeviz_finished) self._loop.raised.connect(self.__on_error)
def _init_ui(self): # implement your user interface here (for setting hyperparameters) gui.separator(self.controlArea) box = gui.widgetBox(self.controlArea, "Hyperparameter") gui.separator(self.controlArea) gui.lineEdit(box, self, 'n_neighbors', label='Number of neighbors to use by default for kneighbors queries. (IntVariable)', callback=None) gui.comboBox(box, self, 'algorithm', label='Algorithm used to compute the nearest neighbors.', items=['auto', 'ball_tree', 'kd_tree', 'brute'], callback=None) gui.lineEdit(box, self, 'leaf_size', label='Leaf size passed to BallTree or KDTree. (IntVariable)', callback=None) gui.comboBox(box, self, 'metric', label='Metric used for the distance computation.', items=['cityblock', 'cosine', 'euclidean', 'l1', 'l2', 'manhattan', 'braycurtis', 'canberra', 'chebyshev', 'correlation', 'dice', 'hamming', 'jaccard', 'kulsinski', 'mahalanobis', 'matching', 'minkowski', 'rogerstanimoto', 'russellrao', 'seuclidean', 'sokalmichener', 'sokalsneath', 'sqeuclidean', 'yule'], callback=None) gui.lineEdit(box, self, 'p', label='Parameter for the Minkowski metric from. (IntVariable)', callback=None) gui.doubleSpin( box, self, "contamination", minv=0., maxv=1., step=0.001, label="Input contamination, float in (0,0.5].", # callbackOnReturn = True, # checked = "BoundedFloat" ) # return_subseq_inds = Setting(False) gui.checkBox(box, self, "return_subseq_inds", label='If return subsequence index.', callback=None) # use_semantic_types = Setting(False) gui.checkBox(box, self, "use_semantic_types", label='Mannally select columns if active.', callback=None) # use_columns = Setting(()) gui.lineEdit(box, self, "use_columns_buf", label='Column index to use when use_semantic_types is activated. Tuple, e.g. (0,1,2)', validator=None, callback=self._use_columns_callback) # exclude_columns = Setting(()) gui.lineEdit(box, self, "exclude_columns_buf", label='Column index to exclude when use_semantic_types is activated. Tuple, e.g. (0,1,2)', validator=None, callback=self._exclude_columns_callback) # return_result = Setting(['append', 'replace', 'new']) gui.comboBox(box, self, "return_result", sendSelectedValue=True, label='Output results.', items=['new', 'append', 'replace'], ) # add_index_columns = Setting(False) gui.checkBox(box, self, "add_index_columns", label='Keep index in the outputs.', callback=None) # error_on_no_input = Setting(True) gui.checkBox(box, self, "error_on_no_input", label='Error on no input.', callback=None) # return_semantic_type = Setting(['https://metadata.datadrivendiscovery.org/types/Attribute', # 'https://metadata.datadrivendiscovery.org/types/ConstructedAttribute']) gui.comboBox(box, self, "return_semantic_type", sendSelectedValue=True, label='Semantic type attach with results.', items=['https://metadata.datadrivendiscovery.org/types/Attribute', 'https://metadata.datadrivendiscovery.org/types/ConstructedAttribute'], ) # Only for test gui.button(box, self, "Print Hyperparameters", callback=self._print_hyperparameter) gui.auto_apply(box, self, "autosend", box=False) self.data = None self.info.set_input_summary(self.info.NoInput) self.info.set_output_summary(self.info.NoOutput)
def __init__(self): super().__init__() self.data = None self.editors = {} box = QtGui.QGroupBox( title=self.tr("Feature Definitions") ) box.setLayout(QtGui.QHBoxLayout()) self.controlArea.layout().addWidget(box) # Layout for the list view layout = QtGui.QVBoxLayout(spacing=1, margin=0) self.featuremodel = DescriptorModel() self.featuremodel.wrap(self.descriptors) self.featureview = QtGui.QListView( minimumWidth=200, sizePolicy=QSizePolicy(QSizePolicy.Minimum, QSizePolicy.MinimumExpanding) ) self.featureview.setItemDelegate(FeatureItemDelegate()) self.featureview.setModel(self.featuremodel) self.featureview.selectionModel().selectionChanged.connect( self._on_selectedVariableChanged ) self.featuretoolbar = ActionToolBar() self.addaction = QtGui.QAction( "+", self, toolTip="Create a new feature", shortcut=QtGui.QKeySequence.New ) menu = QtGui.QMenu() cont = menu.addAction("Continuous") cont.triggered.connect( lambda: self.addFeature(ContinuousDescriptor("Name", "", 2)) ) disc = menu.addAction("Discrete") disc.triggered.connect( lambda: self.addFeature( DiscreteDescriptor("Name", "", ("0", "1"), -1, False)) ) string = menu.addAction("String") string.triggered.connect( lambda: self.addFeature(StringDescriptor("Name", "")) ) menu.addSeparator() self.duplicateaction = menu.addAction("Duplicate selected feature") self.duplicateaction.triggered.connect(self.duplicateFeature) self.duplicateaction.setEnabled(False) self.addaction.setMenu(menu) self.removeaction = QtGui.QAction( unicodedata.lookup("MINUS SIGN"), self, toolTip="Remove selected feature", # shortcut=QtGui.QKeySequence.Delete, # shortcutContext=Qt.WidgetShortcut ) self.removeaction.triggered.connect(self.removeSelectedFeature) self.featuretoolbar.addAction(self.addaction) self.featuretoolbar.addAction(self.removeaction) layout.addWidget(self.featureview) layout.addWidget(self.featuretoolbar) box.layout().addLayout(layout, 1) self.editorstack = QtGui.QStackedWidget( sizePolicy=QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) ) for descclass, editorclass in self.EDITORS: editor = editorclass() editor.featureChanged.connect(self._on_modified) self.editors[descclass] = editor self.editorstack.addWidget(editor) self.editorstack.setEnabled(False) box.layout().addWidget(self.editorstack, 3) gui.button(self.controlArea, self, "Commit", callback=self.apply, default=True)
def __init__(self): super().__init__() box = gui.widgetBox(self.mainArea, True, margin=0) self.graph = OWScatterPlotGraph(self, box, "ScatterPlot") box.layout().addWidget(self.graph.plot_widget) plot = self.graph.plot_widget axispen = QtGui.QPen(self.palette().color(QtGui.QPalette.Text)) axis = plot.getAxis("bottom") axis.setPen(axispen) axis = plot.getAxis("left") axis.setPen(axispen) self.data = None # Orange.data.Table self.subset_data = None # Orange.data.Table self.data_metas_X = None # self.data, where primitive metas are moved to X self.attribute_selection_list = None # list of Orange.data.Variable common_options = { "labelWidth": 50, "orientation": "horizontal", "sendSelectedValue": True, "valueType": str } box = gui.widgetBox(self.controlArea, "Axis Data") self.cb_attr_x = gui.comboBox(box, self, "attr_x", label="Axis x:", callback=self.update_attr, **common_options) self.cb_attr_y = gui.comboBox(box, self, "attr_y", label="Axis y:", callback=self.update_attr, **common_options) self.vizrank = self.VizRank(self) vizrank_box = gui.widgetBox(box, None, orientation='horizontal') gui.separator(vizrank_box, width=common_options["labelWidth"]) self.vizrank_button = gui.button( vizrank_box, self, "Rank projections", callback=self.vizrank.reshow, tooltip="Find projections with good class separation") self.vizrank_button.setEnabled(False) gui.separator(box) gui.valueSlider(box, self, value='graph.jitter_size', label='Jittering: ', values=self.jitter_sizes, callback=self.reset_graph_data, labelFormat=lambda x: "None" if x == 0 else ("%.1f %%" if x < 1 else "%d %%") % x) gui.checkBox(gui.indentedBox(box), self, 'graph.jitter_continuous', 'Jitter continuous values', callback=self.reset_graph_data) box = gui.widgetBox(self.controlArea, "Points") self.cb_attr_color = gui.comboBox(box, self, "graph.attr_color", label="Color:", emptyString="(Same color)", callback=self.update_colors, **common_options) self.cb_attr_label = gui.comboBox(box, self, "graph.attr_label", label="Label:", emptyString="(No labels)", callback=self.graph.update_labels, **common_options) self.cb_attr_shape = gui.comboBox(box, self, "graph.attr_shape", label="Shape:", emptyString="(Same shape)", callback=self.graph.update_shapes, **common_options) self.cb_attr_size = gui.comboBox(box, self, "graph.attr_size", label="Size:", emptyString="(Same size)", callback=self.graph.update_sizes, **common_options) g = self.graph.gui box2 = g.point_properties_box(self.controlArea, box) gui.button(box2, self, "Set Colors", self.set_colors) box = gui.widgetBox(self.controlArea, "Plot Properties") g.add_widgets([g.ShowLegend, g.ShowGridLines], box) gui.checkBox(box, self, value='graph.tooltip_shows_all', label='Show all data on mouse hover') self.cb_class_density = gui.checkBox(box, self, value='graph.class_density', label='Show class density', callback=self.update_density) self.zoom_select_toolbar = g.zoom_select_toolbar( gui.widgetBox(self.controlArea, "Zoom/Select"), nomargin=True, buttons=[ g.StateButtonsBegin, g.SimpleSelect, g.Pan, g.Zoom, g.StateButtonsEnd, g.ZoomReset ]) buttons = self.zoom_select_toolbar.buttons buttons[g.Zoom].clicked.connect(self.graph.zoom_button_clicked) buttons[g.Pan].clicked.connect(self.graph.pan_button_clicked) buttons[g.SimpleSelect].clicked.connect( self.graph.select_button_clicked) buttons[g.ZoomReset].clicked.connect(self.graph.reset_button_clicked) self.controlArea.layout().addStretch(100) self.icons = gui.attributeIconDict dlg = self.create_color_dialog() self.graph.continuous_palette = dlg.getContinuousPalette("contPalette") self.graph.discrete_palette = dlg.getDiscretePalette("discPalette") dlg.deleteLater() p = self.graph.plot_widget.palette() self.graph.set_palette(p) gui.auto_commit(self.controlArea, self, "auto_send_selection", "Send Selection") def zoom(s): """Zoom in/out by factor `s`.""" viewbox = plot.getViewBox() # scaleBy scales the view's bounds (the axis range) viewbox.scaleBy((1 / s, 1 / s)) def fit_to_view(): viewbox = plot.getViewBox() viewbox.autoRange() zoom_in = QtGui.QAction("Zoom in", self, triggered=lambda: zoom(1.25)) zoom_in.setShortcuts([ QtGui.QKeySequence(QtGui.QKeySequence.ZoomIn), QtGui.QKeySequence(self.tr("Ctrl+=")) ]) zoom_out = QtGui.QAction("Zoom out", self, shortcut=QtGui.QKeySequence.ZoomOut, triggered=lambda: zoom(1 / 1.25)) zoom_fit = QtGui.QAction("Fit in view", self, shortcut=QtGui.QKeySequence(Qt.ControlModifier | Qt.Key_0), triggered=fit_to_view) self.addActions([zoom_in, zoom_out, zoom_fit]) self.graphButton.clicked.connect(self.save_graph)
def _set_control_area(self): box = gui.widgetBox(self.controlArea, '设置:') box.layout().setAlignment(Qt.AlignTop) dir_box = gui.widgetBox(box, '图片文件夹:', orientation=Qt.Horizontal) self.filesCB = gui.comboBox(dir_box, self, "selectedIndex", callback=self._on_recent) self.filesCB.setMinimumContentsLength(20) self.filesCB.setSizeAdjustPolicy( QComboBox.AdjustToMinimumContentsLength) self.loadbutton = gui.button(dir_box, self, "...", callback=self.browse) self.loadbutton.setIcon(self.style().standardIcon( QStyle.SP_DirOpenIcon)) self.loadbutton.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) # filter valid existing filenames self.history = list(filter(os.path.isdir, self.history))[:20] for dir_name in self.history: self.filesCB.addItem(os.path.basename(dir_name), userData=dir_name) # restore the current selection if the filename is # in the history list if self.dir_name in self.history: self.selectedIndex = self.history.index(self.dir_name) else: self.selectedIndex = -1 self.dir_name = None gui.radioButtonsInBox(box, self, 'for_train', btnLabels=['需要训练', '只要预测'], label='是否需要训练', orientation=Qt.Horizontal, callback=self.update_batch_setting) gui.separator(box, height=10) self.batch_box = gui.comboBox(box, self, 'batch_size', items=self.batch_sizes, callback=self.set_size, label='batch size') gui.separator(box, height=10) gui.button( box, self, "载入图片", callback=self.load_images, ) self.next_image_button = gui.button( box, self, "下一组图片", callback=self.next_image, ) self.next_image_button.setEnabled(False)
def _init_ui(self): namesBox = gui.vBox(self.controlArea, "Names") hbox = gui.hBox(namesBox, margin=0, spacing=0) gui.lineEdit(hbox, self, "attr1", "Variable X: ", controlWidth=80, orientation=Qt.Horizontal, callback=self._attr_name_changed) gui.separator(hbox, 21) hbox = gui.hBox(namesBox, margin=0, spacing=0) attr2 = gui.lineEdit(hbox, self, "attr2", "Variable Y: ", controlWidth=80, orientation=Qt.Horizontal, callback=self._attr_name_changed) gui.separator(hbox) gui.checkBox(hbox, self, "hasAttr2", '', disables=attr2, labelWidth=0, callback=self.set_dimensions) gui.separator(namesBox) gui.widgetLabel(namesBox, "Labels") self.classValuesView = listView = gui.ListViewWithSizeHint( preferred_size=(-1, 30)) listView.setModel(self.class_model) itemmodels.select_row(listView, 0) namesBox.layout().addWidget(listView) self.addClassLabel = QAction("+", self, toolTip="Add new class label", triggered=self.add_new_class_label) self.removeClassLabel = QAction( unicodedata.lookup("MINUS SIGN"), self, toolTip="Remove selected class label", triggered=self.remove_selected_class_label) actionsWidget = itemmodels.ModelActionsWidget( [self.addClassLabel, self.removeClassLabel], self) actionsWidget.layout().addStretch(10) actionsWidget.layout().setSpacing(1) namesBox.layout().addWidget(actionsWidget) tBox = gui.vBox(self.controlArea, "Tools", addSpace=True) buttonBox = gui.hBox(tBox) toolsBox = gui.widgetBox(buttonBox, orientation=QGridLayout()) self.toolActions = QActionGroup(self) self.toolActions.setExclusive(True) self.toolButtons = [] for i, (name, tooltip, tool, icon) in enumerate(self.TOOLS): action = QAction( name, self, toolTip=tooltip, checkable=tool.checkable, icon=QIcon(icon), ) action.triggered.connect(partial(self.set_current_tool, tool)) button = QToolButton(iconSize=QSize(24, 24), toolButtonStyle=Qt.ToolButtonTextUnderIcon, sizePolicy=QSizePolicy( QSizePolicy.MinimumExpanding, QSizePolicy.Fixed)) button.setDefaultAction(action) self.toolButtons.append((button, tool)) toolsBox.layout().addWidget(button, i / 3, i % 3) self.toolActions.addAction(action) for column in range(3): toolsBox.layout().setColumnMinimumWidth(column, 10) toolsBox.layout().setColumnStretch(column, 1) undo = self.undo_stack.createUndoAction(self) redo = self.undo_stack.createRedoAction(self) undo.setShortcut(QKeySequence.Undo) redo.setShortcut(QKeySequence.Redo) self.addActions([undo, redo]) self.undo_stack.indexChanged.connect(self.invalidate) gui.separator(tBox) indBox = gui.indentedBox(tBox, sep=8) form = QFormLayout(formAlignment=Qt.AlignLeft, labelAlignment=Qt.AlignLeft, fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow) indBox.layout().addLayout(form) slider = gui.hSlider(indBox, self, "brushRadius", minValue=1, maxValue=100, createLabel=False) form.addRow("Radius:", slider) slider = gui.hSlider(indBox, self, "density", None, minValue=1, maxValue=100, createLabel=False) form.addRow("Intensity:", slider) slider = gui.hSlider(indBox, self, "symbol_size", None, minValue=1, maxValue=100, createLabel=False, callback=self.set_symbol_size) form.addRow("Symbol:", slider) self.btResetToInput = gui.button(tBox, self, "Reset to Input Data", self.reset_to_input) self.btResetToInput.setDisabled(True) gui.auto_send(self.controlArea, self, "autocommit") # main area GUI viewbox = PaintViewBox(enableMouse=False) self.plotview = pg.PlotWidget(background="w", viewBox=viewbox) self.plotview.sizeHint = lambda: QSize( 200, 100) # Minimum size for 1-d painting self.plot = self.plotview.getPlotItem() axis_color = self.palette().color(QPalette.Text) axis_pen = QPen(axis_color) tickfont = QFont(self.font()) tickfont.setPixelSize(max(int(tickfont.pixelSize() * 2 // 3), 11)) axis = self.plot.getAxis("bottom") axis.setLabel(self.attr1) axis.setPen(axis_pen) axis.setTickFont(tickfont) axis = self.plot.getAxis("left") axis.setLabel(self.attr2) axis.setPen(axis_pen) axis.setTickFont(tickfont) if not self.hasAttr2: self.plot.hideAxis('left') self.plot.hideButtons() self.plot.setXRange(0, 1, padding=0.01) self.mainArea.layout().addWidget(self.plotview) self.info.set_input_summary(self.info.NoInput) self.info.set_output_summary(self.info.NoOutput) # enable brush tool self.toolActions.actions()[0].setChecked(True) self.set_current_tool(self.TOOLS[0][2]) self.set_dimensions()
def __init__(self, parent=None, signalManager=None, stored_settings=None): super(OWSql, self).__init__(parent=parent, signalManager=signalManager, stored_settings=stored_settings) self._connection = None vbox = gui.widgetBox(self.controlArea, "Server", addSpace=True) box = gui.widgetBox(vbox) self.servertext = QtGui.QLineEdit(box) self.servertext.setPlaceholderText('Server') if self.host: self.servertext.setText(self.host) box.layout().addWidget(self.servertext) self.databasetext = QtGui.QLineEdit(box) self.databasetext.setPlaceholderText('Database') if self.database: self.databasetext.setText(self.database) box.layout().addWidget(self.databasetext) self.usernametext = QtGui.QLineEdit(box) self.usernametext.setPlaceholderText('Username') if self.username: self.usernametext.setText(self.username) box.layout().addWidget(self.usernametext) self.passwordtext = QtGui.QLineEdit(box) self.passwordtext.setPlaceholderText('Password') self.passwordtext.setEchoMode(QtGui.QLineEdit.Password) if self.password: self.passwordtext.setText(self.password) box.layout().addWidget(self.passwordtext) tables = gui.widgetBox(box, orientation='horizontal') self.tablecombo = QtGui.QComboBox(tables) choices = ['Select a table'] + self.tables + ['Custom SQL'] for i, item in enumerate(choices): self.tablecombo.addItem(item) if item == self.table: self.tablecombo.setCurrentIndex(i) tables.layout().addWidget(self.tablecombo) self.tablecombo.activated[int].connect(self.select_table) self.connectbutton = gui.button(tables, self, '↻', callback=self.connect) self.connectbutton.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) tables.layout().addWidget(self.connectbutton) self.custom_sql = gui.widgetBox(box, orientation='vertical') self.custom_sql.setVisible(False) self.sqltext = QtGui.QTextEdit(self.custom_sql) self.sqltext.setPlainText(self.sql) self.custom_sql.layout().addWidget(self.sqltext) self.executebtn = gui.button(self.custom_sql, self, 'Execute', callback=self.execute_sql) box.layout().addWidget(self.custom_sql) if self.table: self.open_table()
def __init__(self, parent=None): super().__init__(parent) self.data = None box = gui.widgetBox(self.controlArea, self.tr("Name")) gui.lineEdit(box, self, "learner_name") form = QGridLayout() typebox = gui.radioButtonsInBox( self.controlArea, self, "lossfunc", [], orientation=form, ) # Loss function control box = gui.widgetBox(self.controlArea, self.tr("Loss function to be used")) buttonbox = gui.radioButtonsInBox(box, self, "loss_function", btnLabels=[ "Squared loss", "Huber", "Epsilon insensitive", "Squared Epsilon insensitive" ], callback=self._on_func_changed) parambox = gui.widgetBox(box, orientation="horizontal") box = gui.widgetBox(self.controlArea, self.tr("Penalty")) buttonbox = gui.radioButtonsInBox(box, self, "penalty_type", btnLabels=[ "Absolute norm (L1)", "Euclidean norm (L2)", "Elastic Net (both)" ], callback=self._on_penalty_changed) parambox = gui.widgetBox(box, orientation="horizontal") box = gui.widgetBox(self.controlArea, self.tr("Learning rate")) buttonbox = gui.radioButtonsInBox( box, self, "learning_rate", btnLabels=["Inverse scaling", "Constant"], callback=self._on_lrate_changed) box = gui.widgetBox(self.controlArea, self.tr("Constants")) form = QtGui.QFormLayout() form.setContentsMargins(0, 0, 0, 0) box.layout().addLayout(form) alpha = gui.doubleSpin(box, self, "alpha", 0.0, 10.0, step=0.0001) form.addRow("Alpha:", alpha) spin = gui.doubleSpin(box, self, "eta0", 0.0, 10, step=0.01) form.addRow("Eta0:", spin) epsilon = gui.doubleSpin(box, self, "epsilon", 0.0, 10.0, step=0.01) form.addRow("Epsilon:", epsilon) l1_ratio = gui.doubleSpin(box, self, "l1_ratio", 0.0, 10.0, step=0.01) form.addRow("L1 ratio:", l1_ratio) power_t = gui.doubleSpin(box, self, "power_t", 0.0, 10.0, step=0.01) form.addRow("Power t:", power_t) # Number of iterations control box = gui.widgetBox(self.controlArea, "Number of iterations") gui.doubleSpin(box, self, "n_iter", 0, 1e+6, step=1) self._func_params = [epsilon] self._penalty_params = [l1_ratio] self._lrate_params = [power_t] gui.button(self.controlArea, self, "&Apply", callback=self.apply, default=True) self.setSizePolicy( QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)) self.setMinimumWidth(300) self._on_func_changed() self.apply()
def __init__(self): super().__init__() self.data = None self.n_inliers = self.n_outliers = None box = gui.vBox(self.controlArea, "Information") self.data_info_label = gui.widgetLabel(box, self.data_info_default) self.in_out_info_label = gui.widgetLabel(box, self.in_out_info_default) box = gui.vBox(self.controlArea, "Outlier Detection Method") detection = gui.radioButtons(box, self, "outlier_method") gui.appendRadioButton(detection, "One class SVM with non-linear kernel (RBF)") ibox = gui.indentedBox(detection) tooltip = "An upper bound on the fraction of training errors and a " \ "lower bound of the fraction of support vectors" gui.widgetLabel(ibox, 'Nu:', tooltip=tooltip) self.nu_slider = gui.hSlider(ibox, self, "nu", minValue=1, maxValue=100, ticks=10, labelFormat="%d %%", callback=self.nu_changed, tooltip=tooltip) self.gamma_spin = gui.spin(ibox, self, "gamma", label="Kernel coefficient:", step=1e-2, spinType=float, minv=0.01, maxv=10, callback=self.gamma_changed) gui.separator(detection, 12) self.rb_cov = gui.appendRadioButton(detection, "Covariance estimator") ibox = gui.indentedBox(detection) self.l_cov = gui.widgetLabel(ibox, 'Contamination:') self.cont_slider = gui.hSlider(ibox, self, "cont", minValue=0, maxValue=100, ticks=10, labelFormat="%d %%", callback=self.cont_changed) ebox = gui.hBox(ibox) self.cb_emp_cov = gui.checkBox(ebox, self, "empirical_covariance", "Support fraction:", callback=self.empirical_changed) self.support_fraction_spin = gui.spin( ebox, self, "support_fraction", step=1e-1, spinType=float, minv=0.1, maxv=10, callback=self.support_fraction_changed) gui.separator(detection, 12) gui.button(self.buttonsArea, self, "Detect Outliers", callback=self.commit) self.layout().setSizeConstraint(QLayout.SetFixedSize)
def __init__(self): super().__init__() self.__pending_selection = self.selection self._optimizer = None self._optimizer_thread = None self.stop_optimization = False self.data = self.cont_x = None self.cells = self.member_data = None self.selection = None self.colors = self.thresholds = self.bin_labels = None box = gui.vBox(self.controlArea, box="SOM") shape = gui.comboBox(box, self, "", items=("Hexagonal grid", "Square grid")) shape.setCurrentIndex(1 - self.hexagonal) box2 = gui.indentedBox(box, 10) auto_dim = gui.checkBox(box2, self, "auto_dimension", "Set dimensions automatically", callback=self.on_auto_dimension_changed) self.manual_box = box3 = gui.hBox(box2) spinargs = dict(value="", widget=box3, master=self, minv=5, maxv=100, step=5, alignment=Qt.AlignRight) spin_x = gui.spin(**spinargs) spin_x.setValue(self.size_x) gui.widgetLabel(box3, "×") spin_y = gui.spin(**spinargs) spin_y.setValue(self.size_y) gui.rubber(box3) self.manual_box.setEnabled(not self.auto_dimension) initialization = gui.comboBox(box, self, "initialization", items=("Initialize with PCA", "Random initialization", "Replicable random")) start = gui.button(box, self, "Restart", callback=self.restart_som_pressed, sizePolicy=(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed)) self.opt_controls = self.OptControls(shape, auto_dim, spin_x, spin_y, initialization, start) box = gui.vBox(self.controlArea, "Color") gui.comboBox(box, self, "attr_color", searchable=True, callback=self.on_attr_color_change, model=DomainModel(placeholder="(Same color)", valid_types=DomainModel.PRIMITIVE)) gui.checkBox(box, self, "pie_charts", label="Show pie charts", callback=self.on_pie_chart_change) gui.checkBox(box, self, "size_by_instances", label="Size by number of instances", callback=self.on_attr_size_change) gui.rubber(self.controlArea) self.scene = QGraphicsScene(self) self.view = SomView(self.scene) self.view.setMinimumWidth(400) self.view.setMinimumHeight(400) self.view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.view.setRenderHint(QPainter.Antialiasing) self.view.selection_changed.connect(self.on_selection_change) self.view.selection_moved.connect(self.on_selection_move) self.view.selection_mark_changed.connect(self.on_selection_mark_change) self.mainArea.layout().addWidget(self.view) self.elements = None self.grid = None self.grid_cells = None self.legend = None
def __init__(self): super().__init__() self.data = None self.preprocessors = None # Learner name box = gui.widgetBox(self.controlArea, self.tr("Name")) gui.lineEdit(box, self, "learner_name") # Basic properties form = QGridLayout() basic_box = gui.widgetBox(self.controlArea, "Basic properties", orientation=form) form.addWidget(QLabel(self.tr("Number of trees in the forest: ")), 0, 0, Qt.AlignLeft) spin = gui.spin(basic_box, self, "n_estimators", minv=1, maxv=1e4, callback=self.settingsChanged, addToLayout=False, controlWidth=50) form.addWidget(spin, 0, 1, Qt.AlignRight) max_features_cb = gui.checkBox( basic_box, self, "use_max_features", callback=self.settingsChanged, addToLayout=False, label="Consider a number of best attributes at each split") max_features_spin = gui.spin(basic_box, self, "max_features", 2, 50, addToLayout=False, callback=self.settingsChanged, controlWidth=50) form.addWidget(max_features_cb, 1, 0, Qt.AlignLeft) form.addWidget(max_features_spin, 1, 1, Qt.AlignRight) random_state_cb = gui.checkBox(basic_box, self, "use_random_state", callback=self.settingsChanged, addToLayout=False, label="Use seed for random generator:") random_state_spin = gui.spin(basic_box, self, "random_state", 0, 2**31 - 1, addToLayout=False, callback=self.settingsChanged, controlWidth=50) form.addWidget(random_state_cb, 2, 0, Qt.AlignLeft) form.addWidget(random_state_spin, 2, 1, Qt.AlignRight) self._max_features_spin = max_features_spin self._random_state_spin = random_state_spin # Growth control form = QGridLayout() growth_box = gui.widgetBox(self.controlArea, "Growth control", orientation=form) max_depth_cb = gui.checkBox( growth_box, self, "use_max_depth", label="Set maximal depth of individual trees", callback=self.settingsChanged, addToLayout=False) max_depth_spin = gui.spin(growth_box, self, "max_depth", 2, 50, addToLayout=False, callback=self.settingsChanged) form.addWidget(max_depth_cb, 3, 0, Qt.AlignLeft) form.addWidget(max_depth_spin, 3, 1, Qt.AlignRight) max_leaf_nodes_cb = gui.checkBox( growth_box, self, "use_max_leaf_nodes", label="Stop splitting nodes with maximum instances: ", callback=self.settingsChanged, addToLayout=False) max_leaf_nodes_spin = gui.spin(growth_box, self, "max_leaf_nodes", 0, 100, addToLayout=False, callback=self.settingsChanged) form.addWidget(max_leaf_nodes_cb, 4, 0, Qt.AlignLeft) form.addWidget(max_leaf_nodes_spin, 4, 1, Qt.AlignRight) self._max_depth_spin = max_depth_spin self._max_leaf_nodes_spin = max_leaf_nodes_spin # Index on the output # gui.doubleSpin(self.controlArea, self, "index_output", 0, 10000, 1, # label="Index of tree on the output") box = gui.widgetBox(self.controlArea, True, orientation="horizontal") box.layout().addWidget(self.report_button) gui.separator(box, 20) gui.button(box, self, "&Apply", callback=self.apply, default=True) self.settingsChanged() self.apply()
def __init__(self): self.data = None self.output = None self._is_running = False self.isRegexMatch = lambda x: True self.tree = QTreeWidget(self.mainArea, columnCount=2, allColumnsShowFocus=True, alternatingRowColors=True, selectionMode=QTreeWidget.ExtendedSelection, uniformRowHeights=True) self.tree.setHeaderLabels(["Itemsets", "Support", "%"]) self.tree.header().setStretchLastSection(True) self.tree.itemSelectionChanged.connect(self.selectionChanged) self.mainArea.layout().addWidget(self.tree) box = gui.widgetBox(self.controlArea, "Info") self.nItemsets = self.nSelectedExamples = self.nSelectedItemsets = '' gui.label(box, self, "Number of itemsets: %(nItemsets)s") gui.label(box, self, "Selected itemsets: %(nSelectedItemsets)s") gui.label(box, self, "Selected examples: %(nSelectedExamples)s") hbox = gui.widgetBox(box, orientation='horizontal') gui.button(hbox, self, "Expand all", callback=self.tree.expandAll) gui.button(hbox, self, "Collapse all", callback=self.tree.collapseAll) box = gui.widgetBox(self.controlArea, 'Find itemsets') gui.valueSlider(box, self, 'minSupport', values=[.0001, .0005, .001, .005, .01, .05, .1, .5] + list(range(1, 101)), label='Minimal support:', labelFormat="%g%%", callback=lambda: self.find_itemsets()) gui.hSlider(box, self, 'maxItemsets', minValue=10000, maxValue=100000, step=10000, label='Max. number of itemsets:', labelFormat="%d", callback=lambda: self.find_itemsets()) self.button = gui.auto_commit( box, self, 'autoFind', 'Find Itemsets', commit=self.find_itemsets, callback=lambda: self.autoFind and self.find_itemsets()) box = gui.widgetBox(self.controlArea, 'Filter itemsets') gui.lineEdit(box, self, 'filterKeywords', 'Contains:', callback=self.filter_change, orientation='horizontal', tooltip='A comma or space-separated list of regular ' 'expressions.') hbox = gui.widgetBox(box, orientation='horizontal') gui.spin(hbox, self, 'filterMinItems', 1, 998, label='Min. items:', callback=self.filter_change) gui.spin(hbox, self, 'filterMaxItems', 2, 999, label='Max. items:', callback=self.filter_change) gui.checkBox(box, self, 'filterSearch', label='Apply these filters in search', tooltip='If checked, the itemsets are filtered according ' 'to these filter conditions already in the search ' 'phase. \nIf unchecked, the only filters applied ' 'during search are the ones above, ' 'and the itemsets are \nfiltered afterwards only for ' 'display, i.e. only the matching itemsets are shown.') gui.rubber(hbox) gui.rubber(self.controlArea) gui.auto_commit(self.controlArea, self, 'autoSend', 'Send selection') self.filter_change()
def __init__(self): super().__init__() self.old_purge_classes = True self.conditions = [] self.last_output_conditions = None self.data = None box = gui.widgetBox(self.controlArea, 'Conditions', stretch=100) self.cond_list = QtGui.QTableWidget(box) box.layout().addWidget(self.cond_list) self.cond_list.setShowGrid(False) self.cond_list.setSelectionMode(QtGui.QTableWidget.NoSelection) self.cond_list.setColumnCount(3) self.cond_list.setRowCount(0) self.cond_list.verticalHeader().hide() self.cond_list.horizontalHeader().hide() self.cond_list.resizeColumnToContents(0) self.cond_list.horizontalHeader().setResizeMode( QtGui.QHeaderView.Stretch) self.cond_list.viewport().setBackgroundRole(QtGui.QPalette.Window) box2 = gui.widgetBox(box, orientation="horizontal") self.add_button = gui.button(box2, self, "Add condition", callback=self.add_row) self.add_all_button = gui.button(box2, self, "Add all variables", callback=self.add_all) self.remove_all_button = gui.button(box2, self, "Remove all", callback=self.remove_all) gui.rubber(box2) info = gui.widgetBox(self.controlArea, '', orientation="horizontal") box_data_in = gui.widgetBox(info, 'Data In') # self.data_in_rows = gui.widgetLabel(box_data_in, " ") self.data_in_variables = gui.widgetLabel(box_data_in, " ") gui.rubber(box_data_in) box_data_out = gui.widgetBox(info, 'Data Out') self.data_out_rows = gui.widgetLabel(box_data_out, " ") # self.dataOutAttributesLabel = gui.widgetLabel(box_data_out, " ") gui.rubber(box_data_out) box = gui.widgetBox(self.controlArea, orientation="horizontal") box_setting = gui.widgetBox(box, 'Purging') cb = gui.checkBox(box_setting, self, "purge_attributes", "Remove unused values/features", callback=self.on_purge_change) self.purgeClassesCB = gui.checkBox(gui.indentedBox( box_setting, sep=gui.checkButtonOffsetHint(cb)), self, "purge_classes", "Remove unused classes", callback=self.on_purge_change) gui.auto_commit(box, self, "auto_commit", label="Commit", checkbox_label="Commit on change") self.set_data(None) self.resize(600, 400)
def __init__(self): super().__init__() self.data = None self.editors = {} box = gui.widgetBox(self.controlArea, "Variable Definitions") toplayout = QtGui.QHBoxLayout() toplayout.setContentsMargins(0, 0, 0, 0) box.layout().addLayout(toplayout) self.editorstack = QtGui.QStackedWidget(sizePolicy=QSizePolicy( QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) for descclass, editorclass in self.EDITORS: editor = editorclass() editor.featureChanged.connect(self._on_modified) self.editors[descclass] = editor self.editorstack.addWidget(editor) self.editorstack.setEnabled(False) buttonlayout = QtGui.QVBoxLayout(spacing=10) buttonlayout.setContentsMargins(0, 0, 0, 0) self.addbutton = QtGui.QPushButton("New", toolTip="Create a new variable", minimumWidth=120, shortcut=QtGui.QKeySequence.New) def unique_name(fmt, reserved): candidates = (fmt.format(i) for i in count(1)) return next(c for c in candidates if c not in reserved) def reserved_names(): varnames = [] if self.data is not None: varnames = [ var.name for var in self.data.domain.variables + self.data.domain.metas ] varnames += [desc.name for desc in self.featuremodel] return set(varnames) def generate_newname(fmt): return unique_name(fmt, reserved_names()) menu = QtGui.QMenu(self.addbutton) cont = menu.addAction("Continuous") cont.triggered.connect(lambda: self.addFeature( ContinuousDescriptor(generate_newname("X{}"), "", 3))) disc = menu.addAction("Discrete") disc.triggered.connect(lambda: self.addFeature( DiscreteDescriptor(generate_newname("D{}"), "", ("A", "B"), -1, False))) string = menu.addAction("String") string.triggered.connect(lambda: self.addFeature( StringDescriptor(generate_newname("S{}"), ""))) menu.addSeparator() self.duplicateaction = menu.addAction("Duplicate selected variable") self.duplicateaction.triggered.connect(self.duplicateFeature) self.duplicateaction.setEnabled(False) self.addbutton.setMenu(menu) self.removebutton = QtGui.QPushButton( "Remove", toolTip="Remove selected variable", minimumWidth=120, shortcut=QtGui.QKeySequence.Delete) self.removebutton.clicked.connect(self.removeSelectedFeature) buttonlayout.addWidget(self.addbutton) buttonlayout.addWidget(self.removebutton) buttonlayout.addStretch(10) toplayout.addLayout(buttonlayout, 0) toplayout.addWidget(self.editorstack, 10) # Layout for the list view layout = QtGui.QVBoxLayout(spacing=1, margin=0) self.featuremodel = DescriptorModel(parent=self) self.featureview = QtGui.QListView(minimumWidth=200, sizePolicy=QSizePolicy( QSizePolicy.Minimum, QSizePolicy.MinimumExpanding)) self.featureview.setItemDelegate(FeatureItemDelegate(self)) self.featureview.setModel(self.featuremodel) self.featureview.selectionModel().selectionChanged.connect( self._on_selectedVariableChanged) layout.addWidget(self.featureview) box.layout().addLayout(layout, 1) box = gui.widgetBox(self.controlArea, orientation="horizontal") box.layout().addWidget(self.report_button) self.report_button.setMinimumWidth(180) gui.rubber(box) commit = gui.button(box, self, "Commit", callback=self.apply, default=True) commit.setMinimumWidth(180)
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=QtGui.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 = QtGui.QSplitter( orientation=Qt.Horizontal, childrenCollapsible=False, handleWidth=2, ) self.dataview = TableView( verticalScrollBarPolicy=Qt.ScrollBarAlwaysOn, horizontalScrollBarPolicy=Qt.ScrollBarAlwaysOn, horizontalScrollMode=QtGui.QTableView.ScrollPerPixel, selectionMode=QtGui.QTableView.NoSelection, focusPolicy=Qt.StrongFocus ) self.predictionsview = TableView( verticalScrollBarPolicy=Qt.ScrollBarAlwaysOff, horizontalScrollBarPolicy=Qt.ScrollBarAlwaysOn, horizontalScrollMode=QtGui.QTableView.ScrollPerPixel, selectionMode=QtGui.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)
def __init__(self): super().__init__() self.grid = None self.data = None self.data_subset = None self.subset_indices = [] self.nonempty = [] self.allAttrs = [] self.stringAttrs = [] self.domainAttrs = [] self.label_model = DomainModel(placeholder="(No labels)") self.selection = None #: List of _ImageItems self.items = [] self._errcount = 0 self._successcount = 0 self.imageAttrCB = gui.comboBox( self.controlArea, self, "imageAttr", box="Image Filename Attribute", tooltip="Attribute with image filenames", callback=self.change_image_attr, contentsLength=12, addSpace=True, ) # cell fit (resize or crop) self.cellFitRB = gui.radioButtons(self.controlArea, self, "cell_fit", ["Resize", "Crop"], box="Image cell fit", callback=self.set_crop) self.gridSizeBox = gui.vBox(self.controlArea, "Grid size") form = QFormLayout(labelAlignment=Qt.AlignLeft, formAlignment=Qt.AlignLeft, fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow, verticalSpacing=10) self.colSpinner = gui.spin(self.gridSizeBox, self, "columns", minv=2, maxv=40, callback=self.update_size) self.rowSpinner = gui.spin(self.gridSizeBox, self, "rows", minv=2, maxv=40, callback=self.update_size) form.addRow("Columns:", self.colSpinner) form.addRow("Rows:", self.rowSpinner) gui.separator(self.gridSizeBox, 10) self.gridSizeBox.layout().addLayout(form) gui.button(self.gridSizeBox, self, "Set size automatically", callback=self.auto_set_size) self.label_box = gui.vBox(self.controlArea, "Labels") # labels control self.label_attr_cb = gui.comboBox(self.label_box, self, "label_attr", tooltip="Show labels", callback=self.update_size, addSpace=True, model=self.label_model) gui.rubber(self.controlArea) # auto commit self.autoCommitBox = gui.auto_commit( self.controlArea, self, "auto_commit", "Apply", checkbox_label="Apply automatically") self.image_grid = None self.cell_fit = 0 self.thumbnailView = ThumbnailView( alignment=Qt.AlignTop | Qt.AlignLeft, focusPolicy=Qt.StrongFocus, verticalScrollBarPolicy=Qt.ScrollBarAlwaysOff, horizontalScrollBarPolicy=Qt.ScrollBarAlwaysOff) self.mainArea.layout().addWidget(self.thumbnailView) self.scene = self.thumbnailView.scene() self.scene.selectionChanged.connect(self.on_selection_changed) self.loader = ImageLoader(self)
def __init__(self, parent=None): widget.OWWidget.__init__(self, parent) self.min_value, self.max_value = \ self.thresholds.get(self.Scores[self.score_index][0], (1, 0)) #: Input data set self.data = None #: Current target group selection self.targets = [] #: The computed scores self.scores = None #: The computed scores from label permutations self.nulldist = None self.__scores_future = self.__scores_state = None self.__in_progress = False self.test_f = { OWFeatureSelection.LowTail: test_low, OWFeatureSelection.HighTail: test_high, OWFeatureSelection.TwoTail: test_two_tail, } self.histogram = Histogram(enableMouse=False, enableMenu=False, background="w") self.histogram.enableAutoRange(enable=True) self.histogram.getViewBox().setMouseEnabled(False, False) self.histogram.selectionChanged.connect( self.__on_histogram_plot_selection_changed) self.histogram.selectionEdited.connect(self._invalidate_selection) self.mainArea.layout().addWidget(self.histogram) box = gui.widgetBox(self.controlArea, "Info") self.dataInfoLabel = gui.widgetLabel(box, "No data on input.\n") self.dataInfoLabel.setWordWrap(True) self.selectedInfoLabel = gui.widgetLabel(box, "\n") box1 = gui.widgetBox(self.controlArea, "Scoring Method") gui.comboBox( box1, self, "score_index", items=[sm[0] for sm in self.Scores], callback=[self.on_scoring_method_changed, self.update_scores]) box = gui.widgetBox(self.controlArea, "Target Labels") self.label_selection_widget = guiutils.LabelSelectionWidget(self) self.label_selection_widget.setMaximumHeight(150) box.layout().addWidget(self.label_selection_widget) self.label_selection_widget.groupChanged.connect( self.on_label_activated) self.label_selection_widget.groupSelectionChanged.connect( self.on_target_changed) box = gui.widgetBox(self.controlArea, "Selection") box.layout().setSpacing(0) self.max_value_spin = gui.doubleSpin(box, self, "max_value", minv=-1e6, maxv=1e6, step=1e-6, label="Upper threshold:", callback=self.update_boundary, callbackOnReturn=True) self.low_value_spin = gui.doubleSpin(box, self, "min_value", minv=-1e6, maxv=1e6, step=1e-6, label="Lower threshold:", callback=self.update_boundary, callbackOnReturn=True) check = gui.checkBox(box, self, "compute_null", "Compute null distribution", callback=self.update_scores) perm_spin = gui.spin(box, self, "permutations_count", minv=1, maxv=50, label="Permutations:", callback=self.update_scores, callbackOnReturn=True) check.disables.append(perm_spin) box1 = gui.widgetBox(box, orientation='horizontal') pval_spin = gui.doubleSpin(box1, self, "alpha_value", minv=2e-7, maxv=1.0, step=1e-7, label="α-value:") pval_select = gui.button(box1, self, "Select", callback=self.select_p_best, autoDefault=False) check.disables.append(pval_spin) check.disables.append(pval_select) check.makeConsistent() box1 = gui.widgetBox(box, orientation='horizontal') gui.spin(box1, self, "n_best", 0, 10000, step=1, label="Best Ranked:") gui.button(box1, self, "Select", callback=self.select_n_best, autoDefault=False) box = gui.widgetBox(self.controlArea, "Output") acbox = gui.auto_commit(box, self, "auto_commit", "Commit", box=None) acbox.button.setDefault(True) gui.checkBox(box, self, "add_scores_to_output", "Add gene scores to output", callback=self._invalidate_selection) gui.rubber(self.controlArea) self.on_scoring_method_changed() self._executor = concurrent.ThreadExecutor()