def __init__(self, canvasDlg, widgetInfo, *args): WidgetListBase.__init__(self, canvasDlg, widgetInfo) QDockWidget.__init__(self, "Widgets") self.treeWidget = MyTreeWidget(canvasDlg, self) self.treeWidget.tabDict = self.tabDict self.treeWidget.setFocusPolicy( Qt.ClickFocus ) # this is needed otherwise the document window will sometimes strangely lose focus and the output window will be focused self.actions = categoriesPopup.allActions # a widget container to hold the search area and the widget tree self.containerWidget = QWidget() containerBoxLayout = QBoxLayout(QBoxLayout.TopToBottom, self.containerWidget) self.widgetSuggestEdit = OWGUIEx.lineEditHint( self, None, None, useRE=0, caseSensitive=0, matchAnywhere=1, autoSizeListWidget=1, callback=self.widgetSuggestCallback) self.widgetSuggestEdit.setItems([ QListWidgetItem(action.icon(), action.widgetInfo.name) for action in self.actions ]) containerBoxLayout.insertWidget(0, self.widgetSuggestEdit) containerBoxLayout.insertWidget(1, self.treeWidget) self.setWidget(self.containerWidget) iconSize = self.canvasDlg.toolbarIconSizeList[ self.canvasDlg.settings["toolbarIconSize"]] self.treeWidget.setIconSize(QSize(iconSize, iconSize))
def __init__(self, canvasDlg, widgetInfo, *args): WidgetListBase.__init__(self, canvasDlg, widgetInfo) QDockWidget.__init__(self, "Widgets") self.actions = categoriesPopup.allActions self.toolbox = MyQToolBox(canvasDlg.settings["toolboxWidth"], self) self.toolbox.setFocusPolicy( Qt.ClickFocus ) # this is needed otherwise the document window will sometimes strangely lose focus and the output window will be focused self.toolbox.layout().setSpacing(0) # a widget container to hold the search area and the widget tree self.containerWidget = QWidget() containerBoxLayout = QBoxLayout(QBoxLayout.TopToBottom, self.containerWidget) if sys.platform == "darwin": containerBoxLayout.setContentsMargins(0, 0, 0, 0) self.widgetSuggestEdit = OWGUIEx.lineEditHint( self, None, None, useRE=0, caseSensitive=0, matchAnywhere=1, autoSizeListWidget=1, callback=self.widgetSuggestCallback) self.widgetSuggestEdit.setItems([ QListWidgetItem(action.icon(), action.widgetInfo.name) for action in self.actions ]) containerBoxLayout.insertWidget(0, self.widgetSuggestEdit) containerBoxLayout.insertWidget(1, self.toolbox) self.setWidget(self.containerWidget)
def __init__(self, parent=None): OWWidget.__init__(self, parent, title='Line Edit as Filter', wantMainArea=0) self.text = "" s = OWGUIEx.lineEditHint(self.controlArea, self, "text", useRE=0, caseSensitive=0, matchAnywhere=0) s.listWidget.setSpacing(2) s.setStyleSheet( """ QLineEdit { background: #fffff0; border: 1px solid blue} """) s.listWidget.setStyleSheet( """ QListView { background: #fffff0; } QListView::item {padding: 3px 0px 3px 0px} QListView::item:selected, QListView::item:hover { color: white; background: blue;} """ ) cats = orngRegistry.readCategories() items = [] for cat in cats.values(): for widget in cat.values(): iconNames = getFullWidgetIconName(cat, widget) icon = QIcon() for name in iconNames: icon.addPixmap(QPixmap(name)) item = QListWidgetItem(icon, widget.name) #item.setSizeHint(QSize(100, 32)) # items.append(item) s.setItems(items)
def __init__(self, parent, actions): QWidgetAction.__init__(self, parent) self.parent = parent self.actions = actions self.widgetSuggestEdit = OWGUIEx.lineEditHint(self.parent, None, None, useRE = 0, caseSensitive = 0, matchAnywhere = 1, callback = self.callback, autoSizeListWidget = 1) self.widgetSuggestEdit.setItems([QListWidgetItem(action.icon(), action.widgetInfo.name) for action in actions]) self.widgetSuggestEdit.setStyleSheet(""" QLineEdit { background: #fffff0; border: 1px solid orange} """) self.widgetSuggestEdit.listWidget.setStyleSheet(""" QListView { background: #fffff0; } QListView::item {padding: 3px 0px 3px 0px} QListView::item:selected { color: white; background: blue;} """) self.widgetSuggestEdit.listWidget.setIconSize(QSize(16,16)) self.setDefaultWidget(self.widgetSuggestEdit) self._in_callback = False
def __init__(self, parent=None): OWWidget.__init__(self, parent, title='Line Edit as Filter') self.filter = "" self.listboxValue = "" lineEdit = OWGUIEx.lineEditFilter(self.controlArea, self, "filter", "Filter:", useRE = 1, emptyText = "filter...") lineEdit.setListBox(OWGUI.listBox(self.controlArea, self, "listboxValue")) names = [] for i in range(10000): names.append("".join([string.ascii_lowercase[random.randint(0, len(string.ascii_lowercase)-1)] for c in range(10)])) lineEdit.listbox.addItems(names) lineEdit.setAllListItems(names)
def __init__(self, parent=None, signalManager=None, name="Databases update", wantCloseButton=False, searchString="", showAll=True, domains=None, accessCode=""): OWWidget.__init__(self, parent, signalManager, name) self.searchString = searchString self.accessCode = accessCode self.showAll = showAll self.domains = domains self.serverFiles = orngServerFiles.ServerFiles() box = OWGUI.widgetBox(self.mainArea, orientation="horizontal") import OWGUIEx self.lineEditFilter = OWGUIEx.lineEditHint(box, self, "searchString", "Filter", caseSensitive=False, delimiters=" ", matchAnywhere=True, listUpdateCallback=self.SearchUpdate, callbackOnType=True, callback=self.SearchUpdate) box = OWGUI.widgetBox(self.mainArea, "Files") self.filesView = QTreeWidget(self) self.filesView.setHeaderLabels(["Options", "Title", "Size"]) self.filesView.setRootIsDecorated(False) self.filesView.setSelectionMode(QAbstractItemView.NoSelection) self.filesView.setSortingEnabled(True) self.filesView.setItemDelegate(UpdateItemDelegate(self.filesView)) self.connect(self.filesView.model(), SIGNAL("layoutChanged()"), self.SearchUpdate) box.layout().addWidget(self.filesView) box = OWGUI.widgetBox(self.mainArea, orientation="horizontal") OWGUI.button(box, self, "Update all local files", callback=self.UpdateAll, tooltip="Update all updatable files") OWGUI.button(box, self, "Download filtered", callback=self.DownloadFiltered, tooltip="Download all filtered files shown") OWGUI.rubber(box) OWGUI.lineEdit(box, self, "accessCode", "Access Code", orientation="horizontal", callback=self.RetrieveFilesList) self.retryButton = OWGUI.button(box, self, "Retry", callback=self.RetrieveFilesList) self.retryButton.hide() box = OWGUI.widgetBox(self.mainArea, orientation="horizontal") OWGUI.rubber(box) if wantCloseButton: OWGUI.button(box, self, "Close", callback=self.accept, tooltip="Close") ## statusBar = QStatusBar() self.infoLabel = QLabel() self.infoLabel.setAlignment(Qt.AlignCenter) ## statusBar.addWidget(self.infoLabel) ## self.mainArea.layout().addWidget(statusBar) self.mainArea.layout().addWidget(self.infoLabel) self.infoLabel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) self.updateItems = [] self.allTags = [] self.resize(800, 600) # QTimer.singleShot(50, self.UpdateFilesList) QTimer.singleShot(50, self.RetrieveFilesList)
def __init__(self, canvasDlg, widgetInfo, *args): WidgetListBase.__init__(self, canvasDlg, widgetInfo) QDockWidget.__init__(self, "Widgets") self.actions = categoriesPopup.allActions self.toolbox = MyQToolBox(canvasDlg.settings["toolboxWidth"], self) self.toolbox.setFocusPolicy(Qt.ClickFocus) # this is needed otherwise the document window will sometimes strangely lose focus and the output window will be focused self.toolbox.layout().setSpacing(0) # a widget container to hold the search area and the widget tree self.containerWidget = QWidget() containerBoxLayout = QBoxLayout(QBoxLayout.TopToBottom, self.containerWidget) if sys.platform == "darwin": containerBoxLayout.setContentsMargins(0, 0, 0, 0) self.widgetSuggestEdit = OWGUIEx.lineEditHint(self, None, None, useRE = 0, caseSensitive = 0, matchAnywhere = 1, autoSizeListWidget = 1, callback = self.widgetSuggestCallback) self.widgetSuggestEdit.setItems([QListWidgetItem(action.icon(), action.widgetInfo.name) for action in self.actions]) containerBoxLayout.insertWidget(0, self.widgetSuggestEdit) containerBoxLayout.insertWidget(1, self.toolbox) self.setWidget(self.containerWidget)
def __init__(self, parent=None): OWWidget.__init__(self, parent, title='Line Edit as Filter', wantMainArea = 0) self.text = "" s = OWGUIEx.lineEditHint(self.controlArea, self, "text", useRE = 0, caseSensitive = 0, matchAnywhere = 0) s.listWidget.setSpacing(2) s.setStyleSheet(""" QLineEdit { background: #fffff0; border: 1px solid blue} """) s.listWidget.setStyleSheet(""" QListView { background: #fffff0; } QListView::item {padding: 3px 0px 3px 0px} QListView::item:selected, QListView::item:hover { color: white; background: blue;} """) cats = orngRegistry.readCategories() items = [] for cat in cats.values(): for widget in cat.values(): iconNames = getFullWidgetIconName(cat, widget) icon = QIcon() for name in iconNames: icon.addPixmap(QPixmap(name)) item = QListWidgetItem(icon, widget.name) #item.setSizeHint(QSize(100, 32)) # items.append(item) s.setItems(items)
def __init__(self, parent, actions): QWidgetAction.__init__(self, parent) self.parent = parent self.actions = actions self.widgetSuggestEdit = OWGUIEx.lineEditHint(self.parent, None, None, useRE=0, caseSensitive=0, matchAnywhere=1, callback=self.callback, autoSizeListWidget=1) self.widgetSuggestEdit.setItems([ QListWidgetItem(action.icon(), action.widgetInfo.name) for action in actions ]) self.widgetSuggestEdit.setStyleSheet( """ QLineEdit { background: #fffff0; border: 1px solid orange} """) self.widgetSuggestEdit.listWidget.setStyleSheet( """ QListView { background: #fffff0; } QListView::item {padding: 3px 0px 3px 0px} QListView::item:selected { color: white; background: blue;} """ ) self.widgetSuggestEdit.listWidget.setIconSize(QSize(16, 16)) self.setDefaultWidget(self.widgetSuggestEdit)
def __init__(self, parent = None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Data Domain", wantMainArea = 0) self.inputs = [("Examples", ExampleTable, self.setData), ("Attribute Subset", AttributeList, self.setAttributeList)] self.outputs = [("Examples", ExampleTable)] buttonWidth = 50 applyButtonWidth = 101 self.data = None self.receivedAttrList = None self.selectedInput = [] self.inputAttributes = [] self.selectedChosen = [] self.chosenAttributes = [] self.selectedClass = [] self.classAttribute = [] self.metaAttributes = [] self.selectedMeta = [] self.loadSettings() import sip sip.delete(self.controlArea.layout()) grid = QGridLayout() self.controlArea.setLayout(grid) grid.setMargin(0) boxAvail = OWGUI.widgetBox(self, 'Available Attributes', addToLayout = 0) grid.addWidget(boxAvail, 0, 0, 3, 1) self.filterInputAttrs = OWGUIEx.lineEditFilter(boxAvail, self, None, useRE = 1, emptyText = "filter attributes...", callback = self.setInputAttributes, caseSensitive = 0) self.inputAttributesList = OWGUI.listBox(boxAvail, self, "selectedInput", "inputAttributes", callback = self.onSelectionChange, selectionMode = QListWidget.ExtendedSelection, enableDragDrop = 1, dragDropCallback = self.updateInterfaceAndApplyButton) self.filterInputAttrs.listbox = self.inputAttributesList vbAttr = OWGUI.widgetBox(self, addToLayout = 0) grid.addWidget(vbAttr, 0, 1) self.attributesButtonUp = OWGUI.button(vbAttr, self, "Up", self.onAttributesButtonUpClick) self.attributesButtonUp.setMaximumWidth(buttonWidth) self.attributesButton = OWGUI.button(vbAttr, self, ">", self.onAttributesButtonClicked) self.attributesButton.setMaximumWidth(buttonWidth) self.attributesButtonDown = OWGUI.button(vbAttr, self, "Down", self.onAttributesButtonDownClick) self.attributesButtonDown.setMaximumWidth(buttonWidth) boxAttr = OWGUI.widgetBox(self, 'Attributes', addToLayout = 0) grid.addWidget(boxAttr, 0, 2) self.attributesList = OWGUI.listBox(boxAttr, self, "selectedChosen", "chosenAttributes", callback = self.onSelectionChange, selectionMode = QListWidget.ExtendedSelection, enableDragDrop = 1, dragDropCallback = self.updateInterfaceAndApplyButton) self.classButton = OWGUI.button(self, self, ">", self.onClassButtonClicked, addToLayout = 0) self.classButton.setMaximumWidth(buttonWidth) grid.addWidget(self.classButton, 1, 1) boxClass = OWGUI.widgetBox(self, 'Class', addToLayout = 0) boxClass.setFixedHeight(55) grid.addWidget(boxClass, 1, 2) self.classList = OWGUI.listBox(boxClass, self, "selectedClass", "classAttribute", callback = self.onSelectionChange, selectionMode = QListWidget.ExtendedSelection, enableDragDrop = 1, dragDropCallback = self.updateInterfaceAndApplyButton, dataValidityCallback = self.dataValidityCallback) vbMeta = OWGUI.widgetBox(self, addToLayout = 0) grid.addWidget(vbMeta, 2, 1) self.metaButtonUp = OWGUI.button(vbMeta, self, "Up", self.onMetaButtonUpClick) self.metaButtonUp.setMaximumWidth(buttonWidth) self.metaButton = OWGUI.button(vbMeta, self, ">", self.onMetaButtonClicked) self.metaButton.setMaximumWidth(buttonWidth) self.metaButtonDown = OWGUI.button(vbMeta, self, "Down", self.onMetaButtonDownClick) self.metaButtonDown.setMaximumWidth(buttonWidth) boxMeta = OWGUI.widgetBox(self, 'Meta Attributes', addToLayout = 0) grid.addWidget(boxMeta, 2, 2) self.metaList = OWGUI.listBox(boxMeta, self, "selectedMeta", "metaAttributes", callback = self.onSelectionChange, selectionMode = QListWidget.ExtendedSelection, enableDragDrop = 1, dragDropCallback = self.updateInterfaceAndApplyButton) boxApply = OWGUI.widgetBox(self, addToLayout = 0, orientation = "horizontal", addSpace = 1) grid.addWidget(boxApply, 3, 0, 3, 3) self.applyButton = OWGUI.button(boxApply, self, "Apply", callback = self.setOutput) self.applyButton.setEnabled(False) self.applyButton.setMaximumWidth(applyButtonWidth) self.resetButton = OWGUI.button(boxApply, self, "Reset", callback = self.reset) self.resetButton.setMaximumWidth(applyButtonWidth) grid.setRowStretch(0, 4) grid.setRowStretch(1, 0) grid.setRowStretch(2, 2) self.icons = self.createAttributeIconDict() self.inChange = False self.resize(400, 480)
def __init__(self, parent=None, selectText="", applyText="Apply", callbackOnApply=None, callbackOnReset=None): QWidget.__init__(self) if parent: parent.layout().addWidget(self) gl = QGridLayout() gl.setMargin(0) self.setLayout(gl) self.callbackOnApply = callbackOnApply self.callbackOnReset = callbackOnReset #Local Variables buttonWidth = 50 applyButtonWidth = 101 self.inputItems = [] # A backup of all input Items self.availableItems = [ ] # A managed list of the available items that can still be selected (inputItems that are not yet selectedItems) self.availableItems2 = [ "a", "b", "c" ] # A managed list of the available items that can still be selected (inputItems that are not yet selectedItems) self.selectedItems = [] # A managed list of the already selected items # Left pane Box. boxAvail = OWGUI.widgetBox(self, 'Available ' + selectText, addToLayout=0) gl.addWidget(boxAvail, 0, 0, 3, 1) self.filterInputItems = OWGUIEx.lineEditFilter( boxAvail, self, None, useRE=1, emptyText="filter " + selectText + "...", callback=self.__setFilteredInput, caseSensitive=0) self.inputItemsList = OWGUI.listBox( boxAvail, self, None, None, selectionMode=QListWidget.ExtendedSelection) self.filterInputItems.listbox = self.inputItemsList vbItems = OWGUI.widgetBox(self) gl.addWidget(vbItems, 0, 1) self.ButtonAdd = OWGUI.button(vbItems, self, ">", self.__onButtonAddClicked) self.ButtonAdd.setMaximumWidth(buttonWidth) self.ButtonRemove = OWGUI.button(vbItems, self, "<", self.__onButtonRemoveClicked) self.ButtonRemove.setMaximumWidth(buttonWidth) # Right pane selected descriptors. box = OWGUI.widgetBox(self, 'Selected ' + selectText) gl.addWidget(box, 0, 2) self.selectedItemsList = OWGUI.listBox( box, self, None, None, selectionMode=QListWidget.ExtendedSelection) #Apply Reset buttons boxApply = OWGUI.widgetBox(self, '', orientation="horizontal", addToLayout=0) gl.addWidget(boxApply, 3, 0, 1, 3) if self.callbackOnApply != None: self.applyButton = OWGUI.button(boxApply, self, applyText, callback=self.__apply) self.applyButton.setMaximumWidth(applyButtonWidth) self.resetButton = OWGUI.button(boxApply, self, "Reset", callback=self.__reset) self.resetButton.setMaximumWidth(applyButtonWidth)
def __init__(self, parent=None, signalManager=None, name="Databases update", wantCloseButton=False, searchString="", showAll=True, domains=None, accessCode=""): OWWidget.__init__(self, parent, signalManager, name, wantMainArea=False) self.searchString = searchString self.accessCode = accessCode self.showAll = showAll self.domains = domains self.serverFiles = serverfiles.ServerFiles() box = OWGUI.widgetBox(self.controlArea, orientation="horizontal") self.lineEditFilter = \ OWGUIEx.lineEditHint(box, self, "searchString", "Filter", caseSensitive=False, delimiters=" ", matchAnywhere=True, listUpdateCallback=self.SearchUpdate, callbackOnType=True, callback=self.SearchUpdate) box = OWGUI.widgetBox(self.controlArea, "Files") self.filesView = QTreeWidget(self) self.filesView.setHeaderLabels( ["", "Data Source", "Update", "Last Updated", "Size"]) self.filesView.setRootIsDecorated(False) self.filesView.setUniformRowHeights(True) self.filesView.setSelectionMode(QAbstractItemView.NoSelection) self.filesView.setSortingEnabled(True) self.filesView.sortItems(1, Qt.AscendingOrder) self.filesView.setItemDelegateForColumn( 0, UpdateOptionsItemDelegate(self.filesView)) QObject.connect(self.filesView.model(), SIGNAL("layoutChanged()"), self.SearchUpdate) box.layout().addWidget(self.filesView) box = OWGUI.widgetBox(self.controlArea, orientation="horizontal") self.updateButton = OWGUI.button(box, self, "Update all", callback=self.UpdateAll, tooltip="Update all updatable files", ) self.downloadButton = OWGUI.button(box, self, "Download all", callback=self.DownloadFiltered, tooltip="Download all filtered files shown") self.cancelButton = OWGUI.button(box, self, "Cancel", callback=self.Cancel, tooltip="Cancel scheduled downloads/updates.") OWGUI.rubber(box) OWGUI.lineEdit(box, self, "accessCode", "Access Code", orientation="horizontal", callback=self.RetrieveFilesList) self.retryButton = OWGUI.button(box, self, "Retry", callback=self.RetrieveFilesList) self.retryButton.hide() box = OWGUI.widgetBox(self.controlArea, orientation="horizontal") OWGUI.rubber(box) if wantCloseButton: OWGUI.button(box, self, "Close", callback=self.accept, tooltip="Close") self.infoLabel = QLabel() self.infoLabel.setAlignment(Qt.AlignCenter) self.controlArea.layout().addWidget(self.infoLabel) self.infoLabel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) self.updateItems = [] self.resize(800, 600) self.progress = ProgressState(self, maximum=3) self.progress.valueChanged.connect(self._updateProgress) self.progress.rangeChanged.connect(self._updateProgress) self.executor = ThreadExecutor( threadPool=QThreadPool(maxThreadCount=2) ) task = Task(self, function=self.RetrieveFilesList) task.exceptionReady.connect(self.HandleError) task.start() self._tasks = [] self._haveProgress = False
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "Data Domain", wantMainArea=0) #initialize base class self.inputs = [("Examples", ExampleTable, self.onDataInput), ("Attribute Subset", AttributeList, self.onAttributeList)] self.outputs = [("Examples", ExampleTable), ("Classified Examples", ExampleTable), ("Selected Attributes", AttributeList)] buttonWidth = 50 applyButtonWidth = 101 self.data = None self.receivedAttrList = [] self.selectedInput = [] self.inputAttributes = [] self.selectedChosen = [] self.chosenAttributes = [] self.selectedClass = [] self.classAttribute = [] self.metaAttributes = [] self.selectedMeta = [] self.loadSettings() self.usedAttributes = {} self.userWarned = False import sip sip.delete(self.controlArea.layout()) gl = QGridLayout() self.controlArea.setLayout(gl) gl.setMargin(0) boxAvail = OWGUI.widgetBox(self, 'Available Attributes') gl.addWidget(boxAvail, 0, 0, 3, 1) self.filterInputAttrs = OWGUIEx.lineEditFilter( boxAvail, self, None, useRE=1, emptyText="filter attributes...", callback=self.setInputAttributes, caseSensitive=0) self.inputAttributesList = OWGUI.listBox( boxAvail, self, "selectedInput", "inputAttributes", callback=self.onSelectionChange, selectionMode=QListWidget.ExtendedSelection) self.filterInputAttrs.listbox = self.inputAttributesList vbAttr = OWGUI.widgetBox(self, addToLayout=0) gl.addWidget(vbAttr, 0, 1) self.attributesButtonUp = OWGUI.button(vbAttr, self, "Up", self.onAttributesButtonUpClick) self.attributesButtonUp.setMaximumWidth(buttonWidth) self.attributesButton = OWGUI.button(vbAttr, self, ">", self.onAttributesButtonClicked) self.attributesButton.setMaximumWidth(buttonWidth) self.attributesButtonDown = OWGUI.button( vbAttr, self, "Down", self.onAttributesButtonDownClick) self.attributesButtonDown.setMaximumWidth(buttonWidth) boxAttr = OWGUI.widgetBox(self, 'Attributes', addToLayout=0) gl.addWidget(boxAttr, 0, 2) self.attributesList = OWGUI.listBox( boxAttr, self, "selectedChosen", "chosenAttributes", callback=self.onSelectionChange, selectionMode=QListWidget.ExtendedSelection) self.classButton = OWGUI.button(self, self, ">", self.onClassButtonClicked, addToLayout=0) self.classButton.setMaximumWidth(buttonWidth) gl.addWidget(self.classButton, 1, 1) boxClass = OWGUI.widgetBox(self, 'Class', addToLayout=0) boxClass.setFixedHeight(55) gl.addWidget(boxClass, 1, 2) self.classList = OWGUI.listBox( boxClass, self, "selectedClass", "classAttribute", callback=self.onSelectionChange, selectionMode=QListWidget.ExtendedSelection) vbMeta = OWGUI.widgetBox(self, addToLayout=0) gl.addWidget(vbMeta, 2, 1) self.metaButtonUp = OWGUI.button(vbMeta, self, "Up", self.onMetaButtonUpClick) self.metaButtonUp.setMaximumWidth(buttonWidth) self.metaButton = OWGUI.button(vbMeta, self, ">", self.onMetaButtonClicked) self.metaButton.setMaximumWidth(buttonWidth) self.metaButtonDown = OWGUI.button(vbMeta, self, "Down", self.onMetaButtonDownClick) self.metaButtonDown.setMaximumWidth(buttonWidth) boxMeta = OWGUI.widgetBox(self, 'Meta Attributes', addToLayout=0) gl.addWidget(boxMeta, 2, 2) self.metaList = OWGUI.listBox( boxMeta, self, "selectedMeta", "metaAttributes", callback=self.onSelectionChange, selectionMode=QListWidget.ExtendedSelection) boxApply = OWGUI.widgetBox(self, addToLayout=0, orientation="horizontal", addSpace=1) #QHBox(ca) gl.addWidget(boxApply, 3, 0, 1, 3) self.applyButton = OWGUI.button(boxApply, self, "Apply", callback=self.setOutput) self.applyButton.setEnabled(False) self.applyButton.setMaximumWidth(applyButtonWidth) self.resetButton = OWGUI.button(boxApply, self, "Reset", callback=self.reset) self.resetButton.setMaximumWidth(applyButtonWidth) infoBox = OWGUI.widgetBox(self, "Info", addToLayout=0, orientation="horizontal", addSpace=1) gl.addWidget(infoBox, 5, 0, 1, 3) OWGUI.widgetLabel( infoBox, 'Aside from a data set with the selected attributes, \nthe widget also outputs an "Attribute List" which can be used with\n another "Select Attribute" widget to make the same variable selection' ) gl.setRowStretch(0, 4) gl.setRowStretch(1, 0) gl.setRowStretch(2, 2) self.icons = self.createAttributeIconDict() self.inChange = False self.resize(400, 480)
def __init__(self, parent=None, signalManager=None, name="Preprocess"): OWWidget.__init__(self, parent, signalManager, name) self.inputs = [("Example Table", ExampleTable, self.setData) ] #, ("Learner", orange.Learner, self.setLearner)] self.outputs = [("Preprocess", orngWrap.PreprocessedLearner), ("Preprocessed Example Table", ExampleTable) ] #, ("Preprocessor", orange.Preprocessor)] self.autoCommit = False self.changedFlag = False # self.allSchemas = [PreprocessorSchema("Default" , [Preprocessor_discretize(method=orange.EntropyDiscretization()), Preprocessor_dropMissing()])] self.allSchemas = [("Default", [ Preprocessor_discretizeEntropy( method=orange.EntropyDiscretization()), Preprocessor_dropMissing() ], 0)] self.lastSelectedSchemaIndex = 0 self.preprocessorsList = PyListModel([], self) box = OWGUI.widgetBox(self.controlArea, "Preprocessors", addSpace=True) box.layout().setSpacing(1) self.setStyleSheet("QListView::item { margin: 1px;}") self.preprocessorsListView = QListView() self.preprocessorsListSelectionModel = ListSingleSelectionModel( self.preprocessorsList, self) self.preprocessorsListView.setItemDelegate( PreprocessorItemDelegate(self)) self.preprocessorsListView.setModel(self.preprocessorsList) self.preprocessorsListView.setSelectionModel( self.preprocessorsListSelectionModel) self.preprocessorsListView.setSelectionMode(QListView.SingleSelection) self.connect(self.preprocessorsListSelectionModel, SIGNAL("selectedIndexChanged(QModelIndex)"), self.onPreprocessorSelection) self.connect(self.preprocessorsList, SIGNAL("dataChanged(QModelIndex, QModelIndex)"), lambda arg1, arg2: self.commitIf) box.layout().addWidget(self.preprocessorsListView) self.addPreprocessorAction = QAction("+", self) self.addPreprocessorAction.pyqtConfigure( toolTip="Add a new preprocessor to the list") self.removePreprocessorAction = QAction("-", self) self.removePreprocessorAction.pyqtConfigure( toolTip="Remove selected preprocessor from the list") self.removePreprocessorAction.setEnabled(False) self.connect( self.preprocessorsListSelectionModel, SIGNAL("selectedIndexChanged(QModelIndex)"), lambda index: self. removePreprocessorAction.setEnabled(index.isValid())) actionsWidget = ModelActionsWidget( [self.addPreprocessorAction, self.removePreprocessorAction]) actionsWidget.layout().setSpacing(1) actionsWidget.layout().addStretch(10) box.layout().addWidget(actionsWidget) self.connect(self.addPreprocessorAction, SIGNAL("triggered()"), self.onAddPreprocessor) self.connect(self.removePreprocessorAction, SIGNAL("triggered()"), self.onRemovePreprocessor) box = OWGUI.widgetBox(self.controlArea, "Saved Schemas", addSpace=True) self.schemaFilterEdit = OWGUIEx.LineEditFilter(self) box.layout().addWidget(self.schemaFilterEdit) self.schemaList = PyListModel([], self, flags=Qt.ItemIsSelectable | Qt.ItemIsEditable | Qt.ItemIsEnabled) self.schemaListProxy = PySortFilterProxyModel(filter_fmt="{0.name}", parent=self) self.schemaListProxy.setFilterCaseSensitivity(Qt.CaseInsensitive) self.schemaListProxy.setSourceModel(self.schemaList) self.schemaListView = QListView() self.schemaListView.setItemDelegate(PreprocessorSchemaDelegate(self)) # self.schemaListView.setModel(self.schemaList) self.schemaListView.setModel(self.schemaListProxy) self.connect(self.schemaFilterEdit, SIGNAL("textEdited(QString)"), self.schemaListProxy.setFilterRegExp) box.layout().addWidget(self.schemaListView) self.schemaListSelectionModel = ListSingleSelectionModel( self.schemaListProxy, self) self.schemaListView.setSelectionMode(QListView.SingleSelection) self.schemaListView.setSelectionModel(self.schemaListSelectionModel) self.connect(self.schemaListSelectionModel, SIGNAL("selectedIndexChanged(QModelIndex)"), self.onSchemaSelection) self.addSchemaAction = QAction("+", self) self.addSchemaAction.pyqtConfigure( toolTip="Add a new preprocessor schema") self.updateSchemaAction = QAction("Update", self) self.updateSchemaAction.pyqtConfigure( toolTip="Save changes made in the current schema") self.removeSchemaAction = QAction("-", self) self.removeSchemaAction.pyqtConfigure(toolTip="Remove selected schema") self.updateSchemaAction.setEnabled(False) self.removeSchemaAction.setEnabled(False) actionsWidget = ModelActionsWidget([]) actionsWidget.addAction(self.addSchemaAction) actionsWidget.addAction(self.updateSchemaAction).setSizePolicy( QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) actionsWidget.addAction(self.removeSchemaAction) actionsWidget.layout().setSpacing(1) box.layout().addWidget(actionsWidget) self.connect(self.addSchemaAction, SIGNAL("triggered()"), self.onAddSchema) self.connect(self.updateSchemaAction, SIGNAL("triggered()"), self.onUpdateSchema) self.connect(self.removeSchemaAction, SIGNAL("triggered()"), self.onRemoveSchema) self.addPreprocessorsMenuActions = actions = [] for name, pp, kwargs in self.preprocessors: action = QAction(name, self) self.connect(action, SIGNAL("triggered()"), lambda pp=pp, kwargs=kwargs: self.addPreprocessor( pp(**kwargs))) actions.append(action) box = OWGUI.widgetBox(self.controlArea, "Output") cb = OWGUI.checkBox(box, self, "autoCommit", "Commit on any change", callback=self.commitIf) b = OWGUI.button(box, self, "Commit", callback=self.commit) OWGUI.setStopper(self, b, cb, "changedFlag", callback=self.commitIf) self.mainAreaStack = QStackedLayout() self.stackedEditorsCache = {} OWGUI.widgetBox(self.mainArea, orientation=self.mainAreaStack) self.data = None self.learner = None self.loadSettings() self.activateLoadedSettings()
def __init__(self,parent = None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Data Domain",wantMainArea = 0) #initialize base class self.inputs = [("Examples", ExampleTable, self.onDataInput), ("Attribute Subset", AttributeList, self.onAttributeList)] self.outputs = [("Examples", ExampleTable), ("Classified Examples", ExampleTable), ("Selected Attributes", AttributeList)] buttonWidth = 50 applyButtonWidth = 101 self.data = None self.receivedAttrList = [] self.selectedInput = [] self.inputAttributes = [] self.selectedChosen = [] self.chosenAttributes = [] self.selectedClass = [] self.classAttribute = [] self.metaAttributes = [] self.selectedMeta = [] self.loadSettings() self.usedAttributes = {} self.userWarned = False import sip sip.delete(self.controlArea.layout()) gl=QGridLayout() self.controlArea.setLayout(gl) gl.setMargin(0) boxAvail = OWGUI.widgetBox(self,'Available Attributes') gl.addWidget(boxAvail, 0,0,3,1) self.filterInputAttrs = OWGUIEx.lineEditFilter(boxAvail, self, None, useRE = 1, emptyText = "filter attributes...", callback = self.setInputAttributes, caseSensitive = 0) self.inputAttributesList = OWGUI.listBox(boxAvail, self, "selectedInput", "inputAttributes", callback = self.onSelectionChange, selectionMode = QListWidget.ExtendedSelection) self.filterInputAttrs.listbox = self.inputAttributesList vbAttr = OWGUI.widgetBox(self, addToLayout = 0) gl.addWidget(vbAttr, 0,1) self.attributesButtonUp = OWGUI.button(vbAttr, self, "Up", self.onAttributesButtonUpClick) self.attributesButtonUp.setMaximumWidth(buttonWidth) self.attributesButton = OWGUI.button(vbAttr, self, ">",self.onAttributesButtonClicked) self.attributesButton.setMaximumWidth(buttonWidth) self.attributesButtonDown = OWGUI.button(vbAttr, self, "Down", self.onAttributesButtonDownClick) self.attributesButtonDown.setMaximumWidth(buttonWidth) boxAttr = OWGUI.widgetBox(self,'Attributes', addToLayout = 0) gl.addWidget(boxAttr, 0,2) self.attributesList = OWGUI.listBox(boxAttr, self, "selectedChosen", "chosenAttributes", callback = self.onSelectionChange, selectionMode = QListWidget.ExtendedSelection) self.classButton = OWGUI.button(self, self, ">", self.onClassButtonClicked, addToLayout = 0) self.classButton.setMaximumWidth(buttonWidth) gl.addWidget(self.classButton, 1,1) boxClass = OWGUI.widgetBox(self,'Class', addToLayout = 0) boxClass.setFixedHeight(55) gl.addWidget(boxClass, 1,2) self.classList = OWGUI.listBox(boxClass, self, "selectedClass", "classAttribute", callback = self.onSelectionChange, selectionMode = QListWidget.ExtendedSelection) vbMeta = OWGUI.widgetBox(self, addToLayout = 0) gl.addWidget(vbMeta, 2,1) self.metaButtonUp = OWGUI.button(vbMeta, self, "Up", self.onMetaButtonUpClick) self.metaButtonUp.setMaximumWidth(buttonWidth) self.metaButton = OWGUI.button(vbMeta, self, ">",self.onMetaButtonClicked) self.metaButton.setMaximumWidth(buttonWidth) self.metaButtonDown = OWGUI.button(vbMeta, self, "Down", self.onMetaButtonDownClick) self.metaButtonDown.setMaximumWidth(buttonWidth) boxMeta = OWGUI.widgetBox(self,'Meta Attributes', addToLayout = 0) gl.addWidget(boxMeta, 2,2) self.metaList = OWGUI.listBox(boxMeta, self, "selectedMeta", "metaAttributes", callback = self.onSelectionChange, selectionMode = QListWidget.ExtendedSelection) boxApply = OWGUI.widgetBox(self, addToLayout = 0, orientation = "horizontal", addSpace = 1) #QHBox(ca) gl.addWidget(boxApply, 3,0,1,3) self.applyButton = OWGUI.button(boxApply, self, "Apply", callback = self.setOutput) self.applyButton.setEnabled(False) self.applyButton.setMaximumWidth(applyButtonWidth) self.resetButton = OWGUI.button(boxApply, self, "Reset", callback = self.reset) self.resetButton.setMaximumWidth(applyButtonWidth) infoBox = OWGUI.widgetBox(self,"Info" ,addToLayout = 0, orientation = "horizontal", addSpace = 1) gl.addWidget(infoBox, 5,0,1,3) OWGUI.widgetLabel(infoBox, 'Aside from a data set with the selected attributes, \nthe widget also outputs an "Attribute List" which can be used with\n another "Select Attribute" widget to make the same variable selection') gl.setRowStretch(0, 4) gl.setRowStretch(1, 0) gl.setRowStretch(2, 2) self.icons = self.createAttributeIconDict() self.inChange = False self.resize(400,480)
def __init__(self, parent=None, selectText="", applyText="Apply", callbackOnApply=None, callbackOnReset=None): QWidget.__init__(self) if parent: parent.layout().addWidget(self) gl = QGridLayout() gl.setMargin(0) self.setLayout(gl) self.callbackOnApply = callbackOnApply self.callbackOnReset = callbackOnReset # Local Variables buttonWidth = 50 applyButtonWidth = 101 self.inputItems = [] # A backup of all input Items self.availableItems = ( [] ) # A managed list of the available items that can still be selected (inputItems that are not yet selectedItems) self.availableItems2 = [ "a", "b", "c", ] # A managed list of the available items that can still be selected (inputItems that are not yet selectedItems) self.selectedItems = [] # A managed list of the already selected items # Left pane Box. boxAvail = OWGUI.widgetBox(self, "Available " + selectText, addToLayout=0) gl.addWidget(boxAvail, 0, 0, 3, 1) self.filterInputItems = OWGUIEx.lineEditFilter( boxAvail, self, None, useRE=1, emptyText="filter " + selectText + "...", callback=self.__setFilteredInput, caseSensitive=0, ) self.inputItemsList = OWGUI.listBox(boxAvail, self, None, None, selectionMode=QListWidget.ExtendedSelection) self.filterInputItems.listbox = self.inputItemsList vbItems = OWGUI.widgetBox(self) gl.addWidget(vbItems, 0, 1) self.ButtonAdd = OWGUI.button(vbItems, self, ">", self.__onButtonAddClicked) self.ButtonAdd.setMaximumWidth(buttonWidth) self.ButtonRemove = OWGUI.button(vbItems, self, "<", self.__onButtonRemoveClicked) self.ButtonRemove.setMaximumWidth(buttonWidth) # Right pane selected descriptors. box = OWGUI.widgetBox(self, "Selected " + selectText) gl.addWidget(box, 0, 2) self.selectedItemsList = OWGUI.listBox(box, self, None, None, selectionMode=QListWidget.ExtendedSelection) # Apply Reset buttons boxApply = OWGUI.widgetBox(self, "", orientation="horizontal", addToLayout=0) gl.addWidget(boxApply, 3, 0, 1, 3) if self.callbackOnApply != None: self.applyButton = OWGUI.button(boxApply, self, applyText, callback=self.__apply) self.applyButton.setMaximumWidth(applyButtonWidth) self.resetButton = OWGUI.button(boxApply, self, "Reset", callback=self.__reset) self.resetButton.setMaximumWidth(applyButtonWidth)