コード例 #1
0
def ppd(pObj):
    ppd = c_void_p()
    # OSStatus PMPrinterCopyDescriptionURL ( PMPrinter printer, CFStringRef descriptionType, CFURLRef _Nullable *fileURL );
    OSStatus = PrintCore.PMPrinterCopyDescriptionURL(pObj,
                                                     kPMPPDDescriptionType,
                                                     byref(ppd))
    return objc.objc_object(c_void_p=ppd)
コード例 #2
0
    def EnableHighDPI(self, enable=True):
        """Attempts to enable/disable high-resolution rendering.
        """

        if not self._setGLContext():
            return

        self.__dpiscale = 1.0

        # GetContentScaleFactor does not
        # exist in wxpython 3.0.2.0
        try:
            scale = self.GetContentScaleFactor()

        except AttributeError:
            return

        # If the display can't scale,
        # (scale == 1) there's no point
        # in enabling it.
        scale = float(scale)
        enable = enable and scale > 1

        # TODO Support other platforms
        try:
            import objc
        except ImportError:
            return

        nsview = objc.objc_object(c_void_p=self.GetHandle())
        nsview.setWantsBestResolutionOpenGLSurface_(enable)

        if enable: self.__dpiscale = scale
        else: self.__dpiscale = 1.0
コード例 #3
0
    def EnableHighDPI(self, enable=True):
        """Attempts to enable/disable high-resolution rendering.
        """

        # We don't necessarily need to
        # enable high-DPI support - see
        # __init__.
        if not WXGLCanvasTarget.canToggleHighDPI():
            return

        if not self._setGLContext():
            return

        self.__dpiscale = 1.0

        # If the display can't scale,
        # (scale == 1) there's no point
        # in enabling it.
        scale = self.GetContentScaleFactor()
        enable = enable and scale > 1

        # on macOS, we have to set
        # scaling on the GL canvas
        try:
            import objc
            nsview = objc.objc_object(c_void_p=self.GetHandle())
            nsview.setWantsBestResolutionOpenGLSurface_(enable)

        # objc library not present
        except ImportError:
            return

        if enable: self.__dpiscale = scale
        else: self.__dpiscale = 1.0
コード例 #4
0
    def EnableHighDPI(self, enable=True):
        """Attempts to enable/disable high-resolution rendering.
        """

        # Not relevant under linux -
        # see note in __init__
        if platform.system() != 'Darwin':
            return

        if not self._setGLContext():
            return

        self.__dpiscale = 1.0

        # If the display can't scale,
        # (scale == 1) there's no point
        # in enabling it.
        scale = self.GetContentScaleFactor()
        enable = enable and scale > 1

        # on macOS, we have to set
        # scaling on the GL canvas
        try:
            import objc
            nsview = objc.objc_object(c_void_p=self.GetHandle())
            nsview.setWantsBestResolutionOpenGLSurface_(enable)

        # objc library not present
        except ImportError:
            return

        if enable: self.__dpiscale = scale
        else: self.__dpiscale = 1.0
コード例 #5
0
    def test_macosx_display(self):
        """
        Test display on Mac OS X
        """
        # GIVEN: A new SlideController instance on Mac OS X.
        self.screens.set_current_display(0)
        display = MagicMock()

        # WHEN: The default controller is built and a reference to the underlying NSView is stored.
        main_display = MainDisplay(display)
        try:
            nsview_pointer = main_display.winId().ascapsule()
        except:
            nsview_pointer = voidptr(main_display.winId()).ascapsule()
        pythonapi.PyCapsule_SetName.restype = c_void_p
        pythonapi.PyCapsule_SetName.argtypes = [py_object, c_char_p]
        pythonapi.PyCapsule_SetName(nsview_pointer,
                                    c_char_p(b"objc.__object__"))
        pyobjc_nsview = objc_object(cobject=nsview_pointer)

        # THEN: The window level and collection behavior should be the same as those needed for Mac OS X.
        self.assertEqual(pyobjc_nsview.window().level(),
                         NSMainMenuWindowLevel + 2,
                         'Window level should be NSMainMenuWindowLevel + 2')
        self.assertEqual(
            pyobjc_nsview.window().collectionBehavior(),
            NSWindowCollectionBehaviorManaged,
            'Window collection behavior should be NSWindowCollectionBehaviorManaged'
        )
コード例 #6
0
    def applyMacOsWindowTreatment():
        '''Apply settings to the macOS window object to make it seamless and force dark mode'''

        # Import macOS-specific libraries inside the function to avoid importing them on all platforms
        import AppKit
        import ctypes
        import objc

        # Get the system window ID of the first window
        # Other windows like preferences and onboarding should have the standard window style
        # TODO: Instead of using 1 actually find the main window
        window_id = QtGui.QGuiApplication.allWindows()[1].winId()

        # Convert system window ID into Objective-C NSView object and get the NSWindow of the view
        window_view = objc.objc_object(c_void_p=ctypes.c_void_p(window_id))
        window = window_view.window()

        # Force dark mode to avoid the dreaded white line when light mode is active
        window.setAppearance_(
            AppKit.NSAppearance.appearanceNamed_(
                AppKit.NSAppearanceNameVibrantDark))

        # Remove the window titlebar background
        window.setTitlebarAppearsTransparent_(True)

        # Hide title from window titlebar
        window.setTitleVisibility_(AppKit.NSWindowTitleHidden)

        # Allow window content to overlap the titlebar, creating a seamless window appearance
        window.setStyleMask_(window.styleMask()
                             | AppKit.NSFullSizeContentViewWindowMask)
コード例 #7
0
def IORegistryEntrySearchCFProperty(entry, plane, key, allocator=kCFAllocatorDefault, options=kIORegistryIterateRecursively):
    '''IORegistryEntrySearchCFProperty_ wrapper

    .. _IORegistryEntrySearchCFProperty: https://developer.apple.com/library/mac/#documentation/IOKit/Reference/IOKitLib_header_reference/Reference/reference.html#//apple_ref/doc/c_ref/IORegistryEntrySearchCFProperty
    '''
    prop = _iokit.IORegistryEntrySearchCFProperty(entry, plane, raw_ptr(CFSTR(key)), kCFAllocatorDefault, kIORegistryIterateRecursively)
    return objc_object(c_void_p = prop)
コード例 #8
0
ファイル: darwin.py プロジェクト: Magva7/Python_my_progs
def _wrap_value(value):
    """Converts a pointer to a *Python objc* value.

    :param value: The pointer to convert.

    :return: a wrapped value
    """
    return objc.objc_object(c_void_p=value) if value is not None else None
コード例 #9
0
 def __init__(self, dObj, controller, rawRef=False):
     if rawRef:
         self.cf_type    = objc.objc_object(c_void_p=dObj.__pointer__)
         self.ref_type   = dObj
     else:
         self.cf_type    = dObj
         self.ref_type   = DADiskRef(c_void_p=(dObj.__c_void_p__().value))
     self.controller = controller
コード例 #10
0
ファイル: diskman.py プロジェクト: chilcote/pylab
 def __init__(self, dObj, controller, rawRef=False):
     if rawRef:
         self.cf_type    = objc.objc_object(c_void_p=dObj.__pointer__)
         self.ref_type   = dObj
     else:
         self.cf_type    = dObj
         self.ref_type   = DADiskRef(c_void_p=(dObj.__c_void_p__().value))
     self.controller = controller
コード例 #11
0
def makePathFromOutline(outline):
    path = objc.objc_object(c_void_p=_makePathFromOutline(outline))
    # Not sure why, but the path object comes back with a retain count too many.
    # In _makePathFromOutline(), we do [[NSBezierPath alloc] init], so that's one.
    # We pretty much take over that reference, but I think objc.objc_object()
    # assumes it needs to own it, too.
    path.release()
    return path
コード例 #12
0
    def test_voidp_roundtrip(self):
        arr = objc.lookUpClass('NSArray').array()

        p = arr.__c_void_p__()
        self.assertIsInstance(p, ctypes.c_void_p)
        self.assertEqual(p.value, objc.pyobjc_id(arr))

        v = objc.objc_object(c_void_p=p)
        self.assertIs(v, arr)
コード例 #13
0
    def test_voidp_roundtrip(self):
        arr = objc.lookUpClass('NSArray').array()

        p = arr.__c_void_p__()
        self.assertIsInstance(p, ctypes.c_void_p)
        self.assertEqual(p.value, objc.pyobjc_id(arr))

        v = objc.objc_object(c_void_p=p)
        self.assertIs(v, arr)
コード例 #14
0
ファイル: maindisplay.py プロジェクト: imkernel/openlp
 def __init__(self, parent):
     """
     Constructor
     """
     super(MainDisplay, self).__init__(parent)
     self.screens = ScreenList()
     self.rebuild_css = False
     self.hide_mode = None
     self.override = {}
     self.retranslateUi()
     self.media_object = None
     if self.is_live:
         self.audio_player = AudioPlayer(self)
     else:
         self.audio_player = None
     self.first_time = True
     self.web_loaded = True
     self.setStyleSheet(OPAQUE_STYLESHEET)
     window_flags = QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool | QtCore.Qt.WindowStaysOnTopHint
     if Settings().value('advanced/x11 bypass wm'):
         window_flags |= QtCore.Qt.X11BypassWindowManagerHint
     # TODO: The following combination of window_flags works correctly
     # on Mac OS X. For next OpenLP version we should test it on other
     # platforms. For OpenLP 2.0 keep it only for OS X to not cause any
     # regressions on other platforms.
     if is_macosx():
         window_flags = QtCore.Qt.FramelessWindowHint | QtCore.Qt.Window
     self.setWindowFlags(window_flags)
     self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
     self.set_transparency(False)
     if is_macosx():
         if self.is_live:
             # Get a pointer to the underlying NSView
             try:
                 nsview_pointer = self.winId().ascapsule()
             except:
                 nsview_pointer = voidptr(self.winId()).ascapsule()
             # Set PyCapsule name so pyobjc will accept it
             pythonapi.PyCapsule_SetName.restype = c_void_p
             pythonapi.PyCapsule_SetName.argtypes = [py_object, c_char_p]
             pythonapi.PyCapsule_SetName(nsview_pointer, c_char_p(b"objc.__object__"))
             # Covert the NSView pointer into a pyobjc NSView object
             self.pyobjc_nsview = objc_object(cobject=nsview_pointer)
             # Set the window level so that the MainDisplay is above the menu bar and dock
             self.pyobjc_nsview.window().setLevel_(NSMainMenuWindowLevel + 2)
             # Set the collection behavior so the window is visible when Mission Control is activated
             self.pyobjc_nsview.window().setCollectionBehavior_(NSWindowCollectionBehaviorManaged)
             if self.screens.current['primary']:
                 # Connect focusWindowChanged signal so we can change the window level when the display is not in
                 # focus on the primary screen
                 self.application.focusWindowChanged.connect(self.change_window_level)
     if self.is_live:
         Registry().register_function('live_display_hide', self.hide_display)
         Registry().register_function('live_display_show', self.show_display)
         Registry().register_function('update_display_css', self.css_changed)
     self.close_display = False
コード例 #15
0
    def test_cobject_roundtrip(self):
        arr = objc.lookUpClass('NSArray').array()

        p = arr.__cobject__()
        self.assertEqual(type(p).__name__, "PyCapsule")
        self.assertIn("objc.__object__", repr(p))
        # Note: 

        v = objc.objc_object(cobject=p)
        self.assertIs(v, arr)
コード例 #16
0
    def test_cobject_roundtrip(self):
        arr = objc.lookUpClass('NSArray').array()

        p = arr.__cobject__()
        self.assertEqual(type(p).__name__, "PyCapsule")
        self.assertIn("objc.__object__", repr(p))
        # Note:

        v = objc.objc_object(cobject=p)
        self.assertIs(v, arr)
コード例 #17
0
 def get_paint_context(self, gdk_window):
     nsview_ptr = get_nsview_ptr(gdk_window)
     if self.window_context and self.nsview_ptr!=nsview_ptr:
         self.window_context.destroy()
         self.window_context = None
     if not self.window_context:
         self.nsview_ptr = nsview_ptr
         nsview = objc.objc_object(c_void_p=nsview_ptr)
         log("get_paint_context(%s) nsview(%#x)=%s", gdk_window, nsview_ptr, nsview)
         self.window_context = AGLWindowContext(self.gl_context, nsview)
     return self.window_context
コード例 #18
0
    def test_voidp_using_ctypes(self):
        lib = ctypes.CDLL('/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation')
        func = lib.CFStringCreateWithCString
        func.restype = ctypes.c_void_p
        func.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_int]

        kCFStringEncodingISOLatin1 = 0x0201
        ct_obj = func(None, b"hello world", kCFStringEncodingISOLatin1)
        
        value = objc.objc_object(c_void_p=ct_obj)
        self.assertIsInstance(value, objc.pyobjc_unicode)
        self.assertEqual(objc.pyobjc_id(value.nsstring()), ct_obj)
コード例 #19
0
    def test_voidp_using_ctypes(self):
        lib = ctypes.CDLL(
            '/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation'
        )
        func = lib.CFStringCreateWithCString
        func.restype = ctypes.c_void_p
        func.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_int]

        kCFStringEncodingISOLatin1 = 0x0201
        ct_obj = func(None, b"hello world", kCFStringEncodingISOLatin1)

        value = objc.objc_object(c_void_p=ct_obj)
        self.assertIsInstance(value, objc.pyobjc_unicode)
        self.assertEqual(objc.pyobjc_id(value.nsstring()), ct_obj)
コード例 #20
0
ファイル: gl_context.py プロジェクト: gitmirrors2/xpra
 def get_paint_context(self, gdk_window):
     nsview_ptr = get_nsview_ptr(gdk_window)
     if self.window_context and self.nsview_ptr!=nsview_ptr:
         log("get_paint_context(%s) nsview_ptr has changed, was %#x, now %#x - destroying window context",
             gdk_window, nsview_ptr, self.nsview_ptr)
         self.window_context.destroy()
         self.window_context = None
     if not self.window_context:
         self.nsview_ptr = nsview_ptr
         nsview = objc.objc_object(c_void_p=nsview_ptr)
         log("get_paint_context(%s) nsview(%#x)=%s", gdk_window, nsview_ptr, nsview)
         if self.alpha and enable_transparency:
             self.gl_context.setValues_forParameter_([0], NSOpenGLCPSurfaceOpacity)
             enable_transparency(gdk_window)
         self.window_context = AGLWindowContext(self.gl_context, nsview)
     return self.window_context
コード例 #21
0
def makePathFromArrays(points, tags, contours):
    n_contours = len(contours)
    n_points = len(tags)
    assert len(points) >= n_points
    assert points.shape[1:] == (2, )
    if points.dtype != numpy.int64:
        points = numpy.floor(points + [0.5, 0.5])
        points = points.astype(numpy.int64)
    assert tags.dtype == numpy.byte
    assert contours.dtype == numpy.short
    path = objc.objc_object(c_void_p=_makePathFromArrays(
        n_contours, n_points, points.ctypes.data_as(FT_Vector_p),
        tags.ctypes.data_as(c_char_p), contours.ctypes.data_as(c_short_p)))
    # See comment in makePathFromOutline()
    path.release()
    return path
コード例 #22
0
    def _runloop_thread(self):
        try:
            with objc.autorelease_pool():
                queue_ptr = objc.objc_object(c_void_p=self._dispatch_queue)

                self._manager = CoreBluetooth.CBCentralManager.alloc()
                self._manager.initWithDelegate_queue_options_(
                    self, queue_ptr, None)

                #self._peripheral_manager = CoreBluetooth.CBPeripheralManager.alloc()
                #self._peripheral_manager.initWithDelegate_queue_options_(self, queue_ptr, None)
                self._runloop_started_lock.set()
                AppHelper.runConsoleEventLoop(installInterrupt=True)
        except Exception as e:
            log.exception(e)
        log.info("Exiting runloop")
コード例 #23
0
def handle_retina(_nsview_pointer):
    """ OSX only. hack to detect and handle Retina display
    """
    screen = QtGui.QGuiApplication.instance().primaryScreen()
    pixelDensity = screen.physicalDotsPerInch()

    if pixelDensity >= 147:
        log.info("Retina display detected")
        try:
            import objc
        except ImportError:
            log.critical("pyobjc is not installed... try pip installing it \npip install pyobjc")
        else:
            nsview = objc.objc_object(c_void_p=_nsview_pointer)
            nsview.setWantsBestResolutionOpenGLSurface_(True)
            scaleFactor = nsview.backingScaleFactor()
            rec1 = screen.geometry()
            nsview.setBounds_(((rec1.x(),
                                rec1.y()),
                               (rec1.width() * scaleFactor,
                                rec1.height() * scaleFactor)))
コード例 #24
0
    def show(self):
        super(OverlayGraphicsView, self).show()

        # Constants
        NSWindowCollectionBehaviorFullScreenPrimary = 128
        NSWindowCollectionBehaviorCanJoinAllSpaces = 1 << 0
        NSWindowCollectionBehaviorMoveToActiveSpace = 1 << 1
        NSWindowCollectionBehaviorTransient = 1 << 3
        NSWindowCollectionBehaviorStationary = 1 << 4
        NSWindowCollectionBehaviorFullScreenAuxiliary = 1 << 8

        # Join all spaces (OSX-specific)
        ctypes.pythonapi.PyCObject_AsVoidPtr.restype = ctypes.c_void_p
        ctypes.pythonapi.PyCObject_AsVoidPtr.argtypes = [ctypes.py_object]
        cocoawin = objc.objc_object(
            c_void_p=ctypes.pythonapi.PyCObject_AsVoidPtr(
                self.effectiveWinId().ascobject()))
        cocoawin.window().setCollectionBehavior_(
            NSWindowCollectionBehaviorFullScreenAuxiliary
            | NSWindowCollectionBehaviorCanJoinAllSpaces
            | NSWindowCollectionBehaviorStationary)
        self.cocoawin = cocoawin
コード例 #25
0
    def show(self):
        super(OverlayGraphicsView, self).show()

        # Constants
        NSWindowCollectionBehaviorFullScreenPrimary = 128
        NSWindowCollectionBehaviorCanJoinAllSpaces = 1 << 0
        NSWindowCollectionBehaviorMoveToActiveSpace = 1 << 1
        NSWindowCollectionBehaviorTransient = 1 << 3
        NSWindowCollectionBehaviorStationary = 1 << 4
        NSWindowCollectionBehaviorFullScreenAuxiliary = 1 << 8

        # Join all spaces (OSX-specific)
        ctypes.pythonapi.PyCObject_AsVoidPtr.restype = ctypes.c_void_p
        ctypes.pythonapi.PyCObject_AsVoidPtr.argtypes = [ctypes.py_object]
        cocoawin = objc.objc_object(c_void_p=
            ctypes.pythonapi.PyCObject_AsVoidPtr(
                self.effectiveWinId().ascobject()))
        cocoawin.window().setCollectionBehavior_(
            NSWindowCollectionBehaviorFullScreenAuxiliary |
            NSWindowCollectionBehaviorCanJoinAllSpaces |
            NSWindowCollectionBehaviorStationary
        )
        self.cocoawin = cocoawin
コード例 #26
0
ファイル: test_maindisplay.py プロジェクト: imkernel/openlp
    def test_macosx_display(self):
        """
        Test display on Mac OS X
        """
        # GIVEN: A new SlideController instance on Mac OS X.
        self.screens.set_current_display(0)
        display = MagicMock()

        # WHEN: The default controller is built and a reference to the underlying NSView is stored.
        main_display = MainDisplay(display)
        try:
            nsview_pointer = main_display.winId().ascapsule()
        except:
            nsview_pointer = voidptr(main_display.winId()).ascapsule()
        pythonapi.PyCapsule_SetName.restype = c_void_p
        pythonapi.PyCapsule_SetName.argtypes = [py_object, c_char_p]
        pythonapi.PyCapsule_SetName(nsview_pointer, c_char_p(b"objc.__object__"))
        pyobjc_nsview = objc_object(cobject=nsview_pointer)

        # THEN: The window level and collection behavior should be the same as those needed for Mac OS X.
        self.assertEqual(pyobjc_nsview.window().level(), NSMainMenuWindowLevel + 2,
                         'Window level should be NSMainMenuWindowLevel + 2')
        self.assertEqual(pyobjc_nsview.window().collectionBehavior(), NSWindowCollectionBehaviorManaged,
                         'Window collection behavior should be NSWindowCollectionBehaviorManaged')
コード例 #27
0
ファイル: mainWindow.py プロジェクト: JimiHyun/Accordion
	def __init__(self):
		super(mainWindow, self).__init__(None, title='Cura - ' + version.getVersion())

		wx.EVT_CLOSE(self, self.OnClose)

		# allow dropping any file, restrict later
		self.SetDropTarget(dropTarget.FileDropTarget(self.OnDropFiles))

		# TODO: wxWidgets 2.9.4 has a bug when NSView does not register for dragged types when wx drop target is set. It was fixed in 2.9.5
		if sys.platform.startswith('darwin'):
			try:
				import objc
				nswindow = objc.objc_object(c_void_p=self.MacGetTopLevelWindowRef())
				view = nswindow.contentView()
				view.registerForDraggedTypes_([u'NSFilenamesPboardType'])
			except:
				pass

		self.normalModeOnlyItems = []

		mruFile = os.path.join(profile.getBasePath(), 'mru_filelist.ini')
		self.config = wx.FileConfig(appName="Cura",
						localFilename=mruFile,
						style=wx.CONFIG_USE_LOCAL_FILE)

		self.ID_MRU_MODEL1, self.ID_MRU_MODEL2, self.ID_MRU_MODEL3, self.ID_MRU_MODEL4, self.ID_MRU_MODEL5, self.ID_MRU_MODEL6, self.ID_MRU_MODEL7, self.ID_MRU_MODEL8, self.ID_MRU_MODEL9, self.ID_MRU_MODEL10 = [wx.NewId() for line in xrange(10)]
		self.modelFileHistory = wx.FileHistory(10, self.ID_MRU_MODEL1)
		self.config.SetPath("/ModelMRU")
		self.modelFileHistory.Load(self.config)

		self.ID_MRU_PROFILE1, self.ID_MRU_PROFILE2, self.ID_MRU_PROFILE3, self.ID_MRU_PROFILE4, self.ID_MRU_PROFILE5, self.ID_MRU_PROFILE6, self.ID_MRU_PROFILE7, self.ID_MRU_PROFILE8, self.ID_MRU_PROFILE9, self.ID_MRU_PROFILE10 = [wx.NewId() for line in xrange(10)]
		self.profileFileHistory = wx.FileHistory(10, self.ID_MRU_PROFILE1)
		self.config.SetPath("/ProfileMRU")
		self.profileFileHistory.Load(self.config)

		self.menubar = wx.MenuBar()
		self.fileMenu = wx.Menu()
		
		i = self.fileMenu.Append(-1, _(u"모델 불러오기...\tCTRL+L"))
		self.Bind(wx.EVT_MENU, lambda e: self.scene.showLoadModel(), i)
		i = self.fileMenu.Append(-1, _(u"모델 저장하기...\tCTRL+S"))
		self.Bind(wx.EVT_MENU, lambda e: self.scene.showSaveModel(), i)
		i = self.fileMenu.Append(-1, _(u"새로고침\tF5"))
		self.Bind(wx.EVT_MENU, lambda e: self.scene.reloadScene(e), i)
		i = self.fileMenu.Append(-1, _(u"모델링 지우기"))
		self.Bind(wx.EVT_MENU, lambda e: self.scene.OnDeleteAll(e), i)

		self.fileMenu.AppendSeparator()
		i = self.fileMenu.Append(-1, _(u"출력하기...\tCTRL+P"))
		self.Bind(wx.EVT_MENU, lambda e: self.scene.OnPrintButton(1), i)
		i = self.fileMenu.Append(-1, _(u"G코드 저장하기..."))
		self.Bind(wx.EVT_MENU, lambda e: self.scene.showSaveGCode(), i)
		i = self.fileMenu.Append(-1, _(u"슬라이스 엔진 로그 보기..."))
		self.Bind(wx.EVT_MENU, lambda e: self.scene._showEngineLog(), i)

		self.fileMenu.AppendSeparator()
		i = self.fileMenu.Append(-1, _(u"설정 불러오기..."))
		self.normalModeOnlyItems.append(i)
		self.Bind(wx.EVT_MENU, self.OnLoadProfile, i)
		i = self.fileMenu.Append(-1, _(u"설정 저장하기..."))
		self.normalModeOnlyItems.append(i)
		self.Bind(wx.EVT_MENU, self.OnSaveProfile, i)
		i = self.fileMenu.Append(-1, _(u"G코드의 설정값 불러오기..."))
		self.normalModeOnlyItems.append(i)
		self.Bind(wx.EVT_MENU, self.OnLoadProfileFromGcode, i)
		self.fileMenu.AppendSeparator()
		i = self.fileMenu.Append(-1, _(u"설정값 초기화"))
		self.normalModeOnlyItems.append(i)
		self.Bind(wx.EVT_MENU, self.OnResetProfile, i)

		self.fileMenu.AppendSeparator()
		i = self.fileMenu.Append(-1, _(u"환경설정...\tCTRL+,"))
		self.Bind(wx.EVT_MENU, self.OnPreferences, i)
		i = self.fileMenu.Append(-1, _(u"기기 세팅..."))
		self.Bind(wx.EVT_MENU, self.OnMachineSettings, i)
		self.fileMenu.AppendSeparator()

		# Model MRU list
		modelHistoryMenu = wx.Menu()
		self.fileMenu.AppendMenu(wx.NewId(), '&' + _(u"최근 모델파일"), modelHistoryMenu)
		self.modelFileHistory.UseMenu(modelHistoryMenu)
		self.modelFileHistory.AddFilesToMenu()
		self.Bind(wx.EVT_MENU_RANGE, self.OnModelMRU, id=self.ID_MRU_MODEL1, id2=self.ID_MRU_MODEL10)

		# Profle MRU list
		profileHistoryMenu = wx.Menu()
		self.fileMenu.AppendMenu(wx.NewId(), _(u"최근 설정파일"), profileHistoryMenu)
		self.profileFileHistory.UseMenu(profileHistoryMenu)
		self.profileFileHistory.AddFilesToMenu()
		self.Bind(wx.EVT_MENU_RANGE, self.OnProfileMRU, id=self.ID_MRU_PROFILE1, id2=self.ID_MRU_PROFILE10)

		self.fileMenu.AppendSeparator()
		i = self.fileMenu.Append(wx.ID_EXIT, _(u"종료"))
		self.Bind(wx.EVT_MENU, self.OnQuit, i)
		self.menubar.Append(self.fileMenu, '&' + _(u"파일(File)"))

		toolsMenu = wx.Menu()
		#i = toolsMenu.Append(-1, 'Batch run...')
		#self.Bind(wx.EVT_MENU, self.OnBatchRun, i)
		#self.normalModeOnlyItems.append(i)

		if minecraftImport.hasMinecraft():
			i = toolsMenu.Append(-1, _("Minecraft map import..."))
			self.Bind(wx.EVT_MENU, self.OnMinecraftImport, i)

		if version.isDevVersion():
			i = toolsMenu.Append(-1, _("PID Debugger..."))
			self.Bind(wx.EVT_MENU, self.OnPIDDebugger, i)

		i = toolsMenu.Append(-1, _(u"클립보드에 설정 복사하기"))
		self.Bind(wx.EVT_MENU, self.onCopyProfileClipboard,i)

		toolsMenu.AppendSeparator()
		self.allAtOnceItem = toolsMenu.Append(-1, _(u"한 번에 모두 출력"), kind=wx.ITEM_RADIO)
		self.Bind(wx.EVT_MENU, self.onOneAtATimeSwitch, self.allAtOnceItem)
		self.oneAtATime = toolsMenu.Append(-1, _(u"차례로 하나씩 출력"), kind=wx.ITEM_RADIO)
		self.Bind(wx.EVT_MENU, self.onOneAtATimeSwitch, self.oneAtATime)
		if profile.getPreference('oneAtATime') == 'True':
			self.oneAtATime.Check(True)
		else:
			self.allAtOnceItem.Check(True)

		self.menubar.Append(toolsMenu, _(u"도구(Tools)"))

		#Machine menu for machine configuration/tooling
		self.machineMenu = wx.Menu()
		self.updateMachineMenu()

		self.menubar.Append(self.machineMenu, _(u"기기(Machine)"))

		expertMenu = wx.Menu()
		i = expertMenu.Append(-1, _(u"간편 출력모드로 전환..."), kind=wx.ITEM_RADIO)
		self.switchToQuickprintMenuItem = i
		self.Bind(wx.EVT_MENU, self.OnSimpleSwitch, i)

		i = expertMenu.Append(-1, _(u"상세 설정모드로 전환..."), kind=wx.ITEM_RADIO)
		self.switchToNormalMenuItem = i
		self.Bind(wx.EVT_MENU, self.OnNormalSwitch, i)
		expertMenu.AppendSeparator()

		i = expertMenu.Append(-1, _(u"전문가설정...\tCTRL+E"))
		self.normalModeOnlyItems.append(i)
		self.Bind(wx.EVT_MENU, self.OnExpertOpen, i)
		expertMenu.AppendSeparator()
		i = expertMenu.Append(-1, _(u"초기설정 마법사..."))
		self.Bind(wx.EVT_MENU, self.OnFirstRunWizard, i)
		self.bedLevelWizardMenuItem = expertMenu.Append(-1, _(u"베드수평 마법사..."))
		self.Bind(wx.EVT_MENU, self.OnBedLevelWizard, self.bedLevelWizardMenuItem)
		self.headOffsetWizardMenuItem = expertMenu.Append(-1, _(u"head offset 마법사..."))
		self.Bind(wx.EVT_MENU, self.OnHeadOffsetWizard, self.headOffsetWizardMenuItem)

		self.menubar.Append(expertMenu, _(u"전문가(Expert)"))

		helpMenu = wx.Menu()
		i = helpMenu.Append(-1, _(u"온라인 문서..."))
		self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('http://daid.github.com/Cura'), i)
		i = helpMenu.Append(-1, _(u"오류 보고..."))
		self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('https://github.com/daid/Cura/issues'), i)
		i = helpMenu.Append(-1, _(u"업데이트 확인..."))
		self.Bind(wx.EVT_MENU, self.OnCheckForUpdate, i)
		i = helpMenu.Append(-1, _(u"YouMagine website 열기..."))
		self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('https://www.youmagine.com/'), i)
		i = helpMenu.Append(-1, _(u"소프트웨어 정보..."))
		self.Bind(wx.EVT_MENU, self.OnAbout, i)
		self.menubar.Append(helpMenu, _(u"도움말(Help)"))
		self.SetMenuBar(self.menubar)

		self.splitter = wx.SplitterWindow(self, style = wx.SP_3D | wx.SP_LIVE_UPDATE)
		self.leftPane = wx.Panel(self.splitter, style=wx.BORDER_NONE)
		self.rightPane = wx.Panel(self.splitter, style=wx.BORDER_NONE)
		self.splitter.Bind(wx.EVT_SPLITTER_DCLICK, lambda evt: evt.Veto())

		##Gui components##
		self.simpleSettingsPanel = simpleMode.simpleModePanel(self.leftPane, lambda : self.scene.sceneUpdated())
		self.normalSettingsPanel = normalSettingsPanel(self.leftPane, lambda : self.scene.sceneUpdated())

		self.leftSizer = wx.BoxSizer(wx.VERTICAL)
		self.leftSizer.Add(self.simpleSettingsPanel, 1)
		self.leftSizer.Add(self.normalSettingsPanel, 1, wx.EXPAND)
		self.leftPane.SetSizer(self.leftSizer)

		#Preview window
		self.scene = sceneView.SceneView(self.rightPane)

		#Main sizer, to position the preview window, buttons and tab control
		sizer = wx.BoxSizer()
		self.rightPane.SetSizer(sizer)
		sizer.Add(self.scene, 1, flag=wx.EXPAND)

		# Main window sizer
		sizer = wx.BoxSizer(wx.VERTICAL)
		self.SetSizer(sizer)
		sizer.Add(self.splitter, 1, wx.EXPAND)
		sizer.Layout()
		self.sizer = sizer

		self.updateProfileToAllControls()

		self.SetBackgroundColour(self.normalSettingsPanel.GetBackgroundColour())

		self.simpleSettingsPanel.Show(False)
		self.normalSettingsPanel.Show(False)

		# Set default window size & position
		self.SetSize((wx.Display().GetClientArea().GetWidth()/2,wx.Display().GetClientArea().GetHeight()/2))
		self.Centre()

		#Timer set; used to check if profile is on the clipboard
		self.timer = wx.Timer(self)
		self.Bind(wx.EVT_TIMER, self.onTimer)
		self.timer.Start(1000)
		self.lastTriedClipboard = profile.getProfileString()

		# Restore the window position, size & state from the preferences file
		try:
			if profile.getPreference('window_maximized') == 'True':
				self.Maximize(True)
			else:
				posx = int(profile.getPreference('window_pos_x'))
				posy = int(profile.getPreference('window_pos_y'))
				width = int(profile.getPreference('window_width'))
				height = int(profile.getPreference('window_height'))
				if posx > 0 or posy > 0:
					self.SetPosition((posx,posy))
				if width > 0 and height > 0:
					self.SetSize((width,height))

			self.normalSashPos = int(profile.getPreference('window_normal_sash'))
		except:
			self.normalSashPos = 0
			self.Maximize(True)
		if self.normalSashPos < self.normalSettingsPanel.printPanel.GetBestSize()[0] + 5:
			self.normalSashPos = self.normalSettingsPanel.printPanel.GetBestSize()[0] + 5

		self.splitter.SplitVertically(self.leftPane, self.rightPane, self.normalSashPos)

		if wx.Display.GetFromPoint(self.GetPosition()) < 0:
			self.Centre()
		if wx.Display.GetFromPoint((self.GetPositionTuple()[0] + self.GetSizeTuple()[1], self.GetPositionTuple()[1] + self.GetSizeTuple()[1])) < 0:
			self.Centre()
		if wx.Display.GetFromPoint(self.GetPosition()) < 0:
			self.SetSize((800,600))
			self.Centre()

		self.updateSliceMode()
		self.scene.SetFocus()
