Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to call function in quickly?

Here is my code:

def finish_initializing(self, builder): # pylint: disable=E1002
    super(projectWindow, self).finish_initializing(builder)
    self.AboutDialog = AboutprojectDialog
    self.PreferencesDialog = PreferencesprojectDialog
def test(self,widget):
    print "clicked"
def on_myButton_clicked(self,widget):

The following error I get: NameError: global name 'test' is not defined

share|improve this question
up vote 3 down vote accepted

According to the tutorial video on ,

If your widget is named "myButton",

def test(self,widget):
    print "clicked"
def on_myButton_clicked(self,widget):

This part of your code should be rewritten to below:

self.myButton = self.builder.get_object("myButton") 
def test(widget):
    print "clicked"
def on_myButton_clicked(self, widget):

In advance, it is necessary to start Glade by quickly design command, and to create the button widget.

share|improve this answer

test is a method of the class you are writing so you have to use


where some_widget is whatever value you want to use for the widget parameter of test.

By the way quickly isn't a programming language but a tool. The programming language you are using is Python.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.