0

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)

1 Answer 1

1

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)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.