Reply
Thread Tools
Posts: 8 | Thanked: 1 time | Joined on Jul 2008
#1
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

Last edited by greghudd; 2008-07-18 at 04:23. Reason: bug fix
 
yerga's Avatar
Posts: 696 | Thanked: 1,012 times | Joined on Mar 2006 @ Asturies, Spain
#2
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.
__________________
Daniel Martín Yerga
maemo.org profile
Twitter
 

The Following User Says Thank You to yerga For This Useful Post:
Posts: 8 | Thanked: 1 time | Joined on Jul 2008
#3
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's Avatar
Posts: 868 | Thanked: 474 times | Joined on Oct 2007 @ Capital District, NY, USA
#4
Originally Posted by greghudd View Post
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's Avatar
Posts: 868 | Thanked: 474 times | Joined on Oct 2007 @ Capital District, NY, USA
#5
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's Avatar
Posts: 868 | Thanked: 474 times | Joined on Oct 2007 @ Capital District, NY, USA
#6
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's Avatar
Posts: 868 | Thanked: 474 times | Joined on Oct 2007 @ Capital District, NY, USA
#7
Originally Posted by greghudd View Post
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.
 
Posts: 8 | Thanked: 1 time | Joined on Jul 2008
#8
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's Avatar
Posts: 868 | Thanked: 474 times | Joined on Oct 2007 @ Capital District, NY, USA
#9
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()
 
Posts: 8 | Thanked: 1 time | Joined on Jul 2008
#10
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
 

The Following User Says Thank You to greghudd For This Useful Post:
Reply

Thread Tools

 
Forum Jump


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