python实现tui_Python tuir包_程序模块 - PyPI - Python中文网

reddit终端用户界面(tuir)

一个基于文本的界面(tui),用于从终端查看reddit并与之交互。

tuir是rtv的分支,由michael lazar在this respository中维护到2019年6月3日。

目录

演示

安装

PYPI包

TUIR在PyPI上可用,可以与pip一起安装:$ pip install tuir

从rtv迁移

如果要从rtv迁移到tuir,只需重命名旧的配置目录/config文件即可:$ mv ~/.config/rtv ~/.config/tuir

$ mv ~/.config/tuir/rtv.cfg ~/.config/tuir/tuir.cfg

请注意使用imgur和reddit的新api密钥。替换为sed:$ sed -i 's/E2oEtRQfdfAfNQ/zjyhNI7tK8ivzQ/; s/93396265f59dec9/b33d69ac8931734/' ~/.config/tuir/tuir.cfg

本地软件包

请参阅Repology以获取受支持的发行版包的最新列表。

来源$ git clone https://gitlab.com/ajak/tuir.git

$ cd tuir

$ python setup.py install

窗口

由于缺乏资源和兴趣,Windows不支持TUIR对不起的!

用法

要运行程序,请键入:$ tuir --help

对照组

使用箭头键或vim样式移动来移动光标:按>>和]滚动提交内容

按查看所选提交,按返回

按空格键展开/折叠注释

按u登录(这需要一个用于OAuth的Web浏览器)

按?打开帮助屏幕

按/打开导航提示,您可以在其中键入如下内容:/front

/r/commandprompt+linuxmasterrace

/r/programming/controversial

/u/me

/u/multi-mod/m/art

/domain/github.com

有关命令的完整列表,请参见CONTROLS

设置

配置文件

配置文件存储在{HOME}/.config/tuir/目录中

查看tuir.cfg以获取可配置选项的完整列表。您可以通过运行:$ tuir --copy-config

查看媒体链接

您可以使用mailcap来配置tuir如何打开不同类型的链接。

mailcap文件允许您将不同的mime媒体类型(如image/jpeg或video/mp4)与shell命令相关联。此功能在默认情况下被禁用,因为它需要一些额外的步骤来配置。要开始,请将默认的mailcap模板复制到主目录。$ tuir --copy-mailcap

此模板包含与流行的reddit网站(如imgur、youtube和gfycat一起工作的常见mime类型的示例。打开mailcap模板并按照里面列出的instructions操作。

设置完mailcap文件后,使用tuir --enable-media标志启动tuir(或在tuir.cfg中设置)

环境变量

tuir与之交互的默认程序可以通过环境变量进行配置:$TUIR_EDITORA program used to compose text submissions and comments, e.g. vim, emacs, gedit

If not specified, will fallback to $VISUAL and $EDITOR in that order.

$TUIR_BROWSERA program used to open links to external websites, e.g. firefox, google-chrome, w3m, lynx

If not specified, will fallback to $BROWSER, or your system's default browser.

$TUIR_URLVIEWERA tool used to extract hyperlinks from blocks of text, e.g. urlview, urlscan

If not specified, will fallback to urlview if it is installed.

剪贴板

tuir支持将提交链接复制到os剪贴板。在macos上,这是现成的支持。

在Linux系统上,您需要安装xsel或xclip。

主题

主题可以用来定制TUIR的外观和感觉Solarized Dark

Solarized Light

Papercolor

Molokai

您可以使用--list-themes命令列出所有已安装的主题,并使用--theme选择一个主题。您可以将您的选择永久保存在tuir.cfg文件中。您还可以使用tuir内的f2&kbd>f3键循环浏览所有可用的主题。

有关编写和安装自己的主题的说明,请参见THEMES.md。

常见问题解答为什么在安装/启动tuir时出现错误?摘要>If your distro ships with an older version of python 2.7 or python-requests,

you may experience SSL errors or other package incompatibilities. The

easiest way to fix this is to install tuir using python 3. If you

don't already have pip3, see http://stackoverflow.com/a/6587528 for setup

instructions. Then do$ sudo pip uninstall tuir

$ sudo pip3 install -U tuir详细信息>为什么我看到像m-b~@m-“或^@这样的混乱文本?摘要>This type of text usually shows up when python is unable to render

unicode properly.Try starting TUIR in ascii-only mode with tuir --ascii

Make sure that the terminal/font that you're using supports unicode

Your python may have been built against the wrong curses library,

see here and

here for more information详细信息>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
tui-image-editor 是一个基于 JavaScript 和 HTML5 Canvas 的开源图像编辑器,可以实现图像裁剪、旋转、缩放、滤镜、涂鸦等功能。 下面是一个使用 tui-image-editor 实现画图的示例代码: 1. 安装 tui-image-editor 可以使用 npm 或 yarn 安装 tui-image-editor: ```bash npm install tui-image-editor --save # 或者 yarn add tui-image-editor ``` 2. 在组件中引入 tui-image-editor 可以通过 CDN 或模块化方式引入 tui-image-editor: ```html <template> <div ref="editor"></div> </template> <script> import ImageEditor from 'tui-image-editor'; export default { name: 'DrawImage', mounted() { const editor = new ImageEditor(this.$refs.editor, { includeUI: { loadImage: { path: 'https://img-cdn-qiniu.dcloud.net.cn/images/paint.jpg', name: 'SampleImage', }, theme: { // 主题配置 }, menu: ['shape', 'filter'], initMenu: 'filter', uiSize: { // UI 大小配置 }, }, cssMaxWidth: 700, cssMaxHeight: 500, selectionStyle: { cornerSize: 20, rotatingPointOffset: 70, }, }); }, } </script> ``` 在上面的代码中,我们在组件的 template 中添加了一个 div 元素,并使用 ref 属性获取其引用。 在 mounted 钩子函数中,我们通过 new ImageEditor() 创建了一个新的 tui-image-editor 实例,并将其绑定到组件的 $refs.editor 属性上。 通过 includeUI 属性可以配置 tui-image-editor 的 UI 界面,括加载图片、主题、菜单、UI 大小等。 3. 在组件中使用 tui-image-editor 的 API 可以通过 tui-image-editor 实例的 API 来实现各种画图功能。例如,我们可以在组件中添加一个按钮,点击按钮后在图像上绘制一条线段。 ```html <template> <div> <div ref="editor"></div> <button @click="drawLine">绘制线段</button> </div> </template> <script> import ImageEditor from 'tui-image-editor'; export default { name: 'DrawImage', mounted() { this.editor = new ImageEditor(this.$refs.editor, { includeUI: { loadImage: { path: 'https://img-cdn-qiniu.dcloud.net.cn/images/paint.jpg', name: 'SampleImage', }, theme: { // 主题配置 }, menu: ['shape', 'filter'], initMenu: 'filter', uiSize: { // UI 大小配置 }, }, cssMaxWidth: 700, cssMaxHeight: 500, selectionStyle: { cornerSize: 20, rotatingPointOffset: 70, }, }); }, methods: { drawLine() { const activeObj = this.editor._graphics.getActiveObject(); const points = [ { x: activeObj.left + 50, y: activeObj.top + 50 }, { x: activeObj.left + 100, y: activeObj.top + 100 }, ]; const line = new fabric.Line(points, { strokeWidth: 5, fill: 'red', stroke: 'red', originX: 'left', originY: 'top', }); this.editor._graphics.add(line); this.editor._graphics.renderAll(); this.editor._graphics.setActiveObject(line); }, }, } </script> ``` 在上面的代码中,我们使用了 tui-image-editor 实例的 _graphics 属性来获取当前图像的画布对象,并使用 fabric.js 中的 Line 类来创建一条线段。然后将线段添加到画布对象中,并调用 renderAll() 方法重新渲染画布。 最后,我们使用 setActiveObject() 方法将新创建的线段设为当前选中对象。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值