Editor de texto em Tkinter
Publicado por Perfil removido (última atualização em 13/07/2011)
[ Hits: 17.366 ]
Esse é um pequeno editor de textos feito em Python. Utiliza a interface gráfica Tkinter.
#! /usr/bin/python # -*- coding: UTF-8 -*- from Tkinter import * from tkFileDialog import asksaveasfilename,askopenfilename #Começa a classe do editor: class PyNotePad: # Aqui fica a função inicial: def __init__(self): self.root = Tk() self.root.wm_title("PyNotePad")# Aqui é o digito # "inicia" a scroolbar scrollbar = Scrollbar(self.root) scrollbar.pack(side=RIGHT, fill=Y) menubar = Menu(self.root) #Aqui criamos os menus: MENUarquivo = Menu(menubar) MENUarquivo.add_command(label="Salvar", command=self.salvar) MENUarquivo.add_command(label="Abrir", command=self.abrir) menubar.add_cascade(label="Arquivo", menu=MENUarquivo) MENUajuda = Menu(menubar) MENUajuda.add_command(label="Sobre", command=self.sobre) menubar.add_cascade(label="Ajuda", menu=MENUajuda) self.root.config(menu=menubar) # Aqui adicionamos a parte que fica o texto: self.text = Text(self.root) self.text.pack(expand=YES, fill=BOTH) #aqui configura o scrollbar self.text.config(yscrollcommand=scrollbar.set) scrollbar.config(command=self.text.yview) # Por Fim, a janela: self.root.mainloop() def salvar(self): # Aqui é a função que salva o arquivo: fileName = asksaveasfilename() try: file = open(fileName, 'w') textoutput = self.text.get(0.0, END) file.write(textoutput) except: pass finally: file.close() def abrir(self):# Aqui é a função que abre um arquivo fileName = askopenfilename() try: file = open(fileName, 'r') contents = file.read() self.text.delete(0.0, END) self.text.insert(0.0, contents) except: pass def sobre(self):# uma pequena função "sobre" :D root = Tk() root.wm_title("Sobre") texto=("PyNotePad: Versão 1.0") textONlabel = Label(root, text=texto) textONlabel.pack() # inicia o programa: PyNotePad()
Consumo de memória por processo
tux-gpt - Assistente de IA para o Terminal
Instalação e configuração do Chrony
Programa IRPF - Guia de Instalação e Resolução de alguns Problemas
Como instalar no Linux Jogos da Steam só para Windows
Instalando o Team Viewer no Debian Trixie - problema no Policykit
O Que Fazer Após Instalar Ubuntu 25.04
Autenticação necessária. um aplicativo quer acesso ao chaveiro "c... (1)
O que você está ouvindo agora? [2] (174)
Atalhos duplicados (sobras de instalações anteriores) (0)
Copiar Layout do Teclado para aplicar em outra Distribuição (9)