在Python使用 pdfschedule 的可视化时间表
日程安排是生活的重要组成部分,拥有时间表有助于建立日常工作。无聊的时间表或例行公事通常无济于事。有一个华丽的和视觉上吸引人的时间表会吸引并促使我们去关注和关注。本文介绍了一种为一周中的每一天生成 pdf 格式的简单方法,并使用Python跟踪。
pdfschedule:该模块能够为每周的活动时间表创建 PDF 格式的时间表,并支持使用命令行操作的自定义样式和颜色。
安装
这个模块没有内置于Python。要安装它,请在终端中键入以下命令。
python3 -m pip install pdfschedule
入门
安装完成后,在命令行运行以下命令:
pdfschedule [] [ []]
范围:
- infile :标准输入文件(yaml 格式)。
- outfile : pdf 格式的输出文件,与输入文件同名。 <输入文件>.pdf。
- OPTIONS :可以传递的样式参数。
选项 :
- -C, –color : Event boxes colors, Standard hex codes to be used.
- -F , –font : Any builtin font or path to .ttf file. Defaults to Helvetica.
- -f
, –font-size Event name font size. Sets name of week to: * 1.2 and name of times to / 1.2. Defaults to 10. - -M, –start-monday : Typing this will render start of week to Monday, otherwise, its Sunday.
- -p, –portrait : Sets the output table to portrait mode, which by default is landscape mode.
- -s
, –scale : Shorted the sides of tables by “/factor” . Otherwise, the table takes whole page, baring margins - -T, –no-times : Ignores time not in use.
- –no-weekends : Removed weekends, Sunday and Saturday from table.
输入文件
Yaml:所需的 Yaml 是一个字典列表,其中每个字典代表一个时间表中的每个插槽,以及它的显示描述。
Yaml 中的输入参数 [对于每个计划]
- 名称:框中事件的名称。可选的。
- days:重复上述计划的天数。每个工作日的首字母大写和第一个两个/三个首字母都有效。单字母工作日表示在星期一、星期二、星期三、星期五的情况下有效。
- time:计划时间,“HH:MM – HH:MM” 24 小时格式。分钟 可选。
- color:日程表的背景颜色(以十六进制提供),默认为灰色。
例子:
输入文件:[gfg_tt.yml]
- name: Morning Walk
days: MWF
time: 7-9
color: "0000FF"
- name: Ofc Hours
days: MTWThF
time: 10-19
- name: Exercise
days: M, W, F
time: 19:30 - 20:30
color: "29EE65"
- name: Play Cricket
days: Tu, Th, Sat
time: 19:30 - 20:30
color: "FF94EF"
- name: Surf GFG
days: F, W, M
time: 22-23.59
color: "000000"
- name: Sleep Time
days: MTWThFSatSun
time: 0-7
color: "00FF00"
之后,在命令行上运行此命令:
pdfschedule gfg_tt
输出 :