Guest User

PyScript -> soat

a guest
May 1st, 2022
609
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.85 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <title>Panel Example</title>
  5.     <meta charset="UTF-8">
  6.     <link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css"/>
  7.     <script defer src="https://pyscript.net/alpha/pyscript.js"></script>
  8.     <style>
  9.         table.fixed { table-layout:fixed; width: 600px;}
  10.         table.fixed td { text-align:left; font-size: 100px; width: 20%}
  11.     </style>
  12. </head>
  13. <body>
  14.     <table class="fixed" style="align-self: center; position: absolute; margin: 100px;">
  15.             <td><span id="soat"></span></td>
  16.             <td><span class="blinker"></span></td>
  17.             <td><span id="daqiqa"></span></td>
  18.             <td><span class="blinker"></span></td>
  19.             <td><span id="soniya"></span></td>
  20.         </tr>
  21.         <tr>
  22.             <td></td>
  23.             <td></td>
  24.             <td><span id="til"></span></td>
  25.             <td></td>
  26.             <td></td>
  27.         </tr>
  28.     </table>
  29.  
  30. <py-script>
  31. from js import document
  32. from asyncio import sleep
  33. from datetime import datetime
  34.  
  35. soat = document.querySelector("#soat")
  36. daqiqa = document.querySelector("#daqiqa")
  37. soniya = document.querySelector("#soniya")
  38. blinkers = document.querySelectorAll(".blinker")
  39. til = document.querySelector("#til")
  40.  
  41. async def run():
  42.     blink = True
  43.     while True:
  44.         _blinker = "" if blink else "👁"
  45.         _til = "" if blink else "👅"
  46.         hozirgi_vaqt = datetime.now()
  47.         _soat, _daqiqa, _soniya = hozirgi_vaqt.hour, hozirgi_vaqt.minute, hozirgi_vaqt.second
  48.         soat.textContent = f"{_soat:0<2}"
  49.         daqiqa.textContent = f"{_daqiqa:0<2}"
  50.         soniya.textContent = f"{_soniya:0<2}"
  51.         til.textContent = _til
  52.         for blinker in blinkers:
  53.             blinker.textContent = _blinker
  54.         blink = not blink
  55.         await sleep(1)
  56. await run()
  57. </py-script>
  58.  
  59. </body>
  60. </html>
Advertisement
Add Comment
Please, Sign In to add comment