Ejemplo n.º 1
0
def on_complete(req):
    if req.status == 200 or req.status == 0:
        InfoDialog("Hello", req.text)
        document['lat'] <= "blah "

    else:
        InfoDialog("Error", req.text)
Ejemplo n.º 2
0
def test_browser_widgets_dialog():

    from browser.widgets.dialog import InfoDialog

    # Info box with customized "Ok" button
    d1 = InfoDialog("Test", "Information message", ok="Got it")

    from browser.widgets.dialog import InfoDialog

    # Info box that disappears after 3 seconds
    d1 = InfoDialog("Test", "Closing in 3 seconds", remove_after=3)

    from browser import bind
    from browser.widgets.dialog import InfoDialog, EntryDialog

    d = EntryDialog("Test", "Name")

    @bind(d, "entry")
    def entry(ev):
        value = d.value
        d.close()
        InfoDialog("Test", f"Hello, {value} !")

    ## added
    entry(evt)

    from browser import bind, html
    from browser.widgets.dialog import Dialog, EntryDialog, InfoDialog

    translations = {'Français': 'Salut', 'Español': 'Hola', 'Italiano': 'Ciao'}

    d = Dialog("Test", ok_cancel=True)

    style = dict(textAlign="center", paddingBottom="1em")

    d.panel <= html.DIV("Name " + html.INPUT(), style=style)
    d.panel <= html.DIV(
        "Language " + html.SELECT(html.OPTION(k) for k in translations),
        style=style)

    # Event handler for "Ok" button
    @bind(d.ok_button, "click")
    def ok(ev):
        """InfoDialog with text depending on user entry, at the same position as the
        original box."""
        language = d.select_one("SELECT").value
        prompt = translations[language]
        name = d.select_one("INPUT").value
        left, top = d.scrolled_left, d.scrolled_top
        d.close()
        d3 = InfoDialog("Test", f"{prompt}, {name} !", left=left, top=top)

    ## added
    translations[0] = "test"  # mockbrython hashes to 0, avoid KeyError
    ok(evt)
Ejemplo n.º 3
0
def show(ev): # display dialog 
    inp_user = doc['input_user'].value # grab value from browser
    inp_site = doc['input_site'].value # grab value from browser
    inp_pass = doc['input_pass'].value # grab value from browser
    print(f"inp_user: {inp_user}") # console log
    print(f"inp_site: {inp_site}") # console log
    print(f"inp_pass: {inp_pass}") # console log
    
    if inp_pass == "" or inp_site == "" or inp_pass == "":
        doc['bodyy'] <= "Please fill out inputs!\n" # error for empty space
        raise SystemExit 
    
    
    if len(inp_site) < 6: # if site name is too small
        inp_site = inp_site + inp_site + inp_site # triple its size 
    
    site_key1 = ord(inp_site[:1]) # ord of first letter
    site_key2 = ord(inp_site[1:2]) # ord of second letter
    site_key3 = 0 # starting value
    for letter in inp_site[3:]:
        site_key3 += ord(letter) # ord of rest of letters

    
    moving_pass = inp_pass # make temp moving pass
    
    moving_pass = encode(moving_pass, site_key1) # first encode
    moving_pass = encode(moving_pass, site_key2) # second encode
    moving_pass = encode(moving_pass, site_key3) # third encode
    
    
    end_pass = moving_pass + encode(inp_user, global_key) # duplicate with offset
    
    InfoDialog("New Password: "******"{end_pass}") # display the new pass
Ejemplo n.º 4
0
 def ok(ev):
     """InfoDialog with text depending on user entry, at the same position as the
     original box."""
     language = d.select_one("SELECT").value
     prompt = translations[language]
     name = d.select_one("INPUT").value
     left, top = d.scrolled_left, d.scrolled_top
     d.close()
     d3 = InfoDialog("Test", f"{prompt}, {name} !", left=left, top=top)
Ejemplo n.º 5
0
def myAlert(txt):
    global canMouse
    canMouse=False
    
    document["help"].style["border-style"]="inset"
    d=InfoDialog("Alert!",txt,ok=True, default_css=False)
    @bind(d.ok_button, "click")
    def ok(ev):
        global canMouse
        document["help"].style["border-style"]="outset" 
        canMouse=True
Ejemplo n.º 6
0
def settings_help(event):
    config_id = str(event.currentTarget.value)
    help_info = help_data(document.select(".help"), config_id)

    config_message = ""
    for config_item in ["Description", "Valid Options", "Default Value"]:
        if help_info[0][config_item]:
            config_message += "%s: %s\n" % (config_item,
                                            help_info[0][config_item])

    InfoDialog(config_id, config_message, ok="Got it")
Ejemplo n.º 7
0
 def _open(ev):
     if not websocket.supported:
         InfoDialog("websocket",
                    "WebSocket is not supported by your browser")
         return
     global ws
     # open a web socket
     ws = websocket.WebSocket("wss://echo.websocket.org")
     # bind functions to web socket events
     ws.bind('open', on_open)
     ws.bind('message', on_message)
     ws.bind('close', on_close)
Ejemplo n.º 8
0
 def help(ev) :
     global canMouse
     if not canMouse: return
     canMouse=False
     
     txt="""Click on cells to build cages, then click on number button to select 
     total for cage.<p>When complete, press 'Solve'.
     <p>
     Press 'Sample' for a sample puzzle. 
     <p>
     For background see <a href='https://en.wikipedia.org/wiki/Killer_sudoku'>https://en.wikipedia.org/wiki/Killer_sudoku</a>
     """
     document["help"].style["border-style"]="inset"
     d=InfoDialog("Help",txt,ok=True, default_css=False)
     @bind(d.ok_button, "click")
     def ok(ev):
         global canMouse
         canMouse=True
         document["help"].style["border-style"]="outset"
Ejemplo n.º 9
0
import sys
import builtins
import re

import tb as traceback

from browser import bind, console, document, window, html, DOMNode, worker, timer
from browser.widgets.dialog import Dialog, InfoDialog

if not hasattr(window, "SharedArrayBuffer"):
    InfoDialog("Not available",
        "This program cannot run because SharedArrayBuffer is not supported.<br>"
        "This is probably because your server does not set the required<br>"
        "HTTP headers:<br>"
        "cross-origin-embedder-policy= 'require-corp'<br>"
        "cross-origin-opener-policy= 'same-origin'")
    sys.exit()

py_worker = worker.Worker("python-worker")

class Trace:

    def __init__(self):
        self.buf = ""

    def write(self, data):
        self.buf += str(data)

    def format(self):
        """Remove calls to function in this script from the traceback."""
        lines = self.buf.split("\n")
Ejemplo n.º 10
0
def test():
    InfoDialog("Error", "asdasd")
Ejemplo n.º 11
0
def hello(event):
    InfoDialog("Demo", "Hello world!", left=event.x, top=event.y)
Ejemplo n.º 12
0
 def entry(ev):
     value = d.value
     d.close()
     InfoDialog("Test", f"Hello, {value} !")
Ejemplo n.º 13
0
 def on_close(evt):
     # websocket is closed
     InfoDialog("websocket", "Connection is closed")
     document['openbtn'].disabled = False
     document['closebtn'].disabled = True
     document['sendbtn'].disabled = True
Ejemplo n.º 14
0
 def on_message(evt):
     # message received from server
     InfoDialog("websocket", f"Message received : {evt.data}")
Ejemplo n.º 15
0
 def on_open(evt):
     document['sendbtn'].disabled = False
     document['closebtn'].disabled = False
     document['openbtn'].disabled = True
     InfoDialog("websocket", f"Connection open")
Ejemplo n.º 16
0
 def alert(event):
   InfoDialog("Hello", "버튼이 눌렸다!")