コード例 #1
0
 def file_new_tab(self):
     try:
         # Creating the tab
         tab1 = Frame(self.ta_input)
         self.ta_input.add(tab1, text="Tab " + str(self.tab_counter))
         self.ta_input.pack(expand=1, fill="both")
         # Creating text input
         text = ln.TextAreaWidget(tab1)
         text.bind("<KeyRelease>", self.tag_keywords)
         text.tag_config("keyword1", foreground="blue")
         text.tag_config("keywordfunc", foreground="darkgrey")
         line_numbers = ln.LineNumber(tab1, width=30)
         line_numbers.attach(text)
         line_numbers.pack(side="left", fill="y")
         text.pack(side="right", fill="both", expand=True)
         text.bind("<<Change>>", self._on_change)
         text.bind("<Configure>", self._on_change)
         self.array_tabs.append(text)
         self.array_name.append("Tab " + str(self.tab_counter))
         self.array_canvas.append(line_numbers)
         self.tab_counter += 1
         del tab1, text, line_numbers
     except:
         messagebox.showerror("A OCURRIDO UN ERROR",
                              "No se ha podido crear una nueva pestaña. Por favor, intente nuevamente.")
コード例 #2
0
 def file_open(self):
     try:
         # Getting file name & content
         filename = filedialog.askopenfilename(initialdir="/", title="Select file", filetypes=(
             ("Archivos de Texto", "*.txt"), ("Todos los archivos", "*.*")))
         a_file = open(filename)
         txt_input = a_file.read()
         file_title = os.path.basename(a_file.name)
         # Creating the tab
         tab1 = Frame(self.ta_input)
         self.ta_input.add(tab1, text=file_title)
         self.ta_input.pack(expand=1, fill="both")
         # Creating the text area
         text = ln.TextAreaWidget(tab1)
         text.insert(END, txt_input)
         line_numbers = ln.LineNumber(tab1, width=30)
         line_numbers.attach(text)
         line_numbers.pack(side="left", fill="y")
         text.pack(side="right", fill="both", expand=True)
         text.bind("<<Change>>", self._on_change)
         text.bind("<Configure>", self._on_change)
         self.array_tabs.append(text)
         self.array_name.append(a_file.name)
         self.array_canvas.append(line_numbers)
         self.tab_counter += 1
         a_file.close()
         del filename, a_file, tab1, text, line_numbers
     except:
         pass
コード例 #3
0
 def new_output(self, output=""):
     try:
         # Creando nueva tab
         tab1 = Frame(self.ta_output)
         self.ta_output.add(tab1, text="SALIDA")
         self.ta_output.pack(expand=1, fill="both")
         # Creando campo de texto
         text = ln.TextAreaWidget(tab1, bg="black", fg="white", width=150, height=15)
         text.pack(side="right", fill="both", expand=True)
         text.insert(END, output)
         del text
     except:
         messagebox.showerror("A OCURRIDO UN ERROR",
                              "No se ha podido crear una nueva pestaña. Por favor, intente nuevamente.")