why in the following code,there is no "frame.focus_set()" in the code ,it can
run ,why??
from Tkinter import *
root = Tk()
def callback(event):
print "i am here"
frame = Frame(root, width=100, height=100)
frame.bind("", callback)
frame.pack()
root.mainloop()
-- 原始邮件 --
Hi,
Thus spoketh "守株待兔" <1248283...@qq.com>
unto us on Wed, 17 Aug 2011 17:06:28 +0800:
> why in the following code,there is no "frame.focus_set()" in the
> code ,it can run ,why?? from Tkinter import *
> root = Tk()
> def callback(event):
>print "i am here"
>
> frame = Frame(root, width=1
code1
from Tkinter import *
root = Tk()
def callback(event):
print "i am here"
frame = Frame(root, width=100, height=100)
frame.bind("", callback)
frame.focus_set()
frame.pack()
root.mainloop()
code2
from Tkinter import *
root = Tk()
def callback(event):
print "i am here"
frame = Frame(ro
I think there is no difference. Both positions seem reasonable to me.
So you can insert the set_focus line at whichever position you wish.
2011/8/17 守株待兔 <1248283...@qq.com>:
> code1
> from Tkinter import *
> root = Tk()
> def callback(event):
>print "i am here"
>
> frame = Frame(root, width=1
there is a code:
#coding:utf-8
from Tkinter import *
from sys import stdout, exit # lambda generates a function
widget = Button(None,# but contains just an expression
text='Hello event world',
command=(lambda: stdout.write('He