印刷箱的小包装

boxprint的Python项目详细描述


箱印

印刷盒子的小包装

使用

fromboxprintimportbprintbprint("hello world")
^{pr2}$

示例

简单用法

fromboxprintimportbprint,BoxTypesfromcolorsimport*# ansicolors"""@param width  Max width of the box@param box_type  The type of the box (LIGHT, HEAVY, DOUBLE, ROUND)@param print_func  The print function to use@param stroke_func  How the box characters should be stroked@param fill_func  How the text characters should be filled"""bprint("hello_world",width=40,box_type=BoxTypes.HEAVY,print_func=print)bprint("Text\nWith\nMultiple\nLines")bprint("\nhello_world\n",width=40,box_type=BoxTypes.FILL,stroke_func=lambdatext:color(text,fg="blue"),fill_func=lambdatext:color(text,bg="blue",fg="black"))buf=[]defprint_to_buf(string):buf.append(string)# Boxes apply 2 spaces of padding to the left and right width = (default=80 - 2*2)bprint("Inner Box",width=76,print_func=print_to_buf)inner_box="".join(buf)bprint(f"I am some text!\n{inner_box}",title="Outer Box")
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Hello World                          ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

╭──────────────────────────────────────────────────────────────────────────────╮
│ Text                                                                         │
│ With                                                                         │
│ Multiple                                                                     │
│ Lines                                                                        │
╰──────────────────────────────────────────────────────────────────────────────╯

▗▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▖
▐                                      ▌
▐ hello_world                          ▌
▐                                      ▌
▝▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▘

╭─┤ Outer Box ├────────────────────────────────────────────────────────────────╮
│                                                                              │
│ I am some text!                                                              │
│ ╭──────────────────────────────────────────────────────────────────────────╮ │
│ │ Inner Box                                                                │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────╯

Debug

fromboxprintimportdprinta_list_of_numbers=[1,2,3,4,5]dprint(a_list_of_numbers)a_list_of_numbers=Nonedprint(a_list_of_numbers)
╭─┤ a_list_of_numbers ├────────────────────────────────────────────────────────╮
│                                                                              │
│ tests/test_debug.py:11                                                       │
│                                                                              │
│ type = <class 'list'>                                                        │
│ value = [1, 2, 3, 4, 5]                                                      │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─┤ a_list_of_numbers ├────────────────────────────────────────────────────────╮
│                                                                              │
│ tests/test_debug.py:14                                                       │
│                                                                              │
│ type = <class 'NoneType'>                                                    │
│ value = None                                                                 │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯

当前堆栈

fromboxprintimportstprintdefmy_function(param1,param2):local1=[param1]*4local2="a"stprint(width=60)foriinrange(5):my_function(i,i*3)
╭─┤ my_function - tests/test_stprint.py:35 ├───────────────╮
│                                                          │
│   param1 = 0                                             │
│   param2 = 0                                             │
│   local1 = [0, 0, 0, 0]                                  │
│   local2 = a                                             │
│                                                          │
╰──────────────────────────────────────────────────────────╯
╭─┤ my_function - tests/test_stprint.py:35 ├───────────────╮
│                                                          │
│   param1 = 1                                             │
│   param2 = 3                                             │
│   local1 = [1, 1, 1, 1]                                  │
│   local2 = a                                             │
│                                                          │
╰──────────────────────────────────────────────────────────╯

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

推荐PyPI第三方库


热门话题
如何在java swing表单配置文件中显示动态布局   swing Java使用GridLayout和鼠标交互式JPanel创建JFrame   java使用jsp dao和servlet从数据库中的4行中只插入几行   java SqlLite:我们可以选择行作为列吗?   启动glassfish服务器时java获取错误   PersistenceUnit的java部署[…]失败。关闭此PersistenceUnit的所有工厂   java将具有多个关系的实体与集合中的任何元素进行匹配   java对命名模式的建议,该模式在op失败时尝试强制转换返回null   使用jtwitter的java安卓抛出错误   使用Java方法查找数组中最小int的位置   SwingJava。网络气球提示没有出现   java无法使用JavaMail api发送邮件   java HashSet contains()为自定义对象返回false。hashCode()和equals()似乎实现正确   Java:在运行时和编译时向类中添加字段?   java正在服务类中导入jersey和JAXR,这被认为是错误的做法