Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PyQt5.QtWidgets import QWidget, QLabel, QLineEdit, QDoubleSpinBox, QComboBox, QRadioButton, QPushButton, QHBoxLayout, QVBoxLayout, QTextEdit, QGridLayout
- class AlbumDatabase (QWidget):
- def __init__(self, parent=None):
- super().__init__(parent)
- self.createWidgets()
- self.arrangeWidgets()
- self.setWindowTitle ("Album Database")
- #self.setMinimumSize (320,200)
- #self.setMaximumSize (700,500)
- def createWidgets(self):
- self.albumtitleLabel = QLabel("Album Title: ")
- self.albumtitleLineEdit = QLineEdit()
- self.albumtitleLineEdit.setMaximumSize(300,20)
- self.albumtitleLabel.setBuddy(self.albumtitleLineEdit)
- self.artistLabel = QLabel("Artist: ")
- self.artistLineEdit = QLineEdit()
- self.artistLineEdit.setMaximumSize(300,20)
- self.artistLabel.setBuddy(self.artistLineEdit)
- self.yearLabel = QLabel ("year: ")
- self.yearDoubleSpinBox = QDoubleSpinBox()
- self.yearLabel.setBuddy(self.yearDoubleSpinBox)
- self.yearDoubleSpinBox.setRange(2005,2015);
- self.yearDoubleSpinBox.setSingleStep(1);
- self.genreLabel = QLabel ("Genre: ")
- genreList = ["Rock", "House", "Classical", "Pop", "R&B"]
- self.genreComboBox = QComboBox()
- self.genreComboBox.addItems (genreList)
- self.genreLabel.setBuddy(self.genreComboBox)
- self.formatLabel = QLabel ("Format: ")
- self.lpRadioButton = QRadioButton()
- self.lpLabel = QLabel("LP")
- self.cdRadioButton = QRadioButton()
- self.cdLabel = QLabel("CD")
- self.mp3RadioButton = QRadioButton()
- self.mp3Label = QLabel("MP3")
- self.flacRadiobutton = QRadioButton()
- self.flacLabel = QLabel("FLAC")
- #self.notesLabel = QLabel("Notes: ")
- #self.notesTextEdit = QTextEdit()
- #self.addalbumPushButton = QPushButton("Add Album")
- #self.cancelPushButton = QPushButton("Cancel")
- def arrangeWidgets (self):
- #GridLayout:
- self.topLeftLayout = QGridLayout()
- self.topLeftLayout.addWidget(self.albumtitleLabel,0,0)
- self.topLeftLayout.addWidget(self.albumtitleLineEdit,0,1)
- self.topLeftLayout.addWidget(self.artistLabel,1,0)
- self.topLeftLayout.addWidget(self.artistLineEdit,1,1)
- self.topLeftLayout.addWidget(self.yearLabel,2,0)
- self.topLeftLayout.addWidget(self.yearDoubleSpinBox,2,1)
- self.topLeftLayout.addWidget(self.genreLabel,2,2)
- self.topLeftLayout.addWidget(self.genreComboBox,2,3)
- self.topLeftLayout.addWidget(self.formatLabel,3,0)
- self.topLeftLayout.addWidget(self.lpRadioButton,3,1)
- self.topLeftLayout.addWidget(self.lpLabel,3,2)
- self.topLeftLayout.setSpacing (10)
- #self.radioButtonLayout = QHBoxLayout()
- #self.radioButtonLayout.addWidget(self.formatLabel)
- #self.radioButtonLayout.addWidget(self.lpRadioButton)
- #self.radioButtonLayout.addWidget(self.lpLabel)
- #self.radioButtonLayout = QHBoxLayout()
- #self.radioButtonLayout.addWidget(self.formatLabel)
- #Creating mainLayout:
- self.mainLayout = QHBoxLayout()
- self.mainLayout.addLayout(self.topLeftLayout)
- #self.mainLayout.addLayout(self.radioButtonLayout)
- self.setLayout(self.mainLayout)
- if __name__ == "__main__":
- import sys
- from PyQt5.QtWidgets import QApplication
- app = QApplication (sys.argv)
- window = AlbumDatabase()
- window.show()
- sys.exit (app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement