def load(self, path):
     lines = None
     try:
         f = codecs.open(path, "r", "utf-8")
         lines = [line.strip() for line in f]
         f.close()
     except OSError, e:
         dialogs.showErrorMessage(None, unicode(e), "Lesen fehlgeschlagen")
         return
 def setIntroVideo(self, name):
     filename = os.path.join(self.scene_folder, "intro.txt")
     if name == None:
         try:
             if os.path.exists(filename):
                 os.remove(filename)     
             return   
         except OSError, e:
             dialogs.showErrorMessage(self.parent.frame, unicode(e), "Löschen fehlgeschlagen")
             return
         except IOError, e:
             dialogs.showErrorMessage(self.parent.frame, unicode(e), "Löschen fehlgeschlagen")
             return
 def save(self):
     output = u""
     if not self.path:
         return
     if self.image:
         output += u"image " + self.image + lf
     if self.name:
         output += u"name " + self.name + lf
     try:
         with codecs.open(self.path, "w", "utf-8") as f:
             f.write(output)
     except OSError, e:
         dialogs.showErrorMessage(None, unicode(e), "Speichern fehlgeschlagen")
         return
 def getScriptCode(self):
     output = unicode("")
     ifblock = False
     image_written = False
     atmo_loop_written = False
     atmo_written = False
     atmo_volume_written = False
     color_written = False
     f = codecs.open(self.path, "r", "utf-8")
     try:
         lines = [line.strip() for line in f]
     except OSError, e:
         dialogs.showErrorMessage(self.parent.frame, unicode(e), "Speichern fehlgeschlagen")
         return
 def save(self):
     output = self.getScriptCode()
     try:
         original_path = self.path
         backup_path = self.path + "~"
         if self.parent.config.save_backups:
             shutil.copyfile(original_path, backup_path)
         f = codecs.open(self.path, "w", "utf-8")
         f.write(output)
         f.close()
         self.modified = False
         self.logger.debug(self.path + " saved")
     except OSError, e:
         dialogs.showErrorMessage(self.parent.frame, unicode(e), "Speichern fehlgeschlagen")
         return
 def onPlay(self, evt):
     if not self.temp_audiofile:
         return
     if self.recording:
         dialogs.showErrorMessage(self.frame, u"Bitte stoppen Sie zuerst die Aufnahme!", "Aufnahme stoppen")
         return
     
     if not self.temp_audiofile or not os.path.exists(self.temp_audiofile):
         dialogs.showErrorMessage(self.frame, u"Keine Aufnahme vorhanden!", u"Keine Aufnahme vorhanden")
         return
     self.playing = not self.playing
     
     if not self.playing:
         self.frame.btnPlay.SetLabel("Abspielen")
     else:
         self.frame.btnPlay.SetLabel("Stop")
         thread.start_new_thread(self.play, ())
 def onCreateQuestion(self, evt, default=""):
     dlg = wx.TextEntryDialog(self.parentWindow, u"Bitte einen Frage eingeben", u"Frage hinzufügen", default, wx.OK | wx.CANCEL)
     if dlg.ShowModal() == wx.ID_OK:
         text = dlg.GetValue().strip()
         if len(text) > 0:
             if text in self.frame.lstQuestions.GetItems():
                 dialogs.showErrorMessage(self.parentWindow, u"Diese Frage existiert bereits", u"Frage existiert bereits")
                 self.onCreateQuestion(None, default)
             else:
                 self.talk.sections[self.section].questions.append(controller.talk.Question(text))
                 items = self.frame.lstQuestions.GetItems()
                 items.append(text)
                 self.fillLists()
                 self.frame.lstQuestions.SetItems(items)
                 self.frame.lstQuestions.SetSelection(len(items) - 1)
                 self.onChangeSelection(None)
         else:
             self.onCreateQuestion(None)
 def onCreateSection(self, evt, default = ""):
     dlg = wx.TextEntryDialog(self.parentWindow, u"Bitte einen Namen eingeben", u"Abschnitt anlegen", default, wx.OK | wx.CANCEL)
     if dlg.ShowModal() == wx.ID_OK:
         name = dlg.GetValue().strip()
         if len(name) > 0:
             if name in self.talk.sections:
                 dialogs.showErrorMessage(self.parentWindow, u"Ein Abschnitt mit diesem Namen ist bereits vorhanden", "Fehler")
                 self.onCreateSection(None, name)
             else:
                 self.talk.sections[name] = controller.talk.Section()
                 items = self.frame.chcFirstSection.GetStrings()
                 items.append(name)
                 self.frame.chcFirstSection.SetItems(items)
                 
                 dlg = DLGEditSection(self.talk, name, self.project, self, self.parentWindow)
                 dlg.ShowModal()
     
         else:
             self.onCreateSection(None)
 def onRecord(self, evt):
     if self.playing:
         dialogs.showErrorMessage(self.frame, u"Bitte stoppen Sie zuerst die Wiedergabe!", "Wiedergabe stoppen")
         return
     
     self.recording = not self.recording
     
     if self.recording:
         if not self.temp_audiofile:
             self.temp_audiofile = os.path.join(self.sound_folder, stringhelper.uniqid("temp_", False) + ".wav")
         else:
             if not dialogs.ask(self.frame, u"Bestehende Aufnahme überschreiben?", u"Aufnahme überschreiben"):
                 self.recording = False
                 return
         self.logger.debug("Start recording")
         self.frame.btnRecord.SetLabel("Stop")
         thread.start_new_thread(self.record, ())
     else:
         self.logger.debug("Stop recording")
         self.frame.btnRecord.SetLabel("Aufnehmen")
 def onOK(self, evt):
     filename = self.frame.txtName.GetValue().strip()
     if len(filename) <= 0:
         dialogs.showErrorMessage(self.frame, u"Bitte geben Sie einen Dateinamen ein", u"Falsche Angabe")
         return
     scripting_language = self.frame.choiceLanguage.GetStringSelection()
     if scripting_language == "UAGE Script" and not filename.endswith(".txt"):
         filename += ".txt"
         
     elif scripting_language == "Python" and not filename.endswith(".py"):
         filename += ".py"
         
     fullpath = os.path.join(self.project.script_folder, filename)
     
     if os.path.exists(fullpath):
         dialogs.showErrorMessage(self.frame, u"Eine Datei mit diesem Namen existiert bereits", u"Datei existiert bereits")
         return
     
     handle = codecs.open(fullpath, "a", "utf-8")
     if filename.endswith(".py"):
         handle.write("# -*- coding: utf-8 -*-\n")
     handle.close()
     dialogs.showInfo(self.frame, u"Script wurde erstellt.", u"Script erstellt")
     self.frame.Close()
            return
        except IOError, e:
            dialogs.showErrorMessage(None, unicode(e), "Lesen fehlgeschlagen")
            return
        if lines:
            for line in lines:
                if line.startswith("image"):
                    self.image = line[6:].strip() 
                elif line.startswith("name"):
                    self.name = line[5:].strip() 
                        
    def save(self):
        output = u""
        if not self.path:
            return
        if self.image:
            output += u"image " + self.image + lf
        if self.name:
            output += u"name " + self.name + lf
        try:
            with codecs.open(self.path, "w", "utf-8") as f:
                f.write(output)
        except OSError, e:
            dialogs.showErrorMessage(None, unicode(e), "Speichern fehlgeschlagen")
            return
        except IOError, e:
            dialogs.showErrorMessage(None, unicode(e), "Speichern fehlgeschlagen")
            return
            
            
             if os.path.exists(filename):
                 os.remove(filename)     
             return   
         except OSError, e:
             dialogs.showErrorMessage(self.parent.frame, unicode(e), "Löschen fehlgeschlagen")
             return
         except IOError, e:
             dialogs.showErrorMessage(self.parent.frame, unicode(e), "Löschen fehlgeschlagen")
             return
     content = u"file " + name
     try:
         handle = codecs.open(filename, "w", "utf-8")
         handle.write(content)
         handle.close()
     except OSError, e:
         dialogs.showErrorMessage(self.parent.frame, unicode(e), "Speichern fehlgeschlagen")
         return
     except IOError, e:
         dialogs.showErrorMessage(self.parent.frame, unicode(e), "Speichern fehlgeschlagen")
         return
     
 def readTextFile(self, name):
     name = os.path.join(self.text_folder, name)
     text = []
     if os.path.exists(name):
         f = codecs.open(name, "r", "utf-8")
         for line in f:
             text.append(line.strip())
         f.close()   
         return text
     else: