Exemplo n.º 1
0
def messageBox(message: str,
               caption: str = wx.MessageBoxCaptionStr,
               style: int = wx.OK | wx.CENTER,
               parent: Optional[wx.Window] = None) -> int:
    """Display a message dialog.
	This should be used for all message dialogs
	rather than using C{wx.MessageDialog} and C{wx.MessageBox} directly.
	@param message: The message text.
	@param caption: The caption (title) of the dialog.
	@param style: Same as for wx.MessageBox.
	@param parent: The parent window.
	@return: Same as for wx.MessageBox.
	"""
    from gui import mainFrame
    import gui
    global _messageBoxCounter
    with _messageBoxCounterLock:
        _messageBoxCounter += 1
    if version_year < 2022:
        gui.isInMessageBox = True
    try:
        if not parent:
            mainFrame.prePopup()
        res = wx.MessageBox(message, caption, style, parent or mainFrame)
        if not parent:
            mainFrame.postPopup()
    finally:
        with _messageBoxCounterLock:
            _messageBoxCounter -= 1
        if version_year < 2022:
            gui.isInMessageBox = isInMessageBox()
    return res
def myMessageBox(message,
                 caption=wx.MessageBoxCaptionStr,
                 style=wx.OK | wx.CENTER,
                 parent=None):
    """Display a message dialog.
	This should be used for all message dialogs
	rather than using C{wx.MessageDialog} and C{wx.MessageBox} directly.
	@param message: The message text.
	@type message: str
	@param caption: The caption (title) of the dialog.
	@type caption: str
	@param style: Same as for wx.MessageBox.
	@type style: int
	@param parent: The parent window (optional).
	@type parent: C{wx.Window}
	@return: Same as for wx.MessageBox.
	@rtype: int
	"""
    global isInMessageBox

    option = config.conf.profiles[0]["presentation"][
        "reportObjectDescriptions"]
    config.conf.profiles[0]["presentation"]["reportObjectDescriptions"] = True
    wasAlready = isInMessageBox
    isInMessageBox = True
    if not parent:
        mainFrame.prePopup()
    res = wx.MessageBox(message, caption, style, parent or mainFrame)
    if not parent:
        mainFrame.postPopup()
    if not wasAlready:
        isInMessageBox = False
    config.conf.profiles[0]["presentation"][
        "reportObjectDescriptions"] = option
    return res
 def run(cls):
     if isOpened(cls):
         return
     mainFrame.prePopup()
     d = cls(mainFrame)
     d.CentreOnScreen()
     d.Show()
     mainFrame.postPopup()
    def run(cls, parent, informationLabel, information):
        if isOpened(InformationDialog):
            return

        if not parent:
            mainFrame.prePopup()
        InformationDialog(parent or mainFrame, informationLabel, information)
        if not parent:
            mainFrame.postPopup()
Exemplo n.º 5
0
 def run(cls, parent, informationLabel, information):
     if isOpened(InformationDialog):
         return
     if not parent:
         mainFrame.prePopup()
     d = InformationDialog(parent or mainFrame, informationLabel,
                           information)
     d.CentreOnScreen()
     d.Show()
     if not parent:
         mainFrame.postPopup()
	def run(cls, parent, dialogTitle,informationLabel, information, insertionPointOnLastLine = False):
		if isOpened(InformationDialog):
			return
		
		if parent is None:
			mainFrame.prePopup()
		d = InformationDialog(parent or mainFrame, dialogTitle, informationLabel, information, insertionPointOnLastLine)
		d.CentreOnScreen()
		d.Show()     
		if parent is None:
			mainFrame.postPopup()
Exemplo n.º 7
0
	def run(cls, parent, dialogTitle, informationLabel, information):
		if isOpened(InformationDialog):
			return
		if parent is None:
			mainFrame.prePopup()
		d = InformationDialog(
			parent or mainFrame, dialogTitle,
			informationLabel, information)
		d.Center(wx.BOTH | wx.CENTER_ON_SCREEN)
		d.Show()
		if parent is None:
			mainFrame.postPopup()
 def run(cls):
     from .volumeControl import isInitialized
     if not isInitialized:
         # cannot split sound
         # Translators: message to user to report incompatibility with another add-on.
         wx.CallLater(
             40, ui.message,
             _("Not available cause of conflict with another add-on. See NVDA log"
               ))
         return
     if isOpened(cls):
         return
     mainFrame.prePopup()
     d = cls(mainFrame)
     d.CentreOnScreen()
     d.Show()
     mainFrame.postPopup()
Exemplo n.º 9
0
def messageBox(message: str,
               caption: str = wx.MessageBoxCaptionStr,
               style: int = wx.OK | wx.CENTER,
               parent: Optional[wx.Window] = None) -> int:
    """Display a message dialog.
	Avoid using C{wx.MessageDialog} and C{wx.MessageBox} directly.
	@param message: The message text.
	@param caption: The caption (title) of the dialog.
	@param style: Same as for wx.MessageBox.
	@param parent: The parent window.
	@return: Same as for wx.MessageBox.

	`gui.message.messageBox` is a function which blocks the calling thread,
	until a user responds to the modal dialog.
	This function should be used when an answer is required before proceeding.
	Consider using a custom subclass of a wxDialog if an answer is not required
	or a default answer can be provided.

	It's possible for multiple message boxes to be open at a time.
	Before opening a new messageBox, use `isModalMessageBoxActive`
	to check if another messageBox modal response is still pending.

	Because an answer is required to continue after a modal messageBox is opened,
	some actions such as shutting down are prevented while NVDA is in a possibly uncertain state.
	"""
    from gui import mainFrame
    global _messageBoxCounter
    with _messageBoxCounterLock:
        _messageBoxCounter += 1

    try:
        if not parent:
            mainFrame.prePopup()
        res = wx.MessageBox(message, caption, style, parent or mainFrame)
    finally:
        if not parent:
            mainFrame.postPopup()
        with _messageBoxCounterLock:
            _messageBoxCounter -= 1

    return res
Exemplo n.º 10
0
def browsableMessage(source, type=None, title=None, rootDirs=None):
    """Present the user with a message or an hyperlinked series of messages in a web browser dialog.
	
	A single message can be specified as the value for the `source` argument.
	A series of messages can instead be specified by passing a callback function as `source`.
	The callback function will in turn get called with the URI of the requested message.
	
	The `type` parameter specifies how the returned messages should be converted into HTML documents.
	It accepts the following values:
	 * "html": No conversion but set MIME type to "text/html".
	 * "body": The message is an HTML snippet that gets wrapped as the content of the `body` element
	   of a basic HTML document template.
	 * "markdown": The message is formatted in markdown and gets converted into HTML.
	 * "text": The message is plain text and gets displayed in the regular paragraph body style. No HTML code is interpreted.
	 * "plain": The message is plain text and gets displayed in a monospace font style. No HTML code is interpreted.
	
	If `source` is a callback function and a `type` is specified, the callback is expected to return
	the content as a string or bytearray.
	If `source` is a callback function and no `type` is specified, the callback is expected to return
	a dictionary with the following items:
	 - "mimeType", mapping to the MIME type of the content
	 - and either "stream", mapping to a file-like object to the content
	 - or "data", mapping to a string or bytearray representation of the content
	
	URLs starting with a leading forward slash ("/") are treated as file URLs.
	`rootDirs` specifies the sequence of directories in which files are looked up.
	If omitted, files are looked up in the user configuration directory.
	"""
    # First close the eventual previous instance.
    global lastBrowsableMessageDialog
    if lastBrowsableMessageDialog:
        dlg = lastBrowsableMessageDialog()
        if dlg:
            try:
                dlg.Show(False)
            except:
                pass

    callback = None
    if isinstance(source, string_types):
        callback = lambda id: source if id == "index" else None
        if type is None:
            type = "text"
    elif callable(source):
        callback = source
    else:
        ValueError("Unsupported source type: {}".format(type(source)))
    if type:
        transform = BROWSABLE_MESSAGE_TRANSFORMS[type]
        callback = (lambda a, b: lambda id: b(a(id)))(callback, transform)

    if not title:
        # Translators: The title for the dialog used to present general NVDA messages in browse mode.
        title = _("NVDA Message")

    from gui import mainFrame
    from .gui import WebViewDialog
    if rootDirs is None:
        rootDirs = [globalVars.appArgs.configPath]
    dlg = WebViewDialog(mainFrame, title, callback, rootDirs)
    lastBrowsableMessageDialog = weakref.ref(dlg)
    mainFrame.prePopup()
    dlg.Show()
    mainFrame.postPopup()