How would you design a very “Pythonic” UI framework?

后端 未结 15 2115
日久生厌
日久生厌 2021-02-02 01:29

I have been playing with the Ruby library \"shoes\". Basically you can write a GUI application in the following way:

Shoes.app do
  t = para \"Not clicked!\"
  b         


        
15条回答
  •  没有蜡笔的小新
    2021-02-02 01:52

    Personally, I would try to implement JQuery like API in a GUI framework.

    class MyWindow(Window):
        contents = (
            para('Hello World!'),
            button('Click Me', id='ok'),
            para('Epilog'),
        )
    
        def __init__(self):
            self['#ok'].click(self.message)
            self['para'].hover(self.blend_in, self.blend_out)
    
        def message(self):
            print 'You clicked!'
    
        def blend_in(self, object):
            object.background = '#333333'
    
        def blend_out(self, object):
            object.background = 'WindowBackground'
    

提交回复
热议问题