PyEditor1.2

Updated DragonMastur 0 Tallied Votes 408 Views Share

This is a PyEditor I made because I couldn't get a IDLE working on windows 95.

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

Despite the imports, the raw_input will not work in Python3. You must do assignment and decide which meaning to use. I normally assign raw_input to input in Python2.

Gribouillis 1,391 Programming Explorer Team Colleague

Are you really running windows 95 ? I thought it died more than 15 years ago. You could perhaps rewrite the editor for python 1.5 (which was a very good version of python).

HiHe 174 Junior Poster

The start of a more elaborate editor using the PySide/PyQt GUI toolkit:
https://www.daniweb.com/software-development/python/threads/32007/projects-for-the-beginner/14#post1840298

Tcll 66 Posting Whiz in Training Featured Poster

get off his butt grib, I have a good reason for using WinXP.
Win95 isn't too far behind it, and really, is a fun OS to play with.

in any case, it's good to see programmers still working with outdated OS's. :)
(sometimes you need to take a huge step back in order to make a leaping jump forward)

though I refuse to develop on any newer RAT-ware OS (Win Vista and up)
(don't call BS on me until you have as much knowledge as me)
^I know WTF I talk about when I say MS built a RAT in Windows

if my software doesn't work well with your OS, maybe you should start using a safer OS.

EDIT:
I probably should add, I AM working on my own fully automated IDE for my program, so I might be able to help where needed. :)
while my IDE IS for Python, it's extended to provide extra support for my program...
see this image: http://lh3.ggpht.com/-onzArcPdjJA/U46fpc6ra3I/AAAAAAAAGrw/-5RCmghwV2U/s1355/UMC_SIDE_progress_21.PNG

the editor is built with PyQt4, and is built to give noobs a visual representation of the data they're working with.
basically like HexEdit's template support, but instead of a template, it's one of my program's import/export scripts.

EDIT2:
I AM working on more advanced features than what's displayed in the image...
features such as:
- collapsable code
- VisualStudio-like intellisense
- Aptana convenience functions (quick auto-completion)

I'm stil a noob writing this stuff, but it will come... heh

btw, that black box in the image is a Qt-GL model viewer
it'll show you what data does what with the model

bumsfeld 413 Nearly a Posting Virtuoso

Windows 95 was released on August 24, 1995
As far as computing is concerned this is really, really old!
I can't believe that there are many machines left out there.
Maybe in some museum basement.

Tcll 66 Posting Whiz in Training Featured Poster

is it safe to mention I have a Celeron (Pentium II) 400MHz 384MB RAM (512MB (256MB*2) max (won't boot with higher)) which I've installed XP on for use with fixing my secondary and backup compys.
my primary and laptop are SATA.

let's see 7 or 8 operate on 384MB >:D

my backup compy is a Pentium III (800MHz or 1.8GHz /forgets easily) 1GB RAM (used to be my secondary)

I have a friend who runs a compy similar to this for his every day usage.
(both mine and his run XP) :P

my secondary is new enough to run GFX above PJ64 well, though it's at Pentium 4 x86 level (when that CPU was the best thing around)

I'm looking for an older compy I can get XP running on :3

also, sorry bout going OT with this post XD
people seem to think old technology is simply thrown away...
they don't realize just how good the old tech can be when it's not hacked into ;)

megaflo 29 Newbie Poster

There is a missing single quote around Ctrl+N on line 63. It's hard to run code with a syntax error :)

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

megaflo found an error on line 63
I took the time to correct it
thanks megaflo

sneekula 969 Nearly a Posting Maven

There is also an error in line 12.
Since you are not running Python3 but Python2 tkinter should be Tkinter

fonzali 0 Light Poster

when I ran the program I found several mistakes :
first I commented out line 10
second:line 14 should be StringIO not String10
third:in line 58, with should be width
forth: line 65 file.add_command should be filemenu.add_command
fifth: line 73 should be :
editmenu=Menu(filemenu,tearoff=0)
after fixing all that , it worked fine

DragonMastur 23 Light Poster

I have done a lot of work on it and have a 1.5.8 version of it.

Unfortunitly I got mad at the computer and took it apart. So I still haave it on a drive but no machine. I am useing a raspberrie pi right now.

Tcll 66 Posting Whiz in Training Featured Poster

Unfortunitly I got mad at the computer and took it apart. So I still haave it on a drive but no machine. I am useing a raspberrie pi right now.

ROFL
been there and done that many times XD
I even drop-kicked one of them and cracked the MBd in half for turning my full 160GB HDD RAW (my very first RAW HDD).

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

The Raspberry Pi has Python and Tkinter on it, so give it a try!

Of course the Raspberry Pi comes with Idle/Idle3 and a nice general editor called Leafpad.

DragonMastur 23 Light Poster

vegaseat I tryed to but it didn't work I dont know whats wrong.

But Thanks anyway Everyone.

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.