FlatCAM.py 1.6 KB

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