def confirmQuit(self, okayCallback): self.script.disableControls() def quit(): self.script.enableControls() self.script.refreshTheater() self.preventEscapeLock = False d = gui.ConfirmDialog(_("Confirm Quit"), [ _("You have unsaved changes!"), _("If you quit now, you'll lose them forever!"), _("Are you sure you want to quit?") ]) d.connect(gui.CLOSE, quit) d.okayButton.connect(gui.CLICK, okayCallback) self.preventEscapeLock = True d.open()
def loadTeacherBackdrop(self, _widget): username = _widget.value try: downloadTeachersImage(username) except Exception, e: print "Could not connect.", e d = gui.ConfirmDialog(_("Connection Error"), [ _("You are not connected to the internet."), _("Connect and then click Okay below.") ]) def tryAgain(): d.close() self.teacherBackdrop() d.connect(gui.CLOSE, self.script.refreshTheater) d.okayButton.connect(gui.CLICK, tryAgain) d.open()
def teacherBackdrop(self): teachers = getTeacherList() if teachers: d = gui.TeacherDialog() d.loadTeachers(teachers) d.connect(gui.CLOSE, self.script.refreshTheater) d.connect(gui.CHANGE, self.loadTeacherBackdrop) d.open() else: d = gui.ConfirmDialog(_("Connection Error"), [ _("You are not connected to the internet."), _("Connect and then click Okay below.") ]) def tryAgain(): d.close() self.teacherBackdrop() d.connect(gui.CLOSE, self.script.refreshTheater) d.okayButton.connect(gui.CLICK, tryAgain) d.open()
def export(self, _widget, dialog): fancy = self.script.controls["file-select-export-fancy"].value amount = self.script.controls["file-select-export-amount"].value location = self.script.controls["file-select-export-location"].value if fancy == "Fancy" and location == "Teacher" and amount == "Tons": d = gui.ConfirmDialog(_("Continue Upload?"), [ _("Uploading a script with these settings might take a long time." ), _("Continue the upload anyway?") ]) def continueAnyway(): d.close() dialog.close() self.exportActual(fancy, amount, location) d.connect(gui.CLOSE, self.script.refreshTheater) d.okayButton.connect(gui.CLICK, continueAnyway) d.open() else: dialog.close() self.exportActual(fancy, amount, location)
def confirmActionDialog(self, title, message, okayFunction=None, cancelFunction=None, arguments=None): d = gui.ConfirmDialog(title, message) d.connect(gui.CLOSE, self.script.refreshTheater) if okayFunction is not None: def okayAndCloseFunction(arguments): okayFunction(arguments) d.close() self.script.controls[ "file-button-save"].disabled = not self.script.unsaved self.script.controls["file-button-save"].repaint() self.refreshPanel() d.okayButton.connect(gui.CLICK, okayAndCloseFunction, arguments) else: d.okayButton.connect(gui.CLICK, d.close) if cancelFunction is not None: def cancelAndCloseFunction(arguments): cancelFunction(arguments) d.close() self.script.controls[ "file-button-save"].disabled = not self.script.unsaved self.script.controls["file-button-save"].repaint() self.refreshPanel() d.cancelButton.connect(gui.CLICK, cancelAndCloseFunction, arguments) else: d.cancelButton.connect(gui.CLICK, d.close) d.open()
def exportActual(self, fancy, amount, location): pecial_button = None if hacks['xo']: t = gui.Table() t.tr() if self.script.journal: t.td(gui.Image("games/broadway/images/dialog-folders.png")) t.tr() t.td(gui.Label(_("Folders"))) else: t.td(gui.Image("games/broadway/images/dialog-journal.png")) t.tr() t.td(gui.Label(_("Journal"))) special_button = gui.Button(t) def closeAndExportAs(): dialog.close() self.script.refreshTheater() self.script.journal = not self.script.journal self.exportActual(fancy, amount, location) special_button.connect(gui.CLICK, closeAndExportAs) self.script.refreshTheater() if location == "Here": if fancy == "Fancy": valueType = ['.html'] mimeType = "text/html" else: valueType = ['.txt'] mimeType = "text/plain" if self.script.journal: exportName = self.script.metadata.title dialog = gui.JournalDialog(_("Export a script"), exportName, True, special_button=special_button) dialog.loadJournalItems( datastore.find({'mime_type': mimeType})[0]) else: exportName = filenameStrip( self.script.metadata.title) + valueType[0] dialog = gui.FileDialog(_("Export as %(fanciness)s") % {"fanciness": _(fancy)}, _("Okay"), path=directories['export-folder'], filter=valueType, default=exportName, favorites=defaults['favorites'], special_button=special_button) dialog.open() dialog.connect(gui.CLOSE, self.script.refreshTheater) dialog.connect(gui.CHANGE, self.exportFile, fancy, amount, dialog) else: teachers = getTeacherList() if teachers: dialog = gui.TeacherDialog() dialog.loadTeachers(teachers) dialog.connect(gui.CLOSE, self.script.refreshTheater) dialog.connect(gui.CHANGE, self.upload, fancy, amount, dialog) dialog.open() else: dialog = gui.ConfirmDialog(_("Connection Error"), [ _("You are not connected to the internet."), _("Connect and then click Okay below.") ]) def tryAgain(): dialog.close() self.exportActual(fancy, amount, location) dialog.connect(gui.CLOSE, self.script.refreshTheater) dialog.okayButton.connect(gui.CLICK, tryAgain) dialog.open()
if fancy == "Fancy": self.script.export( (directories['temp'] + "tempExport", fancy, amount)) elif fancy == "Plain": self.script.export( (directories['temp'] + "tempExport", fancy, amount)) except Exception, e: print "Failed to export file.", e try: success = uploadToTeacher(teacher, self.script.metadata.title, fancy, directories['temp'] + "temp.bdw", directories['temp'] + "tempExport") except Exception, e: print "Failed to upload file.", e d = gui.ConfirmDialog(_("Upload Error"), [ _("There was a problem uploading the script."), _("Do you want to try again?") ]) def tryAgain(): d.close() self.upload(_widget, fancy, amount, d) d.connect(gui.CLOSE, self.script.refreshTheater) d.okayButton.connect(gui.CLICK, tryAgain) d.open() def exportFile(self, _widget, fancy, amount, dialog): fullPath = _widget.value dialog.close() if self.script.journal: dsObject = datastore.create()