這項目的緣起只是因為早上忽然發現家中的方格紙沒了,外頭又再下大雨,閒閒沒事想說自己來尻一下順便練習 python 手感
- 熟悉 Reportlab 的繪圖與 PDF 檔案匯出操作
- 熟悉物件導向,力求主程式簡單
- 熟悉項目資料夾架構
- 範例
- Python
- Sublime
- Git
- Tower (Mac only)
- 家裡有印表機
- 有支持世大運
- 按這篇文章讚
- 物件導向概念
- 基本 list 概念與操作方法
- package 安裝方法
- 一點點程式邏輯拆解怎麼用一個 function 畫出主/副線框
- Open the GitHub repository
- Fork it
- Clone it and create a copy on your computer
- Modify the settings.py file
- Run the main.py
- Check the tutorial of reportlab package first, get to know how to create a canvas, put something on it and export it to the pdf file
- Check how does the grid function works
- Start to build the basic main python file: create a canvas > generate the grid > export
- Use list .append() and while loop function to create the xlist/ylist (pls check out myfunc.py/xylist)
- Because u would like to add a major grid in the end, so pls make sure the total numbers of both columns and rows u create can be divided by 5, the hint is trying to use the for loop inside the while loop
- Write a boolean variable into your fun, so that both major/minor grids can call it
- Use xylist to draw a grid
- Now u might find out the whole grid doesn't locate at the middle
- Create the align() function to compute the right starting point, then pass the value to xylist[0]
- Everything just done, but try to do more! Separate all the setting and canvas Spec from main.py
class Settings():
def __init__(self):
self.filename="MyGraphPaper" #no need to assign a file extention
self.size=A4 #check the default setting below
self.xgap=0.5 #in cm
self.ygap=.5 #in cm
self.footer="Copyright © 2017 Dan Project"
#Minor line setting:
self.colorMinor=pink #check the default setting below
self.lineWidthMinor=1
#Major line setting: if u dont want the major grid, set the majorLine=False
self.majorLine=True
self.colorMajor=pink #check the default setting below
self.lineWidthMajor=2<div>
<html lang="zh-Hant-CN">
</div>
https://www.google.com.tw/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=0ahUKEwjI3M6wlPfVAhXNq5QKHbHiAfQQFggxMAE&url=https%3A%2F%2Fwww.reportlab.com%2Fdocs%2Freportlab-userguide.pdf&usg=AFQjCNGZMKURmDlJw9uZ_mAIXO5tlMI81g https://jeffknupp.com/blog/2014/06/18/improve-your-python-python-classes-and-object-oriented-programming/ https://python.swaroopch.com/oop.html http://www.python-course.eu/object_oriented_programming.php