FlatCAM.py 1.6 KB

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