Support Forums
Simple Text Editor - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: Python Programming Language (https://www.supportforums.net/forumdisplay.php?fid=32)
+---- Thread: Simple Text Editor (/showthread.php?tid=3004)



Simple Text Editor - nevets04 - 11-18-2009

Code:
def menu():
    print "1) New Document"
    print "2) Open Existing Document"
    d=int(raw_input("What do you want to do?: "))
    if d == 1:
        new()
    elif d == 2:
        existing()
def new():
    doc = raw_input("What do you want to call you text file?: ")    
    a=open("%s.txt" % doc, 'w')
    q = []
    qn = []
    while True:
        q.append(raw_input(""))     
        if '!done' in q:
            qn = q[:-1]        
            c = "\n".join(qn)        
            a.write(c)
            a.write('\n')
            a.close()
            print "saved!"
            menu()
def existing():
    doc = raw_input("What text document do you want to open?: ")
    a=open("%s.txt" % doc, 'r')
    for line in a:
        print line
    a=open("%s.txt" % doc, 'a')    
    q = []
    qn = []
    while True:
        q.append(raw_input(""))    
        if '!done' in q:
            qn = q[:-1]        
            c = "\n".join(qn)        
            a.write(c)
            a.write('\n')
            a.close()
            print "saved!"
            menu()
menu()

I realize this isn't fully functional, I really just put this out there for people to learn from.


RE: Simple Text Editor - Gaijin - 11-19-2009

But it looks good, nice work nevest!
You're getting better and better with Python.


RE: Simple Text Editor - nevets04 - 11-19-2009

(11-19-2009, 09:56 AM)Master of The Universe Wrote: But it looks good, nice work nevest!
You're getting better and better with Python.

Thanks Smile