太久没写python了,感觉手有点生,用到的知识点
#如何引入module
import Tkinter
#创建window
root = Tkinter.Tk(className="阿平打点软件 V1")
#在xy轴200-200的位置创建400*220的窗口
root.geometry("400x220+200+200")
#执行system command
import os
os.system('ping www.pythontab.com') // 返回值是结果
#LINUX获取日期时间的命令 date
#echo $(date)
# >> 重定向
$python 判断操作系统类型代码
import platform
# "Windows" "Linux"
platform.system()
由于内容比较少,所以code的比较随便哈哈:)
#encoding:utf-8
# author: richard
import platform
import os
from Tkinter import *
inLog = 'C:/inlog.txt'
outLog = 'C:/outlog.txt'
systemString = platform.system()
class App:
def __init__(self, master):
frame = Frame(master)
frame.pack()
self.buttonIn = Button(frame, text=" 入 ", command=self.inHandler)
self.buttonIn.pack(side=LEFT)
self.buttonOut = Button(frame, text=" 出 ", command=self.outHandler)
self.buttonOut.pack(side=RIGHT)
def inHandler(self):
if(systemString =="Windows"):
os.system ('echo %time% >> '+inLog)
else:
os.system ('echo $(date) >> '+inLog)
def outHandler(self):
if(systemString =="Windows"):
os.system ('echo %time% >> '+outLog)
else:
os.system ('echo $(date) >> '+outLog)
root = Tk(className="阿平打点 V1")
root.geometry("200x100+200+200")
app = App(root)
root.mainloop()
参考资料:
http://www.pythonware.com/library/tkinter/introduction/index.htm
http://outofmemory.cn/code-snippet/458/python-decide-caozuoxitong-type-code