コード例 #1
0
    def __init__(self):
        super().__init__(aircrafts="/json/aircraft/list?orderby=reg&amount=99",
                         pilots="/json/user/list?orderby=lastname&amount=99",
                         locations="/json/place/list?amount=99")

        self.mode = "assistant"

        self.allowedRecognizers = [
            self.dateRecognizer, self.aircraftRecognizer, self.pilotRecognizer,
            self.locationRecognizer, self.timeRecognizer,
            self.durationRecognizer
        ]

        self.editorTimeout = None

        self.editor = document["editor"]
        self.editorCol = document["editor-col"]
        self.editorRow = document["editor-row"]
        self.editorProposal = document["editor-proposal"]
        self.final = document["final"]
        self.construction = document["construction"]
        self.constructionRow = document["construction-row"]

        self.batch = document["batch"]
        self.batchSwitch = document["batch-switch"]
        self.batchEditor = document["batch-editor"]
        self.batchErrorRow = None

        self.editorProposal.bind("click", self.selectProposal)
        #editor.bind("keyup", setTimeout)
        self.editor.bind("change", self.checkInput)
        self.batchSwitch.bind("change", self.switchMode)
        document["btn-parse"].bind("click", self.doParse)
        document["btn-time"].bind("click", self.insertTime)

        document["select-preset-location"].bind("change",
                                                self.setDefaultLocation)

        document["batch-aircraft"].bind("dblclick", self.insertObject)
        document["batch-pilot"].bind("dblclick", self.insertObject)
        document["batch-location"].bind("dblclick", self.insertObject)

        window.setTimeout(self.editor.focus, 500)
        window.setInterval(self.updateTime, 1000)

        batch = window.localStorage.getItem(
            datetime.datetime.now().strftime("batch-%Y-%m-%d"))
        if batch:
            window.alert(
                "%d Starts aus localStorage im Batch-Modus wiederhergestellt" %
                (batch.count("\n") + 1))
            self.batchEditor.value = batch
コード例 #2
0
def set_interval(func,interval):
    return window.setInterval(wrap(func),interval)
コード例 #3
0
ファイル: timer.py プロジェクト: zaitsev-adnrey/brython
def set_interval(func, interval, *args):
    return window.setInterval(wrap(func, *args), interval)
コード例 #4
0
    if key == 37 and not paused:
        xv = -1
        yv = 0
    elif key == 38 and not paused:
        xv = 0
        yv = -1
    elif key == 39 and not paused:
        xv = 1
        yv = 0
    elif key == 40 and not paused:
        xv = 0
        yv = 1
    elif key == 32:
        temp = [xv, yv]
        xv = pre_pause[0]
        yv = pre_pause[1]
        pre_pause = [*temp]
        paused = not paused


def show_instructions(evt):
    window.alert(
        "Use the arrow keys to move and press spacebar to pause the game.")


canvas = document["game-board"]
ctx = canvas.getContext("2d")
document.addEventListener("keydown", key_push)
game_loop = window.setInterval(game, 1000 / 15)
instructions_btn = document["instructions-btn"]
instructions_btn.addEventListener("click", show_instructions)
コード例 #5
0
ファイル: microp5.py プロジェクト: esperanc/brythonide
def loop():
    global _loopId
    noLoop()
    _loopId = window.setInterval(_loopCallback, 1000 / _fps)
コード例 #6
0
        gEDIT("sched", gHTML(typ))
        gEDIT("prt", cat[typ])
        currentsched = eval(gHTML("sched"))
        prs, tms = [x[0] for x in currentsched], [x[1] for x in currentsched]
        gEDIT(
            "list",
            '<br>'.join(f"{prs[x]} {'-'*(18-len(prs[x]))} {str(tms[x-1])[:-3]}"
                        for x in range(1, len(prs))))
    for per, end in currentsched:
        if diff(end) >= 0:
            period = per
            end = dt.combine(dt.today(), end)
            rn = dt.now()
            break
    gEDIT("time",
          ':'.join(zf(x) for x in str(end - rn).split('.')[0].split(':')))
    gEDIT("per", f"{period} // ENDS AT {zf(end.hour)}:{zf(end.minute)}")
    d = dt.now()
    gEDIT(
        "date",
        dt(d.year + 4, d.month, d.day, d.hour, d.minute,
           d.second).strftime("%a, %d %b %Y %H:%M:%S UTC"))
    gEDIT("cookie", doc.cookie)
    win.setTimeout(cookies, 1000)


gEDIT("time", "-~-")
if not gHTML("sched"):
    gEDIT("sched", gHTML("norm"))
win.setInterval(get, 1000)
コード例 #7
0
ファイル: main.py プロジェクト: swappt/CodeIslands
def run():
    global runtime
    global run_buffer
    global used_commands

    variables = {}

    window.gebi('error').style.width = '0vw'
    window.gebi('error').style.opacity = 0

    try:
        window.clearInterval(runtime)
    except:
        pass

    display.width = display.width
    turtle.x = display.width / 2
    turtle.y = display.height / 2

    turtle.disp_x = 0
    turtle.disp_y = 0

    turtle.angle = 0

    ctx.beginPath()
    ctx.lineWidth = 3
    ctx.moveTo(turtle.x + dis_center_x, turtle.y + dis_center_y)
    ctx.stroke()

    lines = window.editor.getValue().split('\n')
    lines = list(filter(lambda x: bool(x), lines))

    used_commands = []

    run_buffer = []
    for_buffer = []
    current_buffer = run_buffer

    for line in lines:
        line = line.strip()
        if '=' in line:
            pre, post = line.split('=')

            pre = pre.strip()

            if pre[0] in '0123456789':
                window.gebi('error').style.width = '42vw'
                window.gebi('error').style.opacity = 1
                window.gebi(
                    'error'
                ).innerHTML = 'Error in line "{}": Declarations cannot begin with numericals'.format(
                    line)
                window.hide_error()
                return

            post = post.strip()

            for char in pre:
                if char not in 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_':
                    window.gebi('error').style.width = '42vw'
                    window.gebi('error').style.opacity = 1
                    window.gebi(
                        'error'
                    ).innerHTML = 'Error in line "{}": "{}" not allowed in variable declarations'.format(
                        line, char)
                    window.hide_error()
                    return

            variables[pre] = post

        else:
            for command, action in cmd.items():
                if line.startswith(command):
                    used_commands.append(command)

                    if command in ['FORWARD', 'BACKWARD']:
                        try:
                            arg = int(line.split(' ', 1)[1])
                        except ValueError:
                            try:
                                arg = int(variables[line.split(' ', 1)[1]])
                            except ValueError:
                                window.gebi('error').style.width = '42vw'
                                window.gebi('error').style.opacity = 1
                                window.gebi(
                                    'error'
                                ).innerHTML = 'Error in line "{}": {} only accepts integer values (whole numbers)'.format(
                                    line, command)
                                window.hide_error()
                                return

                            except KeyError:
                                window.gebi('error').style.width = '42vw'
                                window.gebi('error').style.opacity = 1
                                window.gebi(
                                    'error'
                                ).innerHTML = 'Error in line "{}": variable "{}" not defined'.format(
                                    line,
                                    line.split(' ')[1])
                                window.hide_error()
                                return

                        for i in range(5 * arg):
                            current_buffer.append(command + ' 0.2')

                    elif command in ['LEFT', 'RIGHT']:
                        current_buffer.append(command + ' 1')

                    elif command in ['FOR ']:
                        try:
                            arg = int(line.split(' ', 1)[1])
                        except ValueError:
                            window.gebi('error').style.width = '42vw'
                            window.gebi('error').style.opacity = 1
                            window.gebi(
                                'error'
                            ).innerHTML = 'Error in line "{}": {} only accepts integer values (whole numbers)'.format(
                                line, command)
                            window.hide_error()
                            return

                        if len(for_buffer) > 0:
                            for_buffer.append([arg])
                            current_buffer = for_buffer[-1]
                        else:
                            for_buffer.append(arg)
                            current_buffer = for_buffer

                    elif command in ['ENDFOR']:
                        if current_buffer == for_buffer[-1]:
                            cur = for_buffer.pop(-1)
                            counts = cur.pop(0)
                            apval = cur * counts
                            try:
                                for item in apval:
                                    for_buffer[-1].append(item)
                                current_buffer = for_buffer[-1]
                            except:
                                for item in apval:
                                    for_buffer.append(item)
                                current_buffer = for_buffer

                        elif current_buffer == for_buffer:
                            counts = for_buffer.pop(0)
                            apval = for_buffer * counts
                            for item in apval:
                                run_buffer.append(item)

                            current_buffer = run_buffer

                    break
            else:
                window.gebi('error').style.width = '42vw'
                window.gebi('error').style.opacity = 1
                window.gebi(
                    'error'
                ).innerHTML = 'Error in line "{}": Unrecognised command-word'.format(
                    line)
                window.hide_error()
                break

    runtime = window.setInterval(run_action, 35)
コード例 #8
0
ファイル: main.py プロジェクト: swappt/CodeIslands
            map_ctx.lineTo(median_cell[0] + i * cell_w - cell_w / 2,
                           median_cell[1] + j * cell_h - cell_h / 2)
            map_ctx.lineTo(median_cell[0] + i * cell_w - cell_w / 2,
                           median_cell[1] + j * cell_h + cell_h / 2)
            map_ctx.lineTo(median_cell[0] + i * cell_w,
                           median_cell[1] + j * cell_h)

            pattern = map_ctx.createPattern(window.gebi(src), 'repeat')

            map_ctx.fillStyle = pattern
            map_ctx.fill()


start.onclick = run

window.onresize = resize_window
window.setInterval(clouds_render, 55)

document.onkeydown = keysDown
document.onkeyup = keysUp


def load():
    resize_window(None)
    window.hide_load()


document.onload = load()

print('main.py loaded')