python 3.x - how do you open two tkinter Windows one after the other.? -
i new python programming concept of class different of languages java, c++, c# ... , tkinter library. trying basic. first creating frame allow user enter string value; store string value in memory exit frame. creating new file browser allow select specific file rename chosen file string stored in memory earlier. not have specific snippet of code have 2 pieces of codes combined give me result want.
enter code here # snippet input user def printtext(): global e string = e.get() return string tkinter import * root = tk() root.title('name') e = entry(root) e.pack() e.focus_set() b = button(root,text='okay',command=printtext) b.pack(side='bottom') root.mainloop() # file browser import tkinter,tkfiledialog root = tkinter.tk() file = tkfiledialog.askopenfile(parent=root,mode='rb',title='choose file')
why don't try asksaveasfilename in example.but if want use file_path=askopenfilename entry, have use os library, function os.rename (i think) .this code written in python 3 if using python2 change names of libraries.
from tkinter import * import tkinter.filedialog fd def main(): root = tk() root.title('name') #e = entry(root) #e.pack() #e.focus_set() b = button(root,text='okay',command= lambda:printtext(e)) b.pack(side='bottom') root.mainloop() def printtext(e): #string = e.get() #print(string) file = fd.asksaveasfile(title='choose file') #print(file) main()
Comments
Post a Comment