コード例 #28
0
def make_and_model(pObj):
    makeAndModel = c_void_p()
    OSStatus = PrintCore.PMPrinterGetMakeAndModelName(pObj,
                                                      byref(makeAndModel))
    return objc.objc_object(c_void_p=makeAndModel)
コード例 #29
0
ファイル: mainWindow.py プロジェクト: popwar/pythonTest
	def __init__(self):
		super(mainWindow, self).__init__(None, title='Cura - ' + version.getVersion())

		wx.EVT_CLOSE(self, self.OnClose)

		# allow dropping any file, restrict later
		self.SetDropTarget(dropTarget.FileDropTarget(self.OnDropFiles))

		# TODO: wxWidgets 2.9.4 has a bug when NSView does not register for dragged types when wx drop target is set. It was fixed in 2.9.5
		if sys.platform.startswith('darwin'):
			try:
				import objc
				nswindow = objc.objc_object(c_void_p=self.MacGetTopLevelWindowRef())
				view = nswindow.contentView()
				view.registerForDraggedTypes_([u'NSFilenamesPboardType'])
			except:
				pass

		self.normalModeOnlyItems = []

		mruFile = os.path.join(profile.getBasePath(), 'mru_filelist.ini')
		self.config = wx.FileConfig(appName="Cura",
						localFilename=mruFile,
						style=wx.CONFIG_USE_LOCAL_FILE)

		self.ID_MRU_MODEL1, self.ID_MRU_MODEL2, self.ID_MRU_MODEL3, self.ID_MRU_MODEL4, self.ID_MRU_MODEL5, self.ID_MRU_MODEL6, self.ID_MRU_MODEL7, self.ID_MRU_MODEL8, self.ID_MRU_MODEL9, self.ID_MRU_MODEL10 = [wx.NewId() for line in xrange(10)]
		self.modelFileHistory = wx.FileHistory(10, self.ID_MRU_MODEL1)
		self.config.SetPath("/ModelMRU")
		self.modelFileHistory.Load(self.config)

		self.ID_MRU_PROFILE1, self.ID_MRU_PROFILE2, self.ID_MRU_PROFILE3, self.ID_MRU_PROFILE4, self.ID_MRU_PROFILE5, self.ID_MRU_PROFILE6, self.ID_MRU_PROFILE7, self.ID_MRU_PROFILE8, self.ID_MRU_PROFILE9, self.ID_MRU_PROFILE10 = [wx.NewId() for line in xrange(10)]
		self.profileFileHistory = wx.FileHistory(10, self.ID_MRU_PROFILE1)
		self.config.SetPath("/ProfileMRU")
		self.profileFileHistory.Load(self.config)

		self.menubar = wx.MenuBar()
		self.fileMenu = wx.Menu()
		i = self.fileMenu.Append(-1, _("Load model file...\tCTRL+L"))
		self.Bind(wx.EVT_MENU, lambda e: self.scene.showLoadModel(), i)
		i = self.fileMenu.Append(-1, _("Save model...\tCTRL+S"))
		self.Bind(wx.EVT_MENU, lambda e: self.scene.showSaveModel(), i)
		i = self.fileMenu.Append(-1, _("Reload platform\tF5"))
		self.Bind(wx.EVT_MENU, lambda e: self.scene.reloadScene(e), i)
		i = self.fileMenu.Append(-1, _("Clear platform"))
		self.Bind(wx.EVT_MENU, lambda e: self.scene.OnDeleteAll(e), i)

		self.fileMenu.AppendSeparator()
		i = self.fileMenu.Append(-1, _("Print...\tCTRL+P"))
		self.Bind(wx.EVT_MENU, lambda e: self.scene.OnPrintButton(1), i)
		i = self.fileMenu.Append(-1, _("Save GCode...\tCTRL+G"))
		self.Bind(wx.EVT_MENU, lambda e: self.scene.showSaveGCode(), i)
		i = self.fileMenu.Append(-1, _("Show slice engine log..."))
		self.Bind(wx.EVT_MENU, lambda e: self.scene._showEngineLog(), i)

		self.fileMenu.AppendSeparator()
		i = self.fileMenu.Append(-1, _("Open Profile..."))
		self.normalModeOnlyItems.append(i)
		self.Bind(wx.EVT_MENU, self.OnLoadProfile, i)
		i = self.fileMenu.Append(-1, _("Save Profile..."))
		self.normalModeOnlyItems.append(i)
		self.Bind(wx.EVT_MENU, self.OnSaveProfile, i)
		if version.isDevVersion():
			i = self.fileMenu.Append(-1, "Save difference from default...")
			self.normalModeOnlyItems.append(i)
			self.Bind(wx.EVT_MENU, self.OnSaveDifferences, i)
		i = self.fileMenu.Append(-1, _("Load Profile from GCode..."))
		self.normalModeOnlyItems.append(i)
		self.Bind(wx.EVT_MENU, self.OnLoadProfileFromGcode, i)
		self.fileMenu.AppendSeparator()
		i = self.fileMenu.Append(-1, _("Reset Profile to default"))
		self.normalModeOnlyItems.append(i)
		self.Bind(wx.EVT_MENU, self.OnResetProfile, i)

		self.fileMenu.AppendSeparator()
		i = self.fileMenu.Append(-1, _("Preferences...\tCTRL+,"))
		self.Bind(wx.EVT_MENU, self.OnPreferences, i)
		i = self.fileMenu.Append(-1, _("Machine settings..."))
		self.Bind(wx.EVT_MENU, self.OnMachineSettings, i)
		self.fileMenu.AppendSeparator()

		# Model MRU list
		modelHistoryMenu = wx.Menu()
		self.fileMenu.AppendMenu(wx.NewId(), '&' + _("Recent Model Files"), modelHistoryMenu)
		self.modelFileHistory.UseMenu(modelHistoryMenu)
		self.modelFileHistory.AddFilesToMenu()
		self.Bind(wx.EVT_MENU_RANGE, self.OnModelMRU, id=self.ID_MRU_MODEL1, id2=self.ID_MRU_MODEL10)

		# Profle MRU list
		profileHistoryMenu = wx.Menu()
		self.fileMenu.AppendMenu(wx.NewId(), _("Recent Profile Files"), profileHistoryMenu)
		self.profileFileHistory.UseMenu(profileHistoryMenu)
		self.profileFileHistory.AddFilesToMenu()
		self.Bind(wx.EVT_MENU_RANGE, self.OnProfileMRU, id=self.ID_MRU_PROFILE1, id2=self.ID_MRU_PROFILE10)

		self.fileMenu.AppendSeparator()
		i = self.fileMenu.Append(wx.ID_EXIT, _("Quit"))
		self.Bind(wx.EVT_MENU, self.OnQuit, i)
		self.menubar.Append(self.fileMenu, '&' + _("File"))

		toolsMenu = wx.Menu()
		#i = toolsMenu.Append(-1, 'Batch run...')
		#self.Bind(wx.EVT_MENU, self.OnBatchRun, i)
		#self.normalModeOnlyItems.append(i)

		if minecraftImport.hasMinecraft():
			i = toolsMenu.Append(-1, _("Minecraft map import..."))
			self.Bind(wx.EVT_MENU, self.OnMinecraftImport, i)

		if version.isDevVersion():
			i = toolsMenu.Append(-1, _("PID Debugger..."))
			self.Bind(wx.EVT_MENU, self.OnPIDDebugger, i)
			i = toolsMenu.Append(-1, _("Auto Firmware Update..."))
			self.Bind(wx.EVT_MENU, self.OnAutoFirmwareUpdate, i)

		#i = toolsMenu.Append(-1, _("Copy profile to clipboard"))
		#self.Bind(wx.EVT_MENU, self.onCopyProfileClipboard,i)

		toolsMenu.AppendSeparator()
		self.allAtOnceItem = toolsMenu.Append(-1, _("Print all at once"), kind=wx.ITEM_RADIO)
		self.Bind(wx.EVT_MENU, self.onOneAtATimeSwitch, self.allAtOnceItem)
		self.oneAtATime = toolsMenu.Append(-1, _("Print one at a time"), kind=wx.ITEM_RADIO)
		self.Bind(wx.EVT_MENU, self.onOneAtATimeSwitch, self.oneAtATime)
		if profile.getPreference('oneAtATime') == 'True':
			self.oneAtATime.Check(True)
		else:
			self.allAtOnceItem.Check(True)

		self.menubar.Append(toolsMenu, _("Tools"))

		#Machine menu for machine configuration/tooling
		self.machineMenu = wx.Menu()
		self.updateMachineMenu()

		self.menubar.Append(self.machineMenu, _("Machine"))

		expertMenu = wx.Menu()
		i = expertMenu.Append(-1, _("Switch to quickprint..."), kind=wx.ITEM_RADIO)
		self.switchToQuickprintMenuItem = i
		self.Bind(wx.EVT_MENU, self.OnSimpleSwitch, i)

		i = expertMenu.Append(-1, _("Switch to full settings..."), kind=wx.ITEM_RADIO)
		self.switchToNormalMenuItem = i
		self.Bind(wx.EVT_MENU, self.OnNormalSwitch, i)
		expertMenu.AppendSeparator()

		i = expertMenu.Append(-1, _("Open expert settings...\tCTRL+E"))
		self.normalModeOnlyItems.append(i)
		self.Bind(wx.EVT_MENU, self.OnExpertOpen, i)
		expertMenu.AppendSeparator()
		self.bedLevelWizardMenuItem = expertMenu.Append(-1, _("Run bed leveling wizard..."))
		self.Bind(wx.EVT_MENU, self.OnBedLevelWizard, self.bedLevelWizardMenuItem)
		self.headOffsetWizardMenuItem = expertMenu.Append(-1, _("Run head offset wizard..."))
		self.Bind(wx.EVT_MENU, self.OnHeadOffsetWizard, self.headOffsetWizardMenuItem)

		self.menubar.Append(expertMenu, _("Expert"))

		helpMenu = wx.Menu()
		i = helpMenu.Append(-1, _("Online documentation..."))
		self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('http://daid.github.com/Cura'), i)
		i = helpMenu.Append(-1, _("Report a problem..."))
		self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('https://github.com/daid/Cura/issues'), i)
		i = helpMenu.Append(-1, _("Check for update..."))
		self.Bind(wx.EVT_MENU, self.OnCheckForUpdate, i)
		i = helpMenu.Append(-1, _("Open YouMagine website..."))
		self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('https://www.youmagine.com/'), i)
		i = helpMenu.Append(-1, _("About Cura..."))
		self.Bind(wx.EVT_MENU, self.OnAbout, i)
		self.menubar.Append(helpMenu, _("Help"))
		self.SetMenuBar(self.menubar)

		self.splitter = wx.SplitterWindow(self, style = wx.SP_3D | wx.SP_LIVE_UPDATE)
		self.leftPane = wx.Panel(self.splitter, style=wx.BORDER_NONE)
		self.rightPane = wx.Panel(self.splitter, style=wx.BORDER_NONE)
		self.splitter.Bind(wx.EVT_SPLITTER_DCLICK, lambda evt: evt.Veto())

		#Preview window
		self.scene = sceneView.SceneView(self.rightPane)

		##Gui components##
		self.simpleSettingsPanel = simpleMode.simpleModePanel(self.leftPane, self.scene.sceneUpdated)
		self.normalSettingsPanel = normalSettingsPanel(self.leftPane, self.scene.sceneUpdated)

		self.leftSizer = wx.BoxSizer(wx.VERTICAL)
		self.leftSizer.Add(self.simpleSettingsPanel, 1)
		self.leftSizer.Add(self.normalSettingsPanel, 1, wx.EXPAND)
		self.leftPane.SetSizer(self.leftSizer)

		#Main sizer, to position the preview window, buttons and tab control
		sizer = wx.BoxSizer()
		self.rightPane.SetSizer(sizer)
		sizer.Add(self.scene, 1, flag=wx.EXPAND)

		# Main window sizer
		sizer = wx.BoxSizer(wx.VERTICAL)
		self.SetSizer(sizer)
		sizer.Add(self.splitter, 1, wx.EXPAND)
		sizer.Layout()
		self.sizer = sizer

		self.updateProfileToAllControls()

		self.SetBackgroundColour(self.normalSettingsPanel.GetBackgroundColour())

		self.simpleSettingsPanel.Show(False)
		self.normalSettingsPanel.Show(False)

		# Set default window size & position
		self.SetSize((wx.Display().GetClientArea().GetWidth()/2,wx.Display().GetClientArea().GetHeight()/2))
		self.Centre()

		#Timer set; used to check if profile is on the clipboard
		self.timer = wx.Timer(self)
		self.Bind(wx.EVT_TIMER, self.onTimer)
		#self.timer.Start(1000)
		self.lastTriedClipboard = profile.getProfileString()

		# Restore the window position, size & state from the preferences file
		try:
			if profile.getPreference('window_maximized') == 'True':
				self.Maximize(True)
			else:
				posx = int(profile.getPreference('window_pos_x'))
				posy = int(profile.getPreference('window_pos_y'))
				width = int(profile.getPreference('window_width'))
				height = int(profile.getPreference('window_height'))
				if posx > 0 or posy > 0:
					self.SetPosition((posx,posy))
				if width > 0 and height > 0:
					self.SetSize((width,height))

			self.normalSashPos = int(profile.getPreference('window_normal_sash'))
		except:
			self.normalSashPos = 0
			self.Maximize(True)
		if self.normalSashPos < self.normalSettingsPanel.printPanel.GetBestSize()[0] + 5:
			self.normalSashPos = self.normalSettingsPanel.printPanel.GetBestSize()[0] + 5

		self.splitter.SplitVertically(self.leftPane, self.rightPane, self.normalSashPos)

		if wx.Display.GetFromPoint(self.GetPosition()) < 0:
			self.Centre()
		if wx.Display.GetFromPoint((self.GetPositionTuple()[0] + self.GetSizeTuple()[1], self.GetPositionTuple()[1] + self.GetSizeTuple()[1])) < 0:
			self.Centre()
		if wx.Display.GetFromPoint(self.GetPosition()) < 0:
			self.SetSize((800,600))
			self.Centre()

		self.updateSliceMode()
		self.scene.SetFocus()
		self.dialogframe = None
		if Publisher is not None:
			Publisher().subscribe(self.onPluginUpdate, "pluginupdate")

		pluginCount = self.normalSettingsPanel.pluginPanel.GetActivePluginCount()
		if pluginCount == 1:
			self.scene.notification.message("Warning: 1 plugin from the previous session is still active.")

		if pluginCount > 1:
			self.scene.notification.message("Warning: %i plugins from the previous session are still active." % pluginCount)
コード例 #30
0
def main():
    # Arguments
    parser = argparse.ArgumentParser()
    parser.add_argument(
        '-l',
        '--logtofile',
        action='store_true',
        help=
        'enable logging in the file easyDiffraction.log in the system directory tmp instead of the terminal'
    )
    parser.add_argument(
        '-t',
        '--testmode',
        action='store_true',
        help=
        'run the application in test mode: run the tutorial, record a video and exit the application'
    )
    args = parser.parse_args()
    if args.logtofile:
        import easyApp.Logging

    # Paths
    app_name = CONFIG['tool']['poetry']['name']
    current_path = os.path.dirname(sys.argv[0])
    package_path = os.path.join(current_path, f'{app_name}App')
    if not os.path.exists(package_path):
        package_path = current_path

    main_qml_path = QUrl.fromLocalFile(
        os.path.join(package_path, 'Gui', 'main.qml'))
    gui_path = str(QUrl.fromLocalFile(package_path).toString())
    app_icon_path = os.path.join(package_path, 'Gui', 'Resources', 'Logo',
                                 'App.png')
    easyApp_path = os.path.join(easyApp2.__path__[0], '..')

    home_path = pathlib.Path.home()
    settings_path = str(home_path.joinpath(f'.{app_name}', 'settings.ini'))

    languages = CONFIG['ci']['app']['translations']['languages']
    translations_dir = CONFIG['ci']['app']['translations']['dir']
    translations_path = os.path.join(package_path,
                                     *translations_dir.split('/'))

    # QtWebEngine
    QtWebEngine.initialize()

    # Application
    app = App(sys.argv)
    app.setApplicationName(CONFIG['tool']['poetry']['name'])
    app.setApplicationVersion(CONFIG['tool']['poetry']['version'])
    app.setOrganizationName(CONFIG['tool']['poetry']['name'])
    app.setOrganizationDomain(CONFIG['tool']['poetry']['name'])
    app.setWindowIcon(QIcon(app_icon_path))

    app.setWindowIcon(
        QIcon(os.path.join(package_path, 'Gui', 'Resources', 'Logo',
                           'App.png')))
    # QML application engine
    engine = QQmlApplicationEngine()

    # Python objects to be exposed to QML
    py_qml_proxy_obj = PyQmlProxy()
    translator = Translator(app, engine, translations_path, languages)

    # Expose the Python objects to QML
    engine.rootContext().setContextProperty('_pyQmlProxyObj', py_qml_proxy_obj)
    engine.rootContext().setContextProperty('_settingsPath', settings_path)
    engine.rootContext().setContextProperty('_translator', translator)
    engine.rootContext().setContextProperty('_projectConfig', CONFIG)
    engine.rootContext().setContextProperty('_isTestMode', args.testmode)
    engine.rootContext().setContextProperty('_isSystemThemeDark',
                                            darkdetect.isDark())

    # Register types to be instantiated in QML
    qmlRegisterType(Updater, 'easyApp.Logic.Maintenance', 1, 0, 'Updater')

    # Add paths to search for installed modules
    engine.addImportPath(easyApp_path)
    engine.addImportPath(gui_path)

    # Load the root QML file
    engine.load(main_qml_path)

    # Customize app window titlebar
    if platform.system() == "Darwin":
        import ctypes, objc, Cocoa

        # Root application window
        root_obj = engine.rootObjects()
        if not root_obj:
            sys.exit(-1)
        root_window = root_obj[0]

        ptr = int(root_window.winId())
        view = objc.objc_object(c_void_p=ctypes.c_void_p(ptr))
        window = view._.window

        window.setStyleMask_(window.styleMask()
                             | Cocoa.NSFullSizeContentViewWindowMask)
        window.setTitlebarAppearsTransparent_(True)
        window.setTitleVisibility_(Cocoa.NSWindowTitleHidden)

    # Event loop
    if not engine.rootObjects():
        sys.exit(-1)
    sys.exit(app.exec_())
コード例 #31
0
ファイル: auth_db.py プロジェクト: xiexiaojun/pylab
def authorization_right_get(right):
    db_buffer = c_void_p()
    AuthorizationRightGet(right, byref(db_buffer))
    if db_buffer:
        return objc.objc_object(c_void_p=db_buffer).mutableCopy()
    return None
コード例 #32
0
ファイル: auth_db.py プロジェクト: chilcote/pylab
def authorization_right_get(right):
    db_buffer = c_void_p()
    AuthorizationRightGet(right, byref(db_buffer))
    if db_buffer:
        return objc.objc_object(c_void_p=db_buffer).mutableCopy()
    return None
コード例 #33
0
ファイル: snippet.py プロジェクト: szabo92/gistable
 def contents(self):
     # Cast the pointer cArray now points to into a objc object (CFArray/NSArray here)
     return [
         str(x) for x in objc.objc_object(c_void_p=self.cArray.contents)
     ]
コード例 #34
0
 def __init__(self, parent):
     """
     Constructor
     """
     super(MainDisplay, self).__init__(parent)
     self.screens = ScreenList()
     self.rebuild_css = False
     self.hide_mode = None
     self.override = {}
     self.retranslateUi()
     self.media_object = None
     if self.is_live:
         self.audio_player = AudioPlayer(self)
     else:
         self.audio_player = None
     self.first_time = True
     self.web_loaded = True
     self.setStyleSheet(OPAQUE_STYLESHEET)
     window_flags = QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool | QtCore.Qt.WindowStaysOnTopHint
     if Settings().value('advanced/x11 bypass wm'):
         window_flags |= QtCore.Qt.X11BypassWindowManagerHint
     # TODO: The following combination of window_flags works correctly
     # on Mac OS X. For next OpenLP version we should test it on other
     # platforms. For OpenLP 2.0 keep it only for OS X to not cause any
     # regressions on other platforms.
     if is_macosx():
         window_flags = QtCore.Qt.FramelessWindowHint | QtCore.Qt.Window | QtCore.Qt.NoDropShadowWindowHint
     self.setWindowFlags(window_flags)
     self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
     self.set_transparency(False)
     if is_macosx():
         if self.is_live:
             # Get a pointer to the underlying NSView
             try:
                 nsview_pointer = self.winId().ascapsule()
             except:
                 nsview_pointer = voidptr(self.winId()).ascapsule()
             # Set PyCapsule name so pyobjc will accept it
             pythonapi.PyCapsule_SetName.restype = c_void_p
             pythonapi.PyCapsule_SetName.argtypes = [py_object, c_char_p]
             pythonapi.PyCapsule_SetName(nsview_pointer,
                                         c_char_p(b"objc.__object__"))
             # Covert the NSView pointer into a pyobjc NSView object
             self.pyobjc_nsview = objc_object(cobject=nsview_pointer)
             # Set the window level so that the MainDisplay is above the menu bar and dock
             self.pyobjc_nsview.window().setLevel_(NSMainMenuWindowLevel +
                                                   2)
             # Set the collection behavior so the window is visible when Mission Control is activated
             self.pyobjc_nsview.window().setCollectionBehavior_(
                 NSWindowCollectionBehaviorManaged)
             if self.screens.current['primary']:
                 # Connect focusWindowChanged signal so we can change the window level when the display is not in
                 # focus on the primary screen
                 self.application.focusWindowChanged.connect(
                     self.change_window_level)
     if self.is_live:
         Registry().register_function('live_display_hide',
                                      self.hide_display)
         Registry().register_function('live_display_show',
                                      self.show_display)
         Registry().register_function('update_display_css',
                                      self.css_changed)
     self.close_display = False
コード例 #35
0
ファイル: snippet.py プロジェクト: szabo92/gistable
CFDictionaryCreateMutableCopy = CFoundation.CFDictionaryCreateMutableCopy
CFDictionaryCreateMutableCopy.argtypes = [c_void_p, c_int, c_void_p]
CFDictionaryCreateMutableCopy.restype = c_void_p

# We need to pass in a C string (null terminated) UTF-8 encoded path to a FileVault2 encrypted volume (needs to be mounted path or /dev path)
root_volume = create_string_buffer((u"/").encode("UTF-8"))

# Then we can load up the FileVault2 information! :)
family_properties = CoreStorageCopyFamilyPropertiesForMount(root_volume)

# But before we can do ANYTHING with it, we need to make a mutable copy
fv2_CFDictRef = CFDictionaryCreateMutableCopy(0, 0, family_properties)

# But this is a ctypes CFDictionary pointer, which is boring to play with - let's bridge it to pyobjc!
# pyobjc can take a raw pointer to a (known) CF type and convert to the normal NS/CF/python objects
fv2_dict = objc.objc_object(c_void_p=fv2_CFDictRef)

# Yay, now you have data!
# >>> fv2_dict.keys()
# (
#     "com.apple.corestorage.lvf.sequence",
#     "com.apple.corestorage.lvf.groupUUID",
#     DefaultEncryptionContext,
#     "com.apple.corestorage.lvf.uuid",
#     PreviousEncryptionContext,
#     "com.apple.corestorage.lvf.revertState",
#     "com.apple.corestorage.lvf.encryption.type",
#     "com.apple.corestorage.lvf.encryption.status",
#     "com.apple.corestorage.lvf.encryption.context"
# )
# >>> fv2_dict['com.apple.corestorage.lvf.encryption.context'].keys()
コード例 #36
0
ファイル: osx.py プロジェクト: ryuanwei/pymtprotocol
def dispatch_get_global_queue(identifier, flags):
    return objc.objc_object(
        c_void_p=libSystem.dispatch_get_global_queue(identifier, flags))
コード例 #37
0
def printer_name(pObj):
    return objc.objc_object(c_void_p=PMPrinterGetName(pObj))
コード例 #38
0
def device_uri(pObj):
    deviceURI = c_void_p()
    OSStatus = PrintCore.PMPrinterCopyDeviceURI(pObj, byref(deviceURI))
    # return deviceURI
    return objc.objc_object(c_void_p=deviceURI)
コード例 #39
0
    def __init__(self):
        super(mainWindow,
              self).__init__(None, title='Cura - ' + version.getVersion())

        wx.EVT_CLOSE(self, self.OnClose)

        # allow dropping any file, restrict later
        self.SetDropTarget(dropTarget.FileDropTarget(self.OnDropFiles))

        # TODO: wxWidgets 2.9.4 has a bug when NSView does not register for dragged types when wx drop target is set. It was fixed in 2.9.5
        if sys.platform.startswith('darwin'):
            try:
                import objc
                nswindow = objc.objc_object(
                    c_void_p=self.MacGetTopLevelWindowRef())
                view = nswindow.contentView()
                view.registerForDraggedTypes_([u'NSFilenamesPboardType'])
            except:
                pass

        self.normalModeOnlyItems = []

        mruFile = os.path.join(profile.getBasePath(), 'mru_filelist.ini')
        self.config = wx.FileConfig(appName="Cura",
                                    localFilename=mruFile,
                                    style=wx.CONFIG_USE_LOCAL_FILE)

        self.ID_MRU_MODEL1, self.ID_MRU_MODEL2, self.ID_MRU_MODEL3, self.ID_MRU_MODEL4, self.ID_MRU_MODEL5, self.ID_MRU_MODEL6, self.ID_MRU_MODEL7, self.ID_MRU_MODEL8, self.ID_MRU_MODEL9, self.ID_MRU_MODEL10 = [
            wx.NewId() for line in xrange(10)
        ]
        self.modelFileHistory = wx.FileHistory(10, self.ID_MRU_MODEL1)
        self.config.SetPath("/ModelMRU")
        self.modelFileHistory.Load(self.config)

        self.ID_MRU_PROFILE1, self.ID_MRU_PROFILE2, self.ID_MRU_PROFILE3, self.ID_MRU_PROFILE4, self.ID_MRU_PROFILE5, self.ID_MRU_PROFILE6, self.ID_MRU_PROFILE7, self.ID_MRU_PROFILE8, self.ID_MRU_PROFILE9, self.ID_MRU_PROFILE10 = [
            wx.NewId() for line in xrange(10)
        ]
        self.profileFileHistory = wx.FileHistory(10, self.ID_MRU_PROFILE1)
        self.config.SetPath("/ProfileMRU")
        self.profileFileHistory.Load(self.config)

        self.menubar = wx.MenuBar()
        self.fileMenu = wx.Menu()
        i = self.fileMenu.Append(-1, _("Load model file...\tCTRL+L"))
        self.Bind(wx.EVT_MENU, lambda e: self.scene.showLoadModel(), i)
        i = self.fileMenu.Append(-1, _("Save model...\tCTRL+S"))
        self.Bind(wx.EVT_MENU, lambda e: self.scene.showSaveModel(), i)
        i = self.fileMenu.Append(-1, _("Reload platform\tF5"))
        self.Bind(wx.EVT_MENU, lambda e: self.scene.reloadScene(e), i)
        i = self.fileMenu.Append(-1, _("Clear platform"))
        self.Bind(wx.EVT_MENU, lambda e: self.scene.OnDeleteAll(e), i)

        self.fileMenu.AppendSeparator()
        i = self.fileMenu.Append(-1, _("Print...\tCTRL+P"))
        self.Bind(wx.EVT_MENU, lambda e: self.scene.OnPrintButton(1), i)
        i = self.fileMenu.Append(-1, _("Save GCode..."))
        self.Bind(wx.EVT_MENU, lambda e: self.scene.showSaveGCode(), i)
        i = self.fileMenu.Append(-1, _("Show slice engine log..."))
        self.Bind(wx.EVT_MENU, lambda e: self.scene._showEngineLog(), i)

        self.fileMenu.AppendSeparator()
        i = self.fileMenu.Append(-1, _("Open Profile..."))
        self.normalModeOnlyItems.append(i)
        self.Bind(wx.EVT_MENU, self.OnLoadProfile, i)
        i = self.fileMenu.Append(-1, _("Save Profile..."))
        self.normalModeOnlyItems.append(i)
        self.Bind(wx.EVT_MENU, self.OnSaveProfile, i)
        i = self.fileMenu.Append(-1, _("Load Profile from GCode..."))
        self.normalModeOnlyItems.append(i)
        self.Bind(wx.EVT_MENU, self.OnLoadProfileFromGcode, i)
        self.fileMenu.AppendSeparator()
        i = self.fileMenu.Append(-1, _("Reset Profile to default"))
        self.normalModeOnlyItems.append(i)
        self.Bind(wx.EVT_MENU, self.OnResetProfile, i)

        self.fileMenu.AppendSeparator()
        i = self.fileMenu.Append(-1, _("Preferences...\tCTRL+,"))
        self.Bind(wx.EVT_MENU, self.OnPreferences, i)
        i = self.fileMenu.Append(-1, _("Machine settings..."))
        self.Bind(wx.EVT_MENU, self.OnMachineSettings, i)
        self.fileMenu.AppendSeparator()

        # Model MRU list
        modelHistoryMenu = wx.Menu()
        self.fileMenu.AppendMenu(wx.NewId(), '&' + _("Recent Model Files"),
                                 modelHistoryMenu)
        self.modelFileHistory.UseMenu(modelHistoryMenu)
        self.modelFileHistory.AddFilesToMenu()
        self.Bind(wx.EVT_MENU_RANGE,
                  self.OnModelMRU,
                  id=self.ID_MRU_MODEL1,
                  id2=self.ID_MRU_MODEL10)

        # Profle MRU list
        profileHistoryMenu = wx.Menu()
        self.fileMenu.AppendMenu(wx.NewId(), _("Recent Profile Files"),
                                 profileHistoryMenu)
        self.profileFileHistory.UseMenu(profileHistoryMenu)
        self.profileFileHistory.AddFilesToMenu()
        self.Bind(wx.EVT_MENU_RANGE,
                  self.OnProfileMRU,
                  id=self.ID_MRU_PROFILE1,
                  id2=self.ID_MRU_PROFILE10)

        self.fileMenu.AppendSeparator()
        i = self.fileMenu.Append(wx.ID_EXIT, _("Quit"))
        self.Bind(wx.EVT_MENU, self.OnQuit, i)
        self.menubar.Append(self.fileMenu, '&' + _("File"))

        toolsMenu = wx.Menu()
        #i = toolsMenu.Append(-1, 'Batch run...')
        #self.Bind(wx.EVT_MENU, self.OnBatchRun, i)
        #self.normalModeOnlyItems.append(i)

        if minecraftImport.hasMinecraft():
            i = toolsMenu.Append(-1, _("Minecraft map import..."))
            self.Bind(wx.EVT_MENU, self.OnMinecraftImport, i)

        if version.isDevVersion():
            i = toolsMenu.Append(-1, _("PID Debugger..."))
            self.Bind(wx.EVT_MENU, self.OnPIDDebugger, i)

        i = toolsMenu.Append(-1, _("Copy profile to clipboard"))
        self.Bind(wx.EVT_MENU, self.onCopyProfileClipboard, i)

        toolsMenu.AppendSeparator()
        self.allAtOnceItem = toolsMenu.Append(-1,
                                              _("Print all at once"),
                                              kind=wx.ITEM_RADIO)
        self.Bind(wx.EVT_MENU, self.onOneAtATimeSwitch, self.allAtOnceItem)
        self.oneAtATime = toolsMenu.Append(-1,
                                           _("Print one at a time"),
                                           kind=wx.ITEM_RADIO)
        self.Bind(wx.EVT_MENU, self.onOneAtATimeSwitch, self.oneAtATime)
        if profile.getPreference('oneAtATime') == 'True':
            self.oneAtATime.Check(True)
        else:
            self.allAtOnceItem.Check(True)

        self.menubar.Append(toolsMenu, _("Tools"))

        #Machine menu for machine configuration/tooling
        self.machineMenu = wx.Menu()
        self.updateMachineMenu()

        self.menubar.Append(self.machineMenu, _("Machine"))

        expertMenu = wx.Menu()
        i = expertMenu.Append(-1,
                              _("Switch to quickprint..."),
                              kind=wx.ITEM_RADIO)
        self.switchToQuickprintMenuItem = i
        self.Bind(wx.EVT_MENU, self.OnSimpleSwitch, i)

        i = expertMenu.Append(-1,
                              _("Switch to full settings..."),
                              kind=wx.ITEM_RADIO)
        self.switchToNormalMenuItem = i
        self.Bind(wx.EVT_MENU, self.OnNormalSwitch, i)
        expertMenu.AppendSeparator()

        i = expertMenu.Append(-1, _("Open expert settings...\tCTRL+E"))
        self.normalModeOnlyItems.append(i)
        self.Bind(wx.EVT_MENU, self.OnExpertOpen, i)
        expertMenu.AppendSeparator()
        i = expertMenu.Append(-1, _("Run first run wizard..."))
        self.Bind(wx.EVT_MENU, self.OnFirstRunWizard, i)
        self.bedLevelWizardMenuItem = expertMenu.Append(
            -1, _("Run bed leveling wizard..."))
        self.Bind(wx.EVT_MENU, self.OnBedLevelWizard,
                  self.bedLevelWizardMenuItem)
        self.headOffsetWizardMenuItem = expertMenu.Append(
            -1, _("Run head offset wizard..."))
        self.Bind(wx.EVT_MENU, self.OnHeadOffsetWizard,
                  self.headOffsetWizardMenuItem)

        self.menubar.Append(expertMenu, _("Expert"))

        helpMenu = wx.Menu()
        i = helpMenu.Append(-1, _("Online documentation..."))
        self.Bind(wx.EVT_MENU,
                  lambda e: webbrowser.open('http://daid.github.com/Cura'), i)
        i = helpMenu.Append(-1, _("Report a problem..."))
        self.Bind(
            wx.EVT_MENU,
            lambda e: webbrowser.open('https://github.com/daid/Cura/issues'),
            i)
        i = helpMenu.Append(-1, _("Check for update..."))
        self.Bind(wx.EVT_MENU, self.OnCheckForUpdate, i)
        if profile.getPreference('use_youmagine') == 'True':
            i = helpMenu.Append(-1, _("Open YouMagine website..."))
            self.Bind(wx.EVT_MENU,
                      lambda e: webbrowser.open('https://www.youmagine.com/'),
                      i)
        i = helpMenu.Append(-1, _("About Cura..."))
        self.Bind(wx.EVT_MENU, self.OnAbout, i)
        self.menubar.Append(helpMenu, _("Help"))
        self.SetMenuBar(self.menubar)

        self.splitter = wx.SplitterWindow(self,
                                          style=wx.SP_3D | wx.SP_LIVE_UPDATE)
        self.leftPane = wx.Panel(self.splitter, style=wx.BORDER_NONE)
        self.rightPane = wx.Panel(self.splitter, style=wx.BORDER_NONE)
        self.splitter.Bind(wx.EVT_SPLITTER_DCLICK, lambda evt: evt.Veto())

        ##Gui components##
        self.simpleSettingsPanel = simpleMode.simpleModePanel(
            self.leftPane, lambda: self.scene.sceneUpdated())
        self.normalSettingsPanel = normalSettingsPanel(
            self.leftPane, lambda: self.scene.sceneUpdated())

        self.leftSizer = wx.BoxSizer(wx.VERTICAL)
        self.leftSizer.Add(self.simpleSettingsPanel, 1)
        self.leftSizer.Add(self.normalSettingsPanel, 1, wx.EXPAND)
        self.leftPane.SetSizer(self.leftSizer)

        #Preview window
        self.scene = sceneView.SceneView(self.rightPane)

        #Main sizer, to position the preview window, buttons and tab control
        sizer = wx.BoxSizer()
        self.rightPane.SetSizer(sizer)
        sizer.Add(self.scene, 1, flag=wx.EXPAND)

        # Main window sizer
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)
        sizer.Add(self.splitter, 1, wx.EXPAND)
        sizer.Layout()
        self.sizer = sizer

        self.updateProfileToAllControls()

        self.SetBackgroundColour(
            self.normalSettingsPanel.GetBackgroundColour())

        self.simpleSettingsPanel.Show(False)
        self.normalSettingsPanel.Show(False)

        # Set default window size & position
        self.SetSize((wx.Display().GetClientArea().GetWidth() / 2,
                      wx.Display().GetClientArea().GetHeight() / 2))
        self.Centre()

        #Timer set; used to check if profile is on the clipboard
        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.onTimer)
        self.timer.Start(1000)
        self.lastTriedClipboard = profile.getProfileString()

        # Restore the window position, size & state from the preferences file
        try:
            if profile.getPreference('window_maximized') == 'True':
                self.Maximize(True)
            else:
                posx = int(profile.getPreference('window_pos_x'))
                posy = int(profile.getPreference('window_pos_y'))
                width = int(profile.getPreference('window_width'))
                height = int(profile.getPreference('window_height'))
                if posx > 0 or posy > 0:
                    self.SetPosition((posx, posy))
                if width > 0 and height > 0:
                    self.SetSize((width, height))

            self.normalSashPos = int(
                profile.getPreference('window_normal_sash'))
        except:
            self.normalSashPos = 0
            self.Maximize(True)
        if self.normalSashPos < self.normalSettingsPanel.printPanel.GetBestSize(
        )[0] + 5:
            self.normalSashPos = self.normalSettingsPanel.printPanel.GetBestSize(
            )[0] + 5

        self.splitter.SplitVertically(self.leftPane, self.rightPane,
                                      self.normalSashPos)

        if wx.Display.GetFromPoint(self.GetPosition()) < 0:
            self.Centre()
        if wx.Display.GetFromPoint(
            (self.GetPositionTuple()[0] + self.GetSizeTuple()[1],
             self.GetPositionTuple()[1] + self.GetSizeTuple()[1])) < 0:
            self.Centre()
        if wx.Display.GetFromPoint(self.GetPosition()) < 0:
            self.SetSize((800, 600))
            self.Centre()

        self.updateSliceMode()
        self.scene.SetFocus()
コード例 #40
0
def main():
    # Settings
    QCoreApplication.setAttribute(
        Qt.AA_EnableHighDpiScaling)  # DOESN'T WORK, USE SCRIPT INSTEAD
    QCoreApplication.setAttribute(Qt.AA_UseDesktopOpenGL, True)

    # Paths
    app_name = CONFIG['tool']['poetry']['name']
    current_path = os.path.dirname(sys.argv[0])
    package_path = os.path.join(current_path, f'{app_name}App')
    if not os.path.exists(package_path):
        package_path = current_path

    main_qml_path = QUrl.fromLocalFile(
        os.path.join(package_path, 'Gui', 'main.qml'))
    gui_path = str(QUrl.fromLocalFile(package_path).toString())
    easyAppGui_path = os.path.join(easyAppGui.__path__[0], '..')

    home_path = pathlib.Path.home()
    settings_path = str(home_path.joinpath(f'.{app_name}', 'settings.ini'))

    languages = CONFIG['ci']['app']['translations']['languages']
    translations_dir = CONFIG['ci']['app']['translations']['dir']
    translations_path = os.path.join(package_path,
                                     *translations_dir.split('/'))

    # QtWebEngine
    QtWebEngine.initialize()

    # Application
    app = App(sys.argv)
    app.setApplicationName(CONFIG['tool']['poetry']['name'])
    app.setApplicationVersion(CONFIG['tool']['poetry']['version'])
    app.setOrganizationName(CONFIG['tool']['poetry']['name'])
    app.setOrganizationDomain(CONFIG['tool']['poetry']['name'])

    # QML application engine
    engine = QQmlApplicationEngine()

    # Python objects to be exposed to QML
    py_qml_proxy_obj = PyQmlProxy()
    translator = Translator(app, engine, translations_path, languages)
    vtk_handler = VtkCanvasHandler()

    # Expose the Python objects to QML
    engine.rootContext().setContextProperty('_pyQmlProxyObj', py_qml_proxy_obj)
    engine.rootContext().setContextProperty('_settingsPath', settings_path)
    engine.rootContext().setContextProperty('_translator', translator)
    engine.rootContext().setContextProperty('_vtkHandler', vtk_handler)
    engine.rootContext().setContextProperty('_projectConfig', CONFIG)
    engine.rootContext().setContextProperty('_isTestMode', isTestMode())

    # Register types to be instantiated in QML
    qmlRegisterType(FigureCanvasQtQuickAgg, 'MatplotlibBackend', 1, 0,
                    'FigureCanvas')
    qmlRegisterType(FboItem, 'QtVTK', 1, 0, 'VtkFboItem')

    # Add paths to search for installed modules
    engine.addImportPath(easyAppGui_path)
    engine.addImportPath(gui_path)

    # Load the root QML file
    engine.load(main_qml_path)

    # Root application window
    root_window = engine.rootObjects()[0]

    # VTK setup
    app.vtkSetup(root_window)
    vtk_handler.fbo = app._m_vtkFboItem
    vtk_handler.context = root_window
    py_qml_proxy_obj.setVtkHandler(vtk_handler)

    # Customize app window titlebar
    if platform.system() == "Darwin":
        import ctypes, objc, Cocoa

        ptr = int(root_window.winId())
        view = objc.objc_object(c_void_p=ctypes.c_void_p(ptr))
        window = view._.window

        window.setStyleMask_(window.styleMask()
                             | Cocoa.NSFullSizeContentViewWindowMask)
        window.setTitlebarAppearsTransparent_(True)
        window.setTitleVisibility_(Cocoa.NSWindowTitleHidden)

    # Event loop
    if not engine.rootObjects():
        sys.exit(-1)
    sys.exit(app.exec_())