GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sun Sep 21, 2014 4:05 pm

All times are UTC

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: [Solved]Can anyone explain how pygtkmvc connects signals?
PostPosted: Tue Jul 01, 2014 2:13 am 
Familiar Face

Joined: Tue Oct 08, 2013 5:16 am
Posts: 20
Thanks for your help.
I'm trying to understand how Pygtkmvc connects signals. I have a project called "Sandbox" that I'm developing with GTK3, so I can't use Pygtkmvc. I need to understand how the signals should be connected. Connecting the signals in the view is trivial, so how do I do it in the control module?
#!/usr/bin/env python2
# -*- coding: UTF-8 -*-

from gi.repository import Gtk

def setup_path():
    """Sets up the python include paths to include needed directories"""
    import os.path
    import sys
    from src.utils.globals import TOPDIR
    sys.path.insert(0, reduce(os.path.join, (TOPDIR, "resources", "external")))
    sys.path.insert(0, os.path.join(TOPDIR, "src"))

def check_requirements():
    """Checks versions and other requirements"""
    import gtkmvc

def main(*args, **kargs):
    from models.sandmodel import SandModel as SandModel
    from ctrls.sandcontrol import SandCtrl as SandCtrl
    from views.sandview import SandView as SandView

    m = SandModel()
    v = SandView()
    SandCtrl(m, v)


if __name__ == "__main__":
# -*- coding: utf-8 -*-

from gi.repository import Gtk

class SandCtrl(object):

    def __init__(self, m, v):
        #Controller.__init__(self, model, view)
        self.builder = v.builder

    def register_view(self):
        # setup of widgets
        sigs = {'on_sandwindow_destroy': self.on_sandwindow_destroy,

    def register_adapters(self):
        # setup of adapters

    # ---------------------------------------------------------------
    #        Signal handlers
    # ---------------------------------------------------------------
    def on_sandwindow_delete_event(self, win, event):
        Gtk.main_quit()  # say goodbye
        return True

    # ---------------------------------------------------------------
    #        Notifications from observable properties
    # ---------------------------------------------------------------

    # For value-change notifications
#     @Controller.observe("<property_name_here>", assign=True)
#     def value_change(self, model, prop_name, info):
#         # info contains 'new' and 'old' values
#         return

    # For value-change of containers like lists, maps, or method calls for
    # observable class instances.
    # There exist 'before' and 'after' versions, you can use both or only one,
    # depending on your need.
#     @Controller.observe("<property_name_here>", before=True, after=True)
#     def method_call(self, model, prop_name, info):
#         # Info contains:
#         # 'instance' is the object that is being changed
            # (the list for example)
#         # 'method_name' is the name of the method that is used to change it
            # ('append' for example)
#         # 'args' is the list of arguments of the invoked method 'name'
#         # 'kwargs' is the keywords map of the invoked method 'name'
#         # 'result' (only for 'after' notifications)
            # the value returned by the method after the call
#         return

    #@Controller.observe("somevalue", assign=True)
    def somevalue_change(self, model, prop_name, info):

    pass  # end of class SandCtrl
# -*- coding: utf-8 -*-

import utils.globals

from gi.repository import Gtk
import os.path

class SandView (object):
    #glade = os.path.join(utils.globals.GLADE_DIR, "")
    top = "window_appl"

    def __init__(self):
        self.gladefile = os.path.join(utils.globals.GLADE_DIR, "")
        self.builder = Gtk.Builder()
        self.sandwindow = self.builder.get_object("sandwindow")
        #sigs = {'on_sandwindow_destroy': self.on_sandwindow_destroy,

        # construction of manual widgets and other settings

    def on_sandwindow_destroy(self, event):
        Gtk.main_quit()  # say goodbye
        return True

    pass  # end of class SandView

Edited to replace the file attachment with a corrected attachment.

Attachments: [24.31 KiB]
Not downloaded yet
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 3 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group