mlk
By: a guest | Sep 28th, 2008 | Syntax:
Python | Size: 1.24 KB | Hits: 276 | Expires: Never
from peak.events.trellis import *
class Counter(Component):
value = attr(0)
@perform
def show(self):
print 'VALUE:', self.value
class UIModel(Component):
counter = attr()
clicked = attr(resetting_to=False)
@maintain
def inc(self):
if self.clicked:
self.counter.value += 1
######################################################
######################################################
class Controller(Component):
ui = attr()
title = attr()
def __init__(self, **kw):
Component.__init__(self, **kw)
import wx
self.app = wx.PySimpleApp()
self.frame = wx.Frame(None)
self.button = wx.Button(self.frame, label="Increase")
self.button.Bind(wx.EVT_BUTTON, self.on_click)
self.frame.Show()
def run(self):
self.app.MainLoop()
def on_click(self, evt):
self.ui.clicked = True
@perform
def set_title(self):
self.frame.Title = unicode(self.title)
######################################################
######################################################
c = Counter()
ui = UIModel(counter=c)
ctrl = Controller(ui=ui, title=c.__cells__['value'])
ctrl.run()