Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 789a4dca4953f037223e830336ef4af3 > files > 1104

python-enthought-enable-3.2.0-2mdv2010.0.i586.rpm

from copy import copy
import os.path

from enthought.savage.traits.ui.wx.svg_button import SVGButton
from enthought.traits.api import HasTraits, Instance, Str, Int
from enthought.traits.ui.api import Item, View, HGroup

button_size = (64, 64)

class ButtonDemo(HasTraits):
    
    copy_button = SVGButton(label='Copy', 
                            filename=os.path.join(os.path.dirname(__file__), 
                                                  'edit-copy.svg'), 
                            width=button_size[0], 
                            height=button_size[1])
    paste_button = SVGButton(label='Paste', 
                             filename=os.path.join(os.path.dirname(__file__), 
                                                   'edit-paste.svg'), 
                             width=button_size[0], 
                             height=button_size[1])
    text = Str
    clipboard = Str
    
    traits_view = View(HGroup(Item('copy_button', show_label=False),
                              Item('paste_button', show_label=False)),
                       Item('text', width=200),
                       title='SVG Button Demo')
                       
    def _copy_button_fired(self, event):
        self.clipboard = copy(self.text)
        
    def _paste_button_fired(self, event):
        self.text += self.clipboard

                                    
if __name__ == "__main__":
    example = ButtonDemo()
    example.configure_traits()