Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- from PyQt5.QtGui import *
- from PyQt5.QtWidgets import *
- class MyWindow(QWidget):
- def __init__(self):
- super().__init__()
- self.setWindowTitle("Kantor")
- grid = QGridLayout()
- self.setLayout(grid)
- label1 = QLabel("Kwota PLN:")
- label1.setFont(QFont("Calibri", 16))
- grid.addWidget(label1, 1, 0)
- label2 = QLabel("Kwota USD/Euro")
- label2.setFont(QFont("Calibri", 16))
- grid.addWidget(label2, 2, 0)
- self.oblicz_button = QPushButton("Oblicz", self)
- self.oblicz_button.clicked.connect(self.oblicz)
- grid.addWidget(self.oblicz_button, 3, 1)
- self.textbox1 = QTextEdit('10', self)
- grid.addWidget(self.textbox1, 1, 1)
- self.textbox2 = QTextEdit('', self)
- grid.addWidget(self.textbox2, 2, 1)
- self.waluta_radio = QButtonGroup()
- self.radiobutton3 = QRadioButton("USD")
- self.radiobutton3.setChecked(True)
- self.radiobutton3.toggled.connect(self.oblicz)
- grid.addWidget(self.radiobutton3, 2, 2)
- self.radiobutton4 = QRadioButton("Euro")
- self.radiobutton4.setChecked(False)
- self.radiobutton4.toggled.connect(self.oblicz)
- grid.addWidget(self.radiobutton4, 2, 3)
- self.waluta_radio.addButton(self.radiobutton3)
- self.waluta_radio.addButton(self.radiobutton4)
- def oblicz(self):
- waluta = float(self.textbox1.toPlainText())
- if self.radiobutton3.isChecked():
- waluta = waluta * 4.30
- if self.radiobutton4.isChecked():
- waluta = waluta * 4.60
- self.textbox2.setText(str(waluta))
- if __name__ == '__main__':
- app = QApplication(sys.argv)
- MyWindow = MyWindow()
- MyWindow.resize(640, 480)
- MyWindow.show()
- sys.exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement