Esempio n. 1
0
 def __init__(self,
              title,
              message,
              *,
              top=None,
              left=None,
              default_css=True,
              remove_after=None,
              ok=False):
     """If remove_after is set, number of seconds after which the dialog is
     removed."""
     Dialog.__init__(self,
                     title,
                     top=top,
                     left=left,
                     default_css=default_css)
     self.panel <= html.DIV(message)
     if ok:
         ok = ok if isinstance(ok, str) else "Ok"
         self.ok_button = html.BUTTON(ok, Class="brython-dialog-button")
         self.panel <= html.P()
         self.panel <= html.DIV(self.ok_button,
                                style={"text-align": "center"})
         self.ok_button.bind("click", lambda ev: self.remove())
     if remove_after:
         if not isinstance(remove_after, (int, float)):
             raise TypeError("remove_after should be a number, not " +
                             str(remove_after.__class__.__name__))
         window.setTimeout(self.close, remove_after * 1000)
Esempio n. 2
0
def get():
    currentsched = eval(gHTML("sched"))
    if cat[gHTML("typ")] == gHTML("prt") and gHTML("typ") in cat:
        cur = gHTML("typ").split("_")[0]
        typ = cur + ("_half"
                     if eval(gHTML("half")) and gID(cur + "_half") else "")
        gEDIT("typ", typ)
        doc.cookie = f"sched={typ}; path=/"
        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)
Esempio n. 3
0
 def __init__(self, title="", message="", style={}, top=None, left=None,
         remove_after=None):
     """If remove_after is set, number of seconds after which the dialog is
     removed."""
     Dialog.__init__(self, title, style, top, left)
     self.panel <= message
     if remove_after:
         if not isinstance(remove_after, (int, float)):
             raise TypeError("remove_after should be a number, not " +
                 str(remove_after.__class__.__name__))
         window.setTimeout(self.close, remove_after * 1000)
Esempio n. 4
0
def run():
    global alpha
    t.forward(2)
    if (Math.floor(alpha / 360) % 2 == 0):
        t.left(1)
    else:
        t.right(1)

    alpha += 1

    if (alpha < 1440):
        window.setTimeout(run, 20)
Esempio n. 5
0
def run():
    global alpha
    t.forward(2)
    if (Math.floor(alpha / 360) % 2 == 0):
        t.left(1)
    else:
        t.right(1)

    alpha += 1

    if (alpha < 1440):
        window.setTimeout(run, 20)
Esempio n. 6
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
Esempio n. 7
0
 def test_slowly(self):
     """
     This test should wait for 5 seconds for its Deferred to fire, then
     pass.
     """
     from browser import window
     d = Deferred()
     print("one")
     def later():
         d.callback(None)
     print("two")
     window.setTimeout(later, 5000)
     print("three")
     return d
Esempio n. 8
0
def askapitwitter(ev):
    global response
    global posting
    if ev.target.status == 200:
        response = ev.target.responseText
        if response != "Invalid response":
            if posting is False:
                if response != "Invalid response":
                    win.setTimeout(callresponseget, 50)
                else:
                    hideshow("login", "loading", "login")
                    win.swal("Sorry, Request failed")
            else:
                win.setTimeout(callresponsepost, 50)
Esempio n. 9
0
 def start(selector, milliseconde):
     global timeout
     Slide.displ(Slide.current, selector)
     if milliseconde > 0:
         win.clearTimeout(timeout)
         timeout = win.setTimeout(
             Slide.next, milliseconde, selector, milliseconde)
Esempio n. 10
0
 def __init__(self, title="", message="", style={}, top=None, left=None,
         remove_after=None, ok=False):
     """If remove_after is set, number of seconds after which the dialog is
     removed."""
     Dialog.__init__(self, title, style, top, left)
     self.panel <= html.DIV(message)
     if ok:
         ok_button = html.BUTTON("Ok")
         self.panel <= html.P()
         self.panel <= html.DIV(ok_button, style={"text-align": "center"})
         ok_button.bind("click", lambda ev: self.remove())
     if remove_after:
         if not isinstance(remove_after, (int, float)):
             raise TypeError("remove_after should be a number, not " +
                 str(remove_after.__class__.__name__))
         window.setTimeout(self.close, remove_after * 1000)
Esempio n. 11
0
    def setTimeout(self, e):
        e.preventDefault()
        e.stopPropagation()

        if self.editorTimeout:
            window.clearTimeout(self.editorTimeout)
            self.editorTimeout = None

        self.editorTimeout = window.setTimeout(self.checkInput, 1500)
Esempio n. 12
0
def set_timeout(func,interval):
    return int(window.setTimeout(wrap(func),interval))