Esempio n. 1
0
def main():
    global lock

    lock = Lock()

    newGame()
    initSVGCards()
    atlastk.launch(CALLBACKS, headContent=HEAD)
Esempio n. 2
0
class gui:
    def acConnect(self, this, dom, id):
        dom.setLayout("", body)
        dom.focus("input")

    # get the name
    def acSubmit(self, this, dom, id):
        return dom.getContent("input")

    def acClear(self, this, dom, id):
        if (dom.confirm("Are you sure?")):
            dom.setContent("input", "")
            dom.focus("input")

    callbacks = {
        "": acConnect,  # This key is the action label for a new connection.
        "Submit": acSubmit,
        "Clear": acClear,
    }

    Atlas.launch(callbacks)
Esempio n. 3
0
    session.pseudo = pseudo
    dom.add_class("PseudoButton", "hidden")
    dom.disable_element("Pseudo")
    dom.enable_elements(["Message", "MessageButton"])
    dom.focus("Message")
  else:
    dom.alert("Pseudo. not available!")
    dom.set_value("Pseudo", pseudo)
    dom.focus("Pseudo")

def ac_submit_message(session,dom):
  room = session.room

  message = dom.get_value("Message")
  dom.set_value("Message", "")
  dom.focus("Message")
  room.add_message(session.pseudo,message)
  room.display_messages(session,dom)
  atlastk.broadcast_action("Update")     

CALLBACKS = {
  "": ac_connect,
  "Create": ac_create,
  "QRCode": ac_qrcode,
  "SubmitPseudo": ac_submit_pseudo,
  "SubmitMessage": ac_submit_message,
  "Update": lambda session,dom: session.room.display_messages(session,dom) if session.room else None,
}
    
atlastk.launch(CALLBACKS, Session, open("Head.html").read())
Esempio n. 4
0
    poppy.goto_position({id: int(dom.get_content(id))}, 0, wait=True)


def set(dom, motor, position):
    global poppy
    poppy.goto_position({motor: position}, 0, wait=False)
    dom.set_content(motor, position)


def reset(dom, motor):
    set(dom, motor, 0)


def acReset(Poppy, dom):
    global poppy
    reset(dom, "m1")
    reset(dom, "m2")
    reset(dom, "m3")
    reset(dom, "m4")
    reset(dom, "m5")
    reset(dom, "m6")


callbacks = {
    "": acConnect,
    "Move": acMove,
    "Reset": acReset,
}

Atlas.launch(callbacks, Poppy, open("Head.html").read())
Esempio n. 5
0
def ac_connect(dom):
    dom.inner("", body)
    dom.focus("input")


def ac_submit(dom):
    dom.alert("Hello, {}!".format(dom.get_value("input")))
    dom.focus("input")


def ac_clear(dom):
    if dom.confirm("Are you sure?"):
        dom.set_value("input", "")
    dom.focus("input")


def ac_error(dom):
    if dom.confirm("Clicking OK will quit the program (dev testing purpose)!"):
        os._exit(-1)
    dom.focus("input")


callbacks = {
    "": ac_connect,
    "Submit": ac_submit,
    "Clear": ac_clear,
    "Error": ac_error
}

atlastk.launch(callbacks, None, head)
Esempio n. 6
0
def ac_connect(dom):
    dom.inner("", body)
    dom.focus("input")


def ac_submit(dom):
    dom.alert("Hello, " + dom.get_content("input") + "!")
    dom.focus("input")


def ac_clear(dom):
    if dom.confirm("Are you sure?"):
        dom.set_content("input", "")
    dom.focus("input")


def ac_error(dom):
    if dom.confirm("Clicking OK will quit the program (dev testing purpose)!"):
        os._exit(-1)
    dom.focus("input")


callbacks = {
    "": ac_connect,
    "Submit": ac_submit,
    "Clear": ac_clear,
    "Error": ac_error
}

Atlas.launch(callbacks, None, head)
Esempio n. 7
0
 def run(self):
     Atlas.launch(callbacks, None, head)
