当前位置: 首页>>代码示例>>Python>>正文


Python QListWidget.row方法代码示例

本文整理汇总了Python中PySide.QtGui.QListWidget.row方法的典型用法代码示例。如果您正苦于以下问题:Python QListWidget.row方法的具体用法?Python QListWidget.row怎么用?Python QListWidget.row使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PySide.QtGui.QListWidget的用法示例。


在下文中一共展示了QListWidget.row方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MainWindow

# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import row [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:
#.........这里部分代码省略.........
开发者ID:nikolap,项目名称:pdfmerger,代码行数:103,代码来源:pdfMerger.py


注:本文中的PySide.QtGui.QListWidget.row方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。