Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple Text Editor
#1
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.
Reply
#2
But it looks good, nice work nevest!
You're getting better and better with Python.
Reply
#3
(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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)