FlatCAM.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import sys
  2. import os
  3. from PyQt5 import QtWidgets, QtGui
  4. from PyQt5.QtCore import QSettings, Qt
  5. from FlatCAMApp import App
  6. from flatcamGUI import VisPyPatches
  7. from multiprocessing import freeze_support
  8. # import copyreg
  9. # import types
  10. import qdarkstyle
  11. if sys.platform == "win32":
  12. # cx_freeze 'module win32' workaround
  13. pass
  14. os.environ['QT_API'] = 'pyqt5'
  15. def debug_trace():
  16. """
  17. Set a tracepoint in the Python debugger that works with Qt
  18. :return: None
  19. """
  20. from PyQt5.QtCore import pyqtRemoveInputHook
  21. # from pdb import set_trace
  22. pyqtRemoveInputHook()
  23. # set_trace()
  24. if __name__ == '__main__':
  25. # All X11 calling should be thread safe otherwise we have strange issues
  26. # QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_X11InitThreads)
  27. # NOTE: Never talk to the GUI from threads! This is why I commented the above.
  28. freeze_support()
  29. debug_trace()
  30. VisPyPatches.apply_patches()
  31. # apply High DPI support
  32. settings = QSettings("Open Source", "FlatCAM")
  33. if settings.contains("hdpi"):
  34. hdpi_support = settings.value('hdpi', type=int)
  35. else:
  36. hdpi_support = 0
  37. if hdpi_support == 2:
  38. os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1"
  39. else:
  40. os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "0"
  41. app = QtWidgets.QApplication(sys.argv)
  42. app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
  43. # apply style
  44. settings = QSettings("Open Source", "FlatCAM")
  45. if settings.contains("style"):
  46. style = settings.value('style', type=str)
  47. app.setStyle(style)
  48. if hdpi_support == 2:
  49. app.setAttribute(Qt.AA_EnableHighDpiScaling, True)
  50. else:
  51. app.setAttribute(Qt.AA_EnableHighDpiScaling, False)
  52. fc = App()
  53. sys.exit(app.exec_())