SetSize inoperative on TextCtrl (wxpython 2.6.3.2 / py2.3.4)

Hi there,

A wxPython based appli works fine with wxPython 2.6.1.0 and python 2.3.3, but
when installing it on 2.6.3.2/python2.3.4, the 3 TextCtrl it contains generate
an exception when they're created:

wx._core.PyAssertionError C++ assertion "wxAssertFailure" failed in
../src/common/wincmm.cpp (752): min width/height must be less than max
width/height!

While the error message seems rather explicit, I still don't understand what it
refers to. The instruction creating the TextCtrl widget is simply:
self.text = TextCtrl (self, id = -1,
                      style = TE_MULTILINE|TE_READONLY,
                      size = Size (502, 190),
                      pos = Point (0, 0))

As a workaround, I created the TextCtrl with a DefaultSize. The problem is that
when I try to set the size with SetSize, it doesn't work:

print self.text.GetSize ()
self.text.SetSize (Size (502, 190))
print self.text.GetSize ()

will print twice (81, 27) - (which must be the DefaultSize)

Any explanation or suggestion very much appreciated...

Jean-Loup Goulat wrote:

Hi there,

A wxPython based appli works fine with wxPython 2.6.1.0 and python 2.3.3, but
when installing it on 2.6.3.2/python2.3.4,

Which platform?

the 3 TextCtrl it contains generate
an exception when they're created:

wx._core.PyAssertionError C++ assertion "wxAssertFailure" failed in
../src/common/wincmm.cpp (752): min width/height must be less than max width/height!

While the error message seems rather explicit, I still don't understand what it
refers to. The instruction creating the TextCtrl widget is simply:
self.text = TextCtrl (self, id = -1, style = TE_MULTILINE|TE_READONLY,
                      size = Size (502, 190),
                      pos = Point (0, 0))

The assertion is coming from SetSizeHints (which can also be called via SetMinSize or SetMaxSize). Do you call any of these methods? Or does the exception traceback show that it is coming from your constructor call above? BTW, passing the size to the constructor also sets the min size, so if you do something later that causes the max size to be set smaller than that size then you could get this error in that case too.

As a workaround, I created the TextCtrl with a DefaultSize. The problem is that
when I try to set the size with SetSize, it doesn't work:

print self.text.GetSize () self.text.SetSize (Size (502, 190))
print self.text.GetSize ()

will print twice (81, 27) - (which must be the DefaultSize)

Not sure what's going on here. If you're on Windows then it could be related to the deferred sizing that can be done there, but even if it is using the deferred sizing API in this case it should still be returning the pending size...

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Thanks for your reply, answers to your questions inlined below:

Robin Dunn <robin <at> alldunn.com> writes:

[...]

> A wxPython based appli works fine with wxPython 2.6.1.0 and python 2.3.3,

but

> when installing it on 2.6.3.2/python2.3.4,

Which platform?

Red Hat Enterprise Linux 4 (2.6.9 kernel)

[...]

> wx._core.PyAssertionError C++ assertion "wxAssertFailure" failed in
> ../src/common/wincmm.cpp (752): min width/height must be less than max
> width/height!
>

[...]

> self.text = TextCtrl (self, id = -1,
> style = TE_MULTILINE|TE_READONLY,
> size = Size (502, 190),
> pos = Point (0, 0))

The assertion is coming from SetSizeHints (which can also be called via
SetMinSize or SetMaxSize). Do you call any of these methods? Or does
the exception traceback show that it is coming from your constructor
call above? BTW, passing the size to the constructor also sets the min
size, so if you do something later that causes the max size to be set
smaller than that size then you could get this error in that case too.

No call to any of these 3 methods. The exception is indeed coming from the
constructor. No further attempt to modify the size either (the widget is
purposedly created with a fixed - definitive - size).
Is there anything specific to TextCtrl wrt. size argument? (as compared to
Panel, Button... which are uneventfully created the same way)

>

[...]

>
> print self.text.GetSize ()
> self.text.SetSize (Size (502, 190))
> print self.text.GetSize ()
>
> will print twice (81, 27) - (which must be the DefaultSize)

Not sure what's going on here. If you're on Windows then it could be
related to the deferred sizing that can be done there, but even if it is
using the deferred sizing API in this case it should still be returning
the pending size...

As indicated above, this is not on Windows.

Jean-Loup Goulat wrote:

Thanks for your reply, answers to your questions inlined below:

Robin Dunn <robin <at> alldunn.com> writes:

[...]

A wxPython based appli works fine with wxPython 2.6.1.0 and python 2.3.3,

but

when installing it on 2.6.3.2/python2.3.4,

Which platform?

Red Hat Enterprise Linux 4 (2.6.9 kernel)

[...]

wx._core.PyAssertionError C++ assertion "wxAssertFailure" failed in
../src/common/wincmm.cpp (752): min width/height must be less than max width/height!

[...]

self.text = TextCtrl (self, id = -1, style = TE_MULTILINE|TE_READONLY,
                      size = Size (502, 190),
                      pos = Point (0, 0))

The assertion is coming from SetSizeHints (which can also be called via SetMinSize or SetMaxSize). Do you call any of these methods? Or does the exception traceback show that it is coming from your constructor call above? BTW, passing the size to the constructor also sets the min size, so if you do something later that causes the max size to be set smaller than that size then you could get this error in that case too.

No call to any of these 3 methods. The exception is indeed coming from the constructor. No further attempt to modify the size either (the widget is purposedly created with a fixed - definitive - size).
Is there anything specific to TextCtrl wrt. size argument? (as compared to Panel, Button... which are uneventfully created the same way)

Ok, please create a small runnable sample app that shows the problem so I can try to duplicate it here.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn <robin <at> alldunn.com> writes:

Jean-Loup Goulat wrote:
> Thanks for your reply, answers to your questions inlined below:
>
> Robin Dunn <robin <at> alldunn.com> writes:
>
> [...]
>>> A wxPython based appli works fine with wxPython 2.6.1.0 and python 2.3.3,
> but
>>> when installing it on 2.6.3.2/python2.3.4,

[...]

Ok, please create a small runnable sample app that shows the problem so
I can try to duplicate it here.

I obviously should have thought about it before, the origin of the problem is
so basically stupid: reduced display size in the new environment :frowning:
I thought every widget in the appli had a fixed size expressed as a ratio of
available space, but it's not (yet) the case. I've been misled by the fact
that the problem occurred only with TextCtrl, but this was a side effect...

My apologies for any wasted time/effort, I really feel like an idiot now...