hi Friends,
I have used sizers for one of my frame which has Checklist box.

THe checklist box is not displayed at first but on slight resizing the Checklist box is displayed.
Please assist in this regard.

Regards
Dinil

This are the sizers I am using...

hsizer2 = wx.BoxSizer(wx.HORIZONTAL)
hsizer2 = wx.FlexGridSizer(cols=1, hgap=5, vgap=5)
hsizer2.AddGrowableCol(0)

hsizer2.Add(self.customTree,1,wx.EXPAND | wx.ALIGN_LEFT,2)
hsizer2.Add(self.chkLstBox, 1,wx.EXPAND | wx.ALIGN_RIGHT,2)

b = 5
vsizer2 = wx.BoxSizer(wx.VERTICAL)
vsizer2.Add(hsizer2, 1, wx.EXPAND | wx.ALL, b)

self.SetSizer(vsizer2)
#get the size of the main frame
r = self.GetSize()
#set the minimal size of the main frame
self.SetMinSize(r)
self.CenterOnScreen()

When I resize the frame, the controls are visible.... Else all controls are hidden on pop up of frame.

Hi....

self.Refresh is not working....

Please see the aatchments, so that you get a better understanding of what exactly the problem is.

When the frame loads: The tree control and check list box are not aligned properly(Display_Error.jpg).
But when I slightly resize the frame(maximize by dragging) both tree control and check list box are aligned properly.(Display_Proper.jpg).

Can you please help me out with this???

Regards,
Dinil

Attachments Display_Error.JPG 44.45 KB Display_Proper.JPG 49.48 KB

Hello Dinil,
I think the problem might be with assigning the same variable to two sizers:

hsizer2 = wx.BoxSizer(wx.HORIZONTAL)
hsizer2 = wx.FlexGridSizer(cols=1, hgap=5, vgap=5)

Remove The Flexible Sizer and leave Box Sizer an see what it does!

Steve

Hi...

I removed the flex grid sizer..... Its still not working.....

Regards,
Dinil

I have tried self.SetAutoLayout(True)
Its still not working.....
Here is the full code:

b = 0
hsizer1 = wx.BoxSizer(wx.HORIZONTAL)
hsizer1 = wx.FlexGridSizer(cols=1, hgap=5, vgap=5)
hsizer1.AddGrowableCol(0)

hsizer1.Add(self.staticBitmap1, 0,wx.ALIGN_CENTER)
hsizer1.Add(self.staticText1, 0,wx.EXPAND,10)
hsizer1.Add(self.txtActionId, 0,wx.EXPAND,10)
hsizer1.Add(self.btnProceed, 0,wx.ALIGN_CENTER,10)

hsizer2 = wx.BoxSizer(wx.HORIZONTAL)
hsizer2.Add(self.treeAction, 1,wx.EXPAND|wx.ALL,5)
hsizer2.Add(self.customTree,1,wx.EXPAND | wx.ALIGN_LEFT,0)
hsizer2.Add(self.chkLstBox, 1,wx.EXPAND | wx.ALL,0)

hsizer3 = wx.BoxSizer(wx.HORIZONTAL)

hsizer3.Add((130,0), 1)
hsizer3.Add(self.btnNext)
hsizer3.Add((130,10), 1)
hsizer3.Add(self.btnExit1)
hsizer3.Add((130,10), 1)


hsizer4 = wx.BoxSizer(wx.HORIZONTAL)
hsizer4.Add((100,20), 1)
hsizer4.Add(self.btnPrev)
hsizer4.Add((100,20), 1)
hsizer4.Add(self.btnProcSel)
hsizer4.Add((100,20), 1)

hsizer4.Add(self.btnOutput)
hsizer4.Add((100,20),1)

hsizer4.Add(self.btnExit2)
hsizer4.Add((100,20), 1)

### Prgress Bar####
hsizer5 = wx.BoxSizer(wx.HORIZONTAL)
hsizer5.Add(self.gauge1, 1,wx.EXPAND)
### Prgress Bar####


b = 5
vsizer2 = wx.BoxSizer(wx.VERTICAL)
vsizer2.Add(hsizer1, 0, wx.EXPAND | wx.ALL, b)
vsizer2.Add(hsizer2, 1, wx.EXPAND | wx.ALL, b)

