日程处理
目标是输入个文本文件关于日程的,就能够到时间的时候显示出来,在ubuntu系统上运行。
包括以下几点:
1.了解Tkinter。
1.1 参考文献自己制作Python IDEL
1.1.1 制作最简单的文本框和输出。
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import Tkinter as tk
#导入Tkinter模块
#创建一个类
class Application(tk.Frame):
#__init__初始化函数,包含了pack即填充方式。
def __init__(self, master=None):
tk.Frame.__init__(self, master)
self.pack()
#调用createWidgets()方法
self.createWidgets()
def createWidgets(self):
#定义部件1 hi_there模块,设置为button
self.hi_there = tk.Button(self)
self.hi_there["text"] = "Hello World\n(click me)"
self.hi_there["command"] = self.say_hi
self.hi_there.pack(side="top")
#定义部件2 QUIT模块,设置为button
self.QUIT = tk.Button(self, text="QUIT", fg="red",
command=root.destroy)
self.QUIT.pack(side="bottom")
def say_hi(self):
print("hi there, everyone!")
#获取tk实例
root = tk.Tk()
#构造类
app = Application(master=root)
#开始实例化
app.mainloop()
1.1.2 上面的pack是定义填充方式,widget.pack( pack_options ),其中
expand: 当设置为true,部件扩展填充,否则不能使用任何部件的母空间.
fill: 确定是否部件填补分配任何额外的空间,或保持其自己的最小尺寸:无(默认)和X(只填写水平)Y(只填写垂直),或两者兼而有之(填充横向和纵向).
side: 决定哪方父widget包对TOP(默认),下,左,或右.
1.1.3 注意在python2.7中lambda表达式不能直接使用print函数,需要先自定义一个函数然后调用
1.1.4 引入tkFiledialog的时候可以参考文献tkFiledialog引入
from tkFileDialog import *
2.功能模块
2.1 读写CSV文件。
参考CS