Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Import all necessary modules
- # Putting a bracket allows you to type them on more than one line
- # Easier to check for typos and making sure you have everything you need
- from PyQt5.QtCore import Qt
- from PyQt5.QtWidgets import (
- QApplication, QWidget, QPushButton,
- QHBoxLayout, QVBoxLayout, QLabel,
- QMessageBox, QRadioButton)
- # WINNING & LOSING
- # One definition of 'winning' and one definition of 'losing'
- def show_win():
- pass
- def show_lose():
- pass
- # This section is to make a window
- app = QApplication([])
- main_win = QWidget()
- main_win.setWindowTitle('Add your own title here!')
- main_win.resize(400, 200)
- # These are your Questions and Answers
- question = QLabel('Add your question here')
- btn_answer1 = QRadioButton('Answer 1')
- btn_answer2 = QRadioButton('Answer 2')
- btn_answer3 = QRadioButton('Answer 3')
- btn_answer4 = QRadioButton('Answer 4')
- # These are the layouts
- layout_main = QVBoxLayout() # V for Vertical layout
- layoutH1 = QHBoxLayout() # H for Horizontal layout
- layoutH2 = QHBoxLayout()
- layoutH3 = QHBoxLayout()
- layoutH1.addWidget(question, alignment = Qt.AlignCenter)
- layoutH2.addWidget(btn_answer1, alignment = Qt.AlignCenter)
- layoutH2.addWidget(btn_answer2, alignment = Qt.AlignCenter)
- layoutH3.addWidget(btn_answer3, alignment = Qt.AlignCenter)
- layoutH3.addWidget(btn_answer4, alignment = Qt.AlignCenter)
- layout_main.addLayout(layoutH1)
- layout_main.addLayout(layoutH2)
- layout_main.addLayout(layoutH3)
- main_win.setLayout(layout_main)
- # Add what happens when the button is pressed
- # If clicking the right answer = YOU WIN!
- # Wrong answer = YOU LOSE!
- # button_name.clicked.connect(function_name)
- main_win.show()
- app.exec_()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement