Home Forums Wiki Doc Install Extras Screenshots Source Code Projects Blog Users Groups Register
Glx-Dock / Cairo-Dock List of forums Technical discussions | Discussions techniques Erro with on_build_menu()
The latest stable release is the *3.4.0* : How to install it here.
Note: We just switched from BZR to Git on Github! (only to host the code and your future pull requests)
Technical discussions | Discussions techniques

Subjects Author Language Messages Last message
[Locked] Erro with on_build_menu()
jesuisbenjamin English 2 jesuisbenjamin [Read]
15 August 2011 à 17:31

jesuisbenjamin, Sunday 14 August 2011 à 20:32


Subscription date : 28 October 2009
Messages : 415
Heya!

I am trying to make a right click-menu with:


def on_build_menu
(self):

        
"""
            Appends items to right-click menu.
        """

        
self.icon.AddMenuItems(
            {
"widget-type" 0,
            
"label""Add or change subscription",
            
"icon" "gtk-add",
            
"menu" 0,
            
"id" 1,
            
"tooltip" "Use this to add or change your Gmail account details."},
            {
"widget-type" 0,
            
"label""Restart timer",
            
"icon" "gtk-add",
            
"menu" 0,
            
"id" 2,
            
"tooltip" "In case of error the timer stops. Use this to restart timer again."}
            )

    
def on_menu_select(selfiNumEntry):

        
"""
            Launches methods according to menu selection.
        """

        
if iNumEntry == 1:
            
self.add_subscription('username')
        
elif iNumEntry == 2:
            
self.check_subscription()
        else:
            
#should not happen. Kept in case more menu-items need be appended.
            
pass



But I get an error in return. I can't figure out why, I believe I followed the example from the Wiki.

ERROR
:dbus.connection:Unable to set arguments ({'widget-type'0'menu'0'tooltip''Use this to add or change your Gmail account details.''label''Add or change subscription''id'1'icon''gtk-add'}, {'widget-type'0'menu'0'tooltip''In case of error the timer stops. Use this to restart timer again.''label''Restart timer''id'2'icon''gtk-add'}) according to signature u'aa{sv}': <type 'exceptions.TypeError'>: string indices must be integersnot str
ERROR
:dbus.connection:Exception in handler for D-Bus signal:
Traceback (most recent call last):
  
File "/usr/lib/pymodules/python2.7/dbus/connection.py"line 214in maybe_handle_message
    self
._handler(*args, **kwargs)
  
File "/usr/lib/python2.7/dist-packages/CDApplet.py"line 107in _on_build_menu
    self
.on_build_menu()
  
File "./Gmail"line 407in on_build_menu
    
"tooltip" "In case of error the timer stops. Use this to restart timer again."}
  
File "/usr/lib/pymodules/python2.7/dbus/proxies.py"line 140in __call__
    
**keywords)
  
File "/usr/lib/pymodules/python2.7/dbus/connection.py"line 620in call_blocking
    message
.append(signature=signature, *args)
TypeErrorstring indices must be integersnot str



Any idea?

Thanks.
B

fabounet, Monday 15 August 2011 à 14:37


Subscription date : 30 November 2007
Messages : 17118
I think it should be an array of dicts, so try putting the dicts inside brackets []

jesuisbenjamin, Monday 15 August 2011 à 17:31


Subscription date : 28 October 2009
Messages : 415
Thanks, it worked!

Technical discussions | Discussions techniques

Subjects Author Language Messages Last message
[Locked] Erro with on_build_menu()
jesuisbenjamin English 2 jesuisbenjamin [Read]
15 August 2011 à 17:31


Glx-Dock / Cairo-Dock List of forums Technical discussions | Discussions techniques Erro with on_build_menu() Top

Online users :

Powered by ElementSpeak © 2007 Adrien Pilleboue, 2009-2013 Matthieu Baerts.
Dock based on CSS Dock Menu (Ndesign) with jQuery. Icons by zgegball
Cairo-Dock is a free software under GNU-GPL3 licence. First stable version created by Fabounet.
Many thanks to TuxFamily for the web Hosting and Mav for the domain name.