-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathengmonarchs.py
126 lines (96 loc) · 3.28 KB
/
engmonarchs.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import time,copy,sys
from dataclasses import dataclass
from browser import document, html, timer, window
import dragdrop
from dragdrop import px
import random
@dataclass
class MonContent(dragdrop.Content):
Dates: str
Height: str
Monarch: str
Title: str
Width: str
WikiURL: str
img_url: str
text: str
class DragDrop(dragdrop.DragDrop):
def getDeck(self,deck):
self.contentDeck= [MonContent(**p) for p in deck]
def makeHeader(self,content,cardno):
return self.makeHeaderText(content.Title,cardno)
def makeFrontImage(self,content,cardno):
image_id = f'I{cardno}'
body_id = f'B{cardno}'
img = content.img_url
return html.DIV(
html.IMG(
src=img,
id=image_id,
style={"width":px(self.card_width - 10 ),"height":px(self.card_height - 30 - 14)}
),
Class="card-body",
id=body_id
)
def makeBackImage(self,content,cardno):
image_id = f'I{cardno}'
body_id = f'B{cardno}'
txt_id=f'T{cardno}'
date_id=f'D{cardno}'
img = content.img_url
return html.DIV(
html.DIV(
html.A(content.text,href="https://en.wikipedia.org/"+content.WikiURL,target='_blank'),
id=txt_id,
Class="card-text"
)+
html.DIV(html.SPAN(content.Dates),id=date_id,Class="date"),
id=body_id
)
pass
def flipper1(self, card):
super().flipper1(card)
dk = self.get_deck_for_card(card)
if dk.flipped or True:
txt = card.firstChild.nextSibling.innerHTML
card.firstChild.nextSibling.innerHTML = ""
# Naughty - parking txt in card structure
#print(f'flipper1 {txt}')
card.zz2 = txt
def flipper2(self, card):
dk = self.get_deck_for_card(card)
if dk.flipped or True:
card.firstChild.nextSibling.innerHTML = card.zz2
super().flipper2(card)
if dk.flipped or True:
txt = card.firstChild.nextSibling.innerHTML
card.firstChild.nextSibling.innerHTML = ""
# Naughty - parking txt in card structure
#print(f'flipper2b {txt}')
card.zz2 = txt
return
def flipper3(self, card):
super().flipper3(card)
dk = self.get_deck_for_card(card)
if dk.flipped or True:
#print(f'flipper3 {card.zz2}')
card.firstChild.nextSibling.innerHTML = card.zz2
print(card.id, dk.flipped)
if dk.flipped:
txt=None
try:
txt= document['T'+card.id[1:]]
date=document['D'+card.id[1:]]
except:
return
print("XX", date.offsetTop)
offset=date.offsetTop
print("YY")
print(card.id, offset, txt.offsetHeight)
if txt:
for s in range(20,1,-1):
print(f'{txt.id} S {s}')
txt.style.fontSize=px(s)
if txt.offsetHeight <= offset-35:
break
# whendone??