Restore Scrolled Position in TextCTRL
8 answers - 216 bytes -

Is there anyway to store and then restore the scrolled to position in a
wxTextCtrl? Not the HTML one, but just the text one.
Something like STC's GetFirstVisibleLine, but for wxTextCtrl?
Thanks.
No.1 | | 893 bytes |
| 
5/9/06, Ricardo Pedroso <ricardo.pedroso (AT) netvisao (DOT) ptwrote:
Is there anyway to store and then restore the scrolled to position in a
wxTextCtrl? Not the HTML one, but just the text one.
--
See if this will help you:
#wxtextctrlshowposition
Yeah, that's the function I would use if I had pos, but I don't and that's
the problem. Is there a way to see which pos is in the upper left corner?
The position would be preferable, but I might be able to make do with the
line. maybe even the scrolled amount. But I don't know that you can
correctly manually scroll a TextCtrl.
Any ideas on how to get the proper pos?
Ricardo
--
To unsubscribe, e-mail: wxPython-users-unsubscribe (AT) lists (DOT) wxwidgets.org
For additional commands, e-mail: wxPython-users-help (AT) lists (DOT) wxwidgets.org
--
No.2 | | 390 bytes |
| 
Is there anyway to store and then restore the scrolled to position in a
wxTextCtrl? Not the HTML one, but just the text one.
See if this will help you:
#wxtextctrlshowposition
Ricardo
To unsubscribe, e-mail: wxPython-users-unsubscribe (AT) lists (DOT) wxwidgets.org
For additional commands, e-mail: wxPython-users-help (AT) lists (DOT) wxwidgets.org
No.3 | | 1168 bytes |
| 
So no GetFirstVisibleLine type command for TextCtrl? Isn't there some way to
just grab the first line from the windows, etc?
Anyone?
5/9/06, Josh Menke <josh (AT) cs (DOT) byu.eduwrote:
5/9/06, Ricardo Pedroso <ricardo.pedroso (AT) netvisao (DOT) ptwrote:
Is there anyway to store and then restore the scrolled to position in
a
wxTextCtrl? Not the HTML one, but just the text one.
--
See if this will help you:
#wxtextctrlshowposition
--
Yeah, that's the function I would use if I had pos, but I don't and that's
the problem. Is there a way to see which pos is in the upper left corner?
The position would be preferable, but I might be able to make do with the
line. maybe even the scrolled amount. But I don't know that you can
correctly manually scroll a TextCtrl.
Any ideas on how to get the proper pos?
Ricardo
--
To unsubscribe, e-mail: wxPython-users-unsubscribe (AT) lists (DOT) wxwidgets.org
For additional commands, e-mail: wxPython-users-help (AT) lists (DOT) wxwidgets.org
>
>
>
>
No.4 | | 1786 bytes |
| 
K, just to partly answer my own question.
I did the following:
scroll = self.GetScrolledPos(wx.VERTICAL)
This gets me the scrolled position in pixels, I believe. I then, by
trial-and-error, found that the number of pixels in one LINE of scrolling is
19.
So then I did:
self.ScrollLines(scroll/19)
Is there a surefire way to get the exact height of a scroll line in pixels?
Seems like there should be, based on the font, etc.
How do you get the height of a scroll line in pixels?
5/10/06, Josh Menke <josh (AT) cs (DOT) byu.eduwrote:
So no GetFirstVisibleLine type command for TextCtrl? Isn't there some way
to just grab the first line from the windows, etc?
Anyone?
--
5/9/06, Josh Menke <josh (AT) cs (DOT) byu.eduwrote:
5/9/06, Ricardo Pedroso <ricardo.pedroso (AT) netvisao (DOT) pt wrote:
Is there anyway to store and then restore the scrolled to position
in a
wxTextCtrl? Not the HTML one, but just the text one.
--
See if this will help you:
#wxtextctrlshowposition
--
Yeah, that's the function I would use if I had pos, but I don't and
that's the problem. Is there a way to see which pos is in the upper left
corner? The position would be preferable, but I might be able to make do
with the line. maybe even the scrolled amount. But I don't know that you
can correctly manually scroll a TextCtrl.
Any ideas on how to get the proper pos?
Ricardo
--
To unsubscribe, e-mail: wxPython-users-unsubscribe (AT) lists (DOT) wxwidgets.org
For additional commands, e-mail:
wxPython-users-help (AT) lists (DOT) wxwidgets.org
>
>
>
>
No.5 | | 2363 bytes |
| 
Hello Josh,
you can try something like:
linewidth, lineheight = MyTextCtrl.GetTextExtent("Aq")
Then you can use the lineheight result to see if it is closer to 19 or not.
HTH.
Andrea.
5/11/06, Josh Menke <josh (AT) cs (DOT) byu.eduwrote:
K, just to partly answer my own question.
I did the following:
scroll = self.GetScrolledPos(wx.VERTICAL)
This gets me the scrolled position in pixels, I believe. I then, by
trial-and-error, found that the number of pixels in one LINE of scrolling
is
19.
So then I did:
self.ScrollLines(scroll/19)
Is there a surefire way to get the exact height of a scroll line in
pixels?
Seems like there should be, based on the font, etc.
How do you get the height of a scroll line in pixels?
5/10/06, Josh Menke <josh (AT) cs (DOT) byu.eduwrote:
So no GetFirstVisibleLine type command for TextCtrl? Isn't there some
way
to just grab the first line from the windows, etc?
Anyone?
--
>
>
>
5/9/06, Josh Menke < josh (AT) cs (DOT) byu.eduwrote:
5/9/06, Ricardo Pedroso <ricardo.pedroso (AT) netvisao (DOT) pt wrote:
>
>
>
Is there anyway to store and then restore the scrolled to position
in a
wxTextCtrl? Not the HTML one, but just the text one.
--
See if this will help you:
--
#wxtextctrlshowposition
>
>
>
Yeah, that's the function I would use if I had pos, but I don't and
that's the problem. Is there a way to see which pos is in the upper left
corner? The position would be preferable, but I might be able to make do
with the line. maybe even the scrolled amount. But I don't know that
you
can correctly manually scroll a TextCtrl.
Any ideas on how to get the proper pos?
--
>
>
>
>
Ricardo
>
>
>
To unsubscribe, e-mail:
wxPython-users-unsubscribe (AT) lists (DOT) wxwidgets.org
For additional commands, e-mail:
wxPython-users-help (AT) lists (DOT) wxwidgets.org
>
>
>
>
>
>
>
No.6 | | 529 bytes |
| 
So no GetFirstVisibleLine type command for TextCtrl? Isn't there some way
to
just grab the first line from the windows, etc?
Maybe this can do the job:
def GetFirstVisibleLine(self):
res, col, row = self.txt.HitTest((0,0))
pos = self.txt.XYToPosition(col,row) + 1
self.txt.ShowPosition(pos)
Ricardo
To unsubscribe, e-mail: wxPython-users-unsubscribe (AT) lists (DOT) wxwidgets.org
For additional commands, e-mail: wxPython-users-help (AT) lists (DOT) wxwidgets.org
No.7 | | 888 bytes |
| 
5/11/06, Ricardo Pedroso <ricardo.pedroso (AT) netvisao (DOT) ptwrote:
Maybe this can do the job:
def GetFirstVisibleLine(self):
res, col, row = self.txt.HitTest((0,0))
pos = self.txt.XYToPosition(col,row) + 1
self.txt.ShowPosition(pos)
, you were close. I remembered that HitTest returns the row and column for
the text and is not in pixels for TextCtrl. So, the answer is:
def GetFirstVisibleLine(self):
res, col, row = self.txt.HitTest((0,0))
return res+row
It's res+row instead of just row because both no scrolling and one scroll
makes row = 0, whereas res = 1 after the first scroll. Kind of odd but it
works.
Ricardo
--
To unsubscribe, e-mail: wxPython-users-unsubscribe (AT) lists (DOT) wxwidgets.org
For additional commands, e-mail: wxPython-users-help (AT) lists (DOT) wxwidgets.org
--
No.8 | | 361 bytes |
| 
5/11/06, Andrea Gavana <andrea.gavana (AT) gmail (DOT) comwrote:
you can try something like:
linewidth, lineheight = MyTextCtrl.GetTextExtent("Aq")
Then you can use the lineheight result to see if it is closer to 19 or
not.
Thanks Andrea, I'll hold on to this for future reference if I have problems
with HitTest(0,0).