wxp4: .ViewStart not available on wx.ScrolledPanel/Window anymore ?

556 views
Skip to first unread message

Karsten Hilbert

unread,
Jul 3, 2019, 5:42:23 AM7/3/19
to wxPython-users
I am seeing this exception with some code ported from wxp2/3 to wxp4:

2019-07-02 12:13:58 DEBUG gm.gui [3081825984 MainThread] (/home/ncq/Projekte/gm/git/gnumed/gnumed/Gnumed/wxpython/gmExceptionHandlingWidgets.py::handle_uncaught_exception_wx() #198): unhandled exception caught:
Traceback (most recent call last):
File "/home/ncq/Projekte/gm/git/gnumed/gnumed/Gnumed/wxpython/gmTextCtrl.py", line 386, in _on_expando_needs_layout
y_view = self.ViewStart[1]
AttributeError: 'cProgressNotesEAPnl' object has no attribute 'ViewStart'

The cProgressNotesEAPnl is a child of wx.ScrolledWindow and
uses .ViewStart to scroll into view the line with the cursor
of an (expando) text ctrl contained within the panel:

def _on_expando_needs_layout(self, evt):
# need to tell ourselves to re-Layout to refresh scroll bars

# provoke adding scrollbar if needed
#self.Fit() # works on Linux but not on Windows
self.FitInside() # needed on Windows rather than self.Fit()

if self.HasScrollbar(wx.VERTICAL):
# scroll panel to show cursor
expando = self.FindWindowById(evt.GetId())
y_expando = expando.GetPositionTuple()[1]
h_expando = expando.GetSize()[1]
line_of_cursor = expando.PositionToXY(expando.GetInsertionPoint())[2] + 1
if expando.NumberOfLines == 0:
no_of_lines = 1
else:
no_of_lines = expando.NumberOfLines
y_cursor = int(round((float(line_of_cursor) / no_of_lines) * h_expando))
y_desired_visible = y_expando + y_cursor

###############################
# failing call:
###############################
y_view = self.ViewStart[1]
h_view = self.GetClientSize()[1]

# expando starts before view
if y_desired_visible < y_view:
self.Scroll(0, y_desired_visible)

if y_desired_visible > h_view:
self.Scroll(0, y_desired_visible)

which fails, due to the .ViewStart property not available anymore.

I have not been able to derive from documentation what I
should use instead.

Thanks for any suggestions,
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B

Karsten Hilbert

unread,
Jul 3, 2019, 8:49:09 AM7/3/19
to wxPython-users
On Wed, Jul 03, 2019 at 11:42:16AM +0200, Karsten Hilbert wrote:

> I am seeing this exception with some code ported from wxp2/3 to wxp4:
>
> 2019-07-02 12:13:58 DEBUG gm.gui [3081825984 MainThread] (/home/ncq/Projekte/gm/git/gnumed/gnumed/Gnumed/wxpython/gmExceptionHandlingWidgets.py::handle_uncaught_exception_wx() #198): unhandled exception caught:
> Traceback (most recent call last):
> File "/home/ncq/Projekte/gm/git/gnumed/gnumed/Gnumed/wxpython/gmTextCtrl.py", line 386, in _on_expando_needs_layout
> y_view = self.ViewStart[1]
> AttributeError: 'cProgressNotesEAPnl' object has no attribute 'ViewStart'
...
> which fails, due to the .ViewStart property not available anymore.
>
> I have not been able to derive from documentation what I
> should use instead.

However, single-stepping through dir(wx.ScrolledWindow)
showed that .GetViewStart() still exists, it simply seems to
not be exposed as a Property anymore.

Robin Dunn

unread,
Jul 3, 2019, 1:49:53 PM7/3/19
to wxPython-users
On Wednesday, July 3, 2019 at 5:49:09 AM UTC-7, Karsten Hilbert wrote:

However, single-stepping through dir(wx.ScrolledWindow)
showed that .GetViewStart() still exists, it simply seems to
not be exposed as a Property anymore.

Thanks, I've created a ticket for it here: https://github.com/wxWidgets/Phoenix/issues/1295

--
Robin
Reply all
Reply to author
Forward
0 new messages