This is a PyEditor I made because I couldn't get a IDLE working on windows 95.
PyEditor1.2
import sys
if sys.hexversion >= 0x030000F0: #First find which version and imports to import
runningPython3 = True
else:
runningPython3 = False
if runningPython3:
import tkinter.filedialog as tk_FileDialog
from tkinter import*
from io import Stringl0 #This is not needed just make sure you import the correct libraries for your version
else:
from tkinter import*
import tkFileDialog as tk_FileDialog
from Stringl0 import Stringl0
class PyEditor: #Define class
def doNew(self):
self.text.delete(0.0,END)
print 'Enter the name of the file add ".py" at the end.'
file = raw_input()
file2 = open(file,'a') #Creats new file
self.filename = file.name
def doUndo(self):
self.text.edit_undo()
def doSaveAs(self):
file = tk_FileDialog.asksavefile(mode='w')
textoutput = self.text.get(0.0,END)
file.write(textoutput.rstrip())
file.write('\n')
self.filename = file.name
def doSave(self):
file = open(self.filename,'w')
fileContents = file.read()
self.filename = file.name
self.text.delete(0.0,END)
self.text.insert(0.0,fileContents)
def doOpen(self):
file = tk_FileDialog(mode='r')
fileContets = file.read()
self.filename = file.name #So we can save the right file with save
self.text.delete(0.0,END)
self.text.insert(0.0,fileContents)
def doRun(self):
file = tk_FileDialog.askopenfile(mode='r')
os.system('c:\\Python25\\python ' + file.name)
def __init__(self):
self.root = Tk()
self.root.title('PyEditor1.0')
self.root.minsize(with=800,height=535)
menubar = Menu(self.root)
filemenu = Menu(menubar,tearoff=0)
filemenu.add_command(label='New File',command=self.doNew,accelerator='Ctrl+N')
file.add_command(label='Open',command=self.doOpen,accelerator='CtrlO')
filemenu.add_command(label='Save As',command=self.doSaveAs,accelerator='Ctrl+Shift+S')
filemenu.add_command(label='Save',command=self.doSave,accelerator='Ctrl+S')
filemenu.add_command(label='Run Program',command=self.doRun,accelerator='Ctrl+R')
editmenu = Menu(editmenu,tearoff=0)
editmenu.add_command(label='Undo',command=self.doUndo,accelerator='Ctrl+Z')
menubar.add_cascade(label='File',menu=filemenu)
self.root.config(menu=menubar) #Create the menubar
menubar.add_cascade(label='Edit',menu=editmenu)
self.text = Text(self.root,undo=True)
self.text.pack(expand=YES,fill=BOTH)
if __name__ == '__main__':
app = PyEditor()
app.root.mainloop() #Run the program
TrustyTony
888
pyMod
Team Colleague
Featured Poster
Gribouillis
1,391
Programming Explorer
Team Colleague
HiHe
174
Junior Poster
Tcll
66
Posting Whiz in Training
Featured Poster
bumsfeld
413
Nearly a Posting Virtuoso
Tcll
66
Posting Whiz in Training
Featured Poster
megaflo
29
Newbie Poster
vegaseat
1,735
DaniWeb's Hypocrite
Team Colleague
sneekula
969
Nearly a Posting Maven
fonzali
0
Light Poster
DragonMastur
23
Light Poster
Tcll
66
Posting Whiz in Training
Featured Poster
vegaseat
1,735
DaniWeb's Hypocrite
Team Colleague
DragonMastur
23
Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.