How to make wx.TextEntryDialog larger and resizable

I create wx.TextEntryDialog as follows:

 import wx dlg = wx.TextEntryDialog(self, 'Rules:', 'Edit rules', style=wx.TE_MULTILINE|wx.OK|wx.CANCEL) dlg.SetValue(self.rules_text.Value) if dlg.ShowModal() == wx.ID_OK: … 

This leads to a dialog box too small for my needs, and it does not change:

small dialog box

My question is: How to make the dialog box large and mutable? I tried adding the wx.DEFAULT_DIALOG_STYLE and wx.RESIZE_BORDER , but this had no effect other than replacing the text with dots

 dlg = wx.TextEntryDialog(self, 'Rules:', 'Edit rules', style=wx.TE_MULTILINE|wx.OK|wx.CANCEL|wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER) 

small, garbled dialog box

+7
python wxpython wxwidgets wx
source share
1 answer

Time to learn to write your own dialogs !; -)

Built-in dialogs, such as TextEntryDialog , are intended only for the most basic programs. If you need a lot of customization, you need to write your own dialogs.

Here is an example, this should work for you.

 import wx class TextEntryDialog(wx.Dialog): def __init__(self, parent, title, caption): style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER super(TextEntryDialog, self).__init__(parent, -1, title, style=style) text = wx.StaticText(self, -1, caption) input = wx.TextCtrl(self, -1, style=wx.TE_MULTILINE) input.SetInitialSize((400, 300)) buttons = self.CreateButtonSizer(wx.OK|wx.CANCEL) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(text, 0, wx.ALL, 5) sizer.Add(input, 1, wx.EXPAND|wx.ALL, 5) sizer.Add(buttons, 0, wx.EXPAND|wx.ALL, 5) self.SetSizerAndFit(sizer) self.input = input def SetValue(self, value): self.input.SetValue(value) def GetValue(self): return self.input.GetValue() if __name__ == '__main__': app = wx.PySimpleApp() dialog = TextEntryDialog(None, 'Title', 'Caption') dialog.Center() dialog.SetValue('Value') if dialog.ShowModal() == wx.ID_OK: print dialog.GetValue() dialog.Destroy() app.MainLoop() 
+10
source share

All Articles