lexonomy_custom_editor/src/model/model.py

58 lines
1.4 KiB
Python
Raw Normal View History

2019-11-05 21:18:20 +00:00
from model.entry import Entry
2019-11-11 22:04:45 +00:00
from browser import window
2019-11-05 21:18:20 +00:00
class Model:
def __init__(self, names):
2019-11-11 22:04:45 +00:00
# main data stuff
2019-11-05 21:18:20 +00:00
self.entry = None
2019-11-11 22:04:45 +00:00
# report everything that happens!
2019-11-05 21:18:20 +00:00
self.log = []
2019-11-11 22:04:45 +00:00
#runtime info
self.menu_location = (0, 0)
self.menu_target = None
# modal handling
self.modal = lambda: []
2019-11-11 22:04:45 +00:00
self.modal_shown = False
# currently edited stuff
self.translation = None
self.sense = None
# choosing examples
self.chosen_examples = []
self.reset()
self.modal_reset()
2019-11-05 21:18:20 +00:00
2019-11-11 22:04:45 +00:00
def reset(self):
# do both resets at once
self.pre_reset()
self.post_reset()
def pre_reset(self):
# the reset before updating models
self.menu_target = None
2020-01-05 22:58:07 +00:00
self.modal_reset()
def post_reset(self):
# the reset after updating the models
self.chosen_examples = []
def modal_reset(self):
self.modal = lambda: []
2020-01-05 22:58:07 +00:00
self.modal_shown = False
def modal_set(self, modal):
self.modal = modal
self.modal_shown = True
2019-11-05 21:18:20 +00:00
def import_xml(self, xml_text):
parser = __new__(DOMParser())
xmlDoc = parser.parseFromString(xml_text, "text/xml")
self.entry = Entry(xmlDoc.querySelector("entry"))
2019-11-11 22:04:45 +00:00