FlatCAM.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import sys
  2. import os
  3. from PyQt5 import QtWidgets
  4. from PyQt5.QtCore import QSettings, Qt
  5. from FlatCAMApp import App
  6. from multiprocessing import freeze_support
  7. from flatcamGUI import VisPyPatches
  8. if sys.platform == "win32":
  9. # cx_freeze 'module win32' workaround
  10. pass
  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. if __name__ == '__main__':
  21. # All X11 calling should be thread safe otherwise we have strange issues
  22. # QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_X11InitThreads)
  23. # NOTE: Never talk to the GUI from threads! This is why I commented the above.
  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_())