示例#1
0
#!/usr/bin/env python
import gtk

from kiwi.model import PickledModel
from kiwi.ui.views import BaseView
from kiwi.ui.gadgets import quit_if_last

# define the class that holds our application data
class Person(PickledModel):
    name = ""
    address = ""
    phone = ""


person = Person.unpickle()  # load person instance

view = BaseView(delete_handler=quit_if_last, widgets=("name", "address", "phone"), gladefile="person")

# create and run a proxy interface attached to person
view.add_proxy(person, ("name", "address", "phone"))
view.focus_topmost()
view.show_all()

# Enter main lopp, where GTK will handle events
gtk.main()

# save changes done to theinstance
person.save()
示例#2
0

# define the class that holds our application data
class Person(Model):
    name = ""
    address = ""
    phone = ""


person = Person()

view1 = BaseView(delete_handler=quit_if_last,
                 widgets=("name", "address", "phone"),
                 gladefile="person")

# create and run a proxy interface attached to person
view1.add_proxy(person, ("name", "address", "phone"))
view1.focus_topmost()
view1.show_all()

view2 = BaseView(delete_handler=quit_if_last,
                 widgets=("name", "address", "phone"),
                 gladefile="person")

# create and run a proxy interface attached to person
view2.add_proxy(person, ("name", "address", "phone"))
view2.focus_topmost()
view2.show_all()

gtk.main()
示例#3
0
    name = StringCol(default=None)
    address = StringCol(default=None)
    phone = StringCol(default=None)


try:
    # create table if it doesn't exist
    Person.createTable()
except:
    # table already exists
    pass

try:
    # Get the first record
    person = Person.get(1)
except SQLObjectNotFound:
    # Create a new, Empty, record
    person = Person()

view = BaseView(delete_handler=quit_if_last,
                widgets=("name", "address", "phone"),
                gladefile="person")

# create and run a proxy interface attached to person
view.add_proxy(person, ("name", "address", "phone"))
view.focus_topmost()
view.show_all()

# Enter main lopp, where GTK will handle events
gtk.main()
from kiwi.ui.views import BaseView, SlaveView
from kiwi.ui.objectlist import Column
from kiwi.ui.gadgets import quit_if_last

# Main window
addressbook = BaseView(gladefile="addressbook",
                       widgets=("add", "del"),
                       delete_handler=quit_if_last)

## Slave Components:
# Entry editor GUI component
entry_editor = SlaveView(toplevel=addressbook,
                         widgets=("name", "address", "phone"),
                         gladefile="entry_editor")
# Entries list GUI component
list_entries = SlaveView(toplevel=addressbook,
                         widgets=("table",),
                         gladefile="list_entries")

list_entries.table.set_columns([Column("name", title="Name"),
                                Column("address", title="Address"),
                                Column("phone", title="Phone")])

## Attach slaves to main window
addressbook.attach_slave("entry_editor", entry_editor)
addressbook.attach_slave("list", list_entries)

addressbook.show_all()
addressbook.focus_topmost()
gtk.main()
示例#5
0
from kiwi.ui.gadgets import quit_if_last

# define the class that holds our application data
class Person(Model):
    name = ""
    address = ""
    phone = ""


person = Person()

view1 = BaseView(delete_handler=quit_if_last,
                 widgets=("name", "address", "phone"),
                 gladefile="person")

# create and run a proxy interface attached to person
view1.add_proxy(person, ("name", "address", "phone"))
view1.focus_topmost()
view1.show_all()

view2 = BaseView(delete_handler=quit_if_last,
                 widgets=("name", "address", "phone"),
                 gladefile="person")

# create and run a proxy interface attached to person
view2.add_proxy(person, ("name", "address", "phone"))
view2.focus_topmost()
view2.show_all()

gtk.main()