Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1745460
  • 博文数量: 335
  • 博客积分: 4690
  • 博客等级: 上校
  • 技术积分: 4341
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-08 21:38
个人简介

无聊之人--除了技术,还是技术,你懂得

文章分类

全部博文(335)

文章存档

2016年(29)

2015年(18)

2014年(7)

2013年(86)

2012年(90)

2011年(105)

分类: Python/Ruby

2013-04-17 22:59:31

        接着上文,自己动手实现一个专门的比较工具,现在还只是雏形,大体功能如下:
根据用户输入的关键字,遍历文件内容,并显示
支持文件FTP 功能
检查文件是否已文件名为内容开始
根据不同的关键字,生成一个summary 信息
两个文件夹的内容进行对比(待定)


涉及到的python知识点: 
Label,Engry,Button,FileDialog,
StringVar
menu 
pack
grid
对于新手而言,更多的熟悉各个组件的方法与属性。未完待续,欢迎高手指正!

点击(此处)折叠或打开

  1. # -*- coding: cp936 -*-
  2. __author__ = 'kinfinger'
  3. import os
  4. import time
  5. import tkFileDialog
  6. import tkMessageBox
  7. from Tkinter import *


  8. class FileGuiChose(object):
  9.     def __init__(self,initdir=None,frame=None,showframe=None):
  10.         self.entryvar =StringVar()
  11.         self.showframe=showframe
  12.         self.glabel=Label(frame,text=u'你选择的目录为:')
  13.         self.gentry=Entry(frame,textvariable=self.entryvar)
  14.         self.gbutton=Button(frame,command=self.opendir,text=u'选取目录')
  15.         self.glabel.grid(row=0,column=0)
  16.         self.gentry.grid(row=0,column=1)
  17.         self.gbutton.grid(row =0,column=2)

  18.     def opendir(self):
  19.         self.dirname=tkFileDialog.askdirectory()
  20.         self.entryvar.set(self.dirname) # related to entry just for show
  21.         self.fguiShow=FileGuiShow(self.dirname,self.showframe)
  22. class FileGuiShow():
  23.     def __init__(self,directory,showframe):
  24.         if directory:
  25.             self.dirlist=os.listdir(directory)
  26.         else:
  27.             showmessage=directory
  28.             self.messageBox=tkMessageBox.showinfo(showframe,message=showmessage)
  29.         self.showlist=Listbox(showframe,width=800,height=800)
  30.         self.showlist.pack()
  31.         for eachdir in self.dirlist:
  32.             self.showlist.insert(END,eachdir)
  33.         self.showlist.update()
  34. class GuiMenu():
  35.     def hello(self):
  36.         pass
  37.     def File(self):
  38.         pass
  39.     def Edit(self):
  40.         pass
  41.     def View(self):
  42.         pass
  43.     def Help(self):
  44.         tkMessageBox.showinfo(self.root,'作者 kinfinger \n verion 1.0 \n Thank you ')
  45.     def __init__(self,rootmenu):
  46.         self.root=rootmenu   
  47.         self.menubar=Menu(rootmenu)         
  48.         rootmenu['menu']=self.menubar  
  49.         self.menubar.add_command(label = 'File',command =self.File )
  50.         self.menubar.add_command(label = 'Edit',command =self.Edit )
  51.         self.menubar.add_command(label = 'View',command =self.View )
  52.         self.menubar.add_command(label = 'Help',command =self.Help)
  53. def main():
  54.     root = Tk()
  55.     choseFrame=Frame(root,height=50,width=800,bg='red')
  56.     showFrame=Frame(root,height=800,width=800,bg='white')
  57.     choseFrame.pack(side=TOP)
  58.     showFrame.pack(side=TOP)
  59.     GuiMenu(root)
  60.     fguiChose=FileGuiChose(os.curdir,choseFrame,showFrame)
  61.     mainloop()
  62. if __name__ == '__main__':
  63.     main()
REF: 
python Doc
阅读(3970) | 评论(2) | 转发(0) |
给主人留下些什么吧!~~

kinfinger2013-04-24 18:08:21

dizhuang:写的很好啊

自己瞎写着玩的,~~~~~~~~~~··

回复 | 举报

dizhuang2013-04-24 14:22:52

写的很好啊