def initialize(self) -> None: super().initialize() self._mesh_file_handler = MeshFileHandler(self) #type: MeshFileHandler self._workspace_file_handler = WorkspaceFileHandler(self) #type: WorkspaceFileHandler # For some reason, with Qt 5.9 and up, the default "windows" style seems like Windows 95. We have to set the # style to "fusion" so it looks less ugly. pyqt_version_parts = [int(n) for n in PYQT_VERSION_STR.split(".")] if len(pyqt_version_parts) < 2: # Make sure there are at less 2 parts in the version pyqt_version_parts += [0 for _ in range(2 - len(pyqt_version_parts))] if pyqt_version_parts[0] == 5 and pyqt_version_parts[1] > 8: self.setStyle("fusion") # For some reason, with Qt 5.9 and up, the default "windows" style seems like Windows 95. We have to set the # style to "fusion" so it looks less ugly. pyqt_version_parts = [int(n) for n in PYQT_VERSION_STR.split(".")] if len(pyqt_version_parts) < 2: # Make sure there are at less 2 parts in the version pyqt_version_parts += [0 for _ in range(2 - len(pyqt_version_parts))] if pyqt_version_parts[0] == 5 and pyqt_version_parts[1] > 8: self.setStyle("fusion") self.setAttribute(Qt.AA_UseDesktopOpenGL) major_version, minor_version, profile = OpenGLContext.detectBestOpenGLVersion() if major_version is None and minor_version is None and profile is None: Logger.log("e", "Startup failed because OpenGL version probing has failed: tried to create a 2.0 and 4.1 context. Exiting") QMessageBox.critical(None, "Failed to probe OpenGL", "Could not probe OpenGL. This program requires OpenGL 2.0 or higher. Please check your video card drivers.") sys.exit(1) else: opengl_version_str = OpenGLContext.versionAsText(major_version, minor_version, profile) Logger.log("d", "Detected most suitable OpenGL context version: %s", opengl_version_str) OpenGLContext.setDefaultFormat(major_version, minor_version, profile = profile) self._qml_import_paths.append(os.path.join(os.path.dirname(sys.executable), "qml")) self._qml_import_paths.append(os.path.join(self.getInstallPrefix(), "Resources", "qml")) Logger.log("i", "Initializing job queue ...") self._job_queue = JobQueue() self._job_queue.jobFinished.connect(self._onJobFinished) Logger.log("i", "Initializing version upgrade manager ...") self._version_upgrade_manager = VersionUpgradeManager(self)
from UM.Qt.Bindings.Bindings import Bindings from UM.Signal import Signal, signalemitter from UM.Resources import Resources from UM.Logger import Logger from UM.Preferences import Preferences from UM.i18n import i18nCatalog import UM.Settings.InstanceContainer #For version upgrade to know the version number. import UM.Settings.ContainerStack #For version upgrade to know the version number. import UM.Preferences #For version upgrade to know the version number. # Raised when we try to use an unsupported version of a dependency. class UnsupportedVersionError(Exception): pass # Check PyQt version, we only support 5.4 or higher. major, minor = PYQT_VERSION_STR.split(".")[0:2] if int(major) < 5 or int(minor) < 4: raise UnsupportedVersionError("This application requires at least PyQt 5.4.0") ## Application subclass that provides a Qt application object. @signalemitter class QtApplication(QApplication, Application): def __init__(self, **kwargs): plugin_path = "" if sys.platform == "win32": if hasattr(sys, "frozen"): plugin_path = os.path.join(os.path.dirname(os.path.abspath(sys.executable)), "PyQt5", "plugins") Logger.log("i", "Adding QT5 plugin path: %s" % (plugin_path)) QCoreApplication.addLibraryPath(plugin_path) else: import site
from UM.Mesh.ReadMeshJob import ReadMeshJob import UM.Qt.Bindings.Theme from UM.PluginRegistry import PluginRegistry MYPY = False if MYPY: from PyQt5.QtCore import QObject # Raised when we try to use an unsupported version of a dependency. class UnsupportedVersionError(Exception): pass # Check PyQt version, we only support 5.4 or higher. major, minor = PYQT_VERSION_STR.split(".")[0:2] if int(major) < 5 or int(minor) < 4: raise UnsupportedVersionError( "This application requires at least PyQt 5.4.0") ## Application subclass that provides a Qt application object. @signalemitter class QtApplication(QApplication, Application): pluginsLoaded = Signal() applicationRunning = Signal() def __init__(self, tray_icon_name=None, **kwargs): plugin_path = "" if sys.platform == "win32": if hasattr(sys, "frozen"):
QDoubleValidator, QFocusEvent, QFont, QKeyEvent, QKeySequence, QIcon, QImage, QImageWriter, QIntValidator, QLinearGradient, QMouseEvent, QMovie, QPainter, QPainterPath, QPalette, QPen, QPixmap, QPolygon, QRegExpValidator, QTextCursor, QValidator) from PyQt5.uic import loadUi QStringList = list getQApp = QCoreApplication.instance qApp = QCoreApplication.instance qt_imported = True qt_variant = "PyQt5" qt_version_no = list(map(int, QT_VERSION_STR.split("."))) _ver = PYQT_VERSION_STR.split(".") ver = _ver + ["0"] * (3 - len(_ver)) pyqt_version_no = list(map(int, ver))[:3] except ImportError: pass try: from PyQt5.QtWebKit import QWebPage except ImportError: pass # # PyQt4 # if (qt_variant == "PyQt4") or (qt_variant is None and not qt_imported): #
the correct python and PyQt versions. In case this fails, error messages are written to stderr and we exit with returncode ERR_CODE. Module Attributes: PYQT_VERSION: The currently installed PyQt version as tuple if any. PYQT_REQUIRED_VERSION: The minimum PyQt version required. PYTHON_REQUIRED_VERSION: The minimum python version required. ERR_CODE: Returncode used with sys.exit. """ import sys try: from PyQt5.QtCore import PYQT_VERSION_STR PYQT_VERSION = tuple(map(int, PYQT_VERSION_STR.split("."))) except ImportError: # pragma: no cover # PyQt is there in tests, using None is tested # We check explicitly for None before using the tuple version PYQT_VERSION = None # type: ignore PYTHON_REQUIRED_VERSION = (3, 6) PYQT_REQUIRED_VERSION = (5, 9, 2) ERR_CODE = 2 def check_python_version(): """Ensure the python version is new enough.""" if sys.version_info < PYTHON_REQUIRED_VERSION: _exit_version("python", PYTHON_REQUIRED_VERSION, sys.version_info[:3])
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA print('Qtvcp python plugin found:',__file__) # HAL only widgets from qtvcp.plugins.simplewidgets_plugin import * from qtvcp.plugins.led_plugin import LEDPlugin from qtvcp.plugins.hal_label_plugin import HALLabelPlugin from qtvcp.plugins.detach_tabs_plugin import DetachTabWidgetPlugin from qtvcp.plugins.round_progress_bar_plugin import RoundProgressBarPlugin from PyQt5.QtCore import PYQT_VERSION_STR try: v = PYQT_VERSION_STR.split('.') if int(v[1]) > 10: from qtvcp.plugins.joypad_plugin import * except: print('PyQt version {} to old for JoyPad widget'.format(PYQT_VERSION_STR)) # plain widgets from qtvcp.plugins.nurbs_editor_plugin import NurbsEditorPlugin # Linuxcnc widgets from qtvcp.plugins.container_plugin import StateEnableGridLayoutPlugin from qtvcp.plugins.container_plugin import JointEnableWidgetPlugin from qtvcp.plugins.graphics_plugin import GCodeGraphicsPlugin from qtvcp.plugins.widgets_plugin import * from qtvcp.plugins.state_led_plugin import StateLEDPlugin from qtvcp.plugins.status_label_plugin import StatusLabelPlugin
QPen, QPixmap, QPolygon, QRegExpValidator, QValidator ) from PyQt5.uic import loadUi QStringList = list getQApp = QCoreApplication.instance qApp = QCoreApplication.instance qt_imported = True qt_variant = "PyQt5" qt_version_no = list(map(int, QT_VERSION_STR.split("."))) _ver = PYQT_VERSION_STR.split(".") ver = _ver + ["0"] * (3 - len(_ver)) pyqt_version_no = list(map(int, ver))[:3] except ImportError: pass try: from PyQt5.QtWebKit import QWebPage except ImportError: pass # # PyQt4 # if (qt_variant == "PyQt4") or (qt_variant is None and not qt_imported): #