コード例 #1
0
    def query_word(self, word):
        js = youdao_client.query(word)
        if 'basic' not in js:
            return 

        youdao_client.pronounce(word)
        x, y, mods = self.window.get_screen().get_root_window().get_pointer()
        self.window.move(x+15, y+10)
        self.window.present()

        translation = '<br/>'.join(js['translation']) 
        if 'phonetic' in js['basic']:
            phonetic = js['basic']['phonetic']
        else:
            phonetic = ''
        explains = '<br/>'.join(js['basic']['explains']) 
        #web = '<br/>'.join( ['<a href="http://dict.youdao.com/search?le=eng&q=%s">%s</a>: %s'%(i['key'], i['key'], ' '.join(i['value'])) for i in js['web'][:3] ] )
        web = '<br/>'.join( ['<a href="">%s</a>: %s'%(i['key'], ' '.join(i['value'])) for i in js['web'][:3] ] )
        html = '''
        <h2> %s  <span style="color: #A0A0A0; font-size: 15px">[ %s ] </span> </h2>
        <b>基本翻译:</b>
        <p> %s </p>
        <b>网络释意:</b>
        <p> %s </p>

        ''' % (translation, phonetic, explains, web)
                   
        self.view.load_html_string(html, '')
        self.view.reload()
        self.popuptime = time.time()
コード例 #2
0
    def query_word(self, word):
        js = youdao_client.query(word)
        if 'basic' not in js:
            logging.info('IgnoreWord: ' + word)
            return
        logging.info('PronounceWord: ' + word)

        youdao_client.pronounce(word)
        x, y, mods = self.window.get_screen().get_root_window().get_pointer()
        self.window.move(x + 15, y + 10)

        self.window.present()

        translation = '<br/>'.join(js['translation'])
        if 'phonetic' in js['basic']:
            phonetic = js['basic']['phonetic']
        else:
            phonetic = ''
        explains = '<br/>'.join(js['basic']['explains'])
        #web = '<br/>'.join( ['<a href="http://dict.youdao.com/search?le=eng&q=%s">%s</a>: %s'%(i['key'], i['key'], ' '.join(i['value'])) for i in js['web'][:3] ] )
        web = '<br/>'.join([
            '<a href="">%s</a>: %s' % (i['key'], ' '.join(i['value']))
            for i in js['web'][:3]
        ])
        html = '''
<style>
.add_to_wordbook {
    background: url(http://bs.baidu.com/yanglin/add.png) no-repeat;
    vertical-align: middle;
    overflow: hidden;
    display: inline-block;
    vertical-align: top;
    width: 24px;
    padding-top: 26px;
    height: 0;
    margin-left: .5em;
}
</style>

        <h2>
        %(translation)s
        <span style="color: #0B6121; font-size: 12px">< %(phonetic)s > </span>
        <a href="javascript:void(0);" id="wordbook" class="add_to_wordbook" title="点击在浏览器中打开" onclick="document.title='%(word)s'"></a> <br/>
        </h2>

        <span style="color: #A0A0A0; font-size: 15px">[ %(word)s ] </span>
        <b>基本翻译:</b>
        <p> %(explains)s </p>

        <span style="color: #A0A0A0; font-size: 15px">[ %(word)s ] </span>
        <b>网络释意:</b>
        <p> %(web)s </p>

        ''' % locals()

        self.view.load_html_string(html, '')
        self.view.reload()
        self.popuptime = time.time()
コード例 #3
0
    def query_word(self, word):
        js = youdao_client.query(word)
        if 'basic' not in js:
            logging.info('IgnoreWord: ' + word)
            return
        logging.info('PronounceWord: ' + word)

        youdao_client.pronounce(word)
        x, y, mods = self.window.get_screen().get_root_window().get_pointer()
        self.window.move(x, y + 50)

        self.window.present()

        translation = '<br/>'.join(js['translation'])
        if 'phonetic' in js['basic']:
            phonetic = js['basic']['phonetic']
        else:
            phonetic = ''
        explains = '<br/>'.join(js['basic']['explains'])
        #web = '<br/>'.join( ['<a href="http://dict.youdao.com/search?le=eng&q=%s">%s</a>: %s'%(i['key'], i['key'], ' '.join(i['value'])) for i in js['web'][:3] ] )
        web = '<br/>'.join([
            '<em>%s</em>: %s' % (i['key'], ' '.join(i['value']))
            for i in js['web'][:3]
        ])
        html = '''
<style>
.add_to_wordbook {
    vertical-align: middle;
    overflow: hidden;
    display: inline-block;
    vertical-align: top;
    width: 24px;
    padding-top: 26px;
    height: 0;
    margin-left: .5em;
}
</style>

        <h2>
        %(translation)s
        <span style="color: #0B6121; font-size: 12px">< %(phonetic)s > </span>
        </h2>

        <span style="color: #A0A0A0; font-size: 15px">[ %(word)s ] </span>
        <b>基本翻译:</b>
        <p> %(explains)s </p>

        <span style="color: #A0A0A0; font-size: 15px">[ %(word)s ] </span>
        <b>网络释意:</b>
        <p> %(web)s </p>

        ''' % locals()

        self.view.load_html_string(html, '')
        self.view.reload()
        self.popuptime = time.time()
        pyperclip.copy(explains.replace('<br/>', '\n'))
コード例 #4
0
ファイル: dict.py プロジェクト: j1994d/youdao-dict-for-ubuntu
    def query_word(self, word):
        js = youdao_client.query(word)
        if 'basic' not in js:
            logging.info('IgnoreWord: ' + word)
            return
        logging.info('PronounceWord: ' + word)

        youdao_client.pronounce(word)
        x, y, mods = self.window.get_screen().get_root_window().get_pointer()
        self.window.move(x+15, y+10)

        self.window.present()

        translation = '<br/>'.join(js['translation'])
        if 'phonetic' in js['basic']:
            phonetic = js['basic']['phonetic']
        else:
            phonetic = ''
        explains = '<br/>'.join(js['basic']['explains'])
        #web = '<br/>'.join( ['<a href="http://dict.youdao.com/search?le=eng&q=%s">%s</a>: %s'%(i['key'], i['key'], ' '.join(i['value'])) for i in js['web'][:3] ] )
        web = '<br/>'.join( ['<a href="">%s</a>: %s'%(i['key'], ' '.join(i['value'])) for i in js['web'][:3] ] )
        html = '''
<style>
.add_to_wordbook {
    background: url(http://bs.baidu.com/yanglin/add.png) no-repeat;
    vertical-align: middle;
    overflow: hidden;
    display: inline-block;
    vertical-align: top;
    width: 24px;
    padding-top: 26px;
    height: 0;
    margin-left: .5em;
}
</style>

        <h2>
        %(translation)s
        <span style="color: #0B6121; font-size: 12px">< %(phonetic)s > </span>
        <a href="javascript:void(0);" id="wordbook" class="add_to_wordbook" title="点击在浏览器中打开" onclick="document.title='%(word)s'"></a> <br/>
        </h2>

        <span style="color: #A0A0A0; font-size: 15px">[ %(word)s ] </span>
        <b>基本翻译:</b>
        <p> %(explains)s </p>

        <span style="color: #A0A0A0; font-size: 15px">[ %(word)s ] </span>
        <b>网络释意:</b>
        <p> %(web)s </p>

        ''' % locals()

        self.view.load_html_string(html, '')
        self.view.reload()
        self.popuptime = time.time()
コード例 #5
0
    def query_word(self, word):
        js = youdao_client.query(word)
        youdao_client.pronounce(word)
        x, y, mods = self.window.get_screen().get_root_window().get_pointer()
        self.window.move(x + 15, y + 10)
        self.window.present()
        explains = ''
        translation = ''
        web = ''
        phonetic = ''
        if js.has_key('translation'):
            translation = '<br/>'.join(js['translation'])
        if js.has_key('basic'):
            if 'phonetic' in js['basic']:
                phonetic = js['basic']['phonetic']
            if 'explains' in js['basic']:
                explains = '<br/>'.join(js['basic']['explains'])
        if js.has_key('web'):
            web = '<br/>'.join([
                '<a href="http://dict.youdao.com/search?le=eng&q=%s">%s</a>: %s'
                % (i['key'], i['key'], ' '.join(i['value']))
                for i in js['web'][:3]
            ])
        html = '''
<style>
.add_to_wordbook {
    background:  no-repeat;
    vertical-align: middle;
    overflow: hidden;
    display: inline-block;
    vertical-align: top;
    width: 20px;
    padding-top: 20px;
    height: 0;
    margin-left: .5em;
}
</style>
        <h2>
        %(translation)s
        <span style="color: #0B6121; font-size: 13px">< %(phonetic)s > </span>
        </h2>
        <span style="color: #A0A0A0; font-size: 14px"> </span>
        <b>基本翻译:</b>
        <p> %(explains)s </p>
        <span style="color: #A0A0A0; font-size: 14px"> </span>
        <b>网络释意:</b>
        <p> %(web)s </p>
        ''' % locals()
        self.view.load_html_string(html, '')
        self.view.reload()
        self.popuptime = time.time()