Setting SetWindowStyle() changes window size

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Setting SetWindowStyle() changes window size

nitinphlp
Hi, 

I have a frame where the window is restricted from MAXIMIZE and RESIZE using
the style flags during instantiation of the Frame. Later when user presses a
button, I want to make the window resizable for which I'm using the
frame.SetWindowStyle method as shown below (included only the instantiation
and method call snippets). 

main_frame = MainFrame(parent=None, 
                           title=gui_title, 
                           style=wx.MINIMIZE_BOX | wx.SYSTEM_MENU | 
                           wx.CAPTION | wx.CLOSE_BOX, size=(1180, 800)) 


self.SetWindowStyle(wx.MAXIMIZE_BOX | wx.RESIZE_BORDER | 
                            wx.MINIMIZE_BOX | wx.SYSTEM_MENU | 
                            wx.CAPTION | wx.CLOSE_BOX) 


This works well except for the fact that it slightly shrinks the window size
when set and I can see the edges of few of the controls on the UI cropped. 

Could anyone please help me figure out what I'm doing wrong. 

Thanks, 
Nitin



--
Sent from: http://wxpython-users.1045709.n5.nabble.com/

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Setting SetWindowStyle() changes window size

Robin Dunn
On Sunday, January 13, 2019 at 2:04:00 PM UTC-8, nitin philip wrote:
Hi, 

I have a frame where the window is restricted from MAXIMIZE and RESIZE using
the style flags during instantiation of the Frame. Later when user presses a
button, I want to make the window resizable for which I'm using the
frame.SetWindowStyle method as shown below (included only the instantiation
and method call snippets). 

main_frame = MainFrame(parent=None, 
                           title=gui_title, 
                           style=wx.MINIMIZE_BOX | wx.SYSTEM_MENU | 
                           wx.CAPTION | wx.CLOSE_BOX, size=(1180, 800)) 


self.SetWindowStyle(wx.MAXIMIZE_BOX | wx.RESIZE_BORDER | 
                            wx.MINIMIZE_BOX | wx.SYSTEM_MENU | 
                            wx.CAPTION | wx.CLOSE_BOX) 


This works well except for the fact that it slightly shrinks the window size
when set and I can see the edges of few of the controls on the UI cropped. 

Could anyone please help me figure out what I'm doing wrong. 

Probably nothing. IIUC, this is the way I would expect it to work, although it could vary based on platform. A possible workaround to preserve the size of the frame's content would be to use GetClientSize before the change and SetClientSize after.

--
Robin
 

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Setting SetWindowStyle() changes window size

nitinphlp
Thank you Robin for the suggestion. I'm already using the work-around in my
code but was wondering if there was a better way of doing it (or may be not
doing anything at all and the re-sizing be handled automatically :) )

Thanks,
Nitin



--
Sent from: http://wxpython-users.1045709.n5.nabble.com/

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.