Hi,
I am trying to make my "Save All" button to save whatever is selected from the option menu or dropdown to that particular file.
So if I have "animation" selected from the option menu it saves to the animation file 'ji.txt','r+'.
Or if I have "compositing" selected from the option menu it saves to the animation file 'journalinput.txt', 'r+'.
I am also planing to add more to the option menu.
I think I have gotten really close but need just a little help.I done this in python v.3.4.1
Thanks
Here's my code
from tkinter import *
app = Tk()
app.title("GUI Example")
app.geometry('460x460+200+200')
def main():
pass
def animation():
f = open('ji.txt','r+')
journText.delete(1.0, END)
emptyCompString =""
for i in f:
emptyCompString += i
journText.insert(END, emptyCompString )
f.close()
return
def compositing():
f = open('journalinput.txt','r+')
journText.delete(1.0, END)
emptyCompString =""
for i in f:
emptyCompString += i
journText.insert(END, emptyCompString)
f.close()
return
def openFiles(selection):
if selection == "animation":
saveAnim(), animation()
if selection == "compositing":
saveComp(), compositing()
return
def saveAll():
if selectJourn=='animation':
saveAnim()
if selectJourn=='compositing':
saveComp()
return
def saveAnim():
anim = journText.get(1.0, END)
outToFile = open('ji.txt', 'r+')
outToFile.write('\n'+anim)
outToFile.close()
return
def saveComp():
comp = journText.get(1.0, END)
outToFile = open('journalinput.txt', 'r+')
outToFile.write('Sub-Subsject:\n' + comp)
outToFile.close()
return
selectJourn = StringVar()
selectJourn.set('subject')
files = ["animation","compositing"]
selectDropDown = OptionMenu(app, selectJourn, *files, command=openFiles)
selectDropDown.place(x=0, y=1)
button1 = Button(app, text = " Save All ", width = 10, command = saveAll)
button1.place(x=200, y=5, width= 105)
journText = Text(app, height = 5, width = 63)
journText .insert(END,'')
journText .place(x= 7, y = 40)
if __name__=='__main__':main()
app.mainloop()