what is the purpose of sizer.Add (Python wx) in this code?

37 Views Asked by At

I saw the following code and i couldn't understand what the sizer.Add actually does. Changing the position values in sizer.Add doesn't influence the display of the controls in any way.

class gui(wx.Frame):
    def __init__(self, parent, id):
        wx.Frame.__init__(self,parent,id,"Find words in Files",size=(700,600))
        self.defaultDirectory = "C:/Data/Users/madhavan_s1/Downloads/reverse_index"
        self.panel = wx.ScrolledWindow(self,wx.ID_ANY)
        
        
        #Sizer 
    
        self.windowSizer = wx.BoxSizer()
        self.windowSizer.Add(self.panel, 1, wx.ALL | wx.EXPAND)
        self.sizer = wx.GridBagSizer(0,0)
        
        
        #List of files and no of it
        self.no_of_files = 1
        self.fileCtrl = []
        
        #list of folders and no of it
        self.no_of_folders = 1
        self.folderCtrl = []
        
        #search 
        
        self.search_label = wx.StaticText(self.panel, -1, "Search Words: ", (100,35))
        **self.sizer.Add(self.search_label,(100, 35))**
        self.search_name = wx.TextCtrl(self.panel, pos=(200,30), size=(260, -1))
        **self.sizer.Add(self.search_name, (200, 30))**
        
        # File location 
        
        self.file_location_label = wx.StaticText(self.panel, -1, "Where to search ?",(100, 120))
        
        # Adding File Button 
        self.button = wx.Button(self.panel,id=-1,label="Add Files",pos=(100,150),size=(130,-1))
        self.sizer.Add(self.button,(100,150))

In the above code, i changed the following lines of code, but still i dont see any change in the gui

self.sizer = wx.GridBagSizer(4,4)

self.search_label = wx.StaticText(self.panel, label="Search Words: ")
**self.sizer.Add(self.search_label,(0, 2))**
0

There are 0 best solutions below