Esempio n. 8
0
    weight_matrix = reversi.weight_matrix

    if (reversi.put(xy[0], xy[1], player)):
        drawBoard(reversi, dom, False)

        xy = reversi.find_best_position(player * -1, weight_matrix)
        if xy:
            reversi.put(xy[0], xy[1], player * -1)
            time.sleep(1)

        drawBoard(reversi, dom)

    if (reversi.count(EMPTY) == 0 or reversi.count(BLACK) == 0
            or reversi.count(WHITE) == 0):
        if reversi.count(player) > reversi.count(player * -1):
            dom.alert('You win!')
        elif reversi.count(player) < reversi.count(player * -1):
            dom.alert('You lose!')
        else:
            dom.alert('Egality!')


def acNew(reversi, dom):
    reversi.reset()
    drawBoard(reversi, dom)


callbacks = {"": acConnect, "Play": acPlay, "New": acNew}

Atlas.launch(callbacks, Reversi, readAsset("Head.html"), "ReversiTXT")
Esempio n. 9
0
    return pin


def acRed(RGB, dom, id):
    global rPin
    rPin = getPin(dom, id)


def acGreen(RGB, dom, id):
    global gPin
    gPin = getPin(dom, id)


def acBlue(RGB, dom, id):
    global bPin
    bPin = getPin(dom, id)


callbacks = {
    "": acConnect,
    "Select": acSelect,
    "Red": acRed,
    "Green": acGreen,
    "Blue": acBlue,
}

GPIOq.setup()

atlastk.launch(callbacks, RGB, open("Head.html").read())
Esempio n. 10
0
def main():
    newGame()
    atlastk.launch(CALLBACKS, headContent=HEAD)
Esempio n. 11
0
def main(headPath, callback, callbacks, title):
  Atlas.launch(_patchWithCoreObject(callbacks) if callback else _patchWithoutCoreObject(
      callbacks), callback, _getHead(headPath, title))
Esempio n. 12
0
    if (reversi.put(xy[0], xy[1], player)):
        drawBoard(reversi, dom, False)

        xy = reversi.find_best_position(player * -1, weight_matrix)
        if xy:
            reversi.put(xy[0], xy[1], player * -1)
            time.sleep(1)

        drawBoard(reversi, dom)

    if (reversi.count(EMPTY) == 0 or reversi.count(BLACK) == 0
            or reversi.count(WHITE) == 0):
        if reversi.count(player) > reversi.count(player * -1):
            dom.alert('You win!')
        elif reversi.count(player) < reversi.count(player * -1):
            dom.alert('You lose!')
        else:
            dom.alert('Egality!')


def acNew(reversi, dom):
    reversi.reset()
    drawBoard(reversi, dom)


callbacks = {"": acConnect, "Play": acPlay, "New": acNew}

Atlas.launch(callbacks, lambda: Reversi(), readAsset("Head.html"),
             "ReversiIMG")
Esempio n. 13
0
    weight_matrix = reversi.weight_matrix

    if (reversi.put(xy[0], xy[1], player)):
        drawBoard(reversi, dom, False)

        xy = reversi.find_best_position(player * -1, weight_matrix)
        if xy:
            reversi.put(xy[0], xy[1], player * -1)
            time.sleep(1)

        drawBoard(reversi, dom)

    if (reversi.count(EMPTY) == 0 or reversi.count(BLACK) == 0
            or reversi.count(WHITE) == 0):
        if reversi.count(player) > reversi.count(player * -1):
            dom.alert('You win!')
        elif reversi.count(player) < reversi.count(player * -1):
            dom.alert('You lose!')
        else:
            dom.alert('Egality!')


def acNew(reversi, dom):
    reversi.reset()
    drawBoard(reversi, dom)


callbacks = {"": acConnect, "Play": acPlay, "New": acNew}

Atlas.launch(callbacks, Reversi, open("Head.html").read())
Esempio n. 14
0
def atlas():
    Atlas.launch(callbacks, None, read_asset("Head.html"), "Stars")
Esempio n. 15
0
    dom.inner("SVG", svg)

    dom.setValue("Text", set[0]["date"] + " - " + set[len(set) - 1]["date"])


def getRelat(absol):
    return [{
        "date": absol[i]["date"],
        "value": absol[i]["value"] - absol[i - 1]["value"]
    } for i in range(1, len(absol))]


def draw(dom):
    values = dom.getValues(["Code", "Cible", "Relatif"])

    absol = fill(data, values["Code"], values["Cible"])

    drawSet(getRelat(absol) if values["Relatif"] == "true" else absol, dom)


def acConnect(dom):
    dom.inner("", BODY)

    draw(dom)


callbacks = {"": acConnect, "Redraw": lambda dom: draw(dom)}

atlastk.launch(callbacks, None, HEAD)
Esempio n. 16
0
    poppy.goto_position({id: int(dom.get_content(id))}, 0, wait=True)


def set(dom, motor, position):
    global poppy
    poppy.goto_position({motor: position}, 0, wait=False)
    dom.set_content(motor, position)


def reset(dom, motor):
    set(dom, motor, 0)


def acReset(Poppy, dom):
    global poppy
    reset(dom, "m1")
    reset(dom, "m2")
    reset(dom, "m3")
    reset(dom, "m4")
    reset(dom, "m5")
    reset(dom, "m6")


callbacks = {
    "": acConnect,
    "Move": acMove,
    "Reset": acReset,
}

Atlas.launch(callbacks, Poppy, read_asset("Head.html"), "ErgoJr")
Esempio n. 17
0
    for example in range(1, AMOUNT + 1):
        dom.end(
            "Plots",
            f'<fieldset class="hide" id="example{example}">Please wait ({example}/{AMOUNT})…</fieldset>'
        )
        dom.inner(f"example{example}",
                  f"<legend>Example {example}</legend>{run(example)}")
        dom.flush()
        dom.scroll_to(f'example{example}')
        dom.end(
            "Buttons",
            f'<button id="{example}" data-xdh-onevent="Display">{example}</button>'
        )

    dom.enable_element("Ready")
    dom.remove_class(f"example1", "hide")


def ac_display(dom, id):
    dom.add_classes(_hiding)
    dom.remove_class(f"example{id}", "hide")


_hiding = {}

for i in range(1, AMOUNT + 1):
    _hiding[f"example{i}"] = "hide"

atlastk.launch({"": ac_connect, "Display": ac_display}, None, HEAD)
Esempio n. 18
0
import atlastk as Atlas


def readAsset(path):
    return Atlas.readAsset(path, "Hello")


def acConnect(dom):
    dom.setLayout("", readAsset("Main.html"))
    dom.focus("input")


def acSubmit(dom):
    dom.alert("Hello, " + dom.getContent("input") + "!")
    dom.focus("input")


def acClear(dom):
    if (dom.confirm("Are you sure?")):
        dom.setContent("input", "")
    dom.focus("input")


callbacks = {
    "": acConnect,
    "Submit": acSubmit,
    "Clear": acClear,
}

Atlas.launch(callbacks, None, readAsset("Head.html"))
Esempio n. 19
0

def acConnect(this, dom, id):
    dom.setLayout("", readAsset("Main.html"))
    scramble(this, dom)


def acSwap(this, dom, id):
    ix, iy = convert(int(id))
    bx, by = convert(this.blank)

    if (ix == bx):
        delta = 4 if by < iy else -4
        while (by != iy):
            swap(this, dom, this.blank + delta)
            by = convertY(this.blank)
    elif (iy == by):
        delta = 1 if bx < ix else -1
        while (bx != ix):
            swap(this, dom, this.blank + delta)
            bx = convertX(this.blank)


callbacks = {
    "": acConnect,
    "Swap": acSwap,
    "Scramble": lambda this, dom, id: scramble(this, dom)
}

Atlas.launch(callbacks, Puzzle, readAsset("Head.html"), "15-puzzle")
Esempio n. 20
0
    if (bw != EMPTY) and bw == turn:
        for delta in reversible_directions(board, bw, x, y):
            reverse_piece(board, bw, x, y, delta[0], delta[1])
        board[x][y] = bw

        turn = turn * -1

    atlastk.broadcastAction("Refresh")


def ac_refresh(player, dom):
    if turn == None:
        player.__init__()
    Refresh(dom, player)


def ac_new(dom):
    init()
    atlastk.broadcastAction("Refresh")


CALLBACKS = {
    "": ac_connect,
    "Play": ac_play,
    "Refresh": ac_refresh,
    "New": ac_new
}

atlastk.launch(CALLBACKS, Player, open("Head.html").read())
Esempio n. 21
0
    else:
        dom.alert("Title can not be empty!")
        dom.focus("Title")


def ac_cancel(notes, dom):
    note = notes.notes[notes.index]

    result = dom.get_contents(["Title", "Description"])
    title = result["Title"].strip()
    description = result["Description"]

    if (title != note['title']) or (description != note['description']):
        if dom.confirm("Are you sure you want to cancel your modifications?"):
            notes.view(dom)
    else:
        notes.view(dom)


callbacks = {
    "": ac_connect,
    "ToggleDescriptions": ac_toggle_descriptions,
    "Search": ac_search,
    "Edit": ac_edit,
    "Delete": ac_delete,
    "Submit": ac_submit,
    "Cancel": ac_cancel,
}

Atlas.launch(callbacks, Notes, read_asset("Head.html"), "Notes")
Esempio n. 22
0
def atlas():
    Atlas.launch(callbacks, None, open("Head.html").read())
Esempio n. 23
0
		dom.addClass("PseudoButton", "hidden")
		dom.disableElements(["Pseudo", "PseudoButton"])
		dom.enableElements(["Message", "MessageButton"])
		dom.setContent("Pseudo", pseudo)
		dom.focus("Message")
		print("\t>>>> New user: "******"Pseudo. not available!")
		dom.setContent("Pseudo", pseudo)
		dom.focus("Pseudo")

def acSubmitMessage(chatroom, dom):
	message = dom.getContent("Message")
	dom.setContent("Message", "")
	dom.focus("Message")
	chatroom.addMessage(chatroom.pseudo, message)
	chatroom.displayMessages(dom)

def acUpdate(chatroom, dom):
	chatroom.displayMessages(dom)
	dom.setTimeout(1000, "Update")

callbacks = {
		"": acConnect,
		"SubmitPseudo": acSubmitPseudo,
		"SubmitMessage": acSubmitMessage,
		"Update": acUpdate,
	}
		
Atlas.launch(callbacks, Chatroom, readAsset("Head.html"), "Chatroom")
Esempio n. 24
0
import atlastk as Atlas


def read_asset(path):
    return Atlas.read_asset(path, "Blank")


def ac_connect(dom):
    dom.set_layout("", read_asset("Main.html"))
    dom.add_class("Input", "hidden")


def ac_show_input(dom):
    dom.remove_class("Input", "hidden")
    dom.focus("Pattern")


callbacks = {
    "":
    ac_connect,
    "Submit":
    lambda dom, id: dom.set_content("Pattern",
                                    dom.get_content("Pattern").upper()),
    "HideInput":
    lambda dom, id: dom.add_class("Input", "hidden"),
    "ShowInput":
    ac_show_input,
}

Atlas.launch(callbacks, None, read_asset("Head.html"), "Blank")
Esempio n. 25
0
            reversi.count(WHITE) == 0):
        if reversi.count(player) > reversi.count(player * -1):
            dom.alert('You win!')
        elif reversi.count(player) < reversi.count(player * -1):
            dom.alert('You lose!')
        else:
            dom.alert('Egality!')


def acNew(reversi, dom):
    reversi.reset()
    drawBoard(reversi, dom)

def acToggleLayout(reversi, dom):
    if ( reversi.layout == TXT):
        reversi.layout = IMG
    else:
        reversi.layout = TXT

    drawBoard(reversi,dom)


callbacks = {
    "": acConnect,
    "Play": acPlay,
    "New": acNew,
    "ToggleLayout": acToggleLayout,
}

Atlas.launch(callbacks, Reversi, read_asset("Head.html"), "ReversiXSL")
Esempio n. 26
0
import atlastk as Atlas

body = readAsset(body.html)


def acConnect(this, dom, id):
    dom.setLayout("", body)
    dom.focus("input")


def acSubmit(this, dom, id):
    dom.alert("Hello, " + dom.getContent("input") + "!")
    dom.focus("input")


def acClear(this, dom, id):
    if (dom.confirm("Are you sure?")):
        dom.setContent("input", "")
    dom.focus("input")


callbacks = {
    "": acConnect,  # The key is the action label for a new connection.
    "Submit": acSubmit,
    "Clear": acClear,
}

Atlas.launch(callbacks)
Esempio n. 27
0
        dom.add_class("PseudoButton", "hidden")
        #		dom.disable_elements(["Pseudo", "PseudoButton"])
        dom.disable_element("Pseudo")
        dom.enable_elements(["Message", "MessageButton"])
        #		dom.set_content("Pseudo", pseudo)
        dom.focus("Message")
        print("\t>>>> New user: "******"Pseudo. not available!")
        dom.set_content("Pseudo", pseudo)
        dom.focus("Pseudo")


def ac_submit_message(chatroom, dom):
    message = dom.get_content("Message")
    dom.set_content("Message", "")
    dom.focus("Message")
    chatroom.add_message(chatroom.pseudo, message)
    chatroom.display_messages(dom)
    Atlas.broadcast_action("Update")


callbacks = {
    "": ac_connect,
    "SubmitPseudo": ac_submit_pseudo,
    "SubmitMessage": ac_submit_message,
    "Update": lambda chatroom, dom: chatroom.display_messages(dom),
}

Atlas.launch(callbacks, Chatroom, open("Head.html").read())
Esempio n. 28
0
        if correct == len(core.secretWord):
            dom.alert("You've won! Congratulations!")
            reset(core, dom)
            return
    else:
        core.errors += 1
        showHanged(dom, core.errors)

    if core.errors >= len(HANGED_MAN):
        dom.remove_class("Face", "hidden")
        dom.alert("\nYou've run out of guesses. \nYou had " +
                  str(core.errors) + " errors and " +
                  str(len(core.correctGuesses)) + " correct guesses. " +
                  "\n\nThe word was '" + core.secretWord + "'.")
        reset(core, dom)


def acRestart(core, dom):
    if (core.secretWord != ""):
        dom.alert("You had " + str(core.errors) + " errors and " +
                  str(len(core.correctGuesses)) + " correct guesses. " +
                  "\nThe word was '" + core.secretWord + "'.")

    reset(core, dom)


callbacks = {"": acConnect, "Submit": acSubmit, "Restart": acRestart}

Atlas.launch(callbacks, Core, read_asset("Head.html"), "Hangman")
Esempio n. 29
0
# example from : https://github.com/epeios-q37/atlas-python

BODY = """
<fieldset>
 <input id="Input" data-xdh-onevent="Submit" value="World"/>
 <button data-xdh-onevent="Submit">Hello</button>
 <hr/>
 <fieldset>
  <output id="Output">Greetings displayed here!</output>
 </fieldset>
</fieldset>
"""


def ac_connect(dom):
    dom.inner("", BODY)
    dom.focus("Input")


def ac_submit(dom):
    name = dom.get_value("Input")
    dom.set_value("Output", f"Hello, {name}!")
    dom.set_value("Input", "")
    dom.focus("Input")


CALLBACKS = {"": ac_connect, "Submit": ac_submit}

atlastk.launch(CALLBACKS)
Esempio n. 30
0
    return pin


def acRed(RGB, dom, id):
    global rPin
    rPin = getPin(dom, id)


def acGreen(RGB, dom, id):
    global gPin
    gPin = getPin(dom, id)


def acBlue(RGB, dom, id):
    global bPin
    bPin = getPin(dom, id)


callbacks = {
    "": acConnect,
    "Select": acSelect,
    "Red": acRed,
    "Green": acGreen,
    "Blue": acBlue,
}

GPIOq.setup()

Atlas.launch(callbacks, RGB, read_asset("Head.html"), "RGB")