FlatCAM.py 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import sys
  2. import os
  3. from PyQt5 import QtWidgets
  4. from PyQt5.QtCore import QSettings, Qt
  5. from AppMain import App
  6. from AppGUI 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. MIN_VERSION_MAJOR = 3
  14. MIN_VERSION_MINOR = 5
  15. def debug_trace():
  16. """
  17. Set a tracepoint in the Python debugger that works with Qt
  18. :return: None
  19. """
  20. from PyQt5.QtCore import pyqtRemoveInputHook
  21. # from pdb import set_trace
  22. pyqtRemoveInputHook()
  23. # set_trace()
  24. if __name__ == '__main__':
  25. # All X11 calling should be thread safe otherwise we have strange issues
  26. # QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_X11InitThreads)
  27. # NOTE: Never talk to the GUI from threads! This is why I commented the above.
  28. freeze_support()
  29. major_v = sys.version_info.major
  30. minor_v = sys.version_info.minor
  31. # Supported Python version is >= 3.5
  32. if major_v >= MIN_VERSION_MAJOR:
  33. if minor_v >= MIN_VERSION_MINOR:
  34. pass
  35. else:
  36. print("FlatCAM BETA uses PYTHON 3 or later. The version minimum is %s.%s\n"
  37. "Your Python version is: %s.%s" % (MIN_VERSION_MAJOR, MIN_VERSION_MINOR, str(major_v), str(minor_v)))
  38. if minor_v >= 8:
  39. os._exit(0)
  40. else:
  41. sys.exit(0)
  42. else:
  43. print("FlatCAM BETA uses PYTHON 3 or later. The version minimum is %s.%s\n"
  44. "Your Python version is: %s.%s" % (MIN_VERSION_MAJOR, MIN_VERSION_MINOR, str(major_v), str(minor_v)))
  45. sys.exit(0)
  46. debug_trace()
  47. VisPyPatches.apply_patches()
  48. # apply High DPI support
  49. settings = QSettings("Open Source", "FlatCAM")
  50. if settings.contains("hdpi"):
  51. hdpi_support = settings.value('hdpi', type=int)
  52. else:
  53. hdpi_support = 0
  54. if hdpi_support == 2:
  55. os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1"
  56. else:
  57. os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "0"
  58. # if hdpi_support == 2:
  59. # tst_screen = QtWidgets.QApplication(sys.argv)
  60. # if tst_screen.screens()[0].geometry().width() > 1930 or tst_screen.screens()[1].geometry().width() > 1930:
  61. # QGuiApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
  62. # del tst_screen
  63. # else:
  64. # QGuiApplication.setAttribute(Qt.AA_EnableHighDpiScaling, False)
  65. if hdpi_support == 2:
  66. QtWidgets.QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
  67. else:
  68. QtWidgets.QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, False)
  69. app = QtWidgets.QApplication(sys.argv)
  70. # apply style
  71. settings = QSettings("Open Source", "FlatCAM")
  72. if settings.contains("style"):
  73. style = settings.value('style', type=str)
  74. app.setStyle(style)
  75. fc = App()
  76. sys.exit(app.exec_())
  77. # app.exec_()