2010-08-23 15 views
7

creo un wx.TextEntryDialog de la siguiente manera:Como hacer wx.TextEntryDialog más grande y de tamaño variable

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: 
    … 

Esto da lugar a un cuadro de diálogo que es demasiado pequeño para mis necesidades, y que no es de tamaño variable:

small dialog box

Mi pregunta es: ¿Cómo puedo hacer que el cuadro de diálogo sea más grande y redimensionable? He intentado añadir las banderas wx.DEFAULT_DIALOG_STYLE y wx.RESIZE_BORDER, pero que no tuvo ningún efecto, excepto para reemplazar el texto con puntos:

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

+0

Hmm ... con 'wx' 3 en Windows el cuadro de diálogo resultante de' wx.TE_MULTILINE | wx.OK | wx.CANCEL' es de tamaño variable. – rakslice

Respuesta

10

tiempo para aprender cómo escribir sus propios diálogos! ;-)

Los diálogos incorporados como TextEntryDialog son solo para los programas más básicos. Si necesita mucha personalización, debe escribir sus propios cuadros de diálogo.

Aquí hay un ejemplo, esto debería funcionar para usted.

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() 
+0

La bandera 'wx.RESIZE_BORDER' era lo que estaba buscando. – acattle

Cuestiones relacionadas