Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1833914
  • 博文数量: 283
  • 博客积分: 10141
  • 博客等级: 上将
  • 技术积分: 2931
  • 用 户 组: 普通用户
  • 注册时间: 2005-12-21 14:33
文章分类

全部博文(283)

文章存档

2013年(2)

2012年(2)

2011年(17)

2010年(36)

2009年(17)

2008年(18)

2007年(66)

2006年(105)

2005年(20)

分类: Python/Ruby

2006-08-04 15:59:00

系统环境:
Suse 10.0
Python 2.4
dogtail...060804的CVS+自行修改
pyspi 060804的cvs
stardict为RPM安装,版本是2.4.2

主要测试过程如下:
启动应用程序,读取$HOME/Desktop/wordList中的单词逐个查询,查询完毕后查前一个查过的单词,然后接下来查这个单词在字典中的前一个和后一个单词,最后退出。

如果想要测试过程中的屏幕截图,请自行在合适的位置添加
screenshot()

欢迎交流~~~~~

#!/usr/bin/python
from dogtail.config import config
from dogtail.procedural import *
from dogtail.utils import screenshot

#import dogtail.i18n
#dogtail.i18n.loadTranslationsFromPackageMoFiles('gedit')

# Load the UTF-8 demo file. Use codecs.open() instead of open().
from os import environ, path
environ['LANG']='en_US.UTF-8'
if not path.isfile(path.join(path.expandvars("$HOME"), "Desktop", "wordList")):
    print "Please put file \"wordList\" in your $HOME/Desktop"
    raise IOError,'File not exists'

# Load our persistent Dogtail objects
import dogtail.tc
TestString = dogtail.tc.TCString()

from codecs import open
try:
    wl = open(path.join(path.expandvars("$HOME"), "Desktop", "wordList"))
except IOError:
    raise IOError, 'Can not open worldList'

#start stardict
run('stardict')
focus.application('stardict')

click('dialog information')

click('Clear')

#screenshot()

while True:
    #get the word from wordList
    word = wl.readline()

    #End of wordList
    if len(word) == 0:
        break

    focus.text()

    #query the word and sleep to show the result
    focus.widget.text = word
    sleep(2)

    #clear the text
    click('Clear')

wl.close()

#test gtk-undo, go back, and go forward
print "query the previous word in the list"
click('gtk-undo')
sleep(2)

#screenshot()

print "query the previous word in the dictionary"
click('go back')
sleep(2)

print "query the next word in the dictionary"
click('go forward')
sleep(2)
print "query the next word in the dictionary"
click('go forward')
sleep(2)

click('quit')

阅读(2954) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~