Active Topics

 


Reply
Thread Tools
Posts: 146 | Thanked: 15 times | Joined on Oct 2008
#1
Hi,
I am writting a pygtk application for our N810, but I am a newbie at pygtk. I would like to know a few things:

1) How do I access the hardware N810 buttons? For example, how I do use the [+] and [-] to change the font size or volume? How do I use the middle button to make the window fullscreen?

2) How do I use the main window menu?

3) How do I make an image window, that is smaller than the image itself, to be scrollable with the mouse/finger? I know how to add scrollbars, but this is not what I want (this is certainly not a N800 related stuff).

Any help will be appreciated. Thanks!!!!!!!!!!!!!!
L.

Last edited by luis; 2009-05-26 at 02:08.
 
BrentDC's Avatar
Posts: 903 | Thanked: 632 times | Joined on Apr 2008
#2
Here is the base of an application that goes fullscreen when the fullscreen button is tapped. You can add other keys roughly the same way.

Code:
#!/usr/bin/env python2.5

import gtk
import hildon

class Example(hildon.Program):
   def __init__(self):
      hildon.Program.__init__(self)

      self.window = hildon.Window()
      self.window.connect("destroy", self.close_application)
      self.window.connect("key-press-event", self.on_key_press)
      self.window.connect("window-state-event", self.on_window_state_change)
      self.add_window(self.window)

   def on_window_state_change(self, widget, event, *args):
      if event.new_window_state & gtk.gdk.WINDOW_STATE_FULLSCREEN:
         self.window_in_fullscreen = True
      else:
         self.window_in_fullscreen = False

   def on_key_press(self, widget, event, *args):
      if event.keyval == gtk.keysyms.F6:
      # The "Full screen" hardware key has been pressed
         if self.window_in_fullscreen:
            self.window.unfullscreen()
         else:
            self.window.fullscreen()

   def close_application(self, widget):
      gtk.main_quit()

   def run(self):
      gtk.main()

app = Example()
app.run()
As for the other stuff, read the PyGTK tutorial.
__________________
-Brent

Author of TouchSearch -- web searching software for Maemo 5.

Mobile Device lineage: Palm Z22 -> Palm TX -> Nokia N800 -> Nokia N900
 

The Following User Says Thank You to BrentDC For This Useful Post:
Posts: 146 | Thanked: 15 times | Joined on Oct 2008
#3
Originally Posted by BrentDC View Post
Here is the base of an application that goes fullscreen when the fullscreen button is tapped. You can add other keys roughly the same way.
[...]
Yes, that is what I looked for, and it works. Do you know where I can look for the codes for the other keys?

As for the other stuff, read the PyGTK tutorial.
That is what I have been doing for the last week... but didn't find the stuff I asked for.

EDIT: BTW, I observed that you used HildonWindow, HildonProgram, etc. I didn't, and the buttons work. What is the advantage of using Hildon<Stuff>?

Thanks, and sorry for the silly questions,
L.

Last edited by luis; 2009-05-26 at 02:50.
 
BrentDC's Avatar
Posts: 903 | Thanked: 632 times | Joined on Apr 2008
#4
Originally Posted by luis View Post
Yes, that is what I looked for, and it works. Do you know where I can look for the codes for the other keys?



That is what I have been doing for the last week... but didn't find the stuff I asked for.

Thanks!
L.
IIRC, they are all F* keys. Zoon in = F7, zoom out = F8, etc. The d-pad ones are UP, Down, Left, Right. I'm not sure about the center one (maybe try Select).
__________________
-Brent

Author of TouchSearch -- web searching software for Maemo 5.

Mobile Device lineage: Palm Z22 -> Palm TX -> Nokia N800 -> Nokia N900
 
Posts: 146 | Thanked: 15 times | Joined on Oct 2008
#5
Originally Posted by BrentDC View Post
IIRC, they are all F* keys. Zoon in = F7, zoom out = F8, etc. The d-pad ones are UP, Down, Left, Right. I'm not sure about the center one (maybe try Select).
Great! Thanks.

I added a question while you were posting your answer, that probably you didn't see:

I observed that you used HildonWindow, HildonProgram, etc. I didn't, and the buttons work. What is the advantage of using Hildon<Stuff>?

Thanks again,
L.
 
BrentDC's Avatar
Posts: 903 | Thanked: 632 times | Joined on Apr 2008
#6
Originally Posted by luis View Post
Great! Thanks.

I added a question while you were posting your answer, that probably you didn't see:

I observed that you used HildonWindow, HildonProgram, etc. I didn't, and the buttons work. What is the advantage of using Hildon<Stuff>?

Thanks again,
L.
Using the hildon widgets allows you to use hildon-specific functions and methods e.g. adding a menu or toolbar. Since hildon widgets inherit from their gtk counterparts, you should try to use hildon widgets whenever possible (especially base widgets like hildon.Window).
__________________
-Brent

Author of TouchSearch -- web searching software for Maemo 5.

Mobile Device lineage: Palm Z22 -> Palm TX -> Nokia N800 -> Nokia N900
 

The Following User Says Thank You to BrentDC For This Useful Post:
Posts: 146 | Thanked: 15 times | Joined on Oct 2008
#7
Originally Posted by BrentDC View Post
Using the hildon widgets allows you to use hildon-specific functions and methods e.g. adding a menu or toolbar. Since hildon widgets inherit from their gtk counterparts, you should try to use hildon widgets whenever possible (especially base widgets like hildon.Window).
I see. Problem with that is that the very same program won't work on my linux boxes then. Perhaps I would need to do two applications...

Thanks for your help!!
Cheers,
L.
 
BrentDC's Avatar
Posts: 903 | Thanked: 632 times | Joined on Apr 2008
#8
Originally Posted by luis View Post
I see. Problem with that is that the very same program won't work on my linux boxes then. Perhaps I would need to do two applications...

Thanks for your help!!
Cheers,
L.
You can still make it run in both places, it just takes extra work. See:

Code:
on_tablet = True

try:
   import hildon
except ImportError:
   on_tablet = False

[...]

if on_tablet:
   self.window = hildon.Window()
else:
   self.window = gtk.Window()
And do that everytime you use a hildon widget or hildon-specific method.
__________________
-Brent

Author of TouchSearch -- web searching software for Maemo 5.

Mobile Device lineage: Palm Z22 -> Palm TX -> Nokia N800 -> Nokia N900
 

The Following 2 Users Say Thank You to BrentDC For This Useful Post:
daperl's Avatar
Posts: 2,427 | Thanked: 2,986 times | Joined on Dec 2007
#9
If you use debian on your Linux box try:

apt-get install python-hildon

or do a search:

apt-cache search hildon

This works on all of my Ubuntu and Kubuntu boxes.

Write once, run on Linux.

I also just ran this on my mac:

port install py2.5-gtk

MacPorts is extra primo good. No hildon yet though.
__________________
N9: Go white or go home
 
darethehair's Avatar
Posts: 273 | Thanked: 104 times | Joined on Mar 2007 @ Manitoba, Canada
#10
I have referred to this page a lot as well, for the names of the hardware keys that I use in pygtk on Maemo:

http://maemomm.garage.maemo.org/docs...l/ch02s03.html
__________________
There is nothing more dangerous than a bored cat.
 
Reply


 
Forum Jump


All times are GMT. The time now is 16:14.