Hi all. I'm writing a simple GUI to display some text and update the text as I receive data from a multicast address. What I have is a Frame, and then a wxScrolledWindow that is using the Frame as its parent window. The scrolled window contains a vertical box sizer in which there are some wxStaticText inside. There wxStaticText objects are updated based on a timer that triggers every 500 milliseconds. The problem I have is that when the initial Frame.Show() is called, the scroll bar does not appear automatically and causing the text to display weird (if the window is not big enough). Once I resize the window (even if just by a tiny bit), the scroll bar then appears. Can someone tell me what might be causing this problem and how to fix it? Thank you very much.

I'll post a little sample code below.

class WxMain(wx.App):
    def OnInit(self):
        self.window = wx.Frame(None)
        scroll = wx.ScrolledWindow(self.window)
        
        self.vertMainSizer = wx.BoxSizer(wx.VERTICAL)
        self.text1 = wx.StaticText(scroll, -1, '')
        self.text2 = wx.StaticText(scroll, -1, '')
        self.vertMainSizer.Add(self.text1, -1)
        self.vertMainSizer.Add((1, 1), 0)
        self.vertMainSizer.Add(self.text2, -1)

        scroll.SetScrollRate(0,1)
        scroll.SetSizer(self.vertMainSizer)
        self.vertMainSizer.Layout()
        self.window.Layout()
        self.SetTopWindow(self.window)
        self.window.Show()
                             
        #Set a timer to update values
        TIMER_ID = 1000
        self.timer = wx.Timer(self.window, TIMER_ID)
        self.timer.Start(500) #500 milliseconds
        wx.EVT_TIMER(self.window, TIMER_ID, self.Update)
        self.number = 0

    def Update(self, event):
        self.number += 1
        self.text1.SetLabel(str(self.number))
        self.text2.SetLabel(str(self.number*2))

if __name__ == '__main__':
    app = WxMain()
    app.MainLoop()

Recommended Answers

All 2 Replies

Maybe you can try to add

scroll.SetScrollbars(5, 5, 100, 100)

Practice Python Online
http://pyschools.com

Maybe you can try to add

scroll.SetScrollbars(5, 5, 100, 100)

Thank you for the suggestion. I tried that but that still does not show the scroll bar.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.