简化的咒语

cursed的Python项目详细描述


诅咒!:

 ______     __  __     ______     ______     ______     _____
/\  ___\   /\ \/\ \   /\  == \   /\  ___\   /\  ___\   /\  __-.
\ \ \____  \ \ \_\ \  \ \  __<   \ \___  \  \ \  __\   \ \ \/\ \
 \ \_____\  \ \_____\  \ \_\ \_\  \/\_____\  \ \_____\  \ \____-
  \/_____/   \/_____/   \/_/ /_/   \/_____/   \/_____/   \/____/

简化的诅咒界面与并发,为快速和理智的诅咒应用程序。

允许轻松创建窗口和菜单。每个窗口的代码同时运行。

请参阅此处提供的完整文档:http://pythonhosted.org/cursed/

cursed是用python 3.4和2.7进行测试的,其兼容性取决于python包6。

安装

使用PIP,对于最新的稳定版:

$ pip install cursed

或者从项目根目录:

$ python setup.py install

用法

示例:

from cursed import CursedApp, CursedWindow

# the main context of the curses application
app = CursedApp()

# Derive from CursedWindow to declare curses windows to be created after app.run()
# It is required to declare X, Y, WIDTH, and HEIGHT for each window.
# You'll want to put the main looping code for each window thread in the `update` class function.

class MainWindow(CursedWindow):

    # Coordinate for top-left of window.
    X, Y = (0, 0)

    # WIDTH and HEIGHT can be 'max' or integers.
    WIDTH, HEIGHT = ('max', 'max')

    # Create a default border around the window.
    BORDERED = True

    @classmethod
    def update(cls):
        ''' update runs every tick '''

        # Hello world printed at x,y of 0,0
        cls.addstr('Hello, world!', 0, 0)

        # Get character keycode of keypress, or None.
        if cls.getch() == 27:
            # Escape was pressed. Quit.
            # 'quit' must be triggered for each open window for the program to quit.
            # Call cls.trigger('quit') to quit the window you're in, and to quit the other
            # declared windows, call OtherWindow.trigger('quit') which will run in that
            # window's thread, regardless of where it's called.
            cls.trigger('quit')

# To trigger app to start
result = app.run()

# check if ctrl-C was pressed
if result.interrupted():
    print('Quit!')
else:
    # Raises an exception if any thread ran into a different exception.
    result.unwrap()

在存储库的根目录examples/

发行说明

0.2.0:
  • exposed gevent.sleep through a classmethod ^{tt1}$. This allows users to fix issues with long running update functions causing other windows to not respond.
  • Added a CursedWindow PAD, like the curses pad. This can have a huge width and height greater than the terminal width, but allow you to scroll around it. Useful for windows which need only display a smaller rectange of a larger window, like a map that scrolls around with arrow keys.
0.1.9:
  • fixed the ^{tt2}$ and ^{tt3}$ classmethods, since they called _fix_xy twice
  • added info to menu example to explain ^{tt4}$ in update will overwrite menu display
0.1.8:
  • added tons of documentation and examples
0.1.7:
  • Better CursedMenu API
0.1.6:
  • WIDTH or HEIGHT specified as ‘max’ will stretch to the full width or height of the terminal
0.1.5:
  • patched issue with returning bytes in getstr
0.1.4:
  • Implemented getstr
0.1.3:
  • Fixed menu to fill up right side with whitespace
0.1.2:
  • fixed menus stealing keypresses
0.1.1:
  • left and right open menus to sides
  • refactored menus
0.1.0:
  • implemented menus!
0.0.2:
0.0.1:
  • Project created

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java将特定于语言环境的字符串转换为BigDecimal的最佳方法   java生成的数字在下降的水平上增加   java如何验证列表中的元素是否按字母顺序排序   java无法使用Jintellitype包com。梅洛器皿   java Hibernate显示来自JComboBox的记录   java更改模拟器屏幕分辨率?   java如何从可移动/辅助SD卡中删除文件   java检查在MySQL中插入时数据库中是否存在给定的用户名   java如何替换线程。无限循环中的sleep()?   java如何从数据库中获取一列的字符串数据作为数组数据   将内容存储在缓冲区中的java   java ControllerAdvice不处理引发的异常   Java Maven问题   java NullPointerException试图从方法返回2D对象数组时   这个简单的Java代码有什么问题?   java如何删除或访问pom文件中插件的构建时间戳   java销售收据,多选(if/else),while循环,客户更改选择的能力   Java:基于字符串的加载类方法   java OrientDB服务器部分忽略OrientDB_HOME