Re: Entry multiline text

James Scholes
 

Good find. The buttons disappear, because by using style=wx.TE_MULTILINE you are removing the default styling. You'll need to use style=wx.wx.OK|wx.CANCEL|wx.TE_MULTILINE.

Regards,

James Scholes

On 26/03/2020 at 10:04 am, Rui Fontes wrote:
Hello James,
I read that, and I was asking which alternative I should use...
And, by the way, it seems that is possible to use multiline with it...
Read on:
https://www.tutorialspoint.com/wxpython/wx_dialog_class.htm
specially this part:
wx.TextEntryDialog
Object of this class displays a dialog with one text field, a customizable label prompting the user to input and two buttons with predefined styles.
Although this dialog requests a one line input, the text box can be customized by using TextCtrl styles like password and multiline.
Contents of the text field are collected as return value when the user clicks OK button.
But if I include the parameter style=wx.TE_MULTILINE, the text field becomes multiline but the buttons disappear...
Best regards,
Rui Fontes
NVDA portuguese team
Às 15:09 de 26/03/2020, James Scholes escreveu:
The first line of the documentation for wx.TextEntryDialog states:

This class represents a dialog that requests a one-line text string
from the user.

So there is no way to prompt users for multiple lines using this helper.  But just replace it with a modal that has a label, a multi-line wx.TextCtrl and OK/Cancel buttons.

Regards,

James Scholes

On 26/03/2020 at 8:45 am, Rui Fontes wrote:
Hello!


I have the following function to collect a multiline block of text.

It is possible to replace it by a function that collects the all block at once?


     def _addBlock(self):
         # Translators: Message dialog box to add a new block of text.
         dlg = wx.TextEntryDialog(gui.mainFrame, _("Enter the block of text"), self.title)
         dlg.SetValue("")
         if dlg.ShowModal() == wx.ID_OK:
             nBlock = dlg.GetValue()
         else:
             dlg.Destroy()
             return
         if nBlock != "":
             global name
             global newBlock
             newBlock.append(nBlock)
             if gui.messageBox(_("Do you want to add a new line?"), self.title, style=wx.ICON_QUESTION|wx.YES_NO) == wx.YES:
                 self._addBlock()
                 return
         else:
             dlg.Destroy()
             return

Best regards,

Rui Fontes

NVDA portuguese team





Join nvda-addons@nvda-addons.groups.io to automatically receive all group messages.