Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 KB | None | 0 0
  1. from PySide2 import QtWidgets
  2. import sys
  3. from ui import Ui_Form
  4. import linecache
  5. import random
  6. #import math
  7.  
  8.  
  9.  
  10. # Create App
  11.  
  12.  
  13.  
  14. # Create form and init UI
  15. app = QtWidgets.QApplication(sys.argv)
  16. Form = QtWidgets.QWidget()
  17. ui = Ui_Form()
  18. ui.setupUi(Form)
  19. Form.show()
  20.  
  21. # Hook logic
  22.  
  23. frst = ui.lineEdit.text()
  24. twth = ui.lineEdit_2.text()
  25.  
  26. nums = [frst , twth]
  27.  
  28. def num():
  29.     maxi = max(nums)
  30.     mini = min(nums)
  31.  
  32.  
  33. def name():
  34.     with open("input.txt", encoding="utf-8") as inp: lines = inp.readlines()
  35.     random_line = random.choice(lines).strip()
  36.     ui.textBrowser_4.setText(str(random_line))
  37.  
  38. def gennum():
  39.     num()
  40.     rannum = (random.randint(int(mini) , int(maxi)))
  41.     ui.textBrowser_3.setText(str(rannum))
  42.  
  43. def bp():
  44.         name()
  45.         num()
  46.         gennum()
  47.  
  48. ui.pushButton.clicked.connect(bp)
  49. #Run main loop
  50. sys.exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement