-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdialog.py
46 lines (38 loc) · 1.22 KB
/
dialog.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#
# Microlog. Copyright (c) 2023 laffra, dcharbon. All rights reserved.
#
import js # type: ignore
import pyodide # type: ignore
from dashboard import canvas
FLIP_DISTANCE = 70
MOUSE_OFFSET = 20
class Dialog():
def __init__(self):
self.showing = False
self.dialog = js.jQuery("#dialog")
def show(self, canvas: canvas.Canvas, x:float, y:float, html:str):
self.canvas = canvas
self.showing = True
self.addCloseButton()
self.canvas.canvas.parent().append(
self.dialog
.draggable()
.resizable()
.html(html)
.css("left", x)
.css("top", y)
.addClass("ui-widget-content")
.css("position", "absolute")
.css("display", "block")
.css("max-height", js.jQuery("body").height() - 100)
)
def hide(self):
self.showing = False
self.dialog.css("display", "none")
def addCloseButton(self):
self.dialog.append((js.jQuery("<div>")
.addClass("dialog-close-button")
.text("X")
.click(pyodide.ffi.create_proxy(lambda event: self.hide()))
))
dialog = Dialog()