python手记(22)
来源:互联网 发布:角度尺软件 编辑:程序博客网 时间:2024/05/27 20:52
Traits UI快速设计
# Copyright (c) 2007, Enthought, Inc.# License: BSD Style.# wizard.pyfrom traits.api import HasTraits, Int, Strclass Employee(HasTraits): name = Str department = Str salary = Int bonus = IntEmployee().configure_traits()
Traits UI 下载地址:
https://pypi.python.org/pypi/traitsui/
自动检验
HasTraits的派生类用Trait属性保存数据,它相当于MVC模式中的模型(Model)。当没有指定界面显示方式时,Traits库会自动创建一个缺省的界面。我们可以通过视图(View)对象为模型设计更加实用的界面。
# -*- coding: utf-8 -*-# Copyright (c) 2007, Enthought, Inc.# License: BSD Style.from traits.api import HasTraits, Int, Strfrom traitsui.api import View, Itemclass Employee(HasTraits): name = Str department = Str age = Int classes = Int view = View( Item('department', label=u"年级", tooltip=u"班级所属年级"), Item('name', label=u"姓名"), Item('age', label=u"年龄"), Item('classes', label=u"班级"), title = u"学生资料", width=250, height=150, resizable=True )if __name__ == "__main__": p = Employee() p.configure_traits()
- python手记(22)
- Python 手记
- python手记
- python socket 编程手记
- Python重载学习手记
- python手记(1)
- python手记(2)
- python手记(3)
- python手记(4)
- python手记(5)
- python手记(6)
- python手记(7)
- python手记(8)
- python手记(9)
- python手记(10)
- python手记(11)
- python手记(12)
- python手记(14)
- Eclipse代码编辑区,着色插件(Eclipse Color Theme)的安装
- iOS: NSDictionary的方法initWithObjectsAndKeys:
- 02. SQL表达式的灵活使用
- Linux常用小知识
- POJ 1753 Robot Motion
- python手记(22)
- PHP学习笔记
- 就是喜欢这张配图,没什么好解释的。。。
- iOS: NSDictionary的方法isEqualToDictionary:
- rose画用例图折线变直线
- iOS: NSDictionary的方法keyEnumerator
- ASP学习
- HDU 3008 Warcraft (DP 背包)
- Grails构建基于RBAC的权限管理平台(一)