def __init__(self, all_authors, parent): QListWidget.__init__(self, parent) self.setDragEnabled(True) self.setSelectionMode(self.ExtendedSelection) self.setDropIndicatorShown(True) self.setDragDropMode(self.InternalMove) self.setAlternatingRowColors(True) self.d = ItemDelegate(all_authors, self) self.d.edited.connect(self.edited, type=Qt.QueuedConnection) self.setItemDelegate(self.d)
def __init__(self, parent, layerSet=None): QListWidget.__init__(self, parent) self.setSelectionMode(QAbstractItemView.SingleSelection) if layerSet: self._layerSet = layerSet else: self._layerSet = GLayerSet() if layerSet: for l in layerSet.rawLayers: self.addItem(QListWidgetItem(l.name(), self)) self.show()
def __init__(self, parent=None): QListWidget.__init__(self, parent) self.setSelectionMode(self.ExtendedSelection)
def __init__(self, parentWidget, label = '', labelColumn = 0, items = [], defaultRow = 0, setAsDefault = True, heightByRows = 6, spanWidth = False ): """ Appends a QListWidget (Qt) widget to the bottom of I{parentWidget}, a Property Manager group box. @param parentWidget: The parent group box containing this widget. @type parentWidget: PM_GroupBox @param label: The label that appears to the left or right of the checkbox. If spanWidth is True, the label will be displayed on its own row directly above the list widget. To suppress the label, set I{label} to an empty string. @type label: str @param labelColumn: The column number of the label in the group box grid layout. The only valid values are 0 (left column) and 1 (right column). The default is 0 (left column). @type labelColumn: int @param items: list of items (strings) to be inserted in the widget. @type items: list @param defaultRow: The default row (item) selected, where 0 is the first row. @type defaultRow: int @param setAsDefault: If True, will restore <idx> as the current index when the "Restore Defaults" button is clicked. @type setAsDefault: bool @param heightByRows: The height of the list widget. @type heightByRows: int @param spanWidth: If True, the widget and its label will span the width of the group box. Its label will appear directly above the widget (unless the label is empty) and is left justified. @type spanWidth: bool @see: U{B{QListWidget}<http://doc.trolltech.com/4/qlistwidget.html>} """ if 0: # Debugging code print "PM_ListWidget.__init__():" print " label = ", label print " labelColumn = ", labelColumn print " items = ", items print " defaultRow = ", defaultRow print " setAsDefault = ", setAsDefault print " heightByRows = ", heightByRows print " spanWidth = ", spanWidth QListWidget.__init__(self) self.parentWidget = parentWidget self.label = label self.labelColumn = labelColumn self.setAsDefault = setAsDefault self.spanWidth = spanWidth if label: # Create this widget's QLabel. self.labelWidget = QLabel() self.labelWidget.setText(label) # Load QComboBox widget choice items and set initial choice (index). self.insertItems(0, items, setAsDefault) self.setCurrentRow(defaultRow, setAsDefault) # Set height of list widget. margin = self.fontMetrics().leading() * 2 # Mark 2007-05-28 height = heightByRows * self.fontMetrics().lineSpacing() + margin self.setMaximumHeight(height) #As of 2008-04-16, the items in any list widgets won't be sorted #automatically. It can be changes by simply uncommentting the lines #below -- Ninad ##self.setSortingEnabled(True) ##self.sortItems() self.setAlternatingRowColors(True) parentWidget.addPmWidget(self)
def __init__(self, parentWidget, label='', labelColumn=0, items=[], defaultRow=0, setAsDefault=True, heightByRows=6, spanWidth=False): """ Appends a QListWidget (Qt) widget to the bottom of I{parentWidget}, a Property Manager group box. @param parentWidget: The parent group box containing this widget. @type parentWidget: PM_GroupBox @param label: The label that appears to the left or right of the checkbox. If spanWidth is True, the label will be displayed on its own row directly above the list widget. To suppress the label, set I{label} to an empty string. @type label: str @param labelColumn: The column number of the label in the group box grid layout. The only valid values are 0 (left column) and 1 (right column). The default is 0 (left column). @type labelColumn: int @param items: list of items (strings) to be inserted in the widget. @type items: list @param defaultRow: The default row (item) selected, where 0 is the first row. @type defaultRow: int @param setAsDefault: If True, will restore <idx> as the current index when the "Restore Defaults" button is clicked. @type setAsDefault: bool @param heightByRows: The height of the list widget. @type heightByRows: int @param spanWidth: If True, the widget and its label will span the width of the group box. Its label will appear directly above the widget (unless the label is empty) and is left justified. @type spanWidth: bool @see: U{B{QListWidget}<http://doc.trolltech.com/4/qlistwidget.html>} """ if 0: # Debugging code print "PM_ListWidget.__init__():" print " label = ", label print " labelColumn = ", labelColumn print " items = ", items print " defaultRow = ", defaultRow print " setAsDefault = ", setAsDefault print " heightByRows = ", heightByRows print " spanWidth = ", spanWidth QListWidget.__init__(self) self.parentWidget = parentWidget self.label = label self.labelColumn = labelColumn self.setAsDefault = setAsDefault self.spanWidth = spanWidth if label: # Create this widget's QLabel. self.labelWidget = QLabel() self.labelWidget.setText(label) # Load QComboBox widget choice items and set initial choice (index). self.insertItems(0, items, setAsDefault) self.setCurrentRow(defaultRow, setAsDefault) # Set height of list widget. margin = self.fontMetrics().leading() * 2 # Mark 2007-05-28 height = heightByRows * self.fontMetrics().lineSpacing() + margin self.setMaximumHeight(height) #As of 2008-04-16, the items in any list widgets won't be sorted #automatically. It can be changes by simply uncommentting the lines #below -- Ninad ##self.setSortingEnabled(True) ##self.sortItems() self.setAlternatingRowColors(True) parentWidget.addPmWidget(self)
def __init__(self, *args): QListWidget.__init__(self, *args) self.setContextMenuPolicy(Qt.CustomContextMenu) QObject.connect(self, SIGNAL('customContextMenuRequested(const QPoint &)'), self._request_context_menu)