the from tkinter. Filedialog import askopenfilename The import tkinter The import OS
Tkinter. Tk (). The geometry (" 800 x600 + 200 + 20 ") # frame layout (length x width + x + y)
B=tkinter. Button (text="Button") P. lace (x=20, y=20)
Default_dir=r "C: \ Users \ lenovo \ Desktop" # set the default open directory Def WWW (event) : Fn=askopenfilename (title="select files", initialdir=(OS) path) expanduser (default_dir))) Print (fn) Return fn
B.b ind (" & lt; Button 1 & gt;" , the WWW) # print (WWW ()) has been an error here, not use return Tkinter. Mainloop ()
I just started studying Python, there are two simple questions to ask you a great god, and def WWW (event) inside the parameters of the event is what mean? And I want to get the inside of the def parameter fn results, how to put the inside of the fn transfer results come out? I want to return to return no, other methods don't understand, please directly,
CodePudding user response:
Widget events triggered controls
The x, y, position the mouse from the top left corner of the form (coordinates)
X_root, x_y mouse from the top left corner of the screen position (coordinates)
Char keyboard events corresponding character code
Keysym keyboard events corresponds to the string
Keycode keyboard events corresponding key code
Num mouse events corresponding key code
Width, height control of the new size
Type the event type Use event. The type can obtain corresponding event type, other similarly,
Secondly, function WWW () need parameter, so when you use the print give WWW () a parameter should be ok,