FlatCAM.py 1.6 KB

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