Coverage for modules/org/openteacher/interfaces/qt/lessons/topo/topo : 64%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
|
#! /usr/bin/env python3 # -*- coding: utf-8 -*-
# Copyright 2011-2012, Milan Boers # Copyright 2011-2013, 2017, Marten de Vries # # This file is part of OpenTeacher. # # OpenTeacher is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # OpenTeacher is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with OpenTeacher. If not, see <http://www.gnu.org/licenses/>.
"""The module"""
"all": x, "selfstudy": x, "student@home": x, "student@school": x, "teacher": x, "code-documentation": x, "test-suite": x, "default": -1, }
self._mm.mods(type="translator"), self._mm.mods(type="dataTypeIcons"), ) self._mm.mods(type="event"), self._mm.mods(type="ui"), self._mm.mods(type="lessonDialogs"), self._mm.mods(type="buttonRegister"), self._mm.mods(type="topoTeacher"), self._mm.mods(type="topoEnterer"), self._mm.mods(type="testsViewer"), )
# Data type & icon
# Add the button to start except (IndexError, KeyError): pass else: #reasonable priority
# Signals
#setup translation global _ global ngettext
#load translator except IndexError: pass else:
#Translations global _ global ngettext
except IndexError: _, ngettext = str, lambda a, b, n: a if n == 1 else b else: self._mm.resourcePath("translations") )
enterWidget, teachWidget, resultsWidget )
#so they can send changedEvents
"""Lesson object (that means: this techwidget+enterwidget)"""
#defaults
def changed(self): return self._changed
def changed(self, value): self._changed = value self.changedEvent.send()
def changed(self): del self._changed
def path(self):
def path(self, path): """Make sure not to set this before .resources !""" self._path = path if path: # Update map name self.enterWidget.mapChooser.setItemText(0, path) # Update title self.retranslate()
def list(self): return self.enterWidget.list
def list(self, list): # Load the list self.enterWidget.list = list # Update the widgets self.enterWidget.updateWidgets() # Update results widget self.resultsWidget.updateList(list, "topo")
def resources(self): fd, screenshotPath = tempfile.mkstemp() os.close(fd) self._tempFiles.add(screenshotPath)
screenshot = self.enterWidget.enterMap.getScreenshot() screenshot.save(screenshotPath, "PNG")
return { "mapPath": self.enterWidget.mapChooser.currentMap["mapPath"], "mapScreenshot": screenshotPath, }
def resources(self, resources): #TRANSLATORS: used as a label in case a filename of a topo #TRANSLATORS: lesson isn't available. (E.g. because it's #TRANSLATORS: downloaded from some kind of web service.) fileName = _("Import source")
self.enterWidget.mapChooser.insertItem(0, fileName, str({'mapPath': resources["mapPath"], 'knownPlaces': ''})) self.enterWidget.mapChooser.setCurrentIndex(0) self.enterWidget.mapChooser.activated.emit(0)
#close current lesson (if one). Just reuse all the logic. self.fileTab.currentTab = self.enterWidget self.tabChanged() if self.fileTab.currentTab == self.teachWidget: #the tab change wasn't allowed. return False
#ask if the user wants to save if self.changed: lessonDialogsModule = self._modules.default("active", type="lessonDialogs") if not lessonDialogsModule.okToClose(parent=self.fileTab.currentTab): return False
self.fileTab.close() self.stopped.send()
return True
self.fileTab.currentTab = self.enterWidget
self.resultsWidget.updateList(list, "topo") self.changed = True
lessonDialogsModule = self._modules.default("active", type="lessonDialogs") lessonDialogsModule.onTabChanged(self.fileTab, self.enterWidget, self.teachWidget, lambda: self.teachWidget.initiateLesson(self.enterWidget.list, self.enterWidget.mapChooser.currentMap["mapPath"]))
for file in self._tempFiles: os.remove(file)
self.fileTab.title = _("Topo lesson: %s") % os.path.basename(self.path) else:
|