Exemple #1
0
    def __setattr__(self, name, value):
        object.__setattr__(self, name, value)
        if name == 'x': self.b.style.left = f'{50+(value*100)}%'
        elif name == 'y': self.b.style.top = f'{50+(value*100)}%'
        elif name == 'scale_x': self.b.style.width = f'{value*100}%'
        elif name == 'scale_y': self.b.style.height = f'{value*100}%'
        elif name == 'origin':
            self.b.style.transform = f'translate({(-value[0]-.5)*100}%, {(value[1]-.5)*100}%)'
            # elif name == 'origin_y':    self.b.style.transform = f'translate({(-value-.5)*100}%, -50%)'
            # elif name == 'origin':      self.b.style.transformOrigin = f'{value[0]*100}% {value[0]*100}%'
            # elif name == 'origin':      self.b.style.transformOrigin = f'left center'

            # elif name == 'enabled': self.b.disabled = not value
        elif name == 'visible':
            self.b.style.visibility = ('hidden', 'inherit')[int(value)]
        elif name == 'model':
            if value == None: self.b.style.backgroundColor = color.clear
            elif value == 'quad': self.b.style.borderRadius = '0%'

        # if name == 'text': self.b.style.innerHTML = value
        elif name == 'update':
            if callable(value): timer.set_interval(value, 60)
            else: timer.clear_interval(update)

        elif name == 'parent': value.b.appendChild(self.b)
        elif name == 'color': self.b.style.backgroundColor = value
        elif name == 'texture':
            self.b.style.backgroundImage = f"url('{value}.jpg'), url('{value}.png')"
Exemple #2
0
 def turno(self):
     carta_corrente = self.baralho.descarta()
     if (not carta_corrente) or (carta_corrente in self.salas):
         carta_corrente.entra(self.labirinto)
         timer.clear_interval(self.interval)
         if self.rodada_corrente < 5:
             timer.set_timeout(self.rodada, 2000)
         return False
     jogadores_saindo = []
     self.apresenta(carta_corrente)
     ativos = len(self.jogadores_ativos)
     for jogador in self.jogadores_ativos:
         for carta in self.salas:
             carta.premia(jogador, ativos)
     self.atualiza()
     for jogador in self.jogadores_ativos:
         if jogador.decide() == DESISTE:
             self.jogadores_ativos.remove(jogador)
             jogadores_saindo.append(jogador)
     carta_corrente.atualiza_saldo(ativos)
     carta_corrente.divide(jogadores_saindo, self.salas)
     if not self.jogadores_ativos:
         timer.clear_interval(self.interval)
         if self.rodada_corrente < 5:
             timer.set_timeout(self.rodada, 2000)
Exemple #3
0
    def displayNextFrame():
        if element.frame >= numFrames:  # // First, see if we're done
            timer.clear_interval(
                element.intervalId)  # // If so, stop calling ourselves
            """
            del element.frame
            del element.time
            del element.intervalId
            """
            if whendone:
                whendone(element)  # // Invoke whendone function
            return

        for cssprop in animation:
            """
                // For each property, call its animation function, passing the
                // frame number and the elapsed time. Use the return value of the
                // function as the new value of the corresponding style property
                // of the specified element. Use try/catch to ignore any
                // exceptions caused by bad return values.
            """
            element.style[cssprop] = animation[cssprop](element.frame,
                                                        element.time)

        element.frame += 1  # // Increment the frame number
        element.time += timePerFrame  # // Increment the elapsed time
Exemple #4
0
 def _input_change(self, _event=None):
     if self.element:
         if self._model.value != self.element.value:
             if self._input_change_timer:
                 timer.clear_interval(self._input_change_timer)
                 self._input_change_timer = None
             self._model.value = self.element.value
Exemple #5
0
    def oncomplete(request):
        global count
        count += 1
        document.clear()
        data = json.loads(request.responseText)
        ld = {}
        for bikepoint in data:
            idstring = bikepoint["id"]
            idno = int(idstring.split("_")[-1])
            if idno not in bikepoints: continue
            bikes = [
                d for d in bikepoint["additionalProperties"]
                if d["key"] == "NbBikes"
            ][0]
            bikecount = int(bikes["value"])
            ld[bikepoints[idno]] = bikecount

            now = datetime.datetime.now()
            timenow = now.hour + now.minute / 100
            timeseries[bikepoints[idno]].append((timenow, bikecount))

        if count > 1:
            pdd = brycharts.PairedDataDict("Time", "Bikes available",
                                           timeseries)
            brycharts.LineGraph(document, pdd, title)
        else:
            ld = brycharts.LabelledData(ld, "Bikes available")
            brycharts.BarChart(document, ld, title)
        if count == 30: timer.clear_interval(timerid)
Exemple #6
0
 def stop_timer(ev):
     global _timer
     timer.clear_interval(_timer)
     _timer = None
     t = 0
     doc['_timer'].text = '%.2f' % 0
     doc['start'].text = 'Start'
Exemple #7
0
    def move_rect():
        # the attributes of the SVG element are strings, they must be explicitely
        # converted into integers
        rect.attrs["y"] = int(rect.attrs["y"]) + 1

        # ends animation when the rectangle reaches its target
        if int(rect.attrs["y"]) > 50:
            timer.clear_interval(loop)
Exemple #8
0
 def stop(self, *args):
     if self._running:
         for handle in self._scheduled:
             handle.pause()
         self._clean_schedule()
         timer.clear_interval(self._cleanup_timer)
         self._cleanup_timer = None
         self._running = False
Exemple #9
0
    def run(self, *args, **kwargs):
        """"""
        delay = w.get_value('delay')
        pulse = w.get_value('pulse')

        if hasattr(self, 'timer_cue'):
            timer.clear_interval(self.timer_cue)
        self.timer_cue = timer.set_interval(lambda: self.trial(pulse), delay)
Exemple #10
0
 def update_download_btn(self, req):
     if req.status != 200:
         return
     timer.clear_interval(self.wait_btn_timer)
     # print(document["download-mp4"].__dict__)
     document["download-mp4"].href = self.video_path
     document["download-mp4"].className = "ui primary button"
     document["download-mp4"].click()
Exemple #11
0
 def update(self):
     """ FIXME: We need handle the case when the root node
                returns a new element(s) on update
     """
     elems = self.root.update()
     if self.update_timer is not None:
         timer.clear_interval(self.update_timer)
     self.update_timer = None
Exemple #12
0
 def stop(self):
     if self._running:
         for handle in self._scheduled:
             handle.pause()
         self._clean_schedule()
         timer.clear_interval(self._cleanup_timer)
         self._cleanup_timer = None
         self._running = False
Exemple #13
0
 def movendo():
     moventes = [peca for peca in moventes if self.find(peca.pos, sentido).recebe(peca)]
     if not moventes:
         pass
         timer.clear_interval(_timer)
         vazios = [casa for casa in self.casas.values() if casa.peca is None]
         shuffle(vazios)
         vazios.pop().joga()
     return moventes
Exemple #14
0
 def rodando(wait=lambda: None):
     if self.angle in range(10):
         self.cena.forward = y.rotate({'angle': self.angle*pi/20, 'axis': vec(a, b, c)._vec})
         self.angle += 1
     else:
         timer.clear_interval(_timer)
         f = self.cena.forward
         self.cena.forward = vec(int(f.x*2), int(f.y*2), int(f.z*2))._vec
         print(self.cena.forward)
Exemple #15
0
def stop_timer(e):
    global _timer, _alarm
    clear_interval(_timer)
    _timer = None
    calculate_countdown(timer_length)
    display_mins_secs()
    start_button.text = 'Start'
    if stop_button.text is not 'Stop':
        stop_button.text = 'Stop'
        clear_interval(_alarm)
Exemple #16
0
 def _model_change(self, event=None):
     if self._model_change_timer:
         timer.clear_interval(self._model_change_timer)
         self._model_change_timer = None
     if self.element:
         if 'value' in event.data:
             new_val = event.data['value']
         else:
             new_val = self._model.value
         if not self.element.value == new_val:
             self.element.value = new_val
Exemple #17
0
def generateEvent():

    timer.clear_interval(idTimer)

    select = document["select-size"]
    tailleChoisie = select.options[select.selectedIndex].value

    global tailleTableau
    tailleTableau = int(tailleChoisie)

    ajaxEvent()
Exemple #18
0
def set_timer(eventid, ms):
    def fire():
        nonlocal eventid

        pygame.event.post(pygame.event.Event(eventid))

    if eventid not in set_timer.timers:
        set_timer.timers[eventid] = timer.set_interval(fire, ms)
    else:
        timer.clear_interval(set_timer.timers[eventid])
        if ms != 0:
            set_timer.timers[eventid] = timer.set_interval(fire, ms)
Exemple #19
0
def tick():
    global current_block, next_block, play_grid
    if not test_new_position("down"):
        freeze_current_block()
        play_grid.remove_complete_lines(current_block.y)
        if not play_grid.remove_complete_lines(current_block.y) and \
           not current_block.y < (h - boarder_size):
            timer.clear_interval(tick_timer)
            alert("Game Over")
        current_block = next_block
        next_block = Block()
        next_block.paint("next")
        play_grid.draw_grid()
Exemple #20
0
def show():
    global _timer, _alarm
    if countdown.text is '00:00':
        clear_interval(_timer)
        _timer = None
        calculate_countdown(timer_length)
        start_button.text = 'Start'
        stop_button.innerHTML = 'Stop ' + "&#128266;"
        if stop_button.text is not 'Stop':
            _alarm = set_interval(audio.play, 1000)
    else:
        calculate_countdown(counter - time.time())
        display_mins_secs()
Exemple #21
0
 def rodando(wait=lambda: None):
     if self.angle in range(10):
         self.cena.forward = y.rotate({
             'angle': self.angle * pi / 20,
             'axis': vec(a, b, c)._vec
         })
         self.angle += 1
     else:
         timer.clear_interval(_timer)
         f = self.cena.forward
         self.cena.forward = vec(int(f.x * 2), int(f.y * 2),
                                 int(f.z * 2))._vec
         print(self.cena.forward)
Exemple #22
0
 def wait_for_condition():
     result = wait_for()
     if result is True:
         timer.clear_interval(test_timer)
         try:
             return function(inst)
         except:
             exc = traceback.format_exc()
             print(exc, file=sys.stderr)
             window.__BRYTHON_UNITTEST_RESULTS__ = {
                 'exception': exc
             }
     else:
         print("'wait_for' condition is not fulfilled, wait for one second")
Exemple #23
0
 def movendo():
     moventes = [
         peca for peca in moventes
         if self.find(peca.pos, sentido).recebe(peca)
     ]
     if not moventes:
         pass
         timer.clear_interval(_timer)
         vazios = [
             casa for casa in self.casas.values() if casa.peca is None
         ]
         shuffle(vazios)
         vazios.pop().joga()
     return moventes
Exemple #24
0
 def start_timer(ev):
     global _timer, counter
     if _timer is None:
         counter = time.time()
         _timer = timer.set_interval(show, 10)
         doc['start'].text = 'Hold'
     elif _timer == 'hold':  # restart
         # restart timer
         counter = time.time() - float(doc['_timer'].text)
         _timer = timer.set_interval(show, 10)
         doc['start'].text = 'Hold'
     else:  # hold
         timer.clear_interval(_timer)
         _timer = 'hold'
         doc['start'].text = 'Restart'
Exemple #25
0
    def change_params_callback(self, ev):
        self.clear_canvas()
        exec_string = "2 - x"

        def dxdt(x):
            return 2 - x

        self.net = FixedLattice(dxdt, float(self.inputs['dt'].value),
                                int(self.inputs['n_nodes'].value))
        self.canvas.width = 900
        self.canvas.height = 900
        global _timer
        timer.clear_interval(_timer)
        _timer = timer.set_interval(self.update,
                                    10 * float(self.inputs['dt'].value))
Exemple #26
0
def start_timer(e):
    global _timer, counter
    if _timer is None:
        set_timer()
        if timer_length == 0:
            alert("Time must be greater than 0")
        else:
            counter = time.time() + timer_length
            _timer = set_interval(show, 1000)
            start_button.text = 'Hold'
    elif _timer == 'hold':  # restart
        # restart timer
        counter = time.time() + float((int(countdown.text[:2]) * 60) +
                                      int(countdown.text[3:]))
        _timer = set_interval(show, 1000)
        start_button.text = 'Hold'
    else:  # hold
        clear_interval(_timer)
        _timer = 'hold'
        start_button.text = 'Restart'
def parse_queue_exe():
    global queue_exe, timer, idx, running
    if not queue_exe:
        return
    if queue_exe[idx] not in ("found", "no way"):
        cell_id, color = queue_exe[idx].split(' ')
        cell = document[cell_id]
        cell.style.backgroundColor = color
        idx += 1
    else:
        results = queue_exe[idx]
        idx = 0
        queue_exe = list()
        clear_interval(timer)
        timer = None
        enable_button(document["reset"])
        enable_button(document["randomize"])
        if results == "found":
            change_status_text("Path found. Click Reset to try again",
                               STATES_COLOR["path"], "white")
        else:
            change_status_text("No path found. Click Reset to try again",
                               "transparent", "black")
Exemple #28
0
def congrats_msg(rows, columns):
    """
    Checks that all row and colums have distinct values and the length equals nine(9).
    Prints a congratulatory message if true and stops the clock
    """
    count = 0
    for i in range(0, 9):
        if len(set(rows[i]['values'])) == 9 and len(set(
                columns[i]['values'])) == 9:
            count += 1
    if count == 9:
        #stop the clock
        timer1 = cd.timer1
        timer2 = cd.timer2
        timer3 = cd.timer3

        timer.clear_interval(timer1)
        timer.clear_interval(timer2)
        timer.clear_interval(timer3)
        print('genius babe')
        document['winner'].class_name = 'winner'
        document['pause'].class_name = 'hide'
def clock(event):
    """
    starts the clock
    """
    if document['pause_btn'].class_name == "fas fa-pause":
        timer.clear_interval(timer1)
        timer.clear_interval(timer2)
        timer.clear_interval(timer3)

        document['pause_btn'].class_name = "fas fa-play"
        document['seconds'].class_name = 'time_style_pause'
        document['minute'].class_name = 'time_style_pause'
        document['hour'].class_name = 'time_style_pause'
        document['container'].class_name = 'unclickable'
        document['layover_container'].class_name = 'layover_container'

    elif document['pause_btn'].class_name == "fas fa-play":
        run()
        document['pause_btn'].class_name = "fas fa-pause"
        document['seconds'].class_name = 'time_style_start'
        document['minute'].class_name = 'time_style_start'
        document['hour'].class_name = 'time_style_start'
        document['container'].class_name = ''
        document['layover_container'].class_name = 'hide'
Exemple #30
0
def stop_timer(ev):
    timer.clear_interval(tick_timer)
Exemple #31
0
 def stop(self):
     """"""
     timer.clear_interval(self.timer_cue)
Exemple #32
0
def clear_timer(n):
	global Timer1
	if Timer1[n] is not None:
		timer.clear_interval(Timer1[n])
Exemple #33
0
def clear_timer_all():
	global Timer1
	for t in Timer1:
		if t is not None:
			timer.clear_interval(t)