本文整理汇总了Python中PyQt4.Qt.QListWidget.setObjectName方法的典型用法代码示例。如果您正苦于以下问题:Python QListWidget.setObjectName方法的具体用法?Python QListWidget.setObjectName怎么用?Python QListWidget.setObjectName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QListWidget
的用法示例。
在下文中一共展示了QListWidget.setObjectName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tab_widget
# 需要导入模块: from PyQt4.Qt import QListWidget [as 别名]
# 或者: from PyQt4.Qt.QListWidget import setObjectName [as 别名]
class tab_widget(QtGui.QTabWidget):
# Initiate Widget.
def __init__(self, parent=MainWindow):
super(tab_widget, self).__init__()
self.initUI()
# Create all object thats in the AddData tab
def makeAddDataTab(self, grid):
self.author_label = QLabel("Author")
self.author_text = QLineEdit()
self.author_text.setPlaceholderText("Author")
grid.addWidget(self.author_label, 0, 0)
grid.addWidget(self.author_text, 1, 0)
self.title_label = QLabel("Title")
self.title_text = QLineEdit()
self.title_text.setPlaceholderText("Title")
grid.addWidget(self.title_label, 0, 1)
grid.addWidget(self.title_text, 1, 1)
self.date_label = QLabel("Date Read")
self.date_text = QLineEdit()
self.date_text.setPlaceholderText("yy-mm-dd")
grid.addWidget(self.date_label, 2, 1)
grid.addWidget(self.date_text, 3, 1)
self.grade_label = QLabel("Grade")
self.grade_text = QLineEdit()
self.grade_text.setPlaceholderText("Grade 1-5")
grid.addWidget(self.grade_label, 2, 0)
grid.addWidget(self.grade_text, 3, 0)
self.comments_label = QLabel("Comments")
self.comments_text = QLineEdit()
self.comments_text.setPlaceholderText("Comments here")
grid.addWidget(self.comments_label, 4, 0)
grid.addWidget(self.comments_text, 5, 0)
self.genre_label = QLabel("Genre")
self.genre_list = QListWidget(self)
self.genre_list.addItems(self.genreList)
self.genre_list.setObjectName('genre_list')
self.genre_list.itemClicked.connect(self.item_clicked)
grid.addWidget(self.genre_label, 6, 0)
grid.addWidget(self.genre_list, 7, 0)
self.genre2_label = QLabel("Genre2")
self.genre2_list = QListWidget(self)
self.genre2_list.setObjectName("genre2")
self.genre2_list.addItem("Select genre first")
grid.addWidget(self.genre2_label, 6, 1)
grid.addWidget(self.genre2_list, 7, 1)
self.submit = QtGui.QPushButton("Submit Data", self)
self.submit.clicked.connect(self.buttonClicked)
grid.addWidget(self.submit, 8, 1)
self.quit = QtGui.QPushButton("Exit", self)
self.quit.clicked.connect(self.buttonClicked)
self.quit.setMaximumWidth(80)
grid.addWidget(self.quit, 8, 0)
# Creates all the object thats in the getData tab
def makeGetDataTab(self, vbox_inner):
self.authorData = QLineEdit()
self.authorData.setPlaceholderText("Author")
self.authorData.setReadOnly(True)
vbox_inner.addWidget(self.authorData)
self.titleData = QLineEdit()
self.titleData.setPlaceholderText("Title")
self.titleData.setReadOnly(True)
vbox_inner.addWidget(self.titleData)
self.genreData = QLineEdit()
self.genreData.setPlaceholderText("Genre")
self.genreData.setReadOnly(True)
vbox_inner.addWidget(self.genreData)
self.genre2Data = QLineEdit()
self.genre2Data.setPlaceholderText("Genre2")
self.genre2Data.setReadOnly(True)
vbox_inner.addWidget(self.genre2Data)
self.dateData = QLineEdit()
self.dateData.setPlaceholderText("Date read")
self.dateData.setReadOnly(True)
vbox_inner.addWidget(self.dateData)
self.gradeData = QLineEdit()
self.gradeData.setPlaceholderText("Grade")
self.gradeData.setReadOnly(True)
vbox_inner.addWidget(self.gradeData)
self.commentsData = QLineEdit()
self.commentsData.setPlaceholderText("Comments")
self.commentsData.setReadOnly(True)
vbox_inner.addWidget(self.commentsData)
self.titles_list = QListWidget(self)
vbox_inner.addWidget(self.titles_list)
hbox_inner = QtGui.QHBoxLayout()
self.getTitleData = QtGui.QPushButton("Get title data", self)
self.getTitleData.clicked.connect(self.buttonClicked)
hbox_inner.addWidget(self.getTitleData)
self.refreshList = QtGui.QPushButton("Refresh list", self)
self.refreshList.clicked.connect(self.buttonClicked)
hbox_inner.addWidget(self.refreshList)
return hbox_inner
# Initiate the widgets gui
def initUI(self):
#.........这里部分代码省略.........
示例2: tab_widget
# 需要导入模块: from PyQt4.Qt import QListWidget [as 别名]
# 或者: from PyQt4.Qt.QListWidget import setObjectName [as 别名]
class tab_widget(QtGui.QTabWidget):
# Initiate Widget.
def __init__(self, parent=MainWindow):
super(tab_widget, self).__init__()
self.initUI()
# Create interface, and connect buttons to signals.
def initUI(self):
vbox_inner = QVBoxLayout()
grid = QtGui.QGridLayout()
self.genreList = ['Fiction', 'Fact book', 'Poetry']
# Tab 1: Add Data
self.author_label = QLabel("Author")
self.author_text = QLineEdit()
self.author_text.setPlaceholderText("Author")
grid.addWidget(self.author_label, 0, 0)
grid.addWidget(self.author_text, 1, 0)
self.title_label = QLabel("Title")
self.title_text = QLineEdit()
self.title_text.setPlaceholderText("Title")
grid.addWidget(self.title_label, 0, 1)
grid.addWidget(self.title_text, 1, 1)
self.date_label = QLabel("Date Read")
self.date_text = QLineEdit()
self.date_text.setPlaceholderText("yy-mm-dd")
grid.addWidget(self.date_label, 2, 1)
grid.addWidget(self.date_text, 3, 1)
self.grade_label = QLabel("Grade")
self.grade_text = QLineEdit()
self.grade_text.setPlaceholderText("Grade 1-5")
grid.addWidget(self.grade_label, 2, 0)
grid.addWidget(self.grade_text, 3, 0)
self.comments_label = QLabel("Comments")
self.comments_text = QLineEdit()
self.comments_text.setPlaceholderText("Comments here")
grid.addWidget(self.comments_label, 4, 0)
grid.addWidget(self.comments_text, 5, 0)
self.genre_label = QLabel("Genre")
self.genre_list = QListWidget(self)
self.genre_list.addItems(self.genreList)
self.genre_list.setObjectName('genre_list')
self.genre_list.itemClicked.connect(self.item_clicked)
grid.addWidget(self.genre_label, 6, 0)
grid.addWidget(self.genre_list, 7, 0)
self.genre2_label = QLabel("Genre2")
self.genre2_list = QListWidget(self)
self.genre2_list.setObjectName("genre2")
self.genre2_list.addItem("Select genre first")
grid.addWidget(self.genre2_label, 6, 1)
grid.addWidget(self.genre2_list, 7, 1)
# Tab 2:Get Data from file
self.authorData = QLineEdit()
self.authorData.setPlaceholderText("Author")
self.authorData.setReadOnly(True)
vbox_inner.addWidget(self.authorData)
self.titleData = QLineEdit()
self.titleData.setPlaceholderText("Title")
self.titleData.setReadOnly(True)
vbox_inner.addWidget(self.titleData)
self.genreData = QLineEdit()
self.genreData.setPlaceholderText("Genre")
self.genreData.setReadOnly(True)
vbox_inner.addWidget(self.genreData)
self.genre2Data = QLineEdit()
self.genre2Data.setPlaceholderText("Genre2")
self.genre2Data.setReadOnly(True)
vbox_inner.addWidget(self.genre2Data)
self.dateData = QLineEdit()
self.dateData.setPlaceholderText("Date read")
self.dateData.setReadOnly(True)
vbox_inner.addWidget(self.dateData)
self.gradeData = QLineEdit()
self.gradeData.setPlaceholderText("Grade")
self.gradeData.setReadOnly(True)
vbox_inner.addWidget(self.gradeData)
self.commentsData = QLineEdit()
self.commentsData.setPlaceholderText("Comments")
self.commentsData.setReadOnly(True)
vbox_inner.addWidget(self.commentsData)
self.titles_list = QListWidget(self)
#.........这里部分代码省略.........