Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- # -*- coding: utf-8 -*-
- import sys
- from PyQt5.QtWidgets import *
- #QApplication, QWidget, QToolButton
- from PyQt5.QtGui import QIcon
- class Example(QWidget):
- def __init__(self):
- super().__init__()
- self.initUI()
- def initUI(self):
- #создаём кнопку для диалогового окна
- self.button = QPushButton('Dialog', self)
- self.button.move(20, 20)
- self.button.clicked.connect(self.showDialog)
- self.inputedText = QLineEdit(self)
- self.inputedText.move(130, 22)
- self.setGeometry(300, 300, 300, 220)
- self.show()
- def showDialog(self):
- text, ok = QInputDialog.getText(self, 'Input Dialog', 'Enter your name:')
- if ok:
- self.inputedText.setText(str(text))
- if __name__ == '__main__':
- app = QApplication(sys.argv)
- ex = Example()
- sys.exit(app.exec_())A
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement