I want to make my window scrollable only if it goes less than a particular size (if it is opened on the laptop screen, it should be scrollable, but on a bigger monitor, it should not).
I believe this thing is done by using ScrolledWindow or ScrolledPanel by some way, but I exactly don’t know how. Below is a code snippet for the same
import wx
import wx.lib
import wx.lib.scrolledpanel
class MyFrame(wx.Frame):
def __init__(self, *args, **kwds):
screenSize = wx.DisplaySize()
screenWidth = screenSize[0]
screenHeight = screenSize[1]
kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
sizer_1 = wx.BoxSizer(wx.VERTICAL)
self.nb = wx.Notebook(self, wx.ID_ANY)
sizer_1.Add(self.nb, 1, wx.EXPAND, 0)
self.notebook_1_pane_1 = wx.lib.scrolledpanel.ScrolledPanel(self.nb,-1, size=(screenWidth,400), pos=(0,28), style=wx.SIMPLE_BORDER)
self.notebook_1_pane_1.SetupScrolling()
self.SetSizer(sizer_1)
self.Layout()
self.Update()
class MyApp(wx.App):
def OnInit(self):
self.frame = MyFrame(None, wx.ID_ANY, "")
self.SetTopWindow(self.frame)
self.frame.Show()
return True
if __name__ == "__main__":
app = MyApp(0)
app.MainLoop()
Even on the bigger monitor screen where defining self.notebook_1_pane_1 as a simple panel (using wx.Panel) gives proper GUI, making it a scrolledpanel is adding scrollbars even there and making all sizers take additional spaces.
Please help!