TypeError: startView() takes exactly 1 argument (3 given)

2009-12-29 Thread Ron Croonenberg

Hello,

I am trying to write a plugin for Rhythmbox in python and run into a 
'strange' problem. For a method (an action for clicking a button) I 
started a method and however many arguments I use, it keeps giving me 
the same error:


'TypeError: startView() takes exactly 1 argument (3 given)'

does someone have any pointers or tips?, thanks;

Ron

here is the code I have the problem with:

import rb
import pygtk
import gtk, gobject


pygtk.require('2.0')



class tb_button (rb.Plugin):

#
# the init thing
#
   def __init__(self):
  rb.Plugin.__init__(self)

#
# the activate thing
#
   def activate(self, shell):
  self.shell = shell

  view_button = """
  

  


  

  
  """

  # create a new action
  action = gtk.Action('viewAction',
_(' _View'),
_('Browse Track '), "")

  # connect it
  action.connect('activate', self.startView, shell)
  action_group = gtk.ActionGroup('NewActionGroup')
  action_group.add_action(action)
  shell.get_ui_manager().insert_action_group(action_group)

  # add it to the toolbar
  ui_manager = shell.get_ui_manager()
  ui_manager.add_ui_from_string(view_button)



#
# Start the  View
#
   def startView(self, widget, shell, se):
# nothing yet
  return

--
http://mail.python.org/mailman/listinfo/python-list


Re: TypeError: startView() takes exactly 1 argument (3 given)

2009-12-30 Thread Ron Croonenberg



Dave Angel wrote:

Ron Croonenberg wrote:

Hello,

I am trying to write a plugin for Rhythmbox in python and run into a 
'strange' problem. For a method (an action for clicking a button) I 
started a method and however many arguments I use, it keeps giving me 
the same error:


'TypeError: startView() takes exactly 1 argument (3 given)'

does someone have any pointers or tips?, thanks;

Ron

here is the code I have the problem with:

import rb
import pygtk
import gtk, gobject


pygtk.require('2.0')



class tb_button (rb.Plugin):

#
# the init thing
#
   def __init__(self):
  rb.Plugin.__init__(self)

#
# the activate thing
#
   def activate(self, shell):
  self.shell = shell

  view_button = """
  

  


  

  
  """

  # create a new action
  action = gtk.Action('viewAction',
_(' _View'),
_('Browse Track '), "")

  # connect it
  action.connect('activate', self.startView, shell)
  action_group = gtk.ActionGroup('NewActionGroup')
  action_group.add_action(action)
  shell.get_ui_manager().insert_action_group(action_group)

  # add it to the toolbar
  ui_manager = shell.get_ui_manager()
  ui_manager.add_ui_from_string(view_button)



#
# Start the  View
#
   def startView(self, widget, shell, se):
# nothing yet
  return


Please give the complete error traceback, and make sure it matches the 
code you post.  I'm guessing that the subset of the error message you're 
quoting occurs when you define startView() as taking only self as a 
parameter.


A quick caveat.  I'm not familiar with GTK in particular, but I 
recognize the paradigm.  You're defining an event handler (startView).  
And you define a certain set of parameters (not arguments), presently 
called self, widge, shell, and se.


But you're not calling it, you're connecting it to an action.  So when 
that action triggers (or event happens), the GUI system will call your 
event handler.  You don't control the arguments it passes, and 
apparently it passes 3.  So you need to change the formal parameters in 
your def to match.


More specifically what are those parameters ?  I don't know, but you 
should be able to tell from sample pyGTK sources, or somebody else can 
chime in.  And maybe I'm totally nuts here.


DaveA




Hello Dave,

I don't think you're nuts *lol*.  Actually I have been thinking along a 
similar line. (although I am new to python and probably thinking along C 
lines too much)


I saw some postings/articles that I found with google mentioning a 
python bug with that behavior. (However I think that the chances of me 
running into a bug vs me making a mistake is probably 1:)


