您的位置:首页 > 编程语言 > Python开发

Python实现简单时间人流数据收集工具

2013-04-12 23:17 891 查看
同事(www.apinglai.com)周末去某克咖啡收集人流数据, 花了点时间弄了个简单的工具给他 。

太久没写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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: