Editor de texto em Tkinter
Publicado por Perfil removido (última atualização em 13/07/2011)
[ Hits: 17.419 ]
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()
Virus, trojan, sei la o que é isso
Botnet em Python sem segredos!
Atualizando o Passado: Linux no Lenovo G460 em 2025
aaPanel - Um Painel de Hospedagem Gratuito e Poderoso
O macete do Warsaw no Linux Mint e cia
Visualizar arquivos em formato markdown (ex.: README.md) pelo terminal
Dando - teoricamente - um gás no Gnome-Shell do Arch Linux
Como instalar o Google Cloud CLI no Ubuntu/Debian
Mantenha seu Sistema Leve e Rápido com a Limpeza do APT!
Procurando vídeos de YouTube pelo terminal e assistindo via mpv (2025)
O 1º artigo a gente nunca esquece (1)
Pastas da raiz foram para a área de trabalho [RESOLVIDO] (9)
Problema ao atualizar archlinux nvidia [RESOLVIDO] (3)