def __init__(self,parent=None,dataModel = None): QListView.__init__(self, parent) self._dataModel = dataModel self._selectedDisplayMapping = OrderedDict() self._modelDisplayMapping = OrderedDict() self._attrModel = QStandardItemModel(self)
def __init__(self, qpart, model): QListView.__init__(self, qpart.viewport()) self.setAttribute(Qt.WA_DeleteOnClose) self.setItemDelegate(HTMLDelegate(self)) self._qpart = qpart self.setFont(qpart.font()) self.setCursor(QCursor(Qt.PointingHandCursor)) self.setFocusPolicy(Qt.NoFocus) self.setModel(model) self._selectedIndex = -1 # if cursor moved, we shall close widget, if its position (and model) hasn't been updated self._closeIfNotUpdatedTimer = QTimer(self) self._closeIfNotUpdatedTimer.setInterval(200) self._closeIfNotUpdatedTimer.setSingleShot(True) self._closeIfNotUpdatedTimer.timeout.connect(self._afterCursorPositionChanged) qpart.installEventFilter(self) qpart.cursorPositionChanged.connect(self._onCursorPositionChanged) self.clicked.connect(lambda index: self.itemSelected.emit(index.row())) self.updateGeometry() self.show() qpart.setFocus()
def test_dock_standalone(self): widget = QWidget() layout = QHBoxLayout() widget.setLayout(layout) layout.addStretch(1) widget.show() dock = CollapsibleDockWidget() layout.addWidget(dock) list_view = QListView() list_view.setModel(QStringListModel(["a", "b"], list_view)) label = QLabel("A label. ") label.setWordWrap(True) dock.setExpandedWidget(label) dock.setCollapsedWidget(list_view) dock.setExpanded(True) self.app.processEvents() def toogle(): dock.setExpanded(not dock.expanded()) self.singleShot(2000, toogle) toogle() self.app.exec_()
def __init__(self, parent=None): super().__init__(parent) self.data = None self.input_vars = () self._invalidated = False box = gui.widgetBox(self.controlArea, "Domain Features") self.domain_model = itemmodels.VariableListModel() self.domain_view = QListView(selectionMode=QListView.SingleSelection) self.domain_view.setModel(self.domain_model) self.domain_view.selectionModel().selectionChanged.connect( self._on_selection_changed) box.layout().addWidget(self.domain_view) box = gui.widgetBox(self.controlArea, "Reset") gui.button(box, self, "Reset selected", callback=self.reset_selected) gui.button(box, self, "Reset all", callback=self.reset_all) gui.auto_commit(self.controlArea, self, "autocommit", "Commit", "Commit on change is on") box = gui.widgetBox(self.mainArea, "Edit") self.editor_stack = QtGui.QStackedWidget() self.editor_stack.addWidget(DiscreteVariableEditor()) self.editor_stack.addWidget(ContinuousVariableEditor()) self.editor_stack.addWidget(VariableEditor()) box.layout().addWidget(self.editor_stack)
def keyPressEvent(self, event): if event.matches(QKeySequence.Delete): self._removeSelected() elif event.key() == Qt.Key_Escape: self.currentList.reset() else: QListView.keyPressEvent(self.currentList, event)
def __init__(self, parent = None, model=None): QListView.__init__(self, parent) if model is None: model = LayerStackModel() self.init(model)
def __init__(self): self.data = None self.indices = [] box = gui.vBox(self.controlArea, 'Axes') self.combo_ax2 = gui.comboBox( box, self, 'ax2', label='Y axis:', callback=self.replot, sendSelectedValue=True, orientation='horizontal') self.combo_ax1 = gui.comboBox( box, self, 'ax1', label='Radial:', callback=self.replot, sendSelectedValue=True, orientation='horizontal') box = gui.vBox(self.controlArea, 'Aggregation') self.combo_func = gui.comboBox( box, self, 'agg_func', label='Function:', orientation='horizontal', callback=self.replot) func_model = ListModel(AGG_FUNCTIONS, parent=self) self.combo_func.setModel(func_model) self.attrlist_model = VariableListModel(parent=self) self.attrlist = QListView(selectionMode=QListView.ExtendedSelection) self.attrlist.setModel(self.attrlist_model) self.attrlist.selectionModel().selectionChanged.connect( self.attrlist_selectionChanged) box.layout().addWidget(self.attrlist) gui.rubber(self.controlArea) self.chart = chart = Spiralogram(self, selection_callback=self.on_selection) self.mainArea.layout().addWidget(chart)
def __init__(self, values, checked_values=[]): self.dial = QDialog() self.result = "" # Layout Principal m_vbl = QVBoxLayout(self.dial) # List item checkable view = QListView() m_vbl.addWidget(view) self.m_sim = QStandardItemModel() view.setModel(self.m_sim) self._load_item(values, checked_values) # List buttons bt_all = QPushButton(self.tr("All")) bt_all.clicked.connect(lambda: self._check_all()) bt_nothing = QPushButton(self.tr("Nothing")) bt_nothing.clicked.connect(lambda: self._check_nothing()) bt_print = QPushButton(self.tr("Ok")) bt_print.clicked.connect(lambda: self._check_ok()) # Sub layout for buttons m_vbh = QHBoxLayout() m_vbl.addLayout(m_vbh) m_vbh.addWidget(bt_all) m_vbh.addWidget(bt_nothing) m_vbh.addWidget(bt_print)
def _listKeyPressEvent(self, event): if event.matches(QKeySequence.Delete): self._deleteList() elif event.key() == Qt.Key_Escape: self.playlistList.setCurrentIndex(QModelIndex()) else: QListView.keyPressEvent(self.playlistList, event)
def __init__(self, column, parent=None): """ Class constructor. :param column: Multiple select column object. :type column: MultipleSelectColumn :param parent: Parent widget for the control. :type parent: QWidget """ QListView.__init__(self, parent) #Disable editing of lookup values self.setEditTriggers(QAbstractItemView.NoEditTriggers) self.column = column self._item_model = QStandardItemModel(self) self._value_list = self.column.value_list #Stores lookup objects based on primary keys self._lookup_cache = {} self._initialize() self._association = self.column.association self._first_parent_col = self._association.first_reference_column.name self._second_parent_col = self._association.second_reference_column.name #Association model self._assoc_cls = entity_model(self._association)
def __init__(self, parent): QWidget.__init__(self, parent) while not isinstance(parent, QDialog): parent = parent.parent() self.setObjectName("CheckedListBox" + str(len(parent.findChildren(CheckedListBox)))) self.setObjectName("checkBoxWidget") self.hLayout = QHBoxLayout(self) self.hLayout.setObjectName("hLayout") sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth()) self.setSizePolicy(sizePolicy) # self.frame = Frame() self.listView = QListView(self) self.hLayout.addWidget(self.listView) self.stdModel = QStandardItemModel() self.listView.setModel(self.stdModel) self.hasObject = False self.objList = [] self.checkBoxList = [] self.listView.pressed.connect(self.listView_clicked)
def __init__(self, parent=None): super().__init__(parent) ## Attributes self.data = None self.distances = None self.groups = None self.unique_pos = None self.base_group_index = 0 ## GUI box = gui.widgetBox(self.controlArea, "Info") self.info_box = gui.widgetLabel(box, "\n") ## Separate By box box = gui.widgetBox(self.controlArea, "Separate By") self.split_by_model = itemmodels.PyListModel(parent=self) self.split_by_view = QListView() self.split_by_view.setSelectionMode(QListView.ExtendedSelection) self.split_by_view.setModel(self.split_by_model) box.layout().addWidget(self.split_by_view) self.split_by_view.selectionModel().selectionChanged.connect( self.on_split_key_changed) ## Sort By box box = gui.widgetBox(self.controlArea, "Sort By") self.sort_by_model = itemmodels.PyListModel(parent=self) self.sort_by_view = QListView() self.sort_by_view.setSelectionMode(QListView.ExtendedSelection) self.sort_by_view.setModel(self.sort_by_model) box.layout().addWidget(self.sort_by_view) self.sort_by_view.selectionModel().selectionChanged.connect( self.on_sort_key_changed) ## Distance box box = gui.widgetBox(self.controlArea, "Distance Measure") gui.comboBox(box, self, "selected_distance_index", items=[name for name, _ in self.DISTANCE_FUNCTIONS], callback=self.on_distance_measure_changed) self.scene = QGraphicsScene() self.scene_view = QGraphicsView(self.scene) self.scene_view.setRenderHints(QPainter.Antialiasing) self.scene_view.setAlignment(Qt.AlignLeft | Qt.AlignVCenter) self.mainArea.layout().addWidget(self.scene_view) self.scene_view.installEventFilter(self) self._disable_updates = False self._cached_distances = {} self._base_index_hints = {} self.main_widget = None self.resize(800, 600)
class AppletNoticeWindow(QWidget): def __init__(self, controller): QWidget.__init__(self) self.__controller = controller self.__pkglist = [] # setup widgets self.__vbox_up = QVBoxLayout() self.__critical_label = QLabel() self.__critical_label.setWordWrap(True) self.__list_model = QStringListModel() self.__list_view = QListView() self.__list_view.setModel(self.__list_model) self.__vbox_up.addWidget(self.__critical_label) self.__vbox_up.addWidget(self.__list_view) # bottom buttons self.__vbox = QVBoxLayout() self.__vbox.addLayout(self.__vbox_up) self.__button_hbox = QHBoxLayout() self.__close_button = QPushButton(_("Close")) self.__launch_pm_button = QPushButton(_("Launch Application Browser")) self.__button_hbox.addWidget(self.__launch_pm_button) self.__button_hbox.addWidget(self.__close_button) self.__vbox.addLayout(self.__button_hbox) self.setLayout(self.__vbox) # set window settings self.resize(400, 200) self.setWindowTitle(_("Application updates")) self.connect(self.__close_button, SIGNAL("clicked()"), self.on_close) self.connect(self.__launch_pm_button, SIGNAL("clicked()"), self.on_pm) def closeEvent(self, event): """ We don't want to kill the window, since the whole app will close otherwise. """ event.ignore() self.on_close() def on_pm(self): self.__controller.launch_package_manager() def on_close(self): self.__controller.trigger_notice_window() def populate(self, pkg_data, critical_txt): self.__list_model.setStringList(pkg_data) self.__critical_label.setText(critical_txt) self.__list_view.update()
def _setup_gui_values(self): self.values_edit = QListView() self.values_edit.setEditTriggers(QTreeView.CurrentChanged) self.values_model = itemmodels.PyListModel(flags=Qt.ItemIsSelectable | \ Qt.ItemIsEnabled | Qt.ItemIsEditable) self.values_edit.setModel(self.values_model) self.values_model.dataChanged.connect(self.on_values_changed) self.main_form.addRow("Values", self.values_edit)
class DataListToTreeWidget(DataPusherWidget): ''' DataPusherWidget widget for track layout ''' def __init__(self, parent=None): super(DataListToTreeWidget, self).__init__(parent) self.rightTreeView = None self.leftDataTypeListView = None self.setupRightPane() def setupLeftPane(self): self.leftDataTypeListView = QListView() self.leftScrollArea.setWidgetResizable(True) self.leftVerticalLayout.addWidget(self.leftDataTypeListView) self.leftDataTypeListView.setSelectionMode( QAbstractItemView.ExtendedSelection) def setupRightPane(self): self.rightTreeView = QTreeView() self.rightScrollArea.setWidgetResizable(True) self.rightVerticalLayout.addWidget(self.rightTreeView) self.rightTreeView.setSelectionMode(QAbstractItemView.SingleSelection) def connectSlots(self): self.rightArrowPushButton.clicked.connect(self.rightArrowClicked) self.upPushButton.clicked.connect(self.upClicked) self.downPushButton.clicked.connect(self.downClicked) self.deletePushButton.clicked.connect(self.deleteClicked) def rightArrowClicked(self): logger.debug("rightArrowClicked") model = self.logTypeListView.model() trackList = [] if model is not None: for row in range(model.rowCount()): item = model.item(row) if item.checkState() == Qt.Checked: trackList.append(item.text()) self.populateRightListView(trackList) #see https://wiki.python.org/moin/PyQt/Reading%20selections%20from%20a%20selection%20model def upClicked(self): logger.debug("upClicked") promoteList = [] indexes = self.trackListView.selectionModel().selectedIndexes() model = self.trackListView.model() parent = QModelIndex() #selectedItems = self.trackListView.selectionModel().selectedItems() for index in indexes: #item = model.index(index.row(), index.column(), parent) item = self.getComboBoxItemFromIndex(model, index) #promoteList.append(item) promoteList.append(str(item.data())) logger.debug("data: {0}".format(item.data())) promotedList = self.resortRightList(promoteList) self.populateTrackListView(promotedList)
def close(self): """Explicitly called destructor. Removes widget from the qpart """ self._closeIfNotUpdatedTimer.stop() self._qpart.removeEventFilter(self) self._qpart.cursorPositionChanged.disconnect(self._onCursorPositionChanged) QListView.close(self)
def __init__(self, game, parent=None): QListView.__init__(self, parent) self.game = None self.setWindowTitle(m18n('Explain Scores').replace('&', '') + ' - Kajongg') self.setGeometry(0, 0, 300, 400) self.model = QStringListModel() self.setModel(self.model) StateSaver(self) self.refresh(game)
def __init__(self, window): super(NameList, self).__init__('Current Plots') self.namelist_model = QStandardItemModel() self.namelist_view = QListView() self.namelist_view.setModel(self.namelist_model) self.setWidget(self.namelist_view) self.window = window self.plot_dict = {} self.namelist_view.doubleClicked.connect(self.activate_item)
def __init__(self, parent): ''' @param parent - QMainWindow ''' QListView.__init__(self, parent) self.parentWindow = parent self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.setSelectionBehavior(QAbstractItemView.SelectItems) self.viewport().installEventFilter(self)
def __init__(self, curve_source): QListView.__init__(self) self.curve_source = curve_source self.setViewMode(QListView.IconMode) self.setIconSize(QSize(64,64)) self.model = QStandardItemModel() for curve in curve_source._curves: self.add_curve(curve) self.setModel(self.model) self.setWrapping(True) self.show()
def keyPressEvent(self, evt): """ Protected method implementing special key handling. @param evt reference to the event (QKeyEvent) """ if evt.key() in [Qt.Key_Delete, Qt.Key_Backspace] and \ self.model() is not None: self.removeSelected() evt.setAccepted(True) else: QListView.keyPressEvent(self, evt)
def __init__(self, *args): QListView.__init__(self, *args) self.setModel( AppListModel( [WebApp.get_local_apps_dir(), utils.libFile('.')], self)) self.setIconSize(QtCore.QSize(kIconSize, kIconSize)) self.downloadErrShown = False # To be set through functions self.win = None
def __init__(self, base_maps_list, parent=None, thumb_size=64): QListView.__init__(self, parent) self._model = BaseMapsModel(base_maps_list, parent) self.setModel(self._model) self.setEditTriggers(QListView.NoEditTriggers) self.setViewMode(QListView.IconMode) self.setMovement(QListView.Static) self.setResizeMode(QListView.Adjust) #self.setFlow(QListView.TopToBottom) #self.setWrapping(True) #self.setSpacing(0) self.set_thumb_size(thumb_size)
def __init__(self, words): super(CompleteLineEdit, self).__init__(None) self.words = words # QStringList 整个完成列表的单词 self.listView = QListView(self) self.model = QStringListModel(self) self.listView.setWindowFlags(Qt.ToolTip) self.connect(self, SIGNAL("textChanged(const QString &)"), self, SLOT("setCompleter(const QString &)")) self.connect(self.listView, SIGNAL("clicked(const QModelIndex &)"), self, SLOT("completeText(const QModelIndex &)"))
def __init__(self, parent=None, model=None): """ This method initializes the class. :param parent: Object parent. ( QObject ) """ LOGGER.debug("> Initializing '{0}()' class.".format(self.__class__.__name__)) QListView.__init__(self, parent) # --- Setting class attributes. --- self.setModel(model)
def __init__(self, *args, **kwargs): QListView.__init__(self, *args, **kwargs) self.setViewMode(QListView.IconMode) self.setWrapping(False) self.setWordWrap(True) self.setSelectionMode(QListView.SingleSelection) self.setEditTriggers(QListView.NoEditTriggers) self.setMovement(QListView.Static) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) self.setIconSize(QSize(120, 80))
class ResultWin(QMainWindow): """ Window use to display pylint results """ def __init__(self, parent=None): QMainWindow.__init__(self, parent) self.parent = parent try: self.setAttribute(Qt.WA_Maemo5AutoOrientation, True) except AttributeError: pass self.list_view = QListView() self.list_model = ResultModel() self.list_view.setViewMode(QListView.ListMode) self.list_view.setWordWrap(True) self.list_view.setResizeMode(QListView.Adjust) self.list_view.setModel(self.list_model) self.setCentralWidget(self.list_view) def set_results(self, results): """ Set the tuple in the model """ self.list_model.set_data(results) def append_results(self, results): """ Append the tuple in the model """ self.list_model.append_data(results)
def __init_widgets__(self): """ Initialise the widgets of the window. """ # The Address/Attachment portion of the window self.attach_model = MessageAttachmentModel() attach_list = QListView() attach_list.setModel(self.attach_model) tab_bar_pxm = QPixmap('res/msg_tabbar_r.png') self.tab_bar = QTabWidget() self.tab_bar.setTabPosition(2) self.tab_bar.setIconSize(QSize(16, 16)) self.tab_bar.addTab(QWidget(), QIcon(tab_bar_pxm.copy(0, 0, 16, 16)), '') self.tab_bar.addTab(attach_list, QIcon(tab_bar_pxm.copy(0, 16, 16, 16)), '') # The Composition Properties portion of the window self.subject_line = QLineEdit() self.subject_line.setPlaceholderText('Subject') QObject.connect(self.subject_line, SIGNAL('textEdited(QString)'), self.update_title) priority_label = QLabel('Priority:') priority_dropdown = QComboBox(self) priority_dropdown.addItems( ['Highest', 'High', 'Normal', 'Low', 'Lowest']) subject_prio_layout = QHBoxLayout() subject_prio_layout.addWidget(self.subject_line) # subject_prio_layout.addStretch(1) subject_prio_layout.addWidget(priority_label) subject_prio_layout.addWidget(priority_dropdown) # The actual Composition portion of the window self.message = MessageTextEdit(self) # The bottom pane bottom_pane_layout = QVBoxLayout() bottom_pane_layout.addLayout(subject_prio_layout) bottom_pane_layout.addWidget(self.message) bottom_pane = QWidget() bottom_pane.setLayout(bottom_pane_layout) # Central widget is the splitter splitter = QSplitter() splitter.setOrientation(2) splitter.addWidget(self.tab_bar) splitter.addWidget(bottom_pane) self.setCentralWidget(splitter)
class MainForm(QDialog): def __init__(self, parent=None): super(MainForm, self).__init__(parent) self.model = BarGraphModel() self.barGraphView = BarGraphView() self.barGraphView.setModel(self.model) self.listView = QListView() self.listView.setModel(self.model) self.listView.setItemDelegate(BarGraphDelegate(0, 1000, self)) self.listView.setMaximumWidth(100) self.listView.setEditTriggers(QListView.DoubleClicked | QListView.EditKeyPressed) layout = QHBoxLayout() layout.addWidget(self.listView) layout.addWidget(self.barGraphView, 1) self.setLayout(layout) self.setWindowTitle("Bar Grapher") QTimer.singleShot(0, self.initialLoad) def initialLoad(self): # Generate fake data count = 20 self.model.insertRows(0, count - 1) for row in range(count): value = random.randint(1, 150) color = QColor(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) index = self.model.index(row) self.model.setData(index, value) self.model.setData(index, QVariant(color), Qt.UserRole)
def __init__(self, window): super(NameList, self).__init__('Current Plots') self.namelist_model = QStandardItemModel() self.namelist_view = QListView() self.namelist_view.setModel(self.namelist_model) self.setWidget(self.namelist_view) self.window = window self.plot_dict = {} self.namelist_view.doubleClicked.connect(self.activate_item) self.namelist_view.setContextMenuPolicy(QtConst.ActionsContextMenu) delete_action = QAction("Delete Selected", self.namelist_view) delete_action.triggered.connect(self.delete_item) self.namelist_view.addAction(delete_action)
def __init__(self, parent=None): QMainWindow.__init__(self, parent) self.parent = parent try: self.setAttribute(Qt.WA_Maemo5AutoOrientation, True) except AttributeError: pass self.list_view = QListView() self.list_model = ResultModel() self.list_view.setViewMode(QListView.ListMode) self.list_view.setWordWrap(True) self.list_view.setResizeMode(QListView.Adjust) self.list_view.setModel(self.list_model) self.setCentralWidget(self.list_view)
def _setupUi(self): self.setWindowTitle(tr("Re-Prioritize duplicates")) self.resize(700, 400) #widgets msg = tr("Add criteria to the right box and click OK to send the dupes that correspond the " "best to these criteria to their respective group's " "reference position. Read the help file for more information.") self.promptLabel = QLabel(msg) self.promptLabel.setWordWrap(True) self.categoryCombobox = QComboBox() self.criteriaListView = QListView() self.addCriteriaButton = QPushButton(self.style().standardIcon(QStyle.SP_ArrowRight), "") self.removeCriteriaButton = QPushButton(self.style().standardIcon(QStyle.SP_ArrowLeft), "") self.prioritizationListView = QListView() self.prioritizationListView.setAcceptDrops(True) self.prioritizationListView.setDragEnabled(True) self.prioritizationListView.setDragDropMode(QAbstractItemView.InternalMove) self.prioritizationListView.setSelectionBehavior(QAbstractItemView.SelectRows) self.buttonBox = QDialogButtonBox() self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok) # layout self.mainLayout = QVBoxLayout(self) self.mainLayout.addWidget(self.promptLabel) self.splitter = QSplitter() sp = self.splitter.sizePolicy() sp.setVerticalPolicy(QSizePolicy.Expanding) self.splitter.setSizePolicy(sp) self.leftSide = QWidget() self.leftWidgetsLayout = QVBoxLayout() self.leftWidgetsLayout.addWidget(self.categoryCombobox) self.leftWidgetsLayout.addWidget(self.criteriaListView) self.leftSide.setLayout(self.leftWidgetsLayout) self.splitter.addWidget(self.leftSide) self.rightSide = QWidget() self.rightWidgetsLayout = QHBoxLayout() self.addRemoveButtonsLayout = QVBoxLayout() self.addRemoveButtonsLayout.addItem(verticalSpacer()) self.addRemoveButtonsLayout.addWidget(self.addCriteriaButton) self.addRemoveButtonsLayout.addWidget(self.removeCriteriaButton) self.addRemoveButtonsLayout.addItem(verticalSpacer()) self.rightWidgetsLayout.addLayout(self.addRemoveButtonsLayout) self.rightWidgetsLayout.addWidget(self.prioritizationListView) self.rightSide.setLayout(self.rightWidgetsLayout) self.splitter.addWidget(self.rightSide) self.mainLayout.addWidget(self.splitter) self.mainLayout.addWidget(self.buttonBox)
def __init__(self): super(FeedWatchWidget, self).__init__() self.feedList = AmuleFeedWatcher() self.eventList = EventServer.events # Control buttons: check now, add feed, remove feed checkNowButton = QPushButton('Check feeds now!') self.connect(checkNowButton, SIGNAL('clicked()'), self.checkNow) addFeedButton = QPushButton('Add feed...') self.connect(addFeedButton, SIGNAL('clicked()'), self.addFeed) removeFeedButton = QPushButton('Remove feed...') self.connect(removeFeedButton, SIGNAL('clicked()'), self.removeFeed) buttons = QHBoxLayout() buttons.addWidget(addFeedButton) buttons.addWidget(removeFeedButton) buttons.addStretch() buttons.addWidget(checkNowButton) # main layout layout = QVBoxLayout() self.feedView = QListView() self.feedView.setModel(self.feedList) layout.addWidget(self.feedView) self.connect(self.feedView, SIGNAL('doubleClicked(const QModelIndex&)'), self.feedEdit) layout.addLayout(buttons) self.eventView = QListView() self.eventView.setSelectionMode(QAbstractItemView.NoSelection) self.eventView.setModel(self.eventList) layout.addWidget(self.eventView) self.setLayout(layout) # check for feeds every 2 hours self.timer = QTimer(self) self.connect(self.timer, SIGNAL('timeout()'), self.checkNow) self.timer.start(2*60*60*1000)
def __init__(self): super().__init__() self.data = None self.component_x = 0 self.component_y = 1 box = gui.vBox(self.controlArea, "Variables") self.varlist = itemmodels.VariableListModel() self.varview = view = QListView(selectionMode=QListView.MultiSelection) view.setModel(self.varlist) view.selectionModel().selectionChanged.connect(self._var_changed) box.layout().addWidget(view) axes_box = gui.vBox(self.controlArea, "Axes") box = gui.vBox(axes_box, "Axis X", margin=0) box.setFlat(True) self.axis_x_cb = gui.comboBox( box, self, "component_x", callback=self._component_changed) box = gui.vBox(axes_box, "Axis Y", margin=0) box.setFlat(True) self.axis_y_cb = gui.comboBox( box, self, "component_y", callback=self._component_changed) self.infotext = gui.widgetLabel( gui.vBox(self.controlArea, "Contribution to Inertia"), "\n" ) gui.rubber(self.controlArea) self.plot = pg.PlotWidget(background="w") self.plot.setMenuEnabled(False) self.mainArea.layout().addWidget(self.plot)
def initGUI(self): self.setWindowTitle(QApplication.applicationName()) layout = QVBoxLayout() headerlayout = QHBoxLayout() homeBtn = QToolButton() homeBtn.setIcon(self.ih.homeButton) homeBtn.setFixedSize(64,64) homeBtn.clicked.connect(self.home) headerlayout.addWidget(homeBtn) label = QLabel("<b>Location</b>") label.setMargin(10) label.setFixedSize(label.sizeHint()) headerlayout.addWidget(label) self.currentLocation = ClickableLabel("") self.currentLocation.setAlignment(Qt.AlignLeft | Qt.AlignVCenter) self.currentLocation.setWordWrap(True) self.currentLocation.setFixedSize(400,64) self.currentLocation.clicked.connect(self.back) headerlayout.addWidget(self.currentLocation) headerlayout.addStretch() layout.addLayout(headerlayout) self.view = QListView() self.view.setSelectionMode( QAbstractItemView.SingleSelection) self.view.setEditTriggers(QAbstractItemView.NoEditTriggers) self.view.setContextMenuPolicy(Qt.CustomContextMenu) self.view.customContextMenuRequested.connect(self.contextMenu) self.view.setModel(self.model) self.view.setModelColumn(0) #self.view.doubleClicked.connect(self.doubleClicked) self.view.activated.connect(self.activated) layout.addWidget(self.view) self.setLayout(layout)
def setupGUI(self): layout = QGridLayout() self.widget = QWidget() self.widget.setLayout(layout) self.setCentralWidget(self.widget) self.setWindowTitle("Nutch Job Service") # create active job list active_label = QLabel("Active Hadoop Jobs") layout.addWidget(active_label, 0, 0) self.lv = QListView() layout.addWidget(self.lv, 1, 0, 3, 1) # Create buttons self.stop_button = QPushButton("Stop") self.refresh_button = QPushButton("Refresh") button_layout = QVBoxLayout() button_layout.addWidget(self.stop_button) button_layout.addWidget(self.refresh_button) layout.addLayout(button_layout, 1, 1) # Start Button self.new_job_layout = QHBoxLayout() self.new_job_combo = QComboBox() self.new_job_combo.addItems(["Inject", "Generate", "Fetch", "Parse", "Solr"]) self.new_job_button = QPushButton("Start New Job") self.new_job_layout.addWidget(self.new_job_combo) self.new_job_layout.addWidget(self.new_job_button) layout.addLayout(self.new_job_layout, 5, 0) # self.statusBar() self.connectSlots()
def eventFilter(self, obj, event): ''' @param obj QObject @paramn event QEvent ''' # if (event.type() == QEvent.MouseButtonPress): # print "Mouse pressed" # if (event.type() == QEvent.ContextMenu): # Now we know that event is an instance of QContextMenuEvent menu = QMenu(self) newPos = self.adjustPosition(event.pos()) modelIndex = self.indexAt(newPos) self.showTransactions = QAction(self.tr("Show transactions"), self) menu.addAction(self.showTransactions) self.connect(self.showTransactions, SIGNAL("triggered()"), lambda : self.parentWindow.showTransactionsForPosition(modelIndex)) self.openWebpage = QAction(self.tr("Open Google Finance webpage"), self) menu.addAction(self.openWebpage) self.connect(self.openWebpage, SIGNAL("triggered()"), lambda : self.parentWindow.openWebpageForPosition(modelIndex)) menu.exec_(event.globalPos()) return QListView.eventFilter(self, obj, event)
def setupUI(self): lay = QVBoxLayout() lay.setContentsMargins(0, 0, 0, 0) self.removeButton = QPushButton(QIcon(QPixmap("img/moduleRemove.png")), "") self.addButton = QPushButton(QIcon(QPixmap("img/moduleAdd.png")),"") self.reloadButton = QPushButton(QIcon(QPixmap("img/moduleReload.png")), "") self.model = Model(self) self.list = QListView() self.list.setModel(self.model) self.list.setIconSize(QSize(32, 32)) lay.addWidget(self.list) hlay = QHBoxLayout() hlay.setContentsMargins(0, 0, 0, 0) hlay.addWidget(self.reloadButton) hlay.addStretch() hlay.addWidget(self.removeButton) hlay.addWidget(self.addButton) lay.addLayout(hlay) self.setLayout(lay) self.addButton.clicked.connect(self.addButtonClick) self.removeButton.clicked.connect(self.removeButtonClick) self.reloadButton.clicked.connect(self.reloadButtonClick) self.list.doubleClicked.connect(self.selectStrategy) self.modules = {}
def setup_ui(self): self.resize(800, 480) self.grid = QGridLayout(self) self.display = pg.PlotWidget(name='st', background='w') add_circles(self.display, (1, 2)) self.grid.addWidget(self.display, 0, 0, 2, 2) self.display.getViewBox().setXRange(-np.pi, np.pi) self.display.getViewBox().setYRange(-np.pi/2, np.pi/2) self.display.getViewBox().setAspectLocked() self.list_view = QListView(self) self.grid.addWidget(self.list_view, 0, 2, 1, 2) self.letter_selector = QComboBox(self) self.grid.addWidget(self.letter_selector, 1, 2, 1, 2) self.preview_btn = QPushButton(self) self.preview_btn.setText('Preview 3D') self.grid.addWidget(self.preview_btn, 2, 0, 1, 1) self.create_core_btn = QPushButton(self) self.create_core_btn.setText('Create core') self.grid.addWidget(self.create_core_btn, 2, 1, 1, 1) self.letter_edt = QLineEdit(self) self.grid.addWidget(self.letter_edt, 2, 2, 1, 1) self.set_letter_btn = QPushButton(self) self.set_letter_btn.setText('Set') self.grid.addWidget(self.set_letter_btn, 2, 3, 1, 1)
def checkablePopup(self): """ Returns the popup if this widget is checkable. :return <QListView> || None """ if (not self._checkablePopup and self.isCheckable()): popup = QListView(self) popup.setSelectionMode(QListView.NoSelection) popup.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) popup.setWindowFlags(Qt.Popup) popup.installEventFilter(self) popup.doubleClicked.connect(self.checkModelIndex) self._checkablePopup = popup return self._checkablePopup
def __init__(self): super().__init__() self.data = None self.input_vars = () self._invalidated = False box = gui.widgetBox(self.controlArea, "Domain Features") self.domain_model = itemmodels.VariableListModel() self.domain_view = QListView( selectionMode=QListView.SingleSelection ) self.domain_view.setModel(self.domain_model) self.domain_view.selectionModel().selectionChanged.connect( self._on_selection_changed) box.layout().addWidget(self.domain_view) box = gui.widgetBox(self.controlArea, "Reset") gui.button(box, self, "Reset selected", callback=self.reset_selected) gui.button(box, self, "Reset all", callback=self.reset_all) gui.auto_commit(self.controlArea, self, "autocommit", "Commit", "Commit on change is on") box = gui.widgetBox(self.mainArea, "Edit") self.editor_stack = QtGui.QStackedWidget() self.editor_stack.addWidget(DiscreteVariableEditor()) self.editor_stack.addWidget(ContinuousVariableEditor()) self.editor_stack.addWidget(VariableEditor()) box.layout().addWidget(self.editor_stack)
def __init__(self): QWidget.__init__(self) self.__filter_popup = FilterPopup(self) self.__filter_popup.filterSettingsChanged.connect(self.onItemChanged) layout = QVBoxLayout() self.model = DataTypeKeysListModel() self.filter_model = DataTypeProxyModel(self.model) filter_layout = QHBoxLayout() self.search_box = SearchBox() self.search_box.filterChanged.connect(self.setSearchString) filter_layout.addWidget(self.search_box) filter_popup_button = QToolButton() filter_popup_button.setIcon(util.resourceIcon("ide/cog_edit.png")) filter_popup_button.clicked.connect(self.showFilterPopup) filter_layout.addWidget(filter_popup_button) layout.addLayout(filter_layout) self.data_type_keys_widget = QListView() self.data_type_keys_widget.setModel(self.filter_model) self.data_type_keys_widget.selectionModel().selectionChanged.connect(self.itemSelected) layout.addSpacing(15) layout.addWidget(self.data_type_keys_widget, 2) layout.addStretch() # layout.addWidget(Legend("Default types", DataTypeKeysListModel.DEFAULT_DATA_TYPE)) layout.addWidget(Legend("Observations available", DataTypeKeysListModel.HAS_OBSERVATIONS)) self.setLayout(layout)
def __init__(self, id, text="Input data", default=[], model=None): QWidget.__init__(self) self.setToolTip("<p>Select input dataset</p>") self.id = id if model is None: self.model = TreeModel() else: self.model = model self.comboBox = QComboBox() self.treeView = QListView(self.comboBox) self.connect(self.comboBox, SIGNAL("currentIndexChanged(int)"), self.changeSelectedText) self.proxyModel = SortFilterProxyModel() self.proxyModel.setDynamicSortFilter(True) self.proxyModel.setFilterKeyColumn(1) self.proxyModel.setSourceModel(self.model) regexp = QRegExp("|".join([r"%s" % i for i in default])) self.proxyModel.setFilterRegExp(regexp) # self.treeView.header().hide() self.currentText = QString() self.treeView.setModel(self.proxyModel) self.comboBox.setModel(self.proxyModel) self.comboBox.setView(self.treeView) # self.treeView.hideColumn(1) # self.treeView.hideColumn(2) # self.treeView.hideColumn(3) self.treeView.viewport().installEventFilter(self.comboBox) label = QLabel(text) hbox = HBoxLayout() hbox.addWidget(label) hbox.addWidget(self.comboBox) self.setLayout(hbox) self.changeSelectedText(None)
def __init__(self, parent): QFrame.__init__(self, parent) self.setContentsMargins(0, 0, 0, 0) layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(1) self._setNameLineEdit = QLineEdit(self) layout.addWidget(self._setNameLineEdit) self._setListView = QListView(self) self._listModel = QStandardItemModel(self) self._proxyModel = QSortFilterProxyModel(self) self._proxyModel.setSourceModel(self._listModel) self._setListView.setModel(self._proxyModel) self._setListView.setItemDelegate(ListItemDelegate(self)) self._setNameLineEdit.textChanged.connect( self._proxyModel.setFilterFixedString) self._completer = QCompleter(self._listModel, self) self._setNameLineEdit.setCompleter(self._completer) self._listModel.itemChanged.connect(self._onSetNameChange) layout.addWidget(self._setListView) buttonLayout = QHBoxLayout() self._addAction = QAction( "+", self, toolTip="Add a new sort key") self._updateAction = QAction( "Update", self, toolTip="Update/save current selection") self._removeAction = QAction( "\u2212", self, toolTip="Remove selected sort key.") self._addToolButton = QToolButton(self) self._updateToolButton = QToolButton(self) self._removeToolButton = QToolButton(self) self._updateToolButton.setSizePolicy( QSizePolicy.MinimumExpanding, QSizePolicy.Minimum) self._addToolButton.setDefaultAction(self._addAction) self._updateToolButton.setDefaultAction(self._updateAction) self._removeToolButton.setDefaultAction(self._removeAction) buttonLayout.addWidget(self._addToolButton) buttonLayout.addWidget(self._updateToolButton) buttonLayout.addWidget(self._removeToolButton) layout.addLayout(buttonLayout) self.setLayout(layout) self._addAction.triggered.connect(self.addCurrentSelection) self._updateAction.triggered.connect(self.updateSelectedSelection) self._removeAction.triggered.connect(self.removeSelectedSelection) self._setListView.selectionModel().selectionChanged.connect( self._onListViewSelectionChanged) self.selectionModel = None self._selections = []
def __init__(self, parent=None, signalManger=None, title="Data Sort"): super(OWDataSort, self).__init__(parent, signalManger, title, wantMainArea=False) #: Mapping (feature.name, feature.var_type) to (sort_index, sort_order) #: where sirt index is the position of the feature in the sortByModel #: and sort_order the Qt.SortOrder flag self.sortroles = {} self.autoCommit = False self._outputChanged = False box = OWGUI.widgetBox(self.controlArea, "Sort By Features") self.sortByView = QListView() self.sortByView.setItemDelegate(SortParamDelegate(self)) self.sortByView.setSelectionMode(QListView.ExtendedSelection) self.sortByView.setDragDropMode(QListView.DragDrop) self.sortByView.setDefaultDropAction(Qt.MoveAction) self.sortByView.viewport().setAcceptDrops(True) self.sortByModel = VariableListModel( flags=Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsDragEnabled | Qt.ItemIsEditable ) self.sortByView.setModel(self.sortByModel) box.layout().addWidget(self.sortByView) box = OWGUI.widgetBox(self.controlArea, "Unused Features") self.unusedView = QListView() self.unusedView.setSelectionMode(QListView.ExtendedSelection) self.unusedView.setDragDropMode(QListView.DragDrop) self.unusedView.setDefaultDropAction(Qt.MoveAction) self.unusedView.viewport().setAcceptDrops(True) self.unusedModel = VariableListModel( flags=Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsDragEnabled ) self.unusedView.setModel(self.unusedModel) box.layout().addWidget(self.unusedView) box = OWGUI.widgetBox(self.controlArea, "Output") cb = OWGUI.checkBox(box, self, "autoCommit", "Auto commit") b = OWGUI.button(box, self, "Commit", callback=self.commit) OWGUI.setStopper(self, b, cb, "_outputChanged", callback=self.commit)
def _setup_gui_values(self): self.values_edit = QListView() self.values_edit.setEditTriggers(QTreeView.CurrentChanged) self.values_model = itemmodels.PyListModel(flags=Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable) self.values_edit.setModel(self.values_model) self.values_model.dataChanged.connect(self.on_values_changed) self.main_form.addRow("Values:", self.values_edit)
def __init__(self, parent): QFrame.__init__(self, parent) self.setFrameStyle(QFrame.Box | QFrame.Sunken) self.setStyleSheet("QListView {background: transparent; }") self.setLayout(QHBoxLayout()) self.layout().setContentsMargins(0, 0, 0, 0) self.listView = QListView(self) self.layout().addWidget(self.listView) self.listView.setModel(self.window().quickAccessModel) self.listView.setMovement(QListView.Snap) self.listView.setFlow(QListView.LeftToRight) self.listView.setResizeMode(QListView.Adjust) gridSize = self.logicalDpiX() / 96 * 60 self.listView.setGridSize(QSize(gridSize, gridSize)) self.listView.setViewMode(QListView.IconMode) self.listView.activated.connect(self.listView.model().runShortcut)
def test_drop_shadow_old(self): w = dropshadow._DropShadowWidget() w.setContentsMargins(20, 20, 20, 20) w.setLayout(QHBoxLayout()) w.layout().setContentsMargins(0, 0, 0, 0) w.layout().addWidget(QListView()) w.show() QTimer.singleShot(1500, lambda: w.setRadius(w.radius + 5)) self.app.exec_()
def __init__(self, parent=None): super(MainForm, self).__init__(parent) self.model = BarGraphModel() self.barGraphView = BarGraphView() self.barGraphView.setModel(self.model) self.listView = QListView() self.listView.setModel(self.model) self.listView.setItemDelegate(BarGraphDelegate(0, 1000, self)) self.listView.setMaximumWidth(100) self.listView.setEditTriggers(QListView.DoubleClicked | QListView.EditKeyPressed) layout = QHBoxLayout() layout.addWidget(self.listView) layout.addWidget(self.barGraphView, 1) self.setLayout(layout) self.setWindowTitle("Bar Grapher") QTimer.singleShot(0, self.initialLoad)
def __init__(self, qpart, model): QListView.__init__(self, qpart.viewport()) # ensure good selected item background on Windows palette = self.palette() palette.setColor(palette.Inactive, palette.Highlight, palette.color(palette.Active, palette.Highlight)) self.setPalette(palette) self.setAttribute(Qt.WA_DeleteOnClose) self.setItemDelegate(HTMLDelegate(self)) self._qpart = qpart self.setFont(qpart.font()) self.setCursor(QCursor(Qt.PointingHandCursor)) self.setFocusPolicy(Qt.NoFocus) self.setModel(model) self._selectedIndex = -1 # if cursor moved, we shall close widget, if its position (and model) hasn't been updated self._closeIfNotUpdatedTimer = QTimer(self) self._closeIfNotUpdatedTimer.setInterval(200) self._closeIfNotUpdatedTimer.setSingleShot(True) self._closeIfNotUpdatedTimer.timeout.connect( self._afterCursorPositionChanged) qpart.installEventFilter(self) qpart.cursorPositionChanged.connect(self._onCursorPositionChanged) self.clicked.connect(lambda index: self.itemSelected.emit(index.row())) self.updateGeometry() self.show() qpart.setFocus()
def __init__(self, parent=None): QListView.__init__(self, parent) self.game_list = [] self.model = QStandardItemModel() self.setModel(self.model) self.setWordWrap(True) self.setUniformItemSizes(True) self.setGridSize(QSize(self.rect().width(), 30)) self.setFont(QFont("Microsoft YaHei", 10)) self.setEditTriggers(QAbstractItemView.NoEditTriggers) # self.setFocusPolicy(Qt.NoFocus) self.setSelectionMode(QAbstractItemView.SingleSelection) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) #self.setAcceptDrops(True) self.game_controller = GameController() self.game_controller.connector.connect(SIGNAL('game_list'), self.add_game_item) self.game_controller.connector.connect(SIGNAL('game_list_clear'), self.clear) self.clicked.connect(self.double_click_on_item) ## ??????
def list_view(self): list = QListView() # Create an empty model for the list's data # model = QStandardItemModel(list) repo = LocusRepository() locusList = repo.get_all_locus() # Create an empty model for the list's data model = QStandardItemModel(list) for locus in locusList: # Create an item with a caption item = QStandardItem(locus.locus_id) # Add the item to the model model.appendRow(item) model.itemChanged.connect(self.on_item_changed) # current_index = 0 # list.currentChanged(current_index) # list.selectionModel().currentChanged.connect(on_current_changed) # self.listWidget.itemClicked.connect(self.printItemText) # app.connect(list, SIGNAL("currentChanged()"), # printItemText) # Apply the model to the list view list.setModel(model) list.selectionModel().currentChanged.connect(self.on_current_changed) self.horizontalLayout_1.addWidget(list)