What I think is weird though is that it doesn't matter how many 
parameters I put there. The error msg is still the same. (it doesn't 
matter if I actually put 1, 2, 3, 4 or even 5 there.  the message is 
exactly the same.'expecting 1 given 3'


I changed the debug level to see if I could get more messages.
(It is a rhythmbox plugin,  for debugging I have to start is with 
something like 'GST_DEBUG=3 rhythmbox &>log-file')
If I change the debug level to 5 or so I still only get that one error 
msg and nothing else. (yes surprised me too)


Ron

--
http://mail.python.org/mailman/listinfo/python-list


Solved: TypeError: startView() takes exactly 1 argument (3 given)

2009-12-30 Thread Ron Croonenberg


ok, problem solved.

In the directory the plugin lives I have(had) a directory called 
'backup' to save things just in case I mess up.


Guess what, RB apparently looks into that directory too and uses the 
class, py file, it finds there instead of the one I am making changes to.


Dave Angel wrote:

Ron Croonenberg wrote:

Hello,

I am trying to write a plugin for Rhythmbox in python and run into a 
'strange' problem. For a method (an action for clicking a button) I 
started a method and however many arguments I use, it keeps giving me 
the same error:


'TypeError: startView() takes exactly 1 argument (3 given)'

does someone have any pointers or tips?, thanks;

Ron

here is the code I have the problem with:

import rb
import pygtk
import gtk, gobject


pygtk.require('2.0')



class tb_button (rb.Plugin):

#
# the init thing
#
   def __init__(self):
  rb.Plugin.__init__(self)

#
# the activate thing
#
   def activate(self, shell):
  self.shell = shell

  view_button = """
  

  


  

  
  """

  # create a new action
  action = gtk.Action('viewAction',
_(' _View'),
_('Browse Track '), "")

  # connect it
  action.connect('activate', self.startView, shell)
  action_group = gtk.ActionGroup('NewActionGroup')
  action_group.add_action(action)
  shell.get_ui_manager().insert_action_group(action_group)

  # add it to the toolbar
  ui_manager = shell.get_ui_manager()
  ui_manager.add_ui_from_string(view_button)



#
# Start the  View
#
   def startView(self, widget, shell, se):
# nothing yet
  return


Please give the complete error traceback, and make sure it matches the 
code you post.  I'm guessing that the subset of the error message you're 
quoting occurs when you define startView() as taking only self as a 
parameter.


A quick caveat.  I'm not familiar with GTK in particular, but I 
recognize the paradigm.  You're defining an event handler (startView).  
And you define a certain set of parameters (not arguments), presently 
called self, widge, shell, and se.


But you're not calling it, you're connecting it to an action.  So when 
that action triggers (or event happens), the GUI system will call your 
event handler.  You don't control the arguments it passes, and 
apparently it passes 3.  So you need to change the formal parameters in 
your def to match.


More specifically what are those parameters ?  I don't know, but you 
should be able to tell from sample pyGTK sources, or somebody else can 
chime in.  And maybe I'm totally nuts here.


DaveA



--
==========
main(p){printf(p,34,p="main(p){printf(p,34,p=%c%s%c,34); }",34); }
==
Ron Croonenberg   |
  | Phone: 1 765 658 4761
Lab Instructor &  | Fax:   1 765 658 4732
Technology Coordinator|
  |
Department of Computer Science| e-mail: r...@depauw.edu
DePauw University |
275 Julian Science & Math Center  |
602 South College Ave.|
Greencastle, IN  46135|
==

--
http://mail.python.org/mailman/listinfo/python-list


Re: I think I found a bug in Python 2.6.4 (in the inspect module)

2009-12-30 Thread Ron Croonenberg

hello,

is there a way, in python, to create a splash window and when the 
program has completed disappears by sending a msg to it? (I tried 
creating two gtk windows but gtk_main doesn't seem to return unless it 
gets closed.)


tia

Ron
--
http://mail.python.org/mailman/listinfo/python-list


whoops: create a splash window in python

2009-12-30 Thread Ron Croonenberg

sorry about posting with the wrong subject...

*
hello,

is there a way, in python, to create a splash window and when the 
program has completed disappears by sending a msg to it? (I tried 
creating two gtk windows but gtk_main doesn't seem to return unless it 
gets closed.)


tia

Ron
*
--
http://mail.python.org/mailman/listinfo/python-list