Guest User

Untitled

a guest
Mar 20th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. import os
  2. import sys
  3. import subprocess
  4. import atexit
  5. from PyQt5 import QtWidgets
  6.  
  7.  
  8. class CalcWindow(QtWidgets.QMainWindow):
  9. def __init__(self):
  10. super(CalcWindow, self).__init__()
  11. self.setWindowTitle("Embedded Calc")
  12. lines_widget = LinesWidget()
  13. self.setCentralWidget(lines_widget)
  14. calc_path = "/Applications/Calculator.app/Contents/MacOS/Calculator"
  15. print("Path = " + calc_path)
  16. print("Exists: " + str(os.path.exists(calc_path)))
  17. p = subprocess.Popen(calc_path)
  18. atexit.register(self.kill_proc, p)
  19.  
  20. @staticmethod
  21. def kill_proc(proc):
  22. try:
  23. proc.terminate()
  24. except Exception:
  25. pass
  26.  
  27.  
  28. class LinesWidget(QtWidgets.QWidget):
  29.  
  30. def __init__(self):
  31. super().__init__()
  32. self.vLayout = QtWidgets.QVBoxLayout()
  33. self.line1 = QtWidgets.QHBoxLayout()
  34. self.line1.addWidget(QtWidgets.QLabel("HELLO"))
  35. self.line1.addWidget(QtWidgets.QLabel("WORLD"))
  36. self.line2 = QtWidgets.QHBoxLayout()
  37. self.line2.addWidget(QtWidgets.QLabel("SUP"))
  38. self.line2.addWidget(QtWidgets.QLabel("DAWG"))
  39. self.vLayout.addLayout(self.line1)
  40. self.vLayout.addLayout(self.line2)
  41. self.setLayout(self.vLayout)
  42.  
  43.  
  44. def main():
  45. app = QtWidgets.QApplication(sys.argv)
  46. calc = CalcWindow()
  47. calc.show()
  48. sys.exit(app.exec_())
  49.  
  50.  
  51. if __name__ == "__main__":
  52. main()
Add Comment
Please, Sign In to add comment