![]() |
Python: scroll a page with keypress; help needed.
I have a python application that I want to implement key-press scrolling on. I already have all the main frame code in place, just have no idea how to scroll something.
Here is the important part of the code: Code:
def on_key_press(self, widget, event, *args): I know I need to add if statements to catch the Up/Down key buttons, but how to you scroll a textview and/or scrolledwindow? The textview is self.textview and scrolledwindow is self.sw (to complicate matters, the scrolledwindow can either be a gtk.ScrolledWindow or mokoui.FingerScroll object). Any help is appreciated. |
Re: Python: scroll a page with keypress; help needed.
This is probably no help, but you know this?
http://www.internettablettalk.com/wi...e_Key_bindings . |
Re: Python: scroll a page with keypress; help needed.
Not going to write any test code, so I haven't tried this at all... First I think you'll need to test for whether it's a ScrolledWindow or FingerScroll... For a ScrolledWindow, use gethadjustment(), then set the value of the returned gtk.Adjustment to some increment above or below its current value, then use sethadjustment() on the ScrolledWindow.
I hope that made sense. Not sure about the FingerScroll. [edit]Here's some mostly-code: Code:
if event.keyval == (UP keysym): [edit2]Looking at mokoui... I believe the code would be the same as the scrolledwindow code, so no need to type test. Again, I haven't tried this at all (I've never even dealt with mokoui before). |
Re: Python: scroll a page with keypress; help needed.
Quote:
|
Re: Python: scroll a page with keypress; help needed.
Quote:
Code:
adj.set_page_increment(gtk.SCROLL_PAGES) |
Re: Python: scroll a page with keypress; help needed.
Hmm... strange, but it seems to be a very surface-level problem. Try this:
Code:
adj.page_incrment = gtk.SCROLL_PAGES |
Re: Python: scroll a page with keypress; help needed.
Today I really tried to get this working...but to no avail. My code is as follows:
Code:
if event.keyval == gtk.keysyms.Up: |
Re: Python: scroll a page with keypress; help needed.
Quote:
|
Re: Python: scroll a page with keypress; help needed.
Also, you're not using the most important gtk.Adjustment attribute: 'page_size'.
And don't forget end conditions. Here's some code: Code:
def pageup(self, sw): |
Re: Python: scroll a page with keypress; help needed.
Code:
def pagedown(self, sw): |
All times are GMT. The time now is 17:10. |
vBulletin® Version 3.8.8