Editor de texto em Tkinter
Publicado por Perfil removido (última atualização em 13/07/2011)
[ Hits: 17.418 ]
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()
Programa para calcular a média e a nota trimestral
Aprenda a Gerenciar Permissões de Arquivos no Linux
Como transformar um áudio em vídeo com efeito de forma de onda (wave form)
Como aprovar Pull Requests em seu repositório Github via linha de comando
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)
Sinto uma leve lentidão ao arrastar, miniminizar e restauras as janela... (0)
Zorin OS - Virtual Box não consigo abrir maquinas virtuais (6)
Iinstalar o Scanner Kodak i940 no Linux Mint 19/20? (3)