Advertisement
Guest User

Untitled

a guest
Sep 5th, 2015
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. import sys
  2. from PyQt5.QtWidgets import (QWidget, QLabel,
  3. QComboBox, QApplication)
  4.  
  5.  
  6. class Example(QWidget):
  7. def __init__(self):
  8. super().__init__()
  9. self.initUI()
  10.  
  11. def initUI(self):
  12. self.lbl = QLabel("Ubuntu", self)
  13.  
  14. combo = QComboBox(self)
  15. combo.addItem("Ubuntu")
  16. combo.addItem("Mandriva")
  17. combo.addItem("Fedora")
  18. combo.addItem("Arch")
  19. combo.addItem("Gentoo")
  20.  
  21. combo.move(50, 50)
  22. self.lbl.move(50, 150)
  23.  
  24. combo.activated[str].connect(self.onActivated)
  25.  
  26. self.setGeometry(300, 300, 300, 200)
  27. self.setWindowTitle('QComboBox')
  28. self.show()
  29.  
  30. def onActivated(self, text):
  31. self.lbl.setText(text)
  32. self.lbl.adjustSize()
  33.  
  34.  
  35. if __name__ == "__main__":
  36. app = QApplication(sys.argv)
  37. ex = Example()
  38. sys.exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement