maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   (me dense maybe) cant get hildon.NamePasswordDialog to work (https://talk.maemo.org/showthread.php?t=22039)

greghudd 2008-07-18 04:08

(me dense maybe) cant get hildon.NamePasswordDialog to work
 
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 2008-07-18 10:08

Re: (me dense maybe) cant get hildon.NamePasswordDialog to work
 
The "clicked" signal for buttons releases one 'hidden' argument.

So if you have:
Code:

button.connect("clicked", on_click, argument1)
You function on_click should be:
Code:

def on_click(widget, argument1):
    ......

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

greghudd 2008-07-18 17:50

Re: (me dense maybe) cant get hildon.NamePasswordDialog to work
 
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 2008-07-18 17:55

Re: (me dense maybe) cant get hildon.NamePasswordDialog to work
 
Quote:

Originally Posted by greghudd (Post 204500)
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 2008-07-18 18:02

Re: (me dense maybe) cant get hildon.NamePasswordDialog to work
 
Nevermind...

check this out...

http://maemo.org/api_refs/4.1/libhil...ginDialog.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 2008-07-18 18:08

Re: (me dense maybe) cant get hildon.NamePasswordDialog to work
 
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.

Code:

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 2008-07-18 18:18

Re: (me dense maybe) cant get hildon.NamePasswordDialog to work
 
Quote:

Originally Posted by greghudd (Post 204500)
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 2008-07-18 18:43

Re: (me dense maybe) cant get hildon.NamePasswordDialog to work
 
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/docu...tml#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 2008-07-18 18:57

Re: (me dense maybe) cant get hildon.NamePasswordDialog to work
 
Since there is no updated Python example here is the translated example.

Code:

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 2008-07-18 18:59

Re: (me dense maybe) cant get hildon.NamePasswordDialog to work
 
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/TwoPoin...hangesOverview

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

greghudd 2008-07-18 19:02

Re: (me dense maybe) cant get hildon.NamePasswordDialog to work
 
Thanks 'Brontide' the code works perfectly.

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

GH


All times are GMT. The time now is 22:08.

vBulletin® Version 3.8.8