热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

开源一步步实现cnblogs博客采集工具实现过滤设置对话框

报告下CnblogsFan项目最新的进度,下午wid完成了过滤设置对话框的布局设计,过滤设置暂时的设计如下:1.根据感兴趣的关键词进行采集;2.限定采集的随笔的发表时间;3.

 

报告下CnblogsFan项目最新的进度, 下午wid完成了过滤设置对话框的布局设计, 过滤设置暂时的设计如下:

  1>. 根据感兴趣的关键词进行采集;

  2>. 限定采集的随笔的发表时间;

  3>. 限定采集随笔内容的最短长度;

 

对话框的设计如下:

对话框由静态框、文本标签、文本框、单选按钮、下拉组合框、滑块以及一个"开始按钮"组成, 相关的代码如下:

#!/usr/bin/python
#
coding:utf-8
#
-------------------------------------------------------------------------------
#
Name: CnblogsFan_FilterDlg.py
#
Purpose:
#
#
Author: Mr.Wid
#
#
Created: 18-10-2012
#
Copyright: (c) Mr.Wid 2012
#
Licence: GNU GPL
#
-------------------------------------------------------------------------------import wx
import timeclass FilterDlg(wx.Dialog):def __init__( self, parent = None ):wx.Dialog.__init__(self,parent = parent,title = u'过滤设置',size = (500, 400 ))#-----感兴趣的关键词-----rect = self.GetClientRect()#--静态库框self.groupKeyWordBox = wx.StaticBox(self,label = u'关键词检索(可选)',pos = ( rect[0] + 20 , rect[1] + 20 ),size = ( rect[2] - 40, rect[0] + 100 ))#--标签提示rect = self.groupKeyWordBox.Rectself.lblKeyWord = wx.StaticText(self,label = u'感兴趣的关键词:',pos = ( rect[0] + 30, rect[1] + 30 ))#--关键词输入文本框rect = self.lblKeyWord.Rectself.txtKeyWord = wx.TextCtrl(self,size = ( 300, -1 ),pos = ( rect[0] + rect[2] + 10, rect[1] - 3 ),value = u'关键词之间用空格隔开')self.tipKeyWordValue = Trueself.txtKeyWord.Bind( wx.EVT_LEFT_DOWN, self.OnClearTipText )#--检索方式选择单选组rect = self.groupKeyWordBox.Rectself.rdoboxKeyMode = wx.RadioBox(self,choices = [ u'仅检索标题', u'全文检索' ],style = wx.RA_HORIZONTAL)self.rdoboxKeyMode.Position = (rect[0] + (rect[2] - self.rdoboxKeyMode.Rect[2]) / 2 ,rect[1] + (rect[3] - self.rdoboxKeyMode.Rect[3]) / 2 + 20)#-----时间过滤-----rect = self.groupKeyWordBox.Rectself.groupTimeBox = wx.StaticBox(self,label = u'允许采集的时间范围(可选)',pos = ( rect[0] , rect[1] + rect[3] + 20 ),size = ( rect[2], rect[0] + 50 ))#-----起始日期下拉选单#--起始年份year = []for i in range( int( time.localtime()[0]), 2002 , -1 ):year.append( str(i) )rect = self.groupTimeBox.Rectself.cboStartYear = wx.ComboBox(self,value = u'',pos = ( rect[0] + 30, rect[1] + 30 ),choices = year)#--起始月份month = []for i in range( 1, 13 ):month.append( str(i) )rect = self.cboStartYear.Rectself.cboStartMonth = wx.ComboBox(self,value = u'',pos = ( rect[0] + rect[2] + 10, rect[1] ),choices = month)#--起始天数rect = self.cboStartMonth.Rectself.cboStartDay = wx.ComboBox(self,value = u'',pos = ( rect[0] + rect[2] + 10, rect[1] ),size = ( rect[2], rect[3] ))self.cboStartMonth.Bind( wx.EVT_COMBOBOX, self.OnShowStartDay )self.cboStartYear.Bind( wx.EVT_COMBOBOX, self.OnShowStartDay )#--标签rect = self.cboStartDay.Rectwx.StaticText(self, label = u'',pos = ( rect[0] + rect[2] + 15, rect[1] + 3 ))#-----截止日期下拉选单#--结束年份year = []for i in range(int( time.localtime()[0]), 2002 , -1 ):year.append( str(i) )rect = self.groupTimeBox.Rectself.cboEndYear = wx.ComboBox(self,value = u'',pos = ( rect[0] + 240, rect[1] + 30 ),choices = year)#--结束月份month = []for i in range( 1, 13 ):month.append( str(i) )rect = self.cboEndYear.Rectself.cboEndMonth = wx.ComboBox(self,value = u'',pos = ( rect[0] + rect[2] + 10, rect[1] ),choices = month)#--结束天数rect = self.cboEndMonth.Rectself.cboEndDay = wx.ComboBox(self,value = u'',pos = ( rect[0] + rect[2] + 10, rect[1] ),size = ( rect[2], rect[3] ))self.cboEndMonth.Bind( wx.EVT_COMBOBOX, self.OnShowEndDay )self.cboEndYear.Bind( wx.EVT_COMBOBOX, self.OnShowEndDay )#-----允许采集的最短内容长度rect = self.groupTimeBox.Rectself.groupLeastBox = wx.StaticBox(self,label = u'允许采集的随笔最短字数(可选)',pos = ( rect[0] , rect[1] + rect[3] + 20 ),size = ( rect[2], rect[3] ))#--建议一个滑块rect = self.groupLeastBox.Rectself.sliderLeastWord = wx.Slider(self,value = 0,minValue = 0,maxValue = 5000,pos = ( rect[0] + 20, rect[1] + 20 ),size = ( 410, -1 ),style = wx.SL_HORIZONTAL | wx.SL_LABELS)#-----开始采集按钮-----rect = self.GetClientRect()self.btnStart = wx.Button(self,label = u'开始采集',size = ( 80, 40 ),pos = ( (rect[2] - 80 ) / 2 , rect[3] - 50 ))#-----事件响应方法------#--清空文本框提示文字def OnClearTipText( self, evt ):self.txtKeyWord.SetFocus()if self.tipKeyWordValue:self.txtKeyWord.SetValue(u'')self.tipKeyWordValue = False#--计算结束下拉选单开始日期"日"的天数def OnShowStartDay( self, evt ):try:year = int( self.cboStartYear.GetLabel() )month = self.cboStartMonth.GetLabel()except:returnday = 31while day:try:time.strptime( '%s-%s-%d'%(year, month, day ), '%Y-%m-%d')self.lstDay = [ str(i) for i in range(1, day + 1) ]self.cboStartDay.SetItems(self.lstDay)self.cboStartDay.SetLabel( u'' )breakexcept:day -= 1#--计算结束下拉选单结束日期"日"的天数def OnShowEndDay( self, evt ):try:year = int( self.cboEndYear.GetLabel() )month = self.cboEndMonth.GetLabel()except:returnday = 31while day:try:time.strptime('%s-%s-%d'%(year, month, day ), '%Y-%m-%d')self.lstDay = [ str(i) for i in range(1, day + 1) ]self.cboEndDay.SetItems(self.lstDay)self.cboEndDay.SetLabel( u'' )breakexcept:day -= 1def test():app = wx.PySimpleApp()dlg = FilterDlg()dlg.ShowModal()if __name__ == '__main__':test()

 

CnblogsFan UI部分的设计就到这了, 下一步进入各模块方法的实现阶段。

--------------

wid, 2012.10.18

 

上一篇: 开源->一步步实现cnblogs博客采集工具->实现辅助对话框

 



推荐阅读
author-avatar
sijiamian_767
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有