Advertisement
programusy

Untitled

Mar 29th, 2023
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. import sys
  2. from PyQt5.QtGui import *
  3. from PyQt5.QtWidgets import *
  4.  
  5.  
  6. class MyWindow(QWidget):
  7. def __init__(self):
  8. super().__init__()
  9. self.setWindowTitle("Kantor")
  10. grid = QGridLayout()
  11. self.setLayout(grid)
  12.  
  13. label1 = QLabel("Kwota PLN:")
  14. label1.setFont(QFont("Calibri", 16))
  15. grid.addWidget(label1, 1, 0)
  16.  
  17. label2 = QLabel("Kwota USD/Euro")
  18. label2.setFont(QFont("Calibri", 16))
  19. grid.addWidget(label2, 2, 0)
  20.  
  21. self.oblicz_button = QPushButton("Oblicz", self)
  22. self.oblicz_button.clicked.connect(self.oblicz)
  23. grid.addWidget(self.oblicz_button, 3, 1)
  24.  
  25. self.textbox1 = QTextEdit('10', self)
  26. grid.addWidget(self.textbox1, 1, 1)
  27. self.textbox2 = QTextEdit('', self)
  28. grid.addWidget(self.textbox2, 2, 1)
  29.  
  30. self.waluta_radio = QButtonGroup()
  31.  
  32. self.radiobutton3 = QRadioButton("USD")
  33. self.radiobutton3.setChecked(True)
  34. self.radiobutton3.toggled.connect(self.oblicz)
  35. grid.addWidget(self.radiobutton3, 2, 2)
  36.  
  37. self.radiobutton4 = QRadioButton("Euro")
  38. self.radiobutton4.setChecked(False)
  39. self.radiobutton4.toggled.connect(self.oblicz)
  40. grid.addWidget(self.radiobutton4, 2, 3)
  41.  
  42. self.waluta_radio.addButton(self.radiobutton3)
  43. self.waluta_radio.addButton(self.radiobutton4)
  44.  
  45. def oblicz(self):
  46. waluta = float(self.textbox1.toPlainText())
  47. if self.radiobutton3.isChecked():
  48. waluta = waluta * 4.30
  49.  
  50. if self.radiobutton4.isChecked():
  51. waluta = waluta * 4.60
  52.  
  53. self.textbox2.setText(str(waluta))
  54.  
  55. if __name__ == '__main__':
  56. app = QApplication(sys.argv)
  57. MyWindow = MyWindow()
  58. MyWindow.resize(640, 480)
  59. MyWindow.show()
  60. sys.exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement