pyqt5 information input windopw

Solutions on MaxInterview for pyqt5 information input windopw by the best coders in the world

showing results for - "pyqt5 information input windopw"
Valerio
11 Nov 2018
1import sysfrom PyQt5.QtWidgets import QApplication, QWidget, QInputDialog, QLineEdit
2from PyQt5.QtGui import QIcon
3class App(QWidget):
4  def __init__(self):
5    super().__init__()
6    self.title = 'PyQt5 input dialogs - pythonspot.com'
7    self.left = 10
8    self.top = 10
9    self.width = 640
10    self.height = 480
11    self.initUI()
12    def initUI(self):
13      self.setWindowTitle(self.title)
14      self.setGeometry(self.left, self.top, self.width, self.height)
15      self.getInteger()
16      self.getText()
17      self.getDouble()
18      self.getChoice()
19      self.show()
20    def getInteger(self):
21      i, okPressed = QInputDialog.getInt(self, "Get integer","Percentage:", 28, 0, 100, 1)
22      if okPressed:
23        print(i)
24    def getDouble(self):
25      d, okPressed = QInputDialog.getDouble(self, "Get double","Value:", 10.50, 0, 100, 10)
26      if okPressed:
27        print(d)
28    def getChoice(self):
29      items = ("Red","Blue","Green")
30      item, okPressed = QInputDialog.getItem(self, "Get item","Color:", items, 0, False)
31      if okPressed and item:
32        print(item)
33    def getText(self):
34      text, okPressed = QInputDialog.getText(self, "Get text","Your name:", QLineEdit.Normal, "")
35      if okPressed and text != '':
36        print(text)
37if __name__ == '__main__':
38  app = QApplication(sys.argv)
39  ex = App()
40  sys.exit(app.exec_())