Python Forum
[WxPython] How to create a static white box text - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: [WxPython] How to create a static white box text (/thread-12202.html)



How to create a static white box text - giu88 - Aug-14-2018

Hello,

I need to create a very simple box to show the path of a file. The application will show, at start up, in the same row (i will use boxSizer(horizontal), a white box empty and a "browse" button. Then i need to update the text in the box with the path after chosing the path.

I am using a static text field but it takes the size of the text, therefore at start up is empty, no box is shown. I need the box to always be shown, with white background.

Thanks


RE: How to create a static white box text - giu88 - Aug-14-2018

This looks like it worked!

box_horiz = wx.BoxSizer(wx.HORIZONTAL)
        self.textPath = wx.StaticText(panel, label="hello", style=wx.TE_READONLY|wx.BORDER_SUNKEN)
        self.textPath.SetBackgroundColour((255,255,255)) 
        self.btnPath = wx.Button(panel,-1,"Path")

        box_horiz.Add(self.textPath,10,wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL|wx.ALL,5)
        box_horiz.Add(self.btnPath,3,wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL|wx.ALL,5)
I'll be happy to see if there is any other better way to do this. Thanks


RE: How to create a static white box text - Larz60+ - Aug-14-2018

what do you mean by white box? (widget name)
You posted answer while I was posting question, disregard