Join the Stack Overflow Community
Stack Overflow is a community of 6.2 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I am trying to do a text entry dialog, but I don´t want to use the built-in method. I´m doing pretty well , the only problem is that is the buttons are displaying perfectly, but the text entry is Hidden.

Where is the issue?

class RouteWindow(wx.Dialog):
   def __init__(self):
    super(RouteWindow, self).__init__(None)
    self.DialogUI()
    self.SetSize((200, 250))
    self.SetTitle("Specify Route...")

   def DialogUI(self):
    pan = wx.Panel(self)
    vbox = wx.BoxSizer(wx.VERTICAL) 
    dial_box = wx.BoxSizer(wx.HORIZONTAL)
    dial_text = wx.StaticText(pan, label = "Route :")
    dial_box.Add(dial_text,0,wx.ALL,5)
    dial_camp = wx.TextCtrl(pan)
    dial_box.Add(dial_camp,wx.EXPAND)
    vbox.Add(dial_box,wx.ALIGN_CENTER|wx.TOP, border = 4)
    opt_box = wx.BoxSizer(wx.HORIZONTAL)
    opt_close = wx.Button(self, label = "Close")
    opt_ok = wx.Button(self, label = "OK" )
    opt_box.Add(opt_ok)
    opt_box.Add(opt_close, flag =  wx.LEFT, border = 5)
    vbox.Add(opt_box, flag = wx.ALIGN_CENTER|wx.BOTTOM, border = 4)
    self.SetSizer(vbox)
share|improve this question
up vote 1 down vote accepted

your layout is wrong ... you need to add pan

def DialogUI(self):
    pan = wx.Panel(self)
    vbox = wx.BoxSizer(wx.VERTICAL) 
    dial_box = wx.BoxSizer(wx.HORIZONTAL)
    dial_text = wx.StaticText(pan, label = "Route :")
    dial_box.Add(dial_text,0,wx.ALL,5)
    dial_camp = wx.TextCtrl(pan)
    dial_box.Add(dial_camp,wx.EXPAND)
    pan.SetSizer(dial_box) #<---- set sizer of pan to be dial_box

    vbox.Add(pan,wx.ALIGN_CENTER|wx.TOP, border = 4) #<----add pan to main sizer
    opt_box = wx.BoxSizer(wx.HORIZONTAL)
    opt_close = wx.Button(self, label = "Close")
    opt_ok = wx.Button(self, label = "OK" )
    opt_box.Add(opt_ok)
    opt_box.Add(opt_close, flag =  wx.LEFT, border = 5)
    vbox.Add(opt_box, flag = wx.ALIGN_CENTER|wx.BOTTOM, border = 4)
    self.SetSizer(vbox)

although I dont understand why you wouldnt use the get_text_from_user builtin but meh ... for that matter i dont really understand why you are creating a panel instead of just attachign to self ...

on a side note if you make

opt_ok = wx.Button(self,wx.ID_OK )
opt_close = wx.Button(self,wx.ID_CANCEL )

you will get some of the behaviour for free (IE return from show modal)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.