Advertisement
Klokova_Sofi

Andrey_PyQT5_lesson_08_12_part1

Dec 8th, 2021
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #!/usr/bin/python3
  2. # -*- coding: utf-8 -*-
  3.  
  4. import sys
  5. from PyQt5.QtWidgets import *
  6. #QApplication, QWidget, QToolButton
  7. from PyQt5.QtGui import QIcon
  8.  
  9. class Example(QWidget):
  10.  
  11. def __init__(self):
  12. super().__init__()
  13. self.initUI()
  14.  
  15. def initUI(self):
  16.  
  17. #создаём кнопку для диалогового окна
  18. self.button = QPushButton('Dialog', self)
  19. self.button.move(20, 20)
  20. self.button.clicked.connect(self.showDialog)
  21.  
  22. self.inputedText = QLineEdit(self)
  23. self.inputedText.move(130, 22)
  24.  
  25. self.setGeometry(300, 300, 300, 220)
  26. self.show()
  27.  
  28. def showDialog(self):
  29. text, ok = QInputDialog.getText(self, 'Input Dialog', 'Enter your name:')
  30. if ok:
  31. self.inputedText.setText(str(text))
  32.  
  33.  
  34.  
  35.  
  36. if __name__ == '__main__':
  37. app = QApplication(sys.argv)
  38. ex = Example()
  39. sys.exit(app.exec_())A
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement