Пример #1
0
def initialize():
	global mainFrame
	if mainFrame:
		raise RuntimeError("GUI already initialized")
	mainFrame = MainFrame()
	wxLang = core.getWxLangOrNone()
	if wxLang:
		# otherwise the system default will be used
		mainFrame.SetLayoutDirection(wxLang.LayoutDirection)
	wx.GetApp().SetTopWindow(mainFrame)
	# In wxPython >= 4.1,
	# wx.CallAfter no longer executes callbacks while NVDA's main thread is within apopup menu or message box.
	# To work around this,
	# Monkeypatch wx.CallAfter to
	# post a WM_NULL message to our top-level window after calling the original CallAfter,
	# which causes wx's event loop to wake up enough to execute the callback.
	old_wx_CallAfter = wx.CallAfter

	def wx_CallAfter_wrapper(func, *args, **kwargs):
		old_wx_CallAfter(func, *args, **kwargs)
		# mainFrame may be None as NVDA could be terminating.
		topHandle = mainFrame.Handle if mainFrame else None
		if topHandle:
			winUser.PostMessage(topHandle, winUser.WM_NULL, 0, 0)
	wx.CallAfter = wx_CallAfter_wrapper
Пример #2
0
def initialize():
    global mainFrame
    if mainFrame:
        raise RuntimeError("GUI already initialized")
    mainFrame = MainFrame()
    wxLang = core.getWxLangOrNone()
    if wxLang:
        # otherwise the system default will be used
        mainFrame.SetLayoutDirection(wxLang.LayoutDirection)
    wx.GetApp().SetTopWindow(mainFrame)
    import monkeyPatches
    monkeyPatches.applyWxMonkeyPatches(mainFrame, winUser, wx)