PDA

View Full Version : (me dense maybe) cant get hildon.NamePasswordDialog to work


greghudd
07-18-2008, 12:08 AM
Hi to group.

(Not new to engineering / programming but new to N800 & PyGTK)

Trying to get the -> hildon.NamePasswordDialog example found at http://pymaemo.garage.maemo.org/ -> Components -> Python-Hildon...(NamePasswordDialog) to work in my code.

Tried out the example on both the N800 / Os2008 device and also on my X86 SBOX devl. environment. I cut-and-pasted the code right out of the doc example. Msg when button clicked is: TypeError: on_click() takes exactly 1 argument (2 given)

Looked all over internet for working example, no joy. Anyone have some working code &/or a pointer to (perhaps) a correct spec. for this feature. I am stumped at this point.

Many Thanks in Advance for help on this. //GregH

yerga
07-18-2008, 06:08 AM
The "clicked" signal for buttons releases one 'hidden' argument.

So if you have: button.connect("clicked", on_click, argument1)

You function on_click should be:
def on_click(widget, argument1):
......

Where the widget argument is the widget who releases the signal, in this case the button.

greghudd
07-18-2008, 01:50 PM
Hi back, Thanks for the useful information in your reply...

Knowing that it seems that the Sample code 'should' work. It doesnt.

Here is some standard GTK Dialog code that does work

<code>

import hildon

def on_click(widget, window):

dialog = gtk.Dialog("Dialog Box Title", None, gtk.DIALOG_MODAL,(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
dialog.set_default_response(gtk.RESPONSE_ACCEPT)
dialog.set_position(gtk.WIN_POS_CENTER)
response = dialog.run()
dialog.hide()

if response == gtk.RESPONSE_OK:
widget.set_label("Name: %s\nPassword: %s" % (dialog.get_name(), dialog.get_password()))
else:
widget.set_label("Enter name and password")

dialog.destroy()

window = hildon.Window()
window.set_title("Dialog Box Test App")
window.set_icon_from_file("apngicongoeshere.png")

button = gtk.Button("Enter name and password")
button.connect("clicked", on_click, window)

window.add(button)
window.show_all()
gtk.main()

<code>

Unfortunately, still cant get the example code to work at all .

If/when I figure this out I will post the answer back. Also, where & to whom would be the proper method to submit errors/bugs in the code or documentation for Python?!?

Cheers. //GregH

brontide
07-18-2008, 01:55 PM
Hi back, Thanks for the useful information in your reply...

Knowing that it seems that the Sample code 'should' work. It doesnt.

Unfortunately, still cant get the example code to work at all .



Can you be more specific on how it doesn't work? Does it just "go away", is there an error message, do you have python-launcher installed, and anything else you think might be affecting it.

brontide
07-18-2008, 02:02 PM
Nevermind...

check this out...

http://maemo.org/api_refs/4.1/libhildon-2.0.4/HildonLoginDialog.html

Always use the most recent api_refs ( why in gods name they changes the name of the dialog without changing the features I will never understand )

Yes, I ran into that as well, I ended up abandoning the Hildon dialog and using my own once I figured out how to set the input-handling to suppress capitalizing the first letter.

brontide
07-18-2008, 02:08 PM
It sounds like you are where I was about a month ago... a few tips.

1) Always use the most recent api refs and work your way backwards if necessary to find the right docs. Extrapolate from the C ref if necessary, it's usually an almost 1:1 mapping ( once you take the pseudo-OO stuff into account ).

2) Don't use GtkBuilder unless you plan on only being on OS2008+

3) Debug by calling python2.5 directly if you have python-launcher installed

4) Setting hildon-input-mode is not very well documented, but here is an example. The number at the end is a bitmap. This is for the username / password dialog in DialCentral fka Grandcentral Dialer.


self._widgetTree.get_widget("usernameentry").set_property('hildon-input-mode', 7)
self._widgetTree.get_widget("passwordentry").set_property('hildon-input-mode', 7|(1 << 29))

brontide
07-18-2008, 02:18 PM
Here is some standard GTK Dialog code that does work

A few more points, hildon.NamePasswordDialog() no longer exists for some stupid reason, replaced with hildon.LoginDialog().

gtk.Dialog does not have the functions get_name() and get_password() so that will fail as well.

greghudd
07-18-2008, 02:43 PM
Hi (again thanks for the reply & thoughts)

I had a feeling that the docs were 'old' and that the interface changed.

For others, I started (reasonably I think) from here @ http://pymaemo.garage.maemo.org/documentation.html#components

for my info. Obviously they are out of date with the current OS2008 release. I am sure it will catch up eventually.

I will tryout the code from the new docs that you pointed me to.

Cheers from Huntington Beach, CA //GHudd

brontide
07-18-2008, 02:57 PM
Since there is no updated Python example here is the translated example.


import gtk
import hildon

def on_click(widget, window):
dialog = hildon.LoginDialog(window)

response = dialog.run()
dialog.hide()

if response == gtk.RESPONSE_OK:
widget.set_label("Name: %s\nPassword: %s" % (dialog.get_username(), dialog.get_password()))
else:
widget.set_label("Enter name and password")

dialog.destroy()

window = hildon.Window()
window.set_title("Test App")

button = gtk.Button("Enter name and password")
button.connect("clicked", on_click, window)

window.add(button)

window.show_all()

gtk.main()

greghudd
07-18-2008, 02:59 PM
Even more.

An FYI

Plowed around internet some more & came across this page that talks about a number of changed/depreciated hildon interfaces that have/are changing: (doc is year 2008)

http://live.gnome.org/Hildon/TwoPointZero/ChangesOverview

Food for thought for others who are learning this going fwd. //GH

greghudd
07-18-2008, 03:02 PM
Thanks 'Brontide' the code works perfectly.

(I cant believe I got stuck on something as brain dead as a dialog box...)

GH