Source

gtkarchitect-main / gtkarchitect / gtkentities / __init__.py

Full commit

"""
Entity definitions for the GTK Entities
"""

import gtk

from ..model.definitions import EntityDefinition, entity_catalog
from ..view.gadget import Gadget, ContainerGadget
from ..view.placeholder import Placeholder


class ButtonGadget(Gadget):

    def create_ui(self):
        t = self.get_toplevel()
        self.widget = gtk.Button()
        t.add(self.widget)


class WindowGadget(ContainerGadget):

    def create_ui(self):
        t = self.get_toplevel()
        self.widget = gtk.Frame()
        t.add(self.widget)


class FrameGadget(ContainerGadget):

    def create_ui(self):
        t = self.get_toplevel()
        self.widget = gtk.Frame('hello')
        t.add(self.widget)


entity_catalog.register_entity_def(
    'GTK Widgets', EntityDefinition('GtkButton', gadget_type=ButtonGadget)
)
entity_catalog.register_entity_def(
    'GTK Widgets', EntityDefinition('GtkWindow', gadget_type=WindowGadget,
                                    is_toplevel=True)
)

entity_catalog.register_entity_def(
    'GTK Widgets', EntityDefinition('GtkFrame', gadget_type=FrameGadget)
)