vsizer2.Add(hsizer3, 0, wx.EXPAND | wx.ALL, b)

vsizer2.Add(hsizer4, 0, wx.EXPAND | wx.ALL, b)

vsizer2.Add(hsizer5, 0, wx.EXPAND | wx.ALL, b)

self.SetSizer(vsizer2)
#get the size of the main frame
r = self.GetSize()
#set the minimal size of the main frame
self.SetMinSize(r)
self.CenterOnScreen()

Tell me if there is something wrong here!!!!....

Regards,
Dinil

Consider my Questions and comments below:

b = 0
# why Both flex and Box sizers have same variable? IMO, they should have different variables! That's why I commented out flex sizer
hsizer1 = wx.BoxSizer(wx.HORIZONTAL)
#hsizer1 = wx.FlexGridSizer(cols=1, hgap=5, vgap=5) 
#hsizer1.AddGrowableCol(0) 

# what do you want to do exactly with this ALIGNING CENTER? If align as center widget then make it second, in adding widgets to sizer instead of first!
hsizer1.Add(self.staticBitmap1, 0,wx.ALIGN_CENTER)

#you have said border to be 10 but border on what side? You should state something like wx.EXPAND | wx.LEFT to make 10px border from left or wx.ALL if, from all sides
hsizer1.Add(self.staticText1, 0,wx.EXPAND,10)
#Ibid.
hsizer1.Add(self.txtActionId, 0,wx.EXPAND,10)
# Still don't know what you are doing with align cebter flag
hsizer1.Add(self.btnProceed, 0,wx.ALIGN_CENTER,10)

hsizer2 = wx.BoxSizer(wx.HORIZONTAL)
# if you need these two to have minimum width when exanded and the latter to be taking the rest of space put proportion = 0
hsizer2.Add(self.treeAction, 1,wx.EXPAND|wx.ALL,5) 
hsizer2.Add(self.customTree,1,wx.EXPAND | wx.ALIGN_LEFT,0)
# wx.ALL isn't necessary for by default border is 0 (IMO)
hsizer2.Add(self.chkLstBox, 1,wx.EXPAND | wx.ALL,0)

hsizer3 = wx.BoxSizer(wx.HORIZONTAL)

hsizer3.Add((130,0), 1) 
hsizer3.Add(self.btnNext) 
hsizer3.Add((130,10), 1) 
hsizer3.Add(self.btnExit1) 
hsizer3.Add((130,10), 1)


hsizer4 = wx.BoxSizer(wx.HORIZONTAL)
hsizer4.Add((100,20), 1) 
hsizer4.Add(self.btnPrev) 
hsizer4.Add((100,20), 1) 
hsizer4.Add(self.btnProcSel) 
hsizer4.Add((100,20), 1)

hsizer4.Add(self.btnOutput) 
hsizer4.Add((100,20),1)

hsizer4.Add(self.btnExit2) 
hsizer4.Add((100,20), 1)

### Prgress Bar####
hsizer5 = wx.BoxSizer(wx.HORIZONTAL)
hsizer5.Add(self.gauge1, 1,wx.EXPAND)
### Prgress Bar####


b = 5
vsizer2 = wx.BoxSizer(wx.VERTICAL)
vsizer2.Add(hsizer1, 0, wx.EXPAND | wx.ALL, b)
vsizer2.Add(hsizer2, 1, wx.EXPAND | wx.ALL, b)

vsizer2.Add(hsizer3, 0, wx.EXPAND | wx.ALL, b)

vsizer2.Add(hsizer4, 0, wx.EXPAND | wx.ALL, b)

vsizer2.Add(hsizer5, 0, wx.EXPAND | wx.ALL, b)

self.SetSizer(vsizer2)
#get the size of the main frame
r = self.GetSize()
#set the minimal size of the main frame
self.SetMinSize(r)
self.CenterOnScreen()

I cannot finish for I have to go on with work.
Just try that first.
NB: If you can provide full code so as one can anlyze what really it does. For I cannot guess what you are doing. Just if you are willing NO FORCING!

Steve

Yeah i definitly agree with steve. Cause what is happening at the moment is that your program makes a BoxSizer and then you instantly overwrite it with a FlexSizer so i would reccomend you get rid of one of them really im just echoing steves words but they are very true.

Thanks for the help...
sorry guys....
I am new to sizers... so i am very much confused.
However i will try to accomodate the shanges that u suggested...
I will get back to you if i am stuck....

Regards,
Dinil

Hi Steve,

I found the tutorial very useful.... thanks for that. Now I have modified my code and here it goes:

vbox = wx.BoxSizer(wx.VERTICAL)
hbox1 = wx.BoxSizer(wx.HORIZONTAL)

hbox1.Add(self.staticBitmap1)

vbox.Add(hbox1, 0, wx.ALIGN_CENTER|wx.BOTTOM|wx.TOP,5)

hbox2 = wx.BoxSizer(wx.HORIZONTAL)
hbox2.Add(self.staticText1, 0)
vbox.Add(hbox2, 0, wx.LEFT|wx.BOTTOM , 10)

hbox3 = wx.BoxSizer(wx.HORIZONTAL)
hbox3.Add(self.txtActionId, 1)
vbox.Add(hbox3, 0, wx.LEFT | wx.RIGHT | wx.EXPAND|wx.BOTTOM, 10)

hbox5 = wx.BoxSizer(wx.HORIZONTAL)
hbox5.Add(self.btnProceed, 0)
vbox.Add(hbox5, 0, wx.ALIGN_CENTER|wx.BOTTOM, 10)

hbox4 = wx.BoxSizer(wx.HORIZONTAL)
hbox4.Add(self.treeAction, 1, wx.EXPAND)
vbox.Add(hbox4, 1, wx.LEFT | wx.RIGHT | wx.EXPAND|wx.BOTTOM, 10)

hbox8 = wx.BoxSizer(wx.HORIZONTAL)
hbox8.Add(self.customTree, 1, wx.EXPAND)
hbox8.Add(self.chkLstBox, 2, wx.EXPAND)
vbox.Add(hbox8, 1, wx.LEFT | wx.RIGHT | wx.EXPAND|wx.BOTTOM, 10)

hbox6 = wx.BoxSizer(wx.HORIZONTAL)
hbox6.Add((100,0), 1)
hbox6.Add(self.btnNext, 0,wx.ALIGN_CENTER|wx.BOTTOM,10)

hbox6.Add((100,0), 1)

hbox6.Add(self.btnExit1, 0, wx.ALIGN_CENTER|wx.BOTTOM , 10)
hbox6.Add((100,0), 1)
vbox.Add(hbox6, 0, wx.ALIGN_CENTER, 0)

hbox9 = wx.BoxSizer(wx.HORIZONTAL)
hbox9.Add((30,0), 1)
hbox9.Add(self.btnPrev, 0,wx.ALIGN_CENTER|wx.BOTTOM,10)

hbox9.Add((30,0), 1)

hbox9.Add(self.btnProcSel, 0, wx.ALIGN_CENTER|wx.BOTTOM , 10)
hbox9.Add((30,0), 1)
hbox9.Add(self.btnOutput, 0, wx.ALIGN_CENTER|wx.BOTTOM , 10)
hbox9.Add((30,0), 1)
hbox9.Add(self.btnExit2, 0, wx.ALIGN_CENTER|wx.BOTTOM , 10)
hbox9.Add((30,0), 1)
vbox.Add(hbox9, 0, wx.ALIGN_CENTER, 0)

hbox7 = wx.BoxSizer(wx.HORIZONTAL)
hbox7.Add(self.gauge1, 1,wx.EXPAND)
vbox.Add(hbox7, 0, wx.EXPAND|wx.BOTTOM, 5)
self.SetSizer(vbox)

r = self.GetSize()
#set the minimal size of the main frame
self.SetMinSize(r)
self.Centre()

self.Show(True)

I have done the following on the frame:
1. A single frame contains all the controls. screen1.jpg is how the frame looks when the frame is initialised.
2. On click of 'Next' button, the tree control, 'Next' and 'Exit1' buttons are hidden and the custom tree control, check list box, 'Previous', 'Process Selected' 'Open Detailed Output' and 'Exit2' buttons are made visible.

Now when I click the 'Next' button, the frame looks like screen2.jpg. If I resize it(manually drag), it looks like screen3.jpg and when I click on 'Previous' button it looks screen4.jpg.

The problem is that when I hide or unhide those controls, all the space on the frame is not occupied on click of buttons. The problem may be with hiding/ unhiding of controls.

Please help me!!!!!.....

Regards,
Dinil

Attachments Screen1.JPG 28.68 KB screen2.JPG 40.34 KB

Ok Dear Dinil,
I think the best way i can help is to post full code here so that I can rectify the problem and repost them. By doing so it will be easy for somebody to work with minimum thinking.

It took alot of time to figure out what are you trying to add and not many will devote in doing so. So IMHO, post full code then rectification must be easy; for I will copy and paste On my IDE and do some debugging and play around and come up with clean code pointing out errors

Any Question? Just post it, No Problem

Hi....
Thanks for devoting your precious time for this work....
I have attached the complete code. Just drag and drop the file 'AppCMA.py' in editor window and then open the file 'CMAGUI.py'. Run the code so that u will understand what exactly the code does.... I have put proper comments whereever necessary.

Please get back to me if u have any doubts.

Thanks for the help!!!!

Regards,
Dinil

Thanks guys for the help......
I have found out a temporary solution... I am using:

size=self.GetEffectiveMinSize()
self.SetSize(size)

This sets the minimum size for the frame. I have added this code on click of 'Next' and 'Previous' buttons.

But now, I am unable to set Tab Index for the controls...... Is there something where we can mention the Tab Index to each control(which are added to sizers)?

Regards,
Dinil

Hi.....

I am unable o set Tab Indices for controls on the frame......

Any help is much appreciated!!!!...

Regards,
Dinil

Hi Dinil,
I have tried to play around with your codes but here is what I found difficult:
Your GUI code is mixed up with Win32 Code and I'm less in Win32. My suggestions are: Separate your GUI from Win32 codes/methods and Leave pure wx.Python module related codes. That Will Make easy for me to work with that complex codes!

Here are simple Observation I have made before I hit the wall:
Note your Original Codes are commented out and I cannot Assure you of nything because I din't tested the code I was trying to rectify, Infact I didin't reach even the end due to mixture, so provide gui code and I will proceed

#Why Horizontal sizer while you have added one element?
         ##hbox2 = wx.BoxSizer(wx.HORIZONTAL)
        ##hbox2.Add(self.staticText1, 0)
        ##vbox.Add(hbox2, 0,  wx.LEFT|wx.BOTTOM , 10)
        vbox.Add(self.staticText1, 0,  wx.LEFT|wx.BOTTOM , 10)
      
#Why Horizontal sizer while you have added one element?
        ##hbox3 = wx.BoxSizer(wx.HORIZONTAL)
        ##hbox3.Add(self.txtActionId, 1)
        ##vbox.Add(hbox3, 0, wx.LEFT | wx.RIGHT | wx.EXPAND|wx.BOTTOM, 10)
        vbox.Add(self.txtActionId, 0, wx.LEFT | wx.RIGHT | wx.EXPAND|wx.BOTTOM, 10)
 
#Why Horizontal sizer while you have added one element?     
        ##hbox5 = wx.BoxSizer(wx.HORIZONTAL)
        ##hbox5.Add(self.btnProceed, 0)
        ##vbox.Add(hbox5, 0, wx.ALIGN_CENTER|wx.BOTTOM, 10)
        vbox.Add(self.btnProceed, 0, wx.ALIGN_CENTER|wx.BOTTOM, 10)
   
#Why Horizontal sizer while you have added one element?     
        ##hbox4 = wx.BoxSizer(wx.HORIZONTAL)
        ##hbox4.Add(self.treeAction, 1, wx.EXPAND)
        ##vbox.Add(hbox4, 1, wx.LEFT | wx.RIGHT | wx.EXPAND|wx.BOTTOM, 10)
        vbox.Add(self.treeAction, 1, wx.LEFT | wx.RIGHT | wx.EXPAND|wx.BOTTOM, 10)

Hi....

size=self.GetEffectiveMinSize()
self.SetSize(size)
This seems to be working fine for me...
Thanks once again....

Regards,
Dinil

This question has already been answered. Start a new discussion instead.