code1 ok -
from Tkinter import *
-
from functools import partial
-
fields = 'Name', 'Job', 'Pay'
-
-
def fetch(entries,event):
-
for entry in entries:
-
print 'Input => "%s"' % entry.get()
-
print event
-
-
-
def makeform(root, fields):
-
entries = []
-
for field in fields:
-
row = Frame(root)
-
lab = Label(row, width=5, text=field)
-
ent = Entry(row)
-
row.pack(side=TOP, fill=X)
-
lab.pack(side=LEFT)
-
ent.pack(side=RIGHT, expand=YES, fill=X)
-
entries.append(ent)
-
return entries
-
-
-
if __name__ == '__main__':
-
-
root = Tk()
-
ents = makeform(root, fields)
-
root.bind('<Return>', partial(fetch,ents))
-
root.mainloop()
-
code2 fail i don't understand why ? -
from Tkinter import *
-
from functools import partial
-
fields = 'Name', 'Job', 'Pay'
-
-
def fetch(entries,event):
-
for entry in entries:
-
print 'Input => "%s"' % entry.get()
-
print event
-
-
-
def makeform(root, fields):
-
entries = []
-
for field in fields:
-
row = Frame(root)
-
lab = Label(row, width=5, text=field)
-
ent = Entry(row)
-
row.pack(side=TOP, fill=X)
-
lab.pack(side=LEFT)
-
ent.pack(side=RIGHT, expand=YES, fill=X)
-
entries.append(ent)
-
return entries
-
-
-
if __name__ == '__main__':
-
-
root = Tk()
-
ents = makeform(root, fields)
-
root.bind('<Return>', partial(fetch,entries=ents))
-
root.mainloop()
-
code3: fail i know the reason -
from Tkinter import *
-
from functools import partial
-
fields = 'Name', 'Job', 'Pay'
-
-
def fetch(event,entries):
-
for entry in entries:
-
print 'Input => "%s"' % entry.get()
-
print event
-
-
-
def makeform(root, fields):
-
entries = []
-
for field in fields:
-
row = Frame(root)
-
lab = Label(row, width=5, text=field)
-
ent = Entry(row)
-
row.pack(side=TOP, fill=X)
-
lab.pack(side=LEFT)
-
ent.pack(side=RIGHT, expand=YES, fill=X)
-
entries.append(ent)
-
return entries
-
-
-
if __name__ == '__main__':
-
-
root = Tk()
-
ents = makeform(root, fields)
-
root.bind('<Return>', partial(fetch,ents))
-
root.mainloop()
-
code4: ok -
from Tkinter import *
-
from functools import partial
-
fields = 'Name', 'Job', 'Pay'
-
-
def fetch(event,entries):
-
for entry in entries:
-
print 'Input => "%s"' % entry.get()
-
print event
-
-
-
def makeform(root, fields):
-
entries = []
-
for field in fields:
-
row = Frame(root)
-
lab = Label(row, width=5, text=field)
-
ent = Entry(row)
-
row.pack(side=TOP, fill=X)
-
lab.pack(side=LEFT)
-
ent.pack(side=RIGHT, expand=YES, fill=X)
-
entries.append(ent)
-
return entries
-
-
-
if __name__ == '__main__':
-
-
root = Tk()
-
ents = makeform(root, fields)
-
root.bind('<Return>', partial(fetch,entries=ents))
-
root.mainloop()
-
there are four codes,code1,code4 it's ok,i know why;
code2,code3,it's not ok,i understand why code2 can't work,
would you mind to tell me why code3 can't work??
the output is:
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1413, in __call__
return self.func(*args)
TypeError: fetch() got multiple values for keyword argument 'entries'
i don't understand it.
0 1165 Sign in to post your reply or Sign up for a free account.
Similar topics
by: Michael Stembera |
last post by:
Here is a very simple piece of code to repro this bug.
template<typename T, int N> inline bool foo( void )
{
return true;
}
template<typename T> inline bool foo<T, 1>( void )
{
return...
|
by: Ronald Mai |
last post by:
In my opinion, Ellipsis might be in the middle, not only in leftmost or
rightmost, so a placeholder approach can be much more flexible and
convenient.
Here is a reference implementation:
_ =...
|
by: tommydkat |
last post by:
Hi! I'm updating a Windows application that we develop that uses a DB2
database. We switched from using Microsoft Developer Studio 6 to
Visual Studio .Net 2003 to build our app and since that...
|
by: Marek Vondrak |
last post by:
Hello.
I have written the following program and am curious why it prints "1" "2".
What are the exact effects of explicitly providing function template
parameters at the call? Is the second...
|
by: laredotornado |
last post by:
Hi,
I want to pass my function
myFunc('a', 'b', 'c')
as an argument to another function. However, this will not work
doStuff('x', 'y', myFunc('a', 'b', 'c'))
|
by: ale.beer |
last post by:
hi everyone. i've notice that in all my pages there is a piece of j-s
code that i've never write (i'm sure about that).
i'm not so smart to understand what it does do, i suppose nothing, but
if...
|
by: Matthew Wilson |
last post by:
I wrote some code to create a user and update a user on a remote box by
sending emails to that remote box. When I was done, I realized that my
create_user function and my update_user function were...
|
by: aaragon |
last post by:
I have this scenario: several arrays for which I have their fixed
values at compilation time. Now, at runtime I need to access a
specific array depending on an integer but I want to avoid if and...
|
by: jacklisp |
last post by:
I have wrote a small function but got the error
function:
/*< squeeze */
void squeeze(char s1,char s2)
{
int de_s ;
int i,j,k;
for(i = 0;s2 !='\0';++i)
{
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |