pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

Python pastebin - collaborative debugging tool View Help


Posted by mlk on Sun 28 Sep 15:36
report abuse | download | new post

  1. from peak.events.trellis import *
  2.  
  3. class Counter(Component):
  4.     value = attr(0)
  5.  
  6.     @perform
  7.     def show(self):
  8.         print 'VALUE:', self.value
  9.  
  10. class UIModel(Component):
  11.     counter = attr()
  12.     clicked = attr(resetting_to=False)
  13.  
  14.     @maintain
  15.     def inc(self):
  16.         if self.clicked:
  17.             self.counter.value += 1
  18.  
  19.  
  20. ######################################################
  21. ######################################################
  22.  
  23. class Controller(Component):
  24.     ui = attr()
  25.     title = attr()
  26.  
  27.     def __init__(self, **kw):
  28.         Component.__init__(self, **kw)
  29.         import wx
  30.         self.app = wx.PySimpleApp()
  31.         self.frame = wx.Frame(None)
  32.         self.button = wx.Button(self.frame, label="Increase")
  33.         self.button.Bind(wx.EVT_BUTTON, self.on_click)
  34.         self.frame.Show()
  35.  
  36.     def run(self):
  37.         self.app.MainLoop()
  38.  
  39.     def on_click(self, evt):
  40.         self.ui.clicked = True
  41.  
  42.     @perform
  43.     def set_title(self):
  44.         self.frame.Title = unicode(self.title)
  45.  
  46. ######################################################
  47. ######################################################
  48.  
  49. c = Counter()
  50. ui = UIModel(counter=c)
  51. ctrl = Controller(ui=ui, title=c.__cells__['value'])
  52. 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.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post