FlatCAM.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 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. # Supported Python version is >= 3.5
  28. if sys.version_info.major >= 3:
  29. if sys.version_info.minor >= 5:
  30. pass
  31. else:
  32. print("FlatCAM BETA uses PYTHON 3. The version minimum is 3.5\n"
  33. "Your Python version is: %s" % str(sys.version_info))
  34. os._exit(0)
  35. else:
  36. print("FlatCAM BETA uses PYTHON 3. The version minimum is 3.5\n"
  37. "Your Python version is: %s" % str(sys.version_info))
  38. os._exit(0)
  39. debug_trace()
  40. VisPyPatches.apply_patches()
  41. # apply High DPI support
  42. settings = QSettings("Open Source", "FlatCAM")
  43. if settings.contains("hdpi"):
  44. hdpi_support = settings.value('hdpi', type=int)
  45. else:
  46. hdpi_support = 0
  47. if hdpi_support == 2:
  48. os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1"
  49. else:
  50. os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "0"
  51. # if hdpi_support == 2:
  52. # tst_screen = QtWidgets.QApplication(sys.argv)
  53. # if tst_screen.screens()[0].geometry().width() > 1930 or tst_screen.screens()[1].geometry().width() > 1930:
  54. # QGuiApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
  55. # del tst_screen
  56. # else:
  57. # QGuiApplication.setAttribute(Qt.AA_EnableHighDpiScaling, False)
  58. if hdpi_support == 2:
  59. QtWidgets.QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
  60. else:
  61. QtWidgets.QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, False)
  62. app = QtWidgets.QApplication(sys.argv)
  63. # apply style
  64. settings = QSettings("Open Source", "FlatCAM")
  65. if settings.contains("style"):
  66. style = settings.value('style', type=str)
  67. app.setStyle(style)
  68. fc = App()
  69. # sys.exit(app.exec_())
  70. app.exec_()