Python图形用户界面入门

说明:本文主要参考traitsUI教程:http://docs.enthought.com/traitsui/tutorials/traits_ui_scientific_app.html#getting-threads-and-the-gui-event-loop-to-play-nice

前期准备

  • pip install traits 安装traits包
  • pip install traitsui 安装traitsUI包
  • pip install python-qt5 安装PyQt5
  • pip install wxPython 安装wxPython

一个最简单的GUI例子

from traits.api import HasTraits, Str, Range, Enum
from traitsui.api import Item, RangeEditor, View

class Person(HasTraits):
    name = Str('Jane Doe')
    age = Range(low=0, high=200)
    gender = Enum('female', 'male')

person_view = View(
    Item('name'),
    Item('gender'),
    Item('age', editor=RangeEditor(mode='spinner')),
    buttons=['OK', 'Cancel'],
    resizable=True,
)

person = Person()
person.age = 30
person.configure_traits(view=person_view)

带图像的交互式GUI

猜你喜欢

转载自blog.csdn.net/cherry593/article/details/84313555