1

I have inherited a wxPython app (story of my life of late) and you cannot make the window any smaller (but you can make it larger). What could be preventing it from being resized smaller? What could I grep for to find what is causing this? The window contains a Notebook with 2 tabs. One tab has a Grid and the other has a Panel and 3 Grids.

Larry Martell
  • 3,526
  • 6
  • 40
  • 76

4 Answers4

0

http://docs.wxwidgets.org/trunk/classwx_top_level_window.html#ac01a45e5d82e4e3be22a4841c1217e11

virtual void wxTopLevelWindow::SetSizeHints (   int     minW,
int     minH,
int     maxW = -1,
int     maxH = -1,
int     incW = -1,
int     incH = -1 
)       
virtual
Allows specification of minimum and maximum window sizes, and window size increments.

If a pair of values is not set (or set to -1), no constraints will be used.

Parameters
minW    The minimum width.
minH    The minimum height.
maxW    The maximum width.
maxH    The maximum height.
incW    Specifies the increment for sizing the width (GTK/Motif/Xt only).
incH    Specifies the increment for sizing the height (GTK/Motif/Xt only).
Remarks
Notice that this function not only prevents the user from resizing the window outside the given bounds but it also prevents the program itself from doing it using wxWindow::SetSize().
Reimplemented from wxWindow.
ravenspoint
  • 19,093
  • 6
  • 57
  • 103
0

It is likely a call to SetMinSize for your Dialog/Frame.

Werner
  • 2,086
  • 1
  • 15
  • 14
  • Nope, no occurrences of SetMinSize anywhere in my code. – Larry Martell Oct 10 '14 at 12:29
  • Hhm, then I would look at 'size=(x, y)' definitions and I just noticed , looking at another problem, that the use of GridBagSizer seems to do this too. – Werner Oct 10 '14 at 12:39
  • If no hard coded sizes then I would tip on the grid's. So, what about putting the three grids onto a ScrolledPanel instead of the Panel. – Werner Oct 10 '14 at 12:46
  • So there were some hard coded 'size=(x, y)' definitions. I removed those and now the window can be resized vertically, but not horizontally. Also it's now coming up full screen, whereas before it was not. – Larry Martell Oct 10 '14 at 14:09
  • Don't get it, but full screen could be due to a call to frame.Maximize() or frame.Iconize(False), but no clue why this had no effect before. – Werner Oct 10 '14 at 14:32
  • Are the grids using up all horizontal space? If yes, check how the grid's are setup. – Werner Oct 10 '14 at 14:35
  • No, no calls to Maximize or Iconize. Yes, the grids use up all the horizontal space. They are declared with wx.EXPAND. I tried removing that and all that changed was that I lost my scrollbars. The window was still full screen and un-resizable in the horizontal direction. – Larry Martell Oct 10 '14 at 20:01
  • can you provide some runnable sample which shows this problems - http://wiki.wxpython.org/MakingSampleApps – Werner Oct 11 '14 at 15:33
  • Unfortunately, no. This code uses an internal package that wraps all the native wxPython and wx function calls. Sometimes 2 or 3 levels of of internal code before you get to the actual wx calls. But when I was grepping for all the things I grepped for, I was grepping all the internal package code as well as the app itself. – Larry Martell Oct 12 '14 at 16:10
0

Some of the elements may have set size. Correctly set sizers for the window, without using implicit window sizer, would not allow you to change the window size to be smaller than needed for the elements with set size. See example:

import wx

class MainWindow(wx.Frame):
    def __init__(self, *args, **kwargs):
        wx.Frame.__init__(self, *args, **kwargs)

        self.panel = wx.Panel(self)
        self.button = wx.Button(self.panel, label="Test", size=(200, 200))

        self.windowSizer = wx.BoxSizer()
        self.windowSizer.Add(self.panel, 1, wx.ALL | wx.EXPAND)

        self.sizer = wx.BoxSizer()
        self.sizer.Add(self.button)

        self.border = wx.BoxSizer()
        self.border.Add(self.sizer, 1, wx.ALL | wx.EXPAND, 5)

        self.panel.SetSizerAndFit(self.border)  
        self.SetSizerAndFit(self.windowSizer)   
        self.Show()

app = wx.App(False)
win = MainWindow(None)
app.MainLoop()

It is not possible to resize the window so it forces the button to be smaller than 200x200.

Fenikso
  • 9,251
  • 5
  • 44
  • 72
  • That may explain why I can't resize it horizontally. But not why it comes up full screen. – Larry Martell Oct 10 '14 at 20:02
  • Before the code was explicitly setting the window size and I could not resize it in any direction. I removed the explicit setting of the window size and then it came up full screen and I could resize it vertically but not horizontally. – Larry Martell Oct 10 '14 at 21:06
0

Well then, I would suppose that the code is handling the resize event, allowing you to make the window larger, but not smaller.

Look for something like void handlerFuncName(wxSizeEvent& event)

Also look for wxEVT_SIZE

ravenspoint
  • 19,093
  • 6
  • 57
  • 103