示例#1
0
from collections import OrderedDict
from talon import voice, ui
from talon.voice import Context, Key
from talon.webview import Webview
from . import basic_keys

# reusable constant for font size (in pixels), to use in calculations
FONT_SIZE = 14
# border spacing, in pixels
BORDER_SIZE = 2

ctx = Context('show')

webview_context = Context('web_view')

webview = Webview()

css_template = '''
<style type="text/css">
        body {
            padding: 0;
            margin: 0;
            font-size: ''' + str(FONT_SIZE) + '''px;
            -webkit-border-vertical-spacing: ''' + str(BORDER_SIZE) + '''px;
            -webkit-border-horizontal-spacing: ''' + str(BORDER_SIZE) + '''px;
            max-height: 200%;
            overflow: auto;
        }
        .contents {
            width: 100%;
        }
示例#2
0
webview_context = Context("helpWebView")


def on_click(data):
    if data["id"] == "close":
        return close_webview()
    elif "page" in data["id"]:
        context, _, page = data["id"].split("-")
        if context == "contexts":
            return render_contexts_help(_, int(page))
        return render_commands_webview(get_context(context), int(page))
    else:
        return render_commands_webview(voice.talon.subs.get(data["id"]))


webview = Webview()
webview.register("click", on_click)

css_template = ("""
<style type="text/css">
    body {
        padding: 0;
        margin: 0;
        font-size: """ + str(FONT_SIZE) + """px;
        -webkit-border-vertical-spacing: """ + str(BORDER_SIZE) + """px;
        -webkit-border-horizontal-spacing: """ + str(BORDER_SIZE) + """px;
    }

    .contents {
        width: 100%;
    }
import string

from talon.webview import Webview
from user import basic_keys

alphabet = list(zip(basic_keys.alpha_alt, string.ascii_lowercase))

webview = Webview()
template = '''
<style type="text/css">
body {a
    padding: 0;
    margin: 0;
}
.contents {
    width: 100%;
}
td {
    text-align: left;
    margin: 0;
    padding: 0;
    padding-left: 5px;
}
</style>
<h3>alphabet</h3>
<div class="contents">
<table>
{% for word, letter in alphabet %}
    <tr><td>{{ letter }}</td><td>{{ word }}</td></tr>
{% endfor %}
</table>
示例#4
0
<style type="text/css">
body {
    width: 200px;
    padding: 0;
    margin: 0;
}
</style>
<h3 id="title">DICTATION ON!</h3>
<br>
<br>
Greedy: {{ greedy }}
<br>
<br>
<br>
"""
webview = Webview()
webview.move(ui.main_screen().width - 250, ui.main_screen().height - 270)


def update_context_and_webview():
    ctx1.reload()
    ctx2.reload()
    ctx3.reload()

    if config.dictation_enabled:
        webview.render(template, greedy=str(config.greedy))
        webview.show()
    else:
        webview.hide()