Setting Size on wx.TextEntryDialog in Python WXWidgets

The process of showing a dialog is easy, but making a text prompt for the user that’s more than one line and in which you’re able to see more than one line is a more tricky thing. Here’s the syntax that worked for me.

dlg_msg = 'Hey user! Enter your text below:'
dlg_title = 'This is a title'
dlg_default_style = "{}"
dlg = wx.TextEntryDialog(parent=self.view, message=dlg_msg, caption=dlg_title, defaultValue=dlg_default_style, style=wx.OK | wx.CANCEL | wx.TE_MULTILINE)
dlg.SetValue("default value\non two lines")
if dlg.ShowModal() == wx.ID_OK:

The vars above the declaration are just for readability. Please note that dlg_default_style is a string, not a dict.

Please note that the default style, though empty, is necessary for the multiline entry to be picked up (at least on OSX)

Leave a Reply

Your email address will not be published. Required fields are marked *