2019년 7월 22일 월요일
Is there a way to perform “if” in python's lambda
The syntax you're looking for:
lambda x: True if x % 2 == 0 else False
But you can't use
print
or raise
in a lambda.2019년 7월 18일 목요일
Qlist selection mode
enum QAbstractItemView::SelectionMode
This enum indicates how the view responds to user selections:
Constant | Value | Description |
---|---|---|
QAbstractItemView::SingleSelection | 1 | When the user selects an item, any already-selected item becomes unselected, and the user cannot unselect the selected item by clicking on it. |
QAbstractItemView::ContiguousSelection | 4 | When the user selects an item in the usual way, the selection is cleared and the new item selected. However, if the user presses the Shift key while clicking on an item, all items between the current item and the clicked item are selected or unselected, depending on the state of the clicked item. |
QAbstractItemView::ExtendedSelection | 3 | When the user selects an item in the usual way, the selection is cleared and the new item selected. However, if the user presses the Ctrl key when clicking on an item, the clicked item gets toggled and all other items are left untouched. If the user presses the Shift key while clicking on an item, all items between the current item and the clicked item are selected or unselected, depending on the state of the clicked item. Multiple items can be selected by dragging the mouse over them. |
QAbstractItemView::MultiSelection | 2 | When the user selects an item in the usual way, the selection status of that item is toggled and the other items are left alone. Multiple items can be toggled by dragging the mouse over them. |
QAbstractItemView::NoSelection | 0 | Items cannot be selected. |
The most commonly used modes are SingleSelection and ExtendedSelection.
2019년 7월 14일 일요일
Remove selected item from the list
def removeSel(self):
listItems=self.listA.selectedItems()
if not listItems: return
for item in listItems:
self.listA.takeItem(self.listA.row(item))
2019년 7월 9일 화요일
PyQt UI로 디렉토리, 파일 경로 얻기
QtGui.QFileDialog.getExistingDirectory(self, 'Open Folder', 'c:/')
QtGui.QFileDialog.getOpenFileName(self, 'Open File', 'c:/')
QtGui.QFileDialog.getOpenFileName(self, 'Open File', 'c:/')
피드 구독하기:
글 (Atom)