예제 #1
0
 def save_script(self, window, x, y, script_text, open_editor = False, color=None):
     global colors_to_set
     
     script_text = script_text.strip()
     
     def open_editor_func():
         nonlocal x, y
         if open_editor:
                 self.script_entry_window(x, y, script_text, color)
     try:
         script_validate = scripts.validate_script(script_text)
     except:
         self.popup(window, "Script Validation Error", self.error_image, "Fatal error while attempting to validate script.\nPlease see LPHK.log for more information.", "OK", end_command = open_editor_func)
         raise
     if script_validate == True:
         if script_text != "":
             script_text = files.strip_lines(script_text)
             scripts.bind(x, y, script_text, colors_to_set[x][y])
             self.draw_canvas()
             lp_colors.updateXY(x, y)
             window.destroy()
         else:
             self.popup(window, "No Script Entered", self.info_image, "Please enter a script to bind.", "OK", end_command = open_editor_func)
     else:
         self.popup(window, "(" + str(x) + ", " + str(y) + ") Syntax Error", self.error_image, "Error in line: " + script_validate[1] + "\n" + script_validate[0], "OK", end_command = open_editor_func)
예제 #2
0
 def import_script(self, textbox, window):
     name = tk.filedialog.askopenfilename(parent=window,
                                          initialdir=files.SCRIPT_PATH,
                                          title="Import script",
                                          filetypes=load_script_filetypes)
     if name:
         text = files.import_script(name)
         text = files.strip_lines(text)
         textbox.delete("1.0", tk.END)
         textbox.insert(tk.INSERT, text)
예제 #3
0
 def export_script(self, textbox, window):
     name = tk.filedialog.asksaveasfilename(parent=window,
                                            initialdir=files.SCRIPT_PATH,
                                            title="Export script",
                                            filetypes=save_script_filetypes)
     if name:
         if files.SCRIPT_EXT not in name:
             name += files.SCRIPT_EXT
         text = textbox.get("1.0", tk.END)
         text = files.strip_lines(text)
         files.export_script(name, text)
예제 #4
0
파일: window.py 프로젝트: thenetimp/LPHK
    def save_script(self, window, x, y, color, script_text):
        script_text = script_text.strip()

        script_validate = scripts.validate_script(script_text)
        if script_validate == True:
            if script_text != "":
                script_text = files.strip_lines(script_text)
                scripts.bind(x, y, script_text, color)
                self.draw_canvas()
                lp_colors.updateXY(x, y)
                window.destroy()
            else:
                self.popup(window, "No Script Entered", self.info_image, "Please enter a script to bind.", "OK")
        else:
            self.popup(window, "Syntax Error", self.warning_image, "Error in line: " + script_validate[1] + "\n" + script_validate[0], "OK")