def __init__(self, master): super().__init__(master) label = gui.label(self, self, 'Language:') label.setAlignment(Qt.AlignRight) self.method_layout.addWidget(label, self.SNOWBALL, 1) snowball_box = widgets.ComboBox(self, 'snowball_language', items=preprocess.SnowballStemmer.supported_languages) snowball_box.currentIndexChanged.connect(self.change_language) self.method_layout.addWidget(snowball_box, self.SNOWBALL, 2) self.methods[self.SNOWBALL].language = self.snowball_language self.udpipe_tokenizer_box = QCheckBox("UDPipe tokenizer", self, checked=self.udpipe_tokenizer) self.udpipe_tokenizer_box.stateChanged.connect(self.change_tokenizer) self.method_layout.addWidget(self.udpipe_tokenizer_box, self.UDPIPE, 1) self.udpipe_label = gui.label(self, self, 'Language:') self.udpipe_label.setAlignment(Qt.AlignRight) self.method_layout.addWidget(self.udpipe_label, self.UDPIPE, 2) self.udpipe_models = UDPipeModels() self.create_udpipe_box() self.udpipe_online = self.udpipe_models.online self.on_off_button.stateChanged.connect(self.check_udpipe_online) self.check_udpipe_online() self.methods[self.UDPIPE].language = self.udpipe_language self.methods[self.UDPIPE].use_tokenizer = self.udpipe_tokenizer
def _setup_control_area(self): settings_box = gui.widgetBox(self.controlArea, "网络设置:") gui.label(settings_box, self, "选择各层模型参数, 输出通道数为 0 表示此层不存在: \n") self.model_info = gui.label(self.mainArea, self, '模型信息') self.grid_type_box = gui.comboBox(settings_box, self, 'out_1', items=self.out_channels[:-1], label='第 1 层卷积输出通道数目') self.grid_type_box = gui.comboBox(settings_box, self, 'out_2', items=self.out_channels, label='第 2 层卷积输出通道数目') self.grid_type_box = gui.comboBox(settings_box, self, 'out_3', items=self.out_channels, label='第 3 层卷积输出通道数目') self.grid_type_box = gui.comboBox(settings_box, self, 'out_4', items=self.out_channels, label='第 4 层卷积输出通道数目') self.grid_type_box = gui.comboBox(settings_box, self, 'out_5', items=self.out_channels, label='第 5 层卷积输出通道数目')
def add_group_settings(self, parent): box = gui.vBox(parent, "Groups") box2 = gui.hBox(box) gui.checkBox(box2, self, "graph.group_lines", "Group lines into", tooltip="Show clusters instead of lines", callback=self.update_graph) gui.spin(box2, self, "graph.number_of_groups", 0, 30, callback=self.update_graph) gui.label(box2, self, "groups") box2 = gui.hBox(box) gui.spin(box2, self, "graph.number_of_steps", 0, 100, label="In no more than", callback=self.update_graph) gui.label(box2, self, "steps")
def __init__(self): super().__init__() self.data(None) self.data_set_size = self.features = self.meta_attributes = "" self.location = "" for box in ("Data Set Size", "Features", "Targets", "Meta Attributes", "Location"): name = box.lower().replace(" ", "_") bo = gui.widgetBox(self.controlArea, box, addSpace=False and box != "Meta Attributes") gui.label(bo, self, "%%(%s)s" % name) # ensure the widget has some decent minimum width. self.targets = "Discrete outcome with 123 values" self.layout().activate() # NOTE: The minimum width is set on the 'contained' widget and # not `self`. The layout will set a fixed size to `self` taking # into account the minimum constraints of the children (it would # override any minimum/fixed size set on `self`). self.controlArea.setMinimumWidth(self.controlArea.sizeHint().width()) self.layout().setSizeConstraint(QtGui.QLayout.SetFixedSize) self.targets = "" self.data_desc = None
def __init__(self): super().__init__() gui.label(self.controlArea, self, "from pandas:") self.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum) self.allSQLSelectWidgets.append(self) # set default settings self.domain = None self.recentConnections = list() self.recentConnections.append("(none)") self.queryFile = None self.query = "" self.lastQuery = None if self.lastQuery is not None: self.query = self.lastQuery sources = pyodbc.dataSources() dsns = list(sources.keys()) dsns.sort() for dsn in dsns: self.recentConnections.append("DSN={dsn}".format(dsn=dsn)) self.connectString = self.recentConnections[0] self.connectBox = gui.widgetBox(self.controlArea, "Database") self.connectLineEdit = gui.lineEdit(self.connectBox, self, "connectString", callback=None) self.connectCombo = gui.comboBox( self.connectBox, self, "connectString", items=self.recentConnections, valueType=str, sendSelectedValue=True ) self.button = gui.button(self.connectBox, self, "connect", callback=self.connectDB, disabled=0) # query self.splitCanvas = QSplitter(QtCore.Qt.Vertical, self.mainArea) self.mainArea.layout().addWidget(self.splitCanvas) self.textBox = gui.widgetBox(self, "HiveQL") 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.selectSubmitBox = QHGroupBox("", self.selectBox) # self.queryTextEdit.setSizePolicy(QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)) # self.queryTextEdit.setMinimumWidth(300) # self.connect(self.queryTextEdit, SIGNAL('returnPressed()'), self.executeQuery) gui.button(self.selectBox, self, "Open...", callback=self.openScript) gui.button(self.selectBox, self, "Save...", callback=self.saveScript) 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) self.domainBox = gui.widgetBox(self.controlArea, "Domain") self.domainLabel = gui.label(self.domainBox, self, "") # 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) self.cnxn = None
def _create_layout(self): self.mainArea.layout().addWidget(self.graphview) info = gui.widgetBox(self.controlArea, 'Info') gui.label(info, self, '%(n_object_types)d object types') gui.label(info, self, '%(n_relations)d relations') # Table view of relation details info = gui.widgetBox(self.controlArea, 'Relations') class TableView(gui.TableView): def __init__(self, parent=None, **kwargs): super().__init__(parent, **kwargs) self._parent = parent self.bold_font = self.BoldFontDelegate(self) # member because PyQt sometimes unrefs too early self.setItemDelegateForColumn(2, self.bold_font) self.setItemDelegateForColumn(4, self.bold_font) self.horizontalHeader().setVisible(False) def selectionChanged(self, selected, deselected): super().selectionChanged(selected, deselected) if not selected: assert len(deselected) > 0 relation = None else: assert len(selected) == 1 data = self._parent.tablemodel[selected[0].top()][0] relation = Relation(data) self._parent.send(Output.RELATION, relation) model = self.tablemodel = PyTableModel(parent=self) table = self.table = TableView(self, selectionMode=TableView.SingleSelection) table.setModel(model) info.layout().addWidget(self.table) gui.lineEdit(self.controlArea, self, 'pref_algo_name', 'Fuser name:', orientation='horizontal', callback=self.checkcommit, enterPlaceholder=True) gui.radioButtons(self.controlArea, self, 'pref_algorithm', [i[0] for i in DECOMPOSITION_ALGO], box='Decomposition algorithm', callback=self.checkcommit) gui.radioButtons(self.controlArea, self, 'pref_initialization', INITIALIZATION_ALGO, box='Initialization algorithm', callback=self.checkcommit) slider = gui.hSlider( self.controlArea, self, 'pref_n_iterations', 'Maximum number of iterations', minValue=10, maxValue=500, createLabel=True, callback=self.checkcommit) slider.setTracking(False) self.slider_rank = gui.hSlider(self.controlArea, self, 'pref_rank', 'Factorization rank', minValue=1, maxValue=100, createLabel=True, labelFormat=" %d%%", callback=self.checkcommit) self.slider_rank.setTracking(False) gui.auto_commit(self.controlArea, self, "autorun", "Run", checkbox_label="Run after any change ")
def __init__(self): super().__init__() self.data = None self.removedAttrs = "-" self.reducedAttrs = "-" self.resortedAttrs = "-" self.removedClasses = "-" self.reducedClasses = "-" self.resortedClasses = "-" boxAt = gui.widgetBox(self.controlArea, "Features") for not_first, (value, label) in enumerate(self.feature_options): if not_first: gui.separator(boxAt, 2) gui.checkBox(boxAt, self, value, label, callback=self.optionsChanged) boxAt = gui.widgetBox(self.controlArea, "Classes", addSpace=True) for not_first, (value, label) in enumerate(self.class_options): if not_first: gui.separator(boxAt, 2) gui.checkBox(boxAt, self, value, label, callback=self.optionsChanged) box3 = gui.widgetBox(self.controlArea, 'Statistics', addSpace=True) for label, value in self.stat_labels: gui.label(box3, self, "{}: %({})s".format(label, value)) gui.auto_commit(self.controlArea, self, "autoSend", "Send Data", checkbox_label="Send automatically", orientation="horizontal") gui.rubber(self.controlArea)
def __init__(self): super().__init__() self._clear_fields() boxs = [ ("Data Set Name", "数据集名称"), ("Data Set Size", "数据集大小"), ("Features", "特征"), ("Targets", "目标"), ("Meta Attributes", "元特征"), ("Location", "位置"), ("Data Attributes", "数据属性"), ] for i, (box, label) in enumerate(boxs): # for box in ("Data Set Name", "Data Set Size", "Features", "Targets", # "Meta Attributes", "Location", "Data Attributes"): name = box.lower().replace(" ", "_") bo = gui.vBox(self.controlArea, label, addSpace=False and box != "Meta Attributes") gui.label(bo, self, "%%(%s)s" % name) # ensure the widget has some decent minimum width. self.targets = "Categorical outcome with 123 values" self.layout().activate() # NOTE: The minimum width is set on the 'contained' widget and # not `self`. The layout will set a fixed size to `self` taking # into account the minimum constraints of the children (it would # override any minimum/fixed size set on `self`). self.targets = "" self.controlArea.setMinimumWidth(self.controlArea.sizeHint().width()) self.layout().setSizeConstraint(QtWidgets.QLayout.SetFixedSize)
def _create_layout(self): self.mainArea.layout().addWidget(self.graphview) info = gui.widgetBox(self.controlArea, 'Info') gui.label(info, self, '%(n_object_types)d object types') gui.label(info, self, '%(n_relations)d relations') # Table view of relation details info = gui.widgetBox(self.controlArea, 'Relations') class TableView(gui.TableView): def __init__(self, parent=None, **kwargs): super().__init__(parent, **kwargs) self._parent = parent self.bold_font = self.BoldFontDelegate(self) # member because PyQt sometimes unrefs too early self.setItemDelegateForColumn(2, self.bold_font) self.setItemDelegateForColumn(4, self.bold_font) self.horizontalHeader().setVisible(False) def selectionChanged(self, selected, deselected): super().selectionChanged(selected, deselected) if not selected: assert len(deselected) > 0 relation = None else: assert len(selected) == 1 data = self._parent.tablemodel[selected[0].top()][0] relation = Relation(data) self._parent.send(Output.RELATION, relation) model = self.tablemodel = PyTableModel(parent=self) table = self.table = TableView(self, selectionMode=TableView.SingleSelection) table.setModel(model) info.layout().addWidget(self.table) gui.lineEdit(self.controlArea, self, 'pref_algo_name', 'Fuser name:', orientation='horizontal', callback=self.checkcommit) gui.radioButtons(self.controlArea, self, 'pref_algorithm', [i[0] for i in DECOMPOSITION_ALGO], box='Decomposition algorithm', callback=self.checkcommit) gui.radioButtons(self.controlArea, self, 'pref_initialization', INITIALIZATION_ALGO, box='Initialization algorithm', callback=self.checkcommit) slider = gui.hSlider( self.controlArea, self, 'pref_n_iterations', 'Maximum number of iterations', minValue=10, maxValue=500, createLabel=True, callback=self.checkcommit) slider.setTracking(False) self.slider_rank = gui.hSlider(self.controlArea, self, 'pref_rank', 'Factorization rank', minValue=1, maxValue=100, createLabel=True, labelFormat=" %d%%", callback=self.checkcommit) self.slider_rank.setTracking(False) gui.auto_commit(self.controlArea, self, "autorun", "Run", checkbox_label="Run after any change ")
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.data(None) self.data_set_size = self.features = self.meta_attributes = "" self.location = "" for box in ("Data Set Size", "Features", "Targets", "Meta Attributes", "Location"): name = box.lower().replace(" ", "_") bo = gui.vBox(self.controlArea, box, addSpace=False and box != "Meta Attributes") gui.label(bo, self, "%%(%s)s" % name) # ensure the widget has some decent minimum width. self.targets = "Discrete outcome with 123 values" self.layout().activate() # NOTE: The minimum width is set on the 'contained' widget and # not `self`. The layout will set a fixed size to `self` taking # into account the minimum constraints of the children (it would # override any minimum/fixed size set on `self`). self.controlArea.setMinimumWidth(self.controlArea.sizeHint().width()) self.layout().setSizeConstraint(QtWidgets.QLayout.SetFixedSize) self.targets = "" self.data_desc = None
def _create_layout(self): info = gui.widgetBox(self.controlArea, 'Info') gui.label(info, self, '%(n_object_types)d object types') gui.label(info, self, '%(n_relations)d relations') # Table view of relation details info = gui.widgetBox(self.controlArea, 'Relations') def send_relation(item): data = item.data(QtCore.Qt.UserRole) self.send(Output.RELATION, Relation(data)) self.table = SimpleTableWidget(info, callback=send_relation) self.controlArea.layout().addStretch(1) gui.lineEdit(self.controlArea, self, 'pref_algo_name', 'Fuser name', callback=self.checkcommit, enterPlaceholder=True) gui.radioButtons(self.controlArea, self, 'pref_algorithm', [i[0] for i in DECOMPOSITION_ALGO], box='Decomposition algorithm', callback=self.checkcommit) gui.radioButtons(self.controlArea, self, 'pref_initialization', INITIALIZATION_ALGO, box='Initialization algorithm', callback=self.checkcommit) gui.hSlider(self.controlArea, self, 'pref_n_iterations', 'Maximum number of iterations', minValue=10, maxValue=500, createLabel=True, callback=self.checkcommit) self.slider_rank = gui.hSlider(self.controlArea, self, 'pref_rank', 'Factorization rank', minValue=1, maxValue=100, createLabel=True, labelFormat=" %d%%", callback=self.checkcommit) gui.auto_commit(self.controlArea, self, "autorun", "Run", checkbox_label="Run after any change ")
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 = None self.extra_data = None content = [ INDEX, INSTANCEID, DomainModel.ATTRIBUTES, DomainModel.CLASSES, DomainModel.METAS] self.model = DomainModelWithTooltips(content) self.extra_model = DomainModelWithTooltips(content) box = gui.hBox(self.controlArea, box=None) no_info = self.data_info(None) self.info_box_data = gui.label(box, self, no_info, box="Data") self.info_box_extra_data = gui.label(box, self, no_info, box="Extra Data") grp = gui.radioButtons( self.controlArea, self, "merging", box="Merging", btnLabels=self.OptionNames, tooltips=self.OptionDescriptions, callback=self.change_merging) grp.layout().setSpacing(8) self.attr_boxes = ConditionBox( self, self.model, self.extra_model, "", "matches") self.attr_boxes.add_row() box = gui.vBox(self.controlArea, box="Row matching") box.layout().addWidget(self.attr_boxes) gui.auto_apply(self.controlArea, self, box=False) # connect after wrapping self.commit with gui.auto_commit! self.attr_boxes.vars_changed.connect(self.commit) self.attr_boxes.vars_changed.connect(self.store_combo_state) self.settingsAboutToBePacked.connect(self.store_combo_state)
def _add_info_box(self): info = gui.vBox(self.controlArea, box="Layout") gui.label( info, self, "Nodes: %(number_of_nodes)i (%(nodes_per_edge).2f per edge); " "%(nSelected)i selected") gui.label( info, self, "Edges: %(number_of_edges)i (%(edges_per_node).2f per node)") lbox = gui.hBox(info) self.relayout_button = gui.button( lbox, self, 'Improve', callback=self.improve, autoDefault=False, tooltip="Optimize the current layout, with a small initial jerk") self.stop_button = gui.button( lbox, self, 'Stop', callback=self.stop_relayout, autoDefault=False, hidden=True) self.randomize_button = gui.button( lbox, self, 'Re-layout', callback=self.restart, autoDefault=False, tooltip="Restart laying out from random positions") gui.hSlider(info, self, "layout_density", minValue=1, maxValue=50, label="Gravity", orientation=Qt.Horizontal, callback_finished=self.improve, tooltip="Lower values improve optimization,\n" "higher work better for graph with many small " "components") gui.checkBox(info, self, "observe_weights", label="Make edges with large weights shorter", callback=self.improve)
def _create_layout(self): self._new_webview() box = gui.widgetBox(self.controlArea, 'Info') gui.label(box, self, '%(n_words)s words') gui.label(box, self, 'Mean weight: %(mean_weight).3f ± %(std_weight).3f') 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 _add_kernel_box(self): # this is part of init, pylint: disable=attribute-defined-outside-init # Initialize with the widest label to measure max width self.kernel_eq = self.kernels[-1][1] box = gui.hBox(self.controlArea, "Kernel") self.kernel_box = buttonbox = gui.radioButtonsInBox( box, self, "kernel_type", btnLabels=[k[0] for k in self.kernels], callback=self._on_kernel_changed) buttonbox.layout().setSpacing(10) gui.rubber(buttonbox) parambox = gui.vBox(box) gui.label(parambox, self, "Kernel: %(kernel_eq)s") common = dict(orientation=Qt.Horizontal, callback=self.settings_changed, alignment=Qt.AlignRight, controlWidth=80) spbox = gui.hBox(parambox) gui.rubber(spbox) inbox = gui.vBox(spbox) gamma = gui.doubleSpin( inbox, self, "gamma", 0.0, 10.0, 0.01, label=" g: ", **common) gamma.setSpecialValueText(self._default_gamma) coef0 = gui.doubleSpin( inbox, self, "coef0", 0.0, 10.0, 0.01, label=" c: ", **common) degree = gui.doubleSpin( inbox, self, "degree", 0.0, 10.0, 0.5, label=" d: ", **common) self._kernel_params = [gamma, coef0, degree] gui.rubber(parambox) # This is the maximal height (all double spins are visible) # and the maximal width (the label is initialized to the widest one) box.layout().activate() box.setFixedHeight(box.sizeHint().height()) box.setMinimumWidth(box.sizeHint().width())
def _add_kernel_box(self): # Initialize with the widest label to measure max width self.kernel_eq = self.kernels[-1][1] self.kernel_box = box = gui.widgetBox( self.controlArea, "Kernel", orientation="horizontal") buttonbox = gui.radioButtonsInBox( box, self, "kernel_type", btnLabels=[k[0] for k in self.kernels], callback=self._on_kernel_changed, addSpace=20) buttonbox.layout().setSpacing(10) gui.rubber(buttonbox) parambox = gui.widgetBox(box) gui.label(parambox, self, "Kernel: %(kernel_eq)s") common = dict(orientation="horizontal", alignment=Qt.AlignRight, controlWidth=80) spbox = gui.widgetBox(parambox, orientation="horizontal") gui.rubber(spbox) inbox = gui.widgetBox(spbox) gamma = gui.doubleSpin( inbox, self, "gamma", 0.0, 10.0, 0.01, label=" g: ", **common) coef0 = gui.doubleSpin( inbox, self, "coef0", 0.0, 10.0, 0.01, label=" c: ", **common) degree = gui.doubleSpin( inbox, self, "degree", 0.0, 10.0, 0.5, label=" d: ", **common) self._kernel_params = [gamma, coef0, degree] gui.rubber(parambox) # This is the maximal height (all double spins are visible) # and the maximal width (the label is initialized to the widest one) box.layout().activate() box.setFixedHeight(box.sizeHint().height()) box.setMinimumWidth(box.sizeHint().width())
def __init__(self): super().__init__() self.data = None self.removedAttrs = "-" self.reducedAttrs = "-" self.resortedAttrs = "-" self.removedClasses = "-" self.reducedClasses = "-" self.resortedClasses = "-" boxAt = gui.vBox(self.controlArea, "Features") for not_first, (value, label) in enumerate(self.feature_options): if not_first: gui.separator(boxAt, 2) gui.checkBox(boxAt, self, value, label, callback=self.optionsChanged) boxAt = gui.vBox(self.controlArea, "Classes", addSpace=True) for not_first, (value, label) in enumerate(self.class_options): if not_first: gui.separator(boxAt, 2) gui.checkBox(boxAt, self, value, label, callback=self.optionsChanged) box3 = gui.vBox(self.controlArea, 'Statistics', addSpace=True) for label, value in self.stat_labels: gui.label(box3, self, "{}: %({})s".format(label, value)) gui.auto_commit(self.buttonsArea, self, "autoSend", "Send Data", checkbox_label="Send automatically", orientation=Qt.Horizontal) gui.rubber(self.controlArea)
def __init__(self): super().__init__() self.corpus = None # GUI box = gui.widgetBox(self.controlArea, "Info") self.info = gui.widgetLabel( box, 'Connect an input corpus to start querying') self.import_box = gui.vBox(self.controlArea, 'Dictionary') self.import_box.setVisible(False) gui.button(self.import_box, self, 'Use dictionary', toggleButton=True, value='dictionary_on', buttonType=QCheckBox) self.dictionarybox = ListEdit(self, 'dictionary_text', '', 60, self) self.dictionarybox.setTextColor(QColor(100, 100, 100)) self.dictionarybox.setReadOnly(True) self.import_box.layout().addWidget(self.dictionarybox) query_box = gui.widgetBox(self.controlArea, 'Query', addSpace=True) self.querytextbox = ListEdit(self, 'queries', '', 80, self) query_box.layout().addWidget(self.querytextbox) query_parameter_box = gui.hBox(self.controlArea, self) gui.radioButtonsInBox(query_parameter_box, self, 'query_mode', btnLabels=QUERY_MODES, box="Query mode", callback=self.toggle_mode) self.count_mode_parameters = gui.vBox(query_parameter_box, self) gui.checkBox(self.count_mode_parameters, self, 'include_unmatched', label="Include unmatched documents") self.filter_mode_parameters = gui.widgetBox(query_parameter_box, self) gui.lineEdit(self.filter_mode_parameters, self, "context_window", 'Output words in context window', validator=QIntValidator()) self.toggle_mode() info_box = gui.hBox(self.controlArea, 'Status') self.status = 'Waiting for input' gui.label(info_box, self, '%(status)s') self.search_button = gui.button(self.controlArea, self, 'Search', self.start_stop, focusPolicy=Qt.NoFocus)
def __init__(self): super().__init__() self.data = None self.extra_data = None self.extra_data = None self.model = itemmodels.VariableListModel() self.model_unique_with_id = itemmodels.VariableListModel() self.extra_model_unique = itemmodels.VariableListModel() self.extra_model_unique_with_id = itemmodels.VariableListModel() box = gui.hBox(self.controlArea, box=None) self.infoBoxData = gui.label( box, self, self.dataInfoText(None), box="Data") self.infoBoxExtraData = gui.label( box, self, self.dataInfoText(None), box="Extra Data") grp = gui.radioButtonsInBox( self.controlArea, self, "merging", box="Merging", callback=self.change_merging) self.attr_boxes = [] radio_width = \ QApplication.style().pixelMetric(QStyle.PM_ExclusiveIndicatorWidth) def add_option(label, pre_label, between_label, merge_type, model, extra_model): gui.appendRadioButton(grp, label) vbox = gui.vBox(grp) box = gui.hBox(vbox) box.layout().addSpacing(radio_width) self.attr_boxes.append(box) gui.widgetLabel(box, pre_label) model[:] = [getattr(self, 'attr_{}_data'.format(merge_type))] extra_model[:] = [getattr(self, 'attr_{}_extra'.format(merge_type))] cb = gui.comboBox(box, self, 'attr_{}_data'.format(merge_type), contentsLength=12, callback=self._invalidate, model=model) cb.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) cb.setFixedWidth(190) gui.widgetLabel(box, between_label) cb = gui.comboBox(box, self, 'attr_{}_extra'.format(merge_type), contentsLength=12, callback=self._invalidate, model=extra_model) cb.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) cb.setFixedWidth(190) vbox.layout().addSpacing(6) add_option("Append columns from Extra Data", "by matching", "with", "augment", self.model, self.extra_model_unique) add_option("Find matching rows", "where", "equals", "merge", self.model_unique_with_id, self.extra_model_unique_with_id) add_option("Concatenate tables, merge rows", "where", "equals", "combine", self.model_unique_with_id, self.extra_model_unique_with_id) self.set_merging()
def refresh_label(path): nonlocal fpbox fpbox.hide() fpbox = None fpbox = gui.vBox(self.controlArea, "Selected File") if (not path.endswith('xlsx')): path = "SELECT AN XLSX FILE" gui.label(fpbox, self, path)
def __init__(self): ConcurrentWidgetMixin.__init__(self) Orange.widgets.data.owpreprocess.OWPreprocess.__init__(self) box = gui.vBox(self.controlArea, "预览") self.preview = "" gui.label(box, self, "%(preview)s", wordWrap=True) self.controlArea.layout().insertWidget(1, box) self.controlArea.setFixedWidth(220)
def _add_kernel_box(self): # Initialize with the widest label to measure max width self.kernel_eq = self.kernels[-1][1] self.kernel_box = box = gui.widgetBox(self.controlArea, "Kernel", orientation="horizontal") buttonbox = gui.radioButtonsInBox( box, self, "kernel_type", btnLabels=[k[0] for k in self.kernels], callback=self._on_kernel_changed, addSpace=20) buttonbox.layout().setSpacing(10) gui.rubber(buttonbox) parambox = gui.widgetBox(box) gui.label(parambox, self, "Kernel: %(kernel_eq)s") common = dict(orientation="horizontal", alignment=Qt.AlignRight, controlWidth=80) spbox = gui.widgetBox(parambox, orientation="horizontal") gui.rubber(spbox) inbox = gui.widgetBox(spbox) gamma = gui.doubleSpin(inbox, self, "gamma", 0.0, 10.0, 0.01, label=" g: ", **common) coef0 = gui.doubleSpin(inbox, self, "coef0", 0.0, 10.0, 0.01, label=" c: ", **common) degree = gui.doubleSpin(inbox, self, "degree", 0.0, 10.0, 0.5, label=" d: ", **common) self._kernel_params = [gamma, coef0, degree] gui.rubber(parambox) # This is the maximal height (all double spins are visible) # and the maximal width (the label is initialized to the widest one) box.layout().activate() box.setFixedHeight(box.sizeHint().height()) box.setMinimumWidth(box.sizeHint().width())
def __init__(self): super().__init__() self.set_environment_id(None) gui.label(self.controlArea, self, "%%(%s)s" % 'environment_id') gui.button(self.controlArea, self, "Open", callback=self.open) gui.button(self.controlArea, self, "Close", callback=self.close)
def __init__(self): super().__init__() self.data = None self.extra_data = None self.extra_data = None self.model = itemmodels.VariableListModel() self.model_unique_with_id = itemmodels.VariableListModel() self.extra_model_unique = itemmodels.VariableListModel() self.extra_model_unique_with_id = itemmodels.VariableListModel() box = gui.hBox(self.controlArea, box=None) self.infoBoxData = gui.label( box, self, self.dataInfoText(None), box="Data") self.infoBoxExtraData = gui.label( box, self, self.dataInfoText(None), box="Extra Data") grp = gui.radioButtonsInBox( self.controlArea, self, "merging", box="Merging", callback=self.change_merging) self.attr_boxes = [] radio_width = \ QApplication.style().pixelMetric(QStyle.PM_ExclusiveIndicatorWidth) def add_option(label, pre_label, between_label, merge_type, model, extra_model): gui.appendRadioButton(grp, label) vbox = gui.vBox(grp) box = gui.hBox(vbox) box.layout().addSpacing(radio_width) self.attr_boxes.append(box) gui.widgetLabel(box, pre_label) model[:] = [getattr(self, 'attr_{}_data'.format(merge_type))] extra_model[:] = [getattr(self, 'attr_{}_extra'.format(merge_type))] cb = gui.comboBox(box, self, 'attr_{}_data'.format(merge_type), callback=self._invalidate, model=model) cb.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) cb.setFixedWidth(190) gui.widgetLabel(box, between_label) cb = gui.comboBox(box, self, 'attr_{}_extra'.format(merge_type), callback=self._invalidate, model=extra_model) cb.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) cb.setFixedWidth(190) vbox.layout().addSpacing(6) add_option("Append columns from Extra Data", "by matching", "with", "augment", self.model, self.extra_model_unique) add_option("Find matching rows", "where", "equals", "merge", self.model_unique_with_id, self.extra_model_unique_with_id) add_option("Concatenate tables, merge rows", "where", "equals", "combine", self.model_unique_with_id, self.extra_model_unique_with_id) self.set_merging()
def __init__(self, parent=None): widget.OWWidget.__init__(self, parent) self.data = None self.target_group = None, [] self.targets = [] self.current_selection = [] self.validindices = numpy.empty((0, ), dtype=int) self.graph = VolcanoGraph(symbolSize=self.symbol_size, background="w") self.graph.setSelectionMode( VolcanoGraph.SymetricSelection if self. symetric_selections else VolcanoGraph.RectSelection) self.graph.selectionChanged.connect(self.on_selection_changed) self.graph.scene().installEventFilter(self) self.graph.getViewBox().setMouseEnabled(False, False) self.graph.getViewBox().enableAutoRange(enable=True) self.graph.plotItem.showGrid(True, True, 0.3) self.mainArea.layout().addWidget(self.graph) ## GUI box = gui.widgetBox(self.controlArea, "Info") self.infoLabel = gui.label(box, self, "") self.infoLabel.setText("No data on input") self.infoLabel2 = gui.label(box, self, "") self.infoLabel2.setText("0 selected genes") box = gui.widgetBox(self.controlArea, "Target Labels") self.target_widget = guiutils.LabelSelectionWidget( self, groupChanged=self.on_label_activated, groupSelectionChanged=self.on_target_changed) box.layout().addWidget(self.target_widget) box = gui.widgetBox(self.controlArea, "Settings") gui.hSlider( box, self, "symbol_size", label="Symbol size: ", minValue=2, maxValue=20, step=1, callback=lambda: self.graph.setSymbolSize(self.symbol_size)) gui.checkBox(box, self, "symetric_selections", "Symmetric selection", callback=self.__on_selectionModeChanged) gui.auto_commit(self.controlArea, self, "auto_commit", "Commit") gui.rubber(self.controlArea)
def __init__(self): super().__init__() self.corpus = None self.api = None self.output_info = '' # API token self.api_dlg = self.CredentialsDialog(self) self.api_dlg.accept(silent=True) gui.button(self.controlArea, self, 'Facebook login', callback=self.api_dlg.exec_, focusPolicy=Qt.NoFocus) # Query self.query_box = gui.widgetBox(self.controlArea, 'Posts', addSpace=True) gui.label(self.query_box, self, 'Page IDs (or page URLs)') self.query_box.layout().addWidget(ListEdit(self, 'page_ids', 'One page ID per line', 80, self)) def date_changed(): d.picker_to.setVisible(self.date_option in [DATE_BETWEEN]) d.picker_from.setVisible(self.date_option in [DATE_FROM, DATE_BETWEEN]) gui.comboBox(self.query_box, self, 'date_option', items=DATE_OPTIONS, label="Date filter", callback = date_changed) date_box = gui.hBox(self.query_box) d = DatePickerInterval(date_box, self, 'date_from', 'date_to', min_date=None, max_date=date.today(), margin=(0, 3, 0, 0)) date_changed() self.mode_box = gui.widgetBox(self.query_box, box=True) mode_box_h = gui.hBox(self.mode_box) gui.radioButtonsInBox(mode_box_h, self, 'mode', btnLabels=['only posts from page itself', 'all public posts on page'], orientation=2) # gui.radioButtonsInBox(mode_box_h, self, 'accumulate', btnLabels=['new results', 'add to previous results'], orientation=2, label='On search:') gui.lineEdit(mode_box_h, self, 'max_documents', label='Max docs per page:', valueType=str, controlWidth=50) comments_box = gui.widgetBox(self.controlArea, box='Comments') gui.radioButtonsInBox(comments_box, self, 'comments', btnLabels=['ignore', 'direct comments', 'all comments'], orientation=2) # Text includes features self.query_box.layout().addWidget( CheckListLayout('Text includes', self, 'text_includes', self.attributes, cols=2, callback=self.set_text_features)) # Output info_box = gui.hBox(self.controlArea, 'Output') gui.label(info_box, self, 'Articles: %(output_info)s') # Buttons self.button_box = gui.hBox(self.controlArea) self.button_box.layout().addWidget(self.report_button) self.search_button = gui.button(self.button_box, self, 'Search', self.start_stop, focusPolicy=Qt.NoFocus)
def __init__(self): super().__init__() self.data = None self.indices = None self.n_selected = 0 self.series_rows = [] # Create the UI controls for selecting axes attributes box = gui.vBox(self.controlArea, 'Axes') self.cbx = gui.comboBox(box, self, 'attr_x', label='X:', orientation='horizontal', callback=self.replot, sendSelectedValue=True) self.cby = gui.comboBox(box, self, 'attr_y', label='Y:', orientation='horizontal', callback=self.replot, sendSelectedValue=True) gui.label(self.controlArea, self, '%(n_selected)d points are selected', box='Info') gui.rubber(self.controlArea) # Create an instance of Scatter plot. Initial Highcharts configuration # can be passed as '_'-delimited keyword arguments. See Highcharts # class docstrings and Highcharts API documentation for more info and # usage examples. self.scatter = Scatterplot( selection_callback=self.on_selection, xAxis_gridLineWidth=0, yAxis_gridLineWidth=0, title_text='Scatterplot example', tooltip_shared=False, # If you pass a string that starts with # these four characters: '/**/'; the string # will be evaluated as a JavaScript # expression and the property will be set # to the evaluation result. tooltip_formatter="""/**/ (function() { return this.x + ', ' + this.y; })""", # In development, we can enable debug mode # and get right-click-inspect and related # console utils available: debug=True) # Just render an empty chart so it shows a nice 'No data to display' # warning self.scatter.chart() self.mainArea.layout().addWidget(self.scatter)
def __init__(self): super().__init__() self.data = None self.removedAttrs = "-" self.reducedAttrs = "-" self.resortedAttrs = "-" self.removedClasses = "-" self.reducedClasses = "-" self.resortedClasses = "-" self.removedMetas = "-" self.reducedMetas = "-" boxAt = gui.vBox(self.controlArea, "Features") for not_first, (value, label) in enumerate(self.feature_options): if not_first: gui.separator(boxAt, 2) gui.checkBox(boxAt, self, value, label, callback=self.optionsChanged) boxAt = gui.vBox(self.controlArea, "Classes", addSpace=True) for not_first, (value, label) in enumerate(self.class_options): if not_first: gui.separator(boxAt, 2) gui.checkBox(boxAt, self, value, label, callback=self.optionsChanged) boxAt = gui.vBox(self.controlArea, "Meta attributes", addSpace=True) for not_first, (value, label) in enumerate(self.meta_options): if not_first: gui.separator(boxAt, 2) gui.checkBox(boxAt, self, value, label, callback=self.optionsChanged) box3 = gui.vBox(self.controlArea, 'Statistics', addSpace=True) for i, (label, value) in enumerate(self.stat_labels): # add a separator after each group of three if i != 0 and i % 3 == 0: gui.separator(box3, 2) gui.label(box3, self, "{}: %({})s".format(label, value)) gui.auto_commit(self.buttonsArea, self, "autoSend", "Apply", orientation=Qt.Horizontal) gui.rubber(self.controlArea)
def __init__(self): super().__init__() self.data(None) for box in ("Data Set Size", "Features", "Targets", "Meta Attributes", "Location"): name = box.lower().replace(" ", "_") bo = gui.widgetBox(self.controlArea, box, addSpace=box != "Meta Attributes") gui.label(bo, self, "%%(%s)s" % name)
def __init__(self): super().__init__() # Init data self.data = None self.selected_data = None self.selected_data_transformed = None # used for transforming the 'selected data' into the 'data' domain self.words = [] self.p_values = [] self.fdr_values = [] # Info section fbox = gui.widgetBox(self.controlArea, "Info") self.info_all = gui.label(fbox, self, 'Cluster words:') self.info_sel = gui.label(fbox, self, 'Selected words:') self.info_fil = gui.label(fbox, self, 'After filtering:') # Filtering settings fbox = gui.widgetBox(self.controlArea, "Filter") hbox = gui.widgetBox(fbox, orientation=0) self.chb_p = gui.checkBox(hbox, self, "filter_by_p", "p-value", callback=self.filter_and_display, tooltip="Filter by word p-value") self.spin_p = gui.doubleSpin(hbox, self, 'filter_p_value', 1e-4, 1, step=1e-4, labelWidth=15, callback=self.filter_and_display, callbackOnReturn=True, tooltip="Max p-value for word") self.spin_p.setEnabled(self.filter_by_p) hbox = gui.widgetBox(fbox, orientation=0) self.chb_fdr = gui.checkBox(hbox, self, "filter_by_fdr", "FDR", callback=self.filter_and_display, tooltip="Filter by word FDR") self.spin_fdr = gui.doubleSpin(hbox, self, 'filter_fdr_value', 1e-4, 1, step=1e-4, labelWidth=15, callback=self.filter_and_display, callbackOnReturn=True, tooltip="Max p-value for word") self.spin_fdr.setEnabled(self.filter_by_fdr) gui.rubber(self.controlArea) # Word's list view self.cols = ['Word', 'p-value', 'FDR'] self.sig_words = QTreeWidget() self.sig_words.setColumnCount(len(self.cols)) self.sig_words.setHeaderLabels(self.cols) self.sig_words.setSortingEnabled(True) self.sig_words.setSelectionMode(QTreeView.ExtendedSelection) self.sig_words.sortByColumn(2, 0) # 0 is ascending order for i in range(len(self.cols)): self.sig_words.resizeColumnToContents(i) self.mainArea.layout().addWidget(self.sig_words)
def __init__(self): super().__init__() self.corpus = None self.api = None self.output_info = '' # API Key self.api_dlg = self.CredentialsDialog(self) self.api_dlg.accept(silent=True) gui.button(self.controlArea, self, 'The Guardian API Key', callback=self.api_dlg.exec_, focusPolicy=Qt.NoFocus) # Query query_box = gui.widgetBox(self.controlArea, 'Query', addSpace=True) self.query_box = QueryBox(query_box, self, self.recent_queries, callback=self.new_query_input) # Year box date_box = gui.hBox(query_box) DatePickerInterval(date_box, self, 'date_from', 'date_to', min_date=None, max_date=date.today(), margin=(0, 3, 0, 0)) # Text includes features self.controlArea.layout().addWidget( CheckListLayout('Text includes', self, 'text_includes', self.attributes, cols=2, callback=self.set_text_features)) # Output info_box = gui.hBox(self.controlArea, 'Output') gui.label(info_box, self, 'Articles: %(output_info)s') # Buttons self.button_box = gui.hBox(self.controlArea) self.button_box.layout().addWidget(self.report_button) self.search_button = gui.button(self.button_box, self, 'Search', self.start_stop, focusPolicy=Qt.NoFocus)
def __init__(self): super().__init__() self.corpus = None # Corpus self.output_mask = None # Output corpus indices self.document_contents = None # QTextDocument self.document_holder = None # QTextEdit self.features = [] # all attributes # ---- CONTROL AREA ---- # Filtering results. filter_result_box = gui.widgetBox(self.controlArea, 'Info') self.info_all = gui.label(filter_result_box, self, 'All documents:') self.info_fil = gui.label(filter_result_box, self, 'After filtering:') # Feature selection. self.feature_listbox = gui.listBox( self.controlArea, self, 'selected_features', 'features', selectionMode=QtGui.QListView.ExtendedSelection, box='Displayed features', callback=self.load_documents,) # Auto-commit box. gui.auto_commit(self.controlArea, self, 'autocommit', 'Send data', 'Auto send is on') # ---- MAIN AREA ---- # Search self.filter_input = gui.lineEdit(self.mainArea, self, '', orientation='horizontal', label='RegExp Filter:') self.filter_input.textChanged.connect(self.filter_input_changed) h_box = gui.widgetBox(self.mainArea, orientation='horizontal', addSpace=True) h_box.layout().setSpacing(0) # Document list. self.document_table = QTableView() self.document_table.setSelectionBehavior(QTableView.SelectRows) self.document_table.setSelectionMode(QTableView.ExtendedSelection) self.document_table.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) self.document_table.horizontalHeader().setResizeMode(QtGui.QHeaderView.Stretch) self.document_table.horizontalHeader().setVisible(False) h_box.layout().addWidget(self.document_table) self.document_table_model = QStandardItemModel(self) self.document_table.setModel(self.document_table_model) self.document_table.setFixedWidth(200) self.document_table.selectionModel().selectionChanged.connect(self.show_document) # Document contents. self.document_holder = QTextEdit() self.document_holder.setReadOnly(True) self.document_holder.setLineWrapMode(QTextEdit.WidgetWidth) h_box.layout().addWidget(self.document_holder)
def __init__(self): super().__init__() # data self.dataA = None self.dataB = None # GUI box = gui.hBox(self.controlArea, "Match instances by") # attribute A selection self.attrViewA = gui.comboBox(box, self, 'attr_a', label="Data A", orientation=Qt.Vertical, sendSelectedValue=True, callback=self._invalidate) self.attrModelA = itemmodels.VariableListModel() self.attrViewA.setModel(self.attrModelA) # attribute B selection self.attrViewB = gui.comboBox(box, self, 'attr_b', label="Data B", orientation=Qt.Vertical, sendSelectedValue=True, callback=self._invalidate) self.attrModelB = itemmodels.VariableListModel() self.attrViewB.setModel(self.attrModelB) # info A box = gui.hBox(self.controlArea, box=None) self.infoBoxDataA = gui.label(box, self, self.dataInfoText(None), box="Data A Info") # info B self.infoBoxDataB = gui.label(box, self, self.dataInfoText(None), box="Data B Info") gui.separator(self.controlArea) box = gui.vBox(self.controlArea, box=True) gui.checkBox(box, self, "inner", "Exclude instances without a match", callback=self._invalidate)
def __init__(self): super().__init__() self.set_initial_values() for box in ("Environment Id", "Observation Space", "Action Space", "Reward Range", "TimeStep Limit", "Trials", "Reward Threshold"): name = box.lower().replace(" ", "_") v_box = gui.vBox(self.controlArea, box, addSpace=False and box != "Meta Attributes") gui.label(v_box, self, "%%(%s)s" % name)
def __init__(self, parent=None): widget.OWWidget.__init__(self, parent) self.data = None self.target_group = None, [] self.targets = [] self.current_selection = [] self.validindices = numpy.empty((0,), dtype=int) self.graph = VolcanoGraph(symbolSize=self.symbol_size, background="w") self.graph.setSelectionMode( VolcanoGraph.SymetricSelection if self.symetric_selections else VolcanoGraph.RectSelection) self.graph.selectionChanged.connect(self.on_selection_changed) self.graph.scene().installEventFilter(self) self.graph.getViewBox().setMouseEnabled(False, False) self.graph.getViewBox().enableAutoRange(enable=True) self.graph.plotItem.showGrid(True, True, 0.3) self.mainArea.layout().addWidget(self.graph) ## GUI box = gui.widgetBox(self.controlArea, "Info") self.infoLabel = gui.label(box, self, "") self.infoLabel.setText("No data on input") self.infoLabel2 = gui.label(box, self, "") self.infoLabel2.setText("0 selected genes") box = gui.widgetBox(self.controlArea, "Target Labels") self.target_widget = guiutils.LabelSelectionWidget( self, groupChanged=self.on_label_activated, groupSelectionChanged=self.on_target_changed) box.layout().addWidget(self.target_widget) box = gui.widgetBox(self.controlArea, "Settings") gui.hSlider(box, self, "symbol_size", label="Symbol size: ", minValue=2, maxValue=20, step=1, callback=lambda: self.graph.setSymbolSize(self.symbol_size)) gui.checkBox(box, self, "symetric_selections", "Symmetric selection", callback=self.__on_selectionModeChanged) gui.auto_commit(self.controlArea, self, "auto_commit", "Commit") gui.rubber(self.controlArea)
def __init__(self): super().__init__() ConcurrentWidgetMixin.__init__(self) self.corpus = None self.learning_thread = None self.__pending_selection = self.selection self.perplexity = "n/a" self.coherence = "n/a" # Commit button gui.auto_commit(self.buttonsArea, self, 'autocommit', 'Commit', box=False) button_group = QButtonGroup(self, exclusive=True) button_group.buttonClicked[int].connect(self.change_method) self.widgets = [] method_layout = QVBoxLayout() self.controlArea.layout().addLayout(method_layout) for i, (method, attr_name) in enumerate(self.methods): widget = method(self, title='Options') widget.setFixedWidth(self.control_area_width) widget.valueChanged.connect(self.commit.deferred) self.widgets.append(widget) setattr(self, attr_name, widget) rb = QRadioButton(text=widget.Model.name) button_group.addButton(rb, i) method_layout.addWidget(rb) method_layout.addWidget(widget) button_group.button(self.method_index).setChecked(True) self.toggle_widgets() method_layout.addStretch() box = gui.vBox(self.controlArea, "Topic evaluation") gui.label(box, self, "Log perplexity: %(perplexity)s") gui.label(box, self, "Topic coherence: %(coherence)s") self.controlArea.layout().insertWidget(1, box) # Topics description self.topic_desc = TopicViewer() self.topic_desc.topicSelected.connect(self.send_topic_by_id) self.mainArea.layout().addWidget(self.topic_desc) self.topic_desc.setFocus()
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') class TableView(gui.TableView): def __init__(self, parent): super().__init__(parent) self._parent = parent def selectionChanged(self, selected, deselected): super().selectionChanged(selected, deselected) parent = self._parent for index in deselected.indexes(): data = parent.tablemodel[index.row()][1] self._parent.selected_words.remove(data) for index in selected.indexes(): data = parent.tablemodel[index.row()][1] self._parent.selected_words.add(data) parent.cloud_reselect() view = self.tableview = TableView(self) model = self.tablemodel = PyTableModel() model.setHorizontalHeaderLabels(['Weight', 'Word']) view.setModel(model) box.layout().addWidget(view)
def __init__(self, parent=None): super().__init__(parent) self.data = None self.preRemoveValues = 1 self.preRemoveClasses = 1 self.removedAttrs = "-" self.reducedAttrs = "-" self.resortedAttrs = "-" self.classAttr = "-" boxAt = gui.widgetBox(self.controlArea, "Attributes") gui.checkBox(boxAt, self, 'sortValues', 'Sort attribute values', callback=self.optionsChanged) gui.separator(boxAt, 2) rua = gui.checkBox( boxAt, self, "removeAttributes", "Remove attributes with less than two values", callback=self.removeAttributesChanged) ruv = gui.checkBox( gui.indentedBox(boxAt, sep=gui.checkButtonOffsetHint(rua)), self, "removeValues", "Remove unused attribute values", callback=self.optionsChanged ) rua.disables = [ruv] rua.makeConsistent() boxAt = gui.widgetBox(self.controlArea, "Classes", addSpace=True) gui.checkBox(boxAt, self, 'sortClasses', 'Sort classes', callback=self.optionsChanged) gui.separator(boxAt, 2) rua = gui.checkBox( boxAt, self, "removeClassAttribute", "Remove class attribute if there are less than two classes", callback=self.removeClassesChanged ) ruv = gui.checkBox( gui.indentedBox(boxAt, sep=gui.checkButtonOffsetHint(rua)), self, "removeClasses", "Remove unused class values", callback=self.optionsChanged ) rua.disables = [ruv] rua.makeConsistent() box3 = gui.widgetBox(self.controlArea, 'Statistics', addSpace=True) gui.label(box3, self, "Removed attributes: %(removedAttrs)s") gui.label(box3, self, "Reduced attributes: %(reducedAttrs)s") gui.label(box3, self, "Resorted attributes: %(resortedAttrs)s") gui.label(box3, self, "Class attribute: %(classAttr)s") gui.auto_commit(self.controlArea, self, "autoSend", "Send Data", checkbox_label="Send automatically", orientation="horizontal") gui.rubber(self.controlArea)
def __init__(self): super().__init__() self.data(None) self.data_set_size = self.features = self.meta_attributes = "" self.location = "" for box in ("Data Set Size", "Features", "Targets", "Meta Attributes", "Location"): name = box.lower().replace(" ", "_") bo = gui.widgetBox(self.controlArea, box, addSpace=False and box != "Meta Attributes") gui.label(bo, self, "%%(%s)s" % name) self.targets = "Discrete class with 123 values" QtGui.qApp.processEvents() QtCore.QTimer.singleShot(0, self.fix_size)
def _create_layout(self): self.mainArea.layout().addWidget(self.graphview) info = gui.widgetBox(self.controlArea, 'Info') gui.label(info, self, '%(n_object_types)d object types') gui.label(info, self, '%(n_relations)d relations') # Table view of relation details info = gui.widgetBox(self.controlArea, 'Relations') def send_relation(selected, deselected): if not selected: assert len(deselected) > 0 relation = None else: assert len(selected) == 1 data = self.table.rowData(selected[0].top()) relation = Relation(data) self.send(Output.RELATION, relation) self.table = gui.TableWidget(info, select_rows=True) self.table.selectionChanged = send_relation self.table.setColumnFilter(bold_item, (1, 3)) gui.lineEdit(self.controlArea, self, 'pref_algo_name', 'Fuser name:', orientation='horizontal', callback=self.checkcommit, enterPlaceholder=True) gui.radioButtons(self.controlArea, self, 'pref_algorithm', [i[0] for i in DECOMPOSITION_ALGO], box='Decomposition algorithm', callback=self.checkcommit) gui.radioButtons(self.controlArea, self, 'pref_initialization', INITIALIZATION_ALGO, box='Initialization algorithm', callback=self.checkcommit) slider = gui.hSlider( self.controlArea, self, 'pref_n_iterations', 'Maximum number of iterations', minValue=10, maxValue=500, createLabel=True, callback=self.checkcommit) slider.setTracking(False) self.slider_rank = gui.hSlider(self.controlArea, self, 'pref_rank', 'Factorization rank', minValue=1, maxValue=100, createLabel=True, labelFormat=" %d%%", callback=self.checkcommit) self.slider_rank.setTracking(False) gui.auto_commit(self.controlArea, self, "autorun", "Run", checkbox_label="Run after any change ")
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.corpus = None # Info box. info_box = gui.widgetBox( self.controlArea, 'Info', ) bow_info = 'No info available.' self.info_label = gui.label(info_box, self, bow_info) # TF-IDF. tfidf_box = gui.widgetBox( self.controlArea, 'Settings', ) self.tfidf_checkbox = gui.checkBox( tfidf_box, self, 'use_tfidf', 'Use TF-IDF' ) self.tfidf_checkbox.stateChanged.connect(self.tfidf_changed) gui.auto_commit( self.controlArea, self, 'autocommit', 'Commit', box=False )
def __init__(self): super().__init__() self.data = None self.reference = None box = gui.vBox(self.controlArea, "Info") self.data_info_label = gui.widgetLabel(box, self._data_info_default) self.ref_info_label = gui.widgetLabel(box, self._ref_info_default) box = gui.vBox(self.controlArea, "Settings") self.distance_combo = gui.comboBox( box, self, "distance_index", orientation=Qt.Horizontal, label="Distance: ", items=[d[0] for d in METRICS], callback=self.settings_changed) check_box = gui.hBox(box) self.exclude_ref_label = gui.label( check_box, self, "Exclude references:") self.exclude_ref_check = gui.checkBox( check_box, self, "exclude_reference", label="", callback=self.settings_changed) box = gui.vBox(self.controlArea, "Output") self.nn_spin = gui.spin( box, self, "n_neighbors", label="Neighbors:", step=1, spinType=int, minv=0, maxv=100, callback=self.settings_changed) box = gui.hBox(self.controlArea, True) self.apply_button = gui.auto_commit(box, self, "auto_apply", "&Apply", box=False, commit=self.apply)
def __init__(self, parent, windowTitle="New York Times API key"): super().__init__(parent, windowTitle=windowTitle) self.parent = parent self.setLayout(QVBoxLayout()) self.layout().setMargin(10) self.mainArea = gui.widgetBox(self) self.layout().addWidget(self.mainArea) # Combo box. self.api_key_combo = QComboBox(self.mainArea) self.api_key_combo.setEditable(True) self.api_key_combo.activated[int].connect(self.select_api_key) self.mainArea.layout().addWidget(self.api_key_combo) # Buttons self.button_box = gui.widgetBox(self.mainArea, orientation="horizontal") gui.button(self.button_box, self, "Check", self.check_api_key) gui.button(self.button_box, self, "OK", self.accept_changes) gui.button(self.button_box, self, "Cancel", self.reject_changes) # Label self.label_box = gui.widgetBox(self, orientation="horizontal") self.api_key_check_label = gui.label(self.label_box, self, "") self.update_validity_label() # Load the most recent API keys. self.set_key_list()
def __init__(self): super().__init__() self.data = None self.data_subset = None self.model = itemmodels.VariableListModel() self.model_unique_with_id = itemmodels.VariableListModel() self.extra_model_unique = itemmodels.VariableListModel() self.extra_model_unique_with_id = itemmodels.VariableListModel() box = gui.hBox(self.controlArea, box=None) self.infoBoxData = gui.label( box, self, self.data_info_text(None), box="Data") self.infoBoxExtraData = gui.label( box, self, self.data_info_text(None), box="Data Subset")
def add_main_layout(self): box = gui.widgetBox(self.controlArea, "Parameters") self.base_estimator = self.DEFAULT_BASE_ESTIMATOR self.base_label = gui.label( box, self, "Base estimator: " + self.base_estimator.name.title()) self.n_estimators_spin = gui.spin( box, self, "n_estimators", 1, 100, label="Number of estimators:", alignment=Qt.AlignRight, controlWidth=80, callback=self.settings_changed) self.learning_rate_spin = gui.doubleSpin( box, self, "learning_rate", 1e-5, 1.0, 1e-5, label="Learning rate:", decimals=5, alignment=Qt.AlignRight, controlWidth=80, callback=self.settings_changed) self.random_seed_spin = gui.spin( box, self, "random_seed", 0, 2 ** 31 - 1, controlWidth=80, label="Fixed seed for random generator:", alignment=Qt.AlignRight, callback=self.settings_changed, checked="use_random_seed", checkCallback=self.settings_changed) # Algorithms box = gui.widgetBox(self.controlArea, "Boosting method") self.cls_algorithm_combo = gui.comboBox( box, self, "algorithm_index", label="Classification algorithm:", items=self.algorithms, orientation=Qt.Horizontal, callback=self.settings_changed) self.reg_algorithm_combo = gui.comboBox( box, self, "loss_index", label="Regression loss function:", items=self.losses, orientation=Qt.Horizontal, callback=self.settings_changed)
def __init__(self, parent, windowTitle="New York Times API key"): super().__init__(parent, windowTitle=windowTitle) self.parent = parent self.setLayout(QVBoxLayout()) self.layout().setMargin(10) self.mainArea = gui.widgetBox(self) self.layout().addWidget(self.mainArea) # Combo box. self.api_key_combo = QComboBox(self.mainArea) self.api_key_combo.setEditable(True) self.api_key_combo.activated[int].connect(self.select_api_key) self.mainArea.layout().addWidget(self.api_key_combo) # Buttons self.button_box = gui.widgetBox(self.mainArea, orientation="horizontal") gui.button(self.button_box, self, "Check", self.check_api_key) gui.button(self.button_box, self, "OK", self.accept_changes) gui.button(self.button_box, self, "Cancel", self.reject_changes) # Label self.label_box = gui.widgetBox(self, orientation="horizontal") self.api_key_check_label = gui.label(self.label_box, self, "") if self.parent.api_key_is_valid: self.api_key_check_label.setText("API key is valid.") else: self.api_key_check_label.setText("API key NOT validated!") # Load the most recent API keys. self.set_key_list()
def _create_layout(self): self.mainArea.layout().addWidget(self.graphview) info = gui.widgetBox(self.controlArea, 'Info') gui.label(info, self, '%(n_object_types)d object types') gui.label(info, self, '%(n_relations)d relations') box = gui.widgetBox(self.controlArea, 'Recipe factors') self.table_factors = gui.TableWidget(box, select_rows=True) self.table_factors.setColumnFilter(bold_item, 1) self.controlArea.layout().addWidget(box) box = gui.widgetBox(self.controlArea, 'Backbone factors') self.table_backbones = gui.TableWidget(box, select_rows=True) self.table_backbones.setColumnFilter(bold_item, (1, 3)) self.controlArea.layout().addWidget(box) box = gui.widgetBox(self.controlArea, 'Completed relations') self.table_completions = gui.TableWidget(box, select_rows=True) self.table_completions.setColumnFilter(bold_item, (1, 3)) self.controlArea.layout().addWidget(box) self.controlArea.layout().addStretch(1) def _on_selected_factor(item): self.table_completions.clearSelection() self.table_backbones.clearSelection() def _on_selected_backbone(item): self.table_completions.clearSelection() self.table_factors.clearSelection() def _on_selected_completion(item): self.table_factors.clearSelection() self.table_backbones.clearSelection() def on_selection_changed(table, itemChanged_handler): def _f(selected, deselected): if not selected: return self.commit(None) item = table.item(selected[0].top(), 0) itemChanged_handler(item) self.commit(item) return _f self.table_factors.selectionChanged = on_selection_changed(self.table_factors, _on_selected_factor) self.table_backbones.selectionChanged = on_selection_changed(self.table_backbones, _on_selected_backbone) self.table_completions.selectionChanged = on_selection_changed(self.table_completions, _on_selected_completion)
def populate_main_area(self): grid = QWidget() grid.setLayout(QGridLayout(grid)) self.mainArea.layout().addWidget(grid) col_type = gui.label(None, self, '%(col_type)s') grid.layout().addWidget(col_type, 0, 1) grid.layout().setAlignment(col_type, Qt.AlignHCenter) row_type = gui.label(None, self, '%(row_type)s') grid.layout().addWidget(row_type, 1, 0) grid.layout().setAlignment(row_type, Qt.AlignVCenter) self.view = QTableView() self.model = None grid.layout().addWidget(self.view, 1, 1)
def __init__(self, master): super().__init__(master) label = gui.label(self, self, "Pattern:") line_edit = widgets.ValidatedLineEdit(self, "pattern", validator=preprocess.RegexpTokenizer.validate_regexp) line_edit.editingFinished.connect(self.pattern_changed) self.method_layout.addWidget(label, self.REGEXP, 1) self.method_layout.addWidget(line_edit, self.REGEXP, 2) self.pattern_changed()
def __init__(self, master): super().__init__(master) label = gui.label(self, self, "Language:") label.setAlignment(QtCore.Qt.AlignRight) self.method_layout.addWidget(label, self.SNOWBALL, 1) box = widgets.ComboBox(self, "snowball_language", items=preprocess.SnowballStemmer.supported_languages) box.currentIndexChanged.connect(self.change_language) self.method_layout.addWidget(box, self.SNOWBALL, 2)
def __init__(self): super().__init__() self.corpus = None # Refresh recent files self.recent_files = [fn for fn in self.recent_files if os.path.exists(fn)] # Browse file box fbox = gui.widgetBox(self.controlArea, "Corpus file", orientation=0) # Drop-down for recent files self.file_combo = QtGui.QComboBox(fbox) self.file_combo.setMinimumWidth(300) fbox.layout().addWidget(self.file_combo) self.file_combo.activated[int].connect(self.select_file) # Browse button browse = gui.button(fbox, self, 'Browse', callback=self.browse_file) browse.setIcon(self.style().standardIcon(QtGui.QStyle.SP_DirOpenIcon)) browse.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) # Reload button reload = gui.button(fbox, self, "Reload", callback=self.reload, default=True) reload.setIcon(self.style().standardIcon(QtGui.QStyle.SP_BrowserReload)) reload.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) # Corpus info ibox = gui.widgetBox(self.controlArea, "Corpus info", addSpace=True) corp_info = "Corpus of 0 documents." self.info_label = gui.label(ibox, self, corp_info) # Used Text Features fbox = gui.widgetBox(self.controlArea, orientation=0) ubox = gui.widgetBox(fbox, "Used text features", addSpace=True) self.used_attrs = VariablesListItemModel() self.used_attrs_view = VariablesListItemView() self.used_attrs_view.setModel(self.used_attrs) ubox.layout().addWidget(self.used_attrs_view) aa = self.used_attrs aa.dataChanged.connect(self.update_feature_selection) aa.rowsInserted.connect(self.update_feature_selection) aa.rowsRemoved.connect(self.update_feature_selection) # Ignored Text Features ibox = gui.widgetBox(fbox, "Ignored text features", addSpace=True) self.unused_attrs = VariablesListItemModel() self.unused_attrs_view = VariablesListItemView() self.unused_attrs_view.setModel(self.unused_attrs) ibox.layout().addWidget(self.unused_attrs_view) # Load the most recent file self.set_file_list() if len(self.recent_files) > 0: self.open_file(self.recent_files[0])