Posted by mlk on Sun 28 Sep 15:36
report abuse | download | new post
- 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()
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.