I am running quickly 12.80.1-0ubuntu2 and for some reason the apps that I generate no longer recognise button clicks. A few weeks ago I created an application using the ubuntu-application template with multiple buttons which referred to the subprocess function. I tried to create an identical application today and it will not work. There is no debug output or anything and the source code is exactly the same.

In glade there is a button called button1 and this is my Window.py source code

# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
# This file is in the public domain

from locale import gettext as _

from gi.repository import Gtk # pylint: disable=E0611
import logging
import subprocess
logger = logging.getLogger('apppool')

from apppool_lib import Window
from apppool.AboutApppoolDialog import AboutApppoolDialog
from apppool.PreferencesApppoolDialog import PreferencesApppoolDialog

# See apppool_lib.Window.py for more details about how this class works
class ApppoolWindow(Window):
    __gtype_name__ = "ApppoolWindow"

    def finish_initializing(self, builder): # pylint: disable=E1002
        """Set up the main window"""
        super(ApppoolWindow, self).finish_initializing(builder)

        self.AboutDialog = AboutApppoolDialog
        self.PreferencesDialog = PreferencesApppoolDialog
        self.button1 = self.builder.get_object("button1")

        # Code for other initialization actions should be added here.
        def on_button1_clicked(self, widget):
            print "No Selected"
            subprocess.call('no-tour', shell=True)

The "No Selected" message doesn't appear in the terminal either making me think that it is not recognising buttons at all. I am pretty sure this is a bug as I have tried it on multiple computers, created a new project all with the same results. This source code used to work last week but not now so I am pretty sure nothing is wrong with that.

def on_button1_clicked(self, widget):
        print "No Selected"
        subprocess.call('no-tour', shell=True)

There was an issue with the indentation with this code. The def line had to be in the same line as the def finish_initializing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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