本文整理汇总了Python中PySide.QtGui.QListWidget.setSelectionMode方法的典型用法代码示例。如果您正苦于以下问题:Python QListWidget.setSelectionMode方法的具体用法?Python QListWidget.setSelectionMode怎么用?Python QListWidget.setSelectionMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QListWidget
的用法示例。
在下文中一共展示了QListWidget.setSelectionMode方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addTab
# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import setSelectionMode [as 别名]
def addTab(self, label ):
layoutWidget = QWidget()
vLayout = QVBoxLayout(layoutWidget)
vLayout.setContentsMargins(5,5,5,5)
setFolderLayout = QHBoxLayout()
listWidget = QListWidget()
listWidget.setSelectionMode( QAbstractItemView.ExtendedSelection )
vLayout.addLayout( setFolderLayout )
vLayout.addWidget( listWidget )
lineEdit = QLineEdit()
setFolderButton = QPushButton( 'Set Folder' )
setFolderLayout.addWidget( lineEdit )
setFolderLayout.addWidget( setFolderButton )
QtCore.QObject.connect( setFolderButton, QtCore.SIGNAL( 'clicked()' ), Functions.setFolder )
QtCore.QObject.connect( listWidget, QtCore.SIGNAL( 'itemSelectionChanged()' ), Functions.loadImagePathArea )
QtCore.QObject.connect( lineEdit, QtCore.SIGNAL( 'textChanged()' ), Functions.lineEdited )
listWidget.setObjectName( Window_global.listWidgetObjectName )
lineEdit.setContextMenuPolicy( QtCore.Qt.NoContextMenu )
lineEdit.setObjectName( Window_global.lineEditObjectName )
lineEdit.returnPressed.connect( Functions.lineEdited )
super( Tab, self ).addTab( layoutWidget, label )
示例2: TestWindow
# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import setSelectionMode [as 别名]
class TestWindow(QMainWindow):
def __init__(self):
super(TestWindow, self).__init__()
self.setWindowTitle('PySide QListWidget Problem')
self._list = QListWidget(self)
self._list.insertItems(0, [str(i + 1) for i in xrange(50)])
# This line seems to be the problem. Change "Contiguous" to "Single"
# and item deletion does not cause the list to scroll to the top.
self._list.setSelectionMode(QAbstractItemView.ContiguousSelection)
button = QPushButton('Delete', self)
button.clicked.connect(self._on_button_clicked)
box = QVBoxLayout()
box.addWidget(self._list)
box.addWidget(button)
widget = QWidget()
widget.setLayout(box)
self.setCentralWidget(widget)
def _on_button_clicked(self):
l = self._list
for item in l.selectedItems():
l.takeItem(l.row(item))
示例3: HiddenDialog
# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import setSelectionMode [as 别名]
class HiddenDialog(QDialog):
lifelines = None
def __init__(self, hiddenLifeline, parent = None):
super(HiddenDialog, self).__init__(parent)
self.lifelines = hiddenLifeline
layout = QVBoxLayout(self)
listTitle = QLabel('Hidden Life-lines')
layout.addWidget(listTitle)
self.listHiddenLifelines = QListWidget()
self.listHiddenLifelines.setFixedWidth(400)
self.listHiddenLifelines.setSelectionMode(QtGui.QAbstractItemView.MultiSelection)
for text in self.lifelines:
item = QtGui.QListWidgetItem(text)
self.listHiddenLifelines.addItem(item)
layout.addWidget(self.listHiddenLifelines)
buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel, QtCore.Qt.Horizontal, self)
buttons.button(QDialogButtonBox.Ok).setText('Show')
buttons.accepted.connect(self.accept)
buttons.rejected.connect(self.reject)
layout.addWidget(buttons)
@staticmethod
def getSelectedItems(lifelines, parent = None):
dialog = HiddenDialog(lifelines,parent)
result = dialog.exec_()
return (result, [str(x.text()) for x in dialog.listHiddenLifelines.selectedItems()])
示例4: __init__
# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import setSelectionMode [as 别名]
def __init__(self ):
QWidget.__init__( self )
layout = QVBoxLayout( self )
label = QLabel()
listWidget = QListWidget()
listWidget.setSelectionMode( QAbstractItemView.ExtendedSelection )
hLayout = QHBoxLayout()
buttonLoad = QPushButton( "LOAD")
buttonRemove = QPushButton( "REMOVE")
hLayout.addWidget( buttonLoad )
hLayout.addWidget( buttonRemove )
layout.addWidget( label )
layout.addWidget( listWidget )
layout.addLayout( hLayout )
self.label = label
self.listWidget = listWidget
self.buttonLoad = buttonLoad
self.buttonRemove = buttonRemove
QtCore.QObject.connect( self.buttonLoad, QtCore.SIGNAL( 'clicked()' ), self.loadCommand )
QtCore.QObject.connect( self.buttonRemove, QtCore.SIGNAL( 'clicked()' ), self.removeCommand )
示例5: MultiListDialog
# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import setSelectionMode [as 别名]
class MultiListDialog(QDialog):
def __init__(self, items): # , parent=None
super(MultiListDialog, self).__init__() # parent
self.resize(800, 550)
self.entries = items
layout = QVBoxLayout(self)
self.listWidget = QListWidget(self)
self.listWidget.setSelectionMode(QAbstractItemView.ExtendedSelection)
self.HlineInputfiles = ConfigLineDir(u"Verzeichnis NI XML:", "dir")
self.HlineOutputfiles = ConfigLineDir(u"Verzeichnis Report:", "dir")
if os.path.isfile(PICKLE_TEMP_FILE):
pkl_file = open(PICKLE_TEMP_FILE, 'rb')
inPath = pickle.load(pkl_file)
outPath = pickle.load(pkl_file)
pkl_file.close()
if os.path.isdir(inPath):
self.HlineInputfiles.editText.setText(inPath)
if os.path.isdir(outPath):
self.HlineOutputfiles.editText.setText(outPath)
layout.addLayout(self.HlineInputfiles)
layout.addLayout(self.HlineOutputfiles)
layout.addWidget(self.listWidget)
layout.addWidget(QLabel("Mehrfachauswahl -> Strg + Mausklick"))
# OK and Cancel buttons
buttons = QDialogButtonBox(QDialogButtonBox.Apply | QDialogButtonBox.Close, Qt.Horizontal, self)
# Apply before Close
buttons.setStyleSheet("* { button-layout: 2 }")
layout.addWidget(buttons)
buttons.rejected.connect(self.close)
buttons.button(QDialogButtonBox.Apply).clicked.connect(self.Apply_Clicked)
self.SetListItems()
self.HlineInputfiles.editText.textChanged.connect(self.RefreshList)
self.HlineInputfiles.editText.textChanged.connect(self.SetListItems)
# def SetOutputDir(self):
# self.HlineOutputfiles.editText.setText(self.HlineInputfiles.getText())
def SetListItems(self, parent=None):
itemslist = os.listdir(self.HlineInputfiles.getText())
for it in itemslist:
if it.endswith(".xml"):
self.listWidget.addItem(it)
def GetMarkedItems(self):
results = []
try:
for el in self.listWidget.selectedItems():
results.append(str(el.text()))
return (results)
except:
return (None)
def RefreshList(self):
self.listWidget.clear()
print "refresh"
def Apply_Clicked(self):
SelectedItems = self.GetMarkedItems()
textMsg = "Selektierte Dateie(n):\r\n"
if len(SelectedItems) > 0:
for file in SelectedItems:
filePath = os.path.join(self.HlineInputfiles.getText(), file)
textMsg += (file + "\r\n")
XmlAnalysis.XmlAnalysis(filePath, self.HlineOutputfiles.getText())
#QMessageBox.information(self, "Report", textMsg)
textMsg += "\r\nReport-Verzeichnis öffnen?\r\n"
msgBox = QMessageBox.StandardButton.Yes
msgBox |= QMessageBox.StandardButton.No
if QMessageBox.question(self, "Report", textMsg, msgBox) == QMessageBox.Yes:
os.startfile(self.HlineOutputfiles.getText())
else:
QMessageBox.warning(self, "Achtung", "Keine Datei selektiert!")
pass
示例6: ToolBox
# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import setSelectionMode [as 别名]
#.........这里部分代码省略.........
self.buttonCapture.setText('Capture')
if const.STATE_INTERACTIVE_RESET == state:
self.buttonCapture.setEnabled(True)
self.buttonCapture.setText('Capture')
elif const.STATE_INTERACTIVE_ACTIVE == state:
self.buttonCapture.setEnabled(True)
self.buttonCapture.setText('Capture')
def setMessageInfo(self,info):
self.msgInfo.setText(info)
def setAvailable(self,threads):
self.sig.emit(threads)
def toggleThreadDisplay(self,item):
print(self.listThread.currentRow())
#if item.isSelected():
# print(item.text() + " is selected")
#else:
# print(item.text() + " is not selected")
self.diagramView.showThread(self.listThread.currentRow(),item.isSelected())
def hideAllMsgNamedAsSelected(self):
self.diagramView.hideAllMessageSelected()
def addThreadList(self,threads):
if not self.groupBoxThreadInfo:
self.groupBoxThreadInfo = QGroupBox()
self.threadInfo = QLabel("Thread Info.")
self.groupBoxThreadInfo.setStyleSheet("QGroupBox {border: 1px solid gray; border-radius: 9px; margin-top: 0.5em} QGroupBox::title {subcontrol-origin: margin; left: 10px; padding: 0 3px 0 3px;")
if not self.threadvbox:
self.threadvbox = QVBoxLayout()
if not self.listThread:
self.listThread = QListWidget()
self.listThread.setFixedWidth(200)
self.listThread.setSelectionMode(QtGui.QAbstractItemView.MultiSelection)
QtCore.QObject.connect(self.listThread, QtCore.SIGNAL("itemClicked(QListWidgetItem *)"), self.toggleThreadDisplay)
self.threadvbox.addWidget(self.threadInfo)
self.threadvbox.addWidget(self.listThread)
self.groupBoxThreadInfo.setLayout(self.threadvbox)
self.addWidget(self.groupBoxThreadInfo)
self.groupBoxThreadInfo.setSizePolicy(self.sizePolicy)
for id in threads:
item = QtGui.QListWidgetItem(id)
self.listThread.addItem(item)
def connectController(self,controller):
self.controller = controller
self.connect(controller,QtCore.SIGNAL('setAvailable()'),self.setAvailable)
def connectDiagramView(self,view):
self.diagramView = view
def disconnectMsgRcv(self,receiver):
print("Implement this method !!! disconnectMsgRcv")
def connectMsgRcv(self,receiver):
self.msgRcv.append(receiver)
def notifyHide(self):
for rcv in self.msgRcv:
rcv.activateHide(True)
def showHiddenLifelines(self):
response, selected_items = HiddenDialog.HiddenDialog.getSelectedItems(self.diagramView.getHiddenLifeLines())
if response:
self.diagramView.showLifelines(selected_items)
def showHiddenMessages(self):
response, selected_items = HiddenMessageDialog.HiddenMessageDialog.getSelectedItems(self.diagramView.getHiddenMessages(),self.diagramView.getHiddenLifeLines())
if response:
if selected_items[3] in self.diagramView.getHiddenLifeLines():
confirmation = ShowLifeLineDialog.ShowLifeLineDialog.confirmToShowLifeLine(selected_items[3])
if confirmation:
self.diagramView.showLifelines([selected_items[3]])
self.diagramView.showMessages(selected_items)
else:
self.diagramView.showMessages(selected_items)
def notifyCapture(self):
for rcv in self.msgRcv:
rcv.activateCapture(True)
def moveToPrev(self):
for rcv in self.msgRcv:
rcv.moveToPrev()
def moveToNext(self):
for rcv in self.msgRcv:
rcv.moveToNext()
def searchMsg(self):
str = self.editTextSearch.toPlainText()
for rcv in self.msgRcv:
rcv.searchMessage(str)
示例7: MainWindow
# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import setSelectionMode [as 别名]
class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.resize(800,600)
self.setWindowTitle('PDF Merger')
about = QAction('About', self)
self.connect(about, SIGNAL('triggered()'), self.show_about)
exit = QAction('Exit', self)
exit.setShortcut('Ctrl+Q')
self.connect(exit, SIGNAL('triggered()'), SLOT('close()'))
self.statusBar()
menubar = self.menuBar()
file = menubar.addMenu('File')
file.addAction(about)
file.addAction(exit)
self.main_widget = QWidget(self)
self.setCentralWidget(self.main_widget)
self.up_down_widget = QWidget(self)
self.options_widget = QWidget(self)
input_files_label = QLabel("Input PDFs\nThis is the order in which the files will be merged too")
self.files_list = QListWidget()
self.files_list.setSelectionMode(QAbstractItemView.ExtendedSelection)
add_button = QPushButton("Add PDF(s) to merge...")
add_button.clicked.connect(self.clicked_add)
up_button = QPushButton("Up")
up_button.clicked.connect(self.move_file_up)
down_button = QPushButton("Down")
down_button.clicked.connect(self.move_file_down)
remove_button = QPushButton("Remove PDF")
remove_button.clicked.connect(self.remove_file)
select_path_label = QLabel("Output PDF")
self.dest_path_edit = QLineEdit()
self.dest_path_edit.setReadOnly(True)
select_path = QPushButton("Select...")
select_path.clicked.connect(self.select_save_path)
start = QPushButton("Start")
start.clicked.connect(self.merge_pdf)
up_down_vbox = QVBoxLayout(self.up_down_widget)
up_down_vbox.addWidget(up_button)
up_down_vbox.addWidget(down_button)
up_down_vbox.addWidget(remove_button)
self.up_down_widget.setLayout(up_down_vbox)
group_input = QGroupBox()
grid_input = QGridLayout()
grid_input.addWidget(add_button, 0, 0)
grid_input.addWidget(input_files_label, 1, 0)
grid_input.addWidget(self.files_list, 2, 0)
grid_input.addWidget(self.up_down_widget, 2, 1)
group_input.setLayout(grid_input)
group_output = QGroupBox()
grid_output = QGridLayout()
grid_output.addWidget(select_path_label, 0, 0)
grid_output.addWidget(self.dest_path_edit, 1, 0)
grid_output.addWidget(select_path, 1, 1)
group_output.setLayout(grid_output)
vbox_options = QVBoxLayout(self.options_widget)
vbox_options.addWidget(group_input)
vbox_options.addWidget(group_output)
vbox_options.addWidget(start)
self.options_widget.setLayout(vbox_options)
splitter_filelist = QSplitter()
splitter_filelist.setOrientation(Qt.Vertical)
splitter_filelist.addWidget(self.options_widget)
vbox_main = QVBoxLayout(self.main_widget)
vbox_main.addWidget(splitter_filelist)
vbox_main.setContentsMargins(0,0,0,0)
def show_about(self):
#TODO add hyperlinks and create simple base website
#TODO versioning system
QMessageBox.about(self, 'About', 'PDF Merger\n2013 Nikola Peric\n\n'
+ 'http://www.example.com/\nhttps://github.com/nikolap/pdfmerger/\n\n'
+ 'Licensed under The MIT License\nhttp://opensource.org/licenses/MIT' )
def clicked_add(self):
fname, _ = QFileDialog.getOpenFileNames(self, 'Select two or more PDFs to merge',
QDir.homePath(), "*.pdf")
self.files_list.addItems(fname)
def move_file_up(self):
sorted_selected_items = self.get_sorted_selected_items()
if 0 not in sorted_selected_items:
for row in sorted_selected_items:
item = self.files_list.takeItem(row)
self.files_list.insertItem(row - 1, item)
def move_file_down(self):
sorted_selected_items = self.get_sorted_selected_items(descending=True)
if (self.files_list.count() - 1) not in sorted_selected_items:
for row in sorted_selected_items:
#.........这里部分代码省略.........
示例8: __init__
# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import setSelectionMode [as 别名]
def __init__(self, *args, **kwargs ):
QMainWindow.__init__( self, *args, **kwargs )
self.installEventFilter( self )
#self.setWindowFlags( QtCore.Qt.Drawer )
self.setWindowTitle( Window_global.title )
verticalSplitter = QSplitter(QtCore.Qt.Vertical)
self.setCentralWidget( verticalSplitter )
horizonSplitter1 = QSplitter(QtCore.Qt.Horizontal)
horizonSplitter2 = QSplitter(QtCore.Qt.Horizontal)
verticalSplitter.addWidget( horizonSplitter1 )
verticalSplitter.addWidget( horizonSplitter2 )
widgetSelArea = QWidget()
layoutSelArea = QVBoxLayout(widgetSelArea)
labelSelTextList = QLabel( 'Images from Selection' )
selTextureList = QListWidget()
selTextureList.setSelectionMode( QAbstractItemView.ExtendedSelection )
layoutSelArea.addWidget( labelSelTextList )
layoutSelArea.addWidget( selTextureList )
imageBaseSelArea = ImageBase()
horizonSplitter1.addWidget( widgetSelArea )
horizonSplitter1.addWidget( imageBaseSelArea )
widgetPathArea = QWidget()
layoutPathArea = QVBoxLayout( widgetPathArea )
layoutAddTab = QHBoxLayout()
removeTabButton = QPushButton( 'Remove Tab' )
addTabButton = QPushButton( 'Add Tab' )
self.tabWidget = Tab()
buttonLayout = QHBoxLayout()
getImageButton = QPushButton( 'Get Image' )
removeImageButton = QPushButton( 'Remove Image' )
layoutPathArea.addLayout( layoutAddTab )
layoutPathArea.addWidget( self.tabWidget )
layoutPathArea.addLayout( buttonLayout )
imageBasePathArea = ImageBase()
layoutAddTab.addWidget( removeTabButton )
layoutAddTab.addWidget( addTabButton )
buttonLayout.addWidget( getImageButton )
buttonLayout.addWidget( removeImageButton )
horizonSplitter2.addWidget( widgetPathArea )
horizonSplitter2.addWidget( imageBasePathArea )
Window_global.selTextureList = selTextureList
Window_global.imageBaseSelArea = imageBaseSelArea
Window_global.imageBasePathArea = imageBasePathArea
Window_global.verticalSplitter = verticalSplitter
Window_global.horizonSplitter1 = horizonSplitter1
Window_global.horizonSplitter2 = horizonSplitter2
Window_global.getImageButton = getImageButton
Window_global.removeImageButton = removeImageButton
Window_global.tabWidget = self.tabWidget
Window_global.tabWidget.addTab( 'newTab' )
verticalSplitter.setSizes( [100,100] )
horizonSplitter1.setSizes( [100,100] )
horizonSplitter2.setSizes( [100,100] )
Window_global.loadInfo()
try:Window_global.loadInfo2()
except:pass
Functions.updateSelTextureList()
QtCore.QObject.connect( addTabButton, QtCore.SIGNAL( 'clicked()' ), self.addTab )
QtCore.QObject.connect( removeTabButton, QtCore.SIGNAL( 'clicked()' ), self.removeTab )
QtCore.QObject.connect( Window_global.selTextureList, QtCore.SIGNAL( 'itemSelectionChanged()' ), Functions.loadImageSelArea )
QtCore.QObject.connect( Window_global.horizonSplitter1, QtCore.SIGNAL( 'splitterMoved(int,int)' ), Functions.splitterMoved1 )
QtCore.QObject.connect( Window_global.horizonSplitter2, QtCore.SIGNAL( 'splitterMoved(int,int)' ), Functions.splitterMoved2 )
QtCore.QObject.connect( getImageButton, QtCore.SIGNAL( 'clicked()' ), Functions.getImage )
QtCore.QObject.connect( removeImageButton, QtCore.SIGNAL( 'clicked()' ), Functions.removeImage )
imageBaseSelArea.clear()
imageBasePathArea.clear()
getImageButton.setEnabled( False )
removeImageButton.setEnabled( False )
示例9: Ui_MainWindow
# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import setSelectionMode [as 别名]
#.........这里部分代码省略.........
self.connect_btn.setObjectName("connect_btn")
login_gbox_connect_layout.addWidget(self.lb_decryption_key)
login_gbox_connect_layout.addWidget(self.decryption_key_le)
login_gbox_connect_layout.addWidget(self.connect_btn)
#### search_gbox
self.search_gbox = QGroupBox(self.leftSplitter)
self.search_gbox.setFlat(True)
self.search_gbox.setObjectName("search_gbox")
self.search_gbox.hide()
search_gbox_layout = QVBoxLayout(self.search_gbox)
search_gbox_mailbox_layout = QVBoxLayout()
search_gbox_date_layout = QHBoxLayout()
search_gbox_from_layout = QHBoxLayout()
search_gbox_to_layout = QHBoxLayout()
search_gbox_subject_layout = QHBoxLayout()
search_gbox_threads_layout = QHBoxLayout()
search_gbox_paramaters_layout = QHBoxLayout()
search_gbox_layout.addLayout(search_gbox_mailbox_layout)
search_gbox_layout.addLayout(search_gbox_date_layout)
search_gbox_layout.addLayout(search_gbox_from_layout)
search_gbox_layout.addLayout(search_gbox_to_layout)
search_gbox_layout.addLayout(search_gbox_subject_layout)
search_gbox_layout.addLayout(search_gbox_threads_layout)
search_gbox_layout.addLayout(search_gbox_paramaters_layout)
self.lb_select_mailbox = QLabel(self.search_gbox)
self.lb_select_mailbox.setObjectName("lb_select_mailbox")
self.mailboxes_lw = QListWidget(self.search_gbox)
self.mailboxes_lw.setEditTriggers(QAbstractItemView.NoEditTriggers)
self.mailboxes_lw.setSelectionMode(QAbstractItemView.ExtendedSelection)
self.mailboxes_lw.setObjectName("mailboxes_lw")
search_gbox_mailbox_layout.addWidget(self.lb_select_mailbox)
search_gbox_mailbox_layout.addWidget(self.mailboxes_lw)
self.after_date_cb = QCheckBox(self.search_gbox)
self.after_date_cb.setObjectName("after_date_cb")
self.after_date_cb.setMinimumWidth(lbMinWidth)
self.after_date_cb.setMaximumWidth(lbMinWidth)
self.after_date_edit = QDateEdit(self.search_gbox)
self.after_date_edit.setCalendarPopup(True)
self.after_date_edit.setObjectName("after_date_edit")
self.after_date_edit.setDate(QDate.currentDate().addDays(-365))
self.after_date_edit.setMaximumDate(QDate.currentDate())
self.after_date_edit.setEnabled(False)
self.before_date_cb = QCheckBox(self.search_gbox)
self.before_date_cb.setObjectName("before_date_cb")
self.before_date_cb.setMinimumWidth(70)
self.before_date_cb.setMaximumWidth(70)
self.before_date_edit = QDateEdit(self.search_gbox)
self.before_date_edit.setCalendarPopup(True)
self.before_date_edit.setObjectName("before_date_edit")
self.before_date_edit.setDate(QDate.currentDate())
self.before_date_edit.setMaximumDate(QDate.currentDate())
self.before_date_edit.setEnabled(False)
search_gbox_date_layout.addWidget(self.after_date_cb)
search_gbox_date_layout.addWidget(self.after_date_edit)
search_gbox_date_layout.addWidget(self.before_date_cb)
search_gbox_date_layout.addWidget(self.before_date_edit)
self.lb_from = QLabel(self.search_gbox)
self.lb_from.setObjectName("lb_from")
self.lb_from.setMinimumWidth(lbMinWidth)
示例10: ProfileSelection
# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import setSelectionMode [as 别名]
class ProfileSelection(QDialog):
'''
classdocs
'''
removeProfile = Signal(Athlete_Model)
profileSelected = Signal(Athlete_Model)
profileUpdate_request = Signal(Athlete_Model, Athlete_Model)
lastProfileDeleted = Signal()
def __init__(self, athletesList):
'''
Constructor
'''
QDialog.__init__(self)
self.setWindowTitle("Profile Selection")
self.athletesList = athletesList
self._initGUI()
def _initGUI(self):
topHLayout = QHBoxLayout()
hLayout = QHBoxLayout()
vLayout = QVBoxLayout()
# Label
greeterText = QLabel("Welcome to <b>Pushup app</b>." + \
"<br><br> Select a profile:")
vLayout.addWidget(greeterText)
# List
self.list = QListWidget()
self.list.setMinimumWidth(150)
self.list.setSelectionMode(QAbstractItemView.SingleSelection)
# SingleSelection is the default value, but I prefer to be sure
self.list.itemSelectionChanged.connect(self._activateButtons)
for athlete in self.athletesList:
iconW = QIcon.fromTheme("user-available")
# doens't work on Mac and Windows
# http://qt-project.org/doc/qt-4.8/qicon.html#fromTheme
listW = QListWidgetItem(iconW, athlete._name)
listW.setData(Qt.UserRole, athlete)
self.list.addItem(listW)
topHLayout.addWidget(self.list)
self.profileWidget = ProfileFormWidget()
self.profileWidget.hide()
topHLayout.addWidget(self.profileWidget)
vLayout.addLayout(topHLayout)
vLayout.addLayout(hLayout)
# Buttons
self.okBtn = QPushButton("Ok")
self.okBtn.setDisabled(True)
self.okBtn.setDefault(True)
self.okBtn.clicked.connect(self._okButtonSlot)
self.list.itemDoubleClicked.connect(self._okButtonSlot)
cancelBtn = QPushButton("Cancel")
cancelBtn.clicked.connect(self._cancelButtonSlot)
self.editBtn = QPushButton("Edit")
self.editBtn.setDisabled(True)
self.editBtn.setCheckable(True)
self.editBtn.clicked.connect(self._toggleProfileEdit)
self.saveBtn = QPushButton("Save changes") # Saves the changes made on the profile
self.saveBtn.hide()
self.saveBtn.clicked.connect(self._saveButtonSlot)
self.removeProfileBtn = QPushButton("Remove Profile")
self.removeProfileBtn.setDisabled(True)
self.removeProfileBtn.clicked.connect(self._removeProfile_Dialog)
hLayout.addWidget(self.editBtn)
hLayout.addWidget(self.removeProfileBtn)
hLayout.addWidget(cancelBtn)
hLayout.addWidget(self.okBtn)
hLayout.addWidget(self.saveBtn)
self.setLayout(vLayout)
def getSelectedProfile(self):
selectedListItem = self.list.selectedItems()[0]
athleteProfile = selectedListItem.data(Qt.UserRole)
return athleteProfile
def updateList(self, athletes):
self.list.clear()
self.athletesList = athletes
for athlete in self.athletesList:
iconW = QIcon.fromTheme("user-available")
#.........这里部分代码省略.........
示例11: MainControl
# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import setSelectionMode [as 别名]
class MainControl(QWidget):
toChangeChunk = Signal(tuple)
toChangeSlice = Signal(int)
def __init__(self, parent):
super(MainControl, self).__init__(parent)
self.parent = parent
self.selectedMinerals = parent.selectedMinerals
self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
lb0 = QLabel('Minecraft Prism chunk minerals finder')
lb1 = QLabel('Chunk X')
lb2 = QLabel('Chunk Z')
lb3 = QLabel('Show deposits of:')
lb4 = QLabel('Slice Elevation')
#lb0.setFrameStyle(QFrame.Box)
lb0.setAlignment(Qt.AlignVCenter | Qt.AlignCenter)
lb2.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
self.txtChunkX = QLineEdit()
self.txtChunkZ = QLineEdit()
self.txtElevation = QLineEdit(str(self.parent.presenter.elevation))
self.txtChunkX.setAlignment(Qt.AlignVCenter | Qt.AlignCenter)
self.txtChunkZ.setAlignment(Qt.AlignVCenter | Qt.AlignCenter)
self.txtElevation.setAlignment(Qt.AlignVCenter | Qt.AlignCenter)
self.btnViewChunk = QPushButton('View Chunk')
self.btnViewChunk.clicked.connect(self.btnViewChunk_OnClick)
self.btnSliceUp = QPushButton('Slice Up')
self.btnSliceUp.clicked.connect(self.btnSliceUp_OnClick)
self.btnSliceDown = QPushButton('Slice Down')
self.btnSliceDown.clicked.connect(self.btnSliceDown_OnClick)
self.lstMinerals = QListWidget()
self.lstMinerals.setSelectionMode(QAbstractItemView.ExtendedSelection)
self.lstMinerals.addItem(SelectedMineral('Gold', 14))
self.lstMinerals.addItem(SelectedMineral('Iron', 15))
self.lstMinerals.addItem(SelectedMineral('Diamond', 56))
self.lstMinerals.addItem(SelectedMineral('Redstone', 73))
self.lstMinerals.addItem(SelectedMineral('Obsidian', 49))
self.lstMinerals.addItem(SelectedMineral('Coal', 16))
self.lstMinerals.addItem(SelectedMineral('Lazurit', 21))
self.lstMinerals.setCurrentItem(self.lstMinerals.item(0))
self.lstMinerals.itemSelectionChanged.connect(self.onSelectedMinerals)
elevBox = QHBoxLayout()
elevBox.addWidget(lb4)
elevBox.addWidget(self.txtElevation)
elevBox.addWidget(self.btnSliceUp)
elevBox.addWidget(self.btnSliceDown)
ly = QGridLayout()
ly.addWidget(lb0, 0, 0, 1, 4)
ly.addWidget(lb1, 1, 0, 1, 1)
ly.addWidget(self.txtChunkX, 1, 1, 1, 1)
ly.addWidget(lb2, 1, 2, 1, 1)
ly.addWidget(self.txtChunkZ, 1, 3, 1, 1)
ly.addWidget(lb3, 2, 0, 1, 2)
ly.addWidget(self.lstMinerals, 2, 2, 1, 2)
ly.addWidget(self.btnViewChunk, 3, 1, 1, 2)
ly.addLayout(elevBox, 4, 0, 1, 4)
ly.setColumnStretch(0, 20)
ly.setColumnStretch(1, 15)
ly.setColumnStretch(2, 46)
ly.setColumnStretch(3, 19)
self.setLayout(ly)
def sizeHint(self):
return QSize(self.parent.controlsWidth, 180)
def btnViewChunk_OnClick(self):
chX = int(self.txtChunkX.text())
chZ = int(self.txtChunkZ.text())
self.toChangeChunk.emit((chX, chZ))
def btnSliceUp_OnClick(self):
elev = int(self.txtElevation.text()) + 1
if elev < 64:
self.toChangeSlice.emit(elev)
self.txtElevation.setText(str(elev))
def btnSliceDown_OnClick(self):
elev = int(self.txtElevation.text()) - 1
if elev > -1:
self.toChangeSlice.emit(elev)
self.txtElevation.setText(str(elev))
def onSelectedMinerals(self):
selMin = []
for item in self.lstMinerals.selectedItems():
selMin.append(item.blockCode)
self.parent.selectedMinerals.setSelectedMinerals(selMin)
示例12: Ui_MainWindow
# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import setSelectionMode [as 别名]
#.........这里部分代码省略.........
login_gbox_pass_layout.addWidget(self.pass_le)
self.connect_btn = QPushButton(self.login_gbox)
self.connect_btn.setObjectName("connect_btn")
login_gbox_connect_layout.addStretch()
login_gbox_connect_layout.addWidget(self.connect_btn)
# search_gbox
self.search_gbox = QGroupBox(self.leftSplitter)
self.search_gbox.hide()
self.search_gbox.setObjectName("search_gbox")
search_gbox_layout = QVBoxLayout(self.search_gbox)
search_gbox_mailbox_layout = QVBoxLayout()
search_gbox_date_layout = QHBoxLayout()
search_gbox_from_layout = QHBoxLayout()
search_gbox_to_layout = QHBoxLayout()
search_gbox_subject_layout = QHBoxLayout()
search_gbox_threads_layout = QHBoxLayout()
search_gbox_paramaters_layout = QHBoxLayout()
search_gbox_layout.addLayout(search_gbox_mailbox_layout)
search_gbox_layout.addLayout(search_gbox_date_layout)
search_gbox_layout.addLayout(search_gbox_from_layout)
search_gbox_layout.addLayout(search_gbox_to_layout)
search_gbox_layout.addLayout(search_gbox_subject_layout)
search_gbox_layout.addLayout(search_gbox_threads_layout)
search_gbox_layout.addLayout(search_gbox_paramaters_layout)
self.lb_select_mailbox = QLabel(self.search_gbox)
self.lb_select_mailbox.setObjectName("lb_select_mailbox")
self.mailboxes_lw = QListWidget(self.search_gbox)
self.mailboxes_lw.setEditTriggers(QAbstractItemView.NoEditTriggers)
self.mailboxes_lw.setSelectionMode(QAbstractItemView.ExtendedSelection)
self.mailboxes_lw.setObjectName("mailboxes_lw")
search_gbox_mailbox_layout.addWidget(self.lb_select_mailbox)
search_gbox_mailbox_layout.addWidget(self.mailboxes_lw)
self.since_date_cb = QCheckBox(self.search_gbox)
self.since_date_cb.setObjectName("since_date_cb")
self.since_date_cb.setMinimumWidth(lbMinWidth)
self.since_date_cb.setMaximumWidth(lbMinWidth)
self.since_date_edit = QDateEdit(self.search_gbox)
self.since_date_edit.setCalendarPopup(True)
self.since_date_edit.setObjectName("since_date_edit")
self.since_date_edit.setDate(QDate.currentDate().addDays(-365))
self.since_date_edit.setMaximumDate(QDate.currentDate())
self.since_date_edit.setEnabled(False)
self.before_date_cb = QCheckBox(self.search_gbox)
self.before_date_cb.setObjectName("before_date_cb")
self.before_date_cb.setMinimumWidth(70)
self.before_date_cb.setMaximumWidth(70)
self.before_date_edit = QDateEdit(self.search_gbox)
self.before_date_edit.setCalendarPopup(True)
self.before_date_edit.setObjectName("before_date_edit")
self.before_date_edit.setDate(QDate.currentDate())
self.before_date_edit.setMaximumDate(QDate.currentDate())
self.before_date_edit.setEnabled(False)
search_gbox_date_layout.addWidget(self.since_date_cb)
search_gbox_date_layout.addWidget(self.since_date_edit)
search_gbox_date_layout.addWidget(self.before_date_cb)
search_gbox_date_layout.addWidget(self.before_date_edit)
self.lb_from = QLabel(self.search_gbox)
self.lb_from.setObjectName("lb_from")
self.lb_from.setMinimumWidth(lbMinWidth)