Help for Tkinter and python's programming

aurel-le-gnou aurelienviolet at noos.fr
Sat Jun 1 22:30:41 EDT 2002


Hi,


I'm french and just beginning in Python's programming.
I'm doing a really simple GUI with the module "Tkinter" for the
implementation of a meta search engine based on Google and altavista.

This Gui is quite finished but i've a problem. I'm sure it's really
stupid but I really not understand the reasons of this pb.
If someone can Help me, it would be really fine.


Here is my problem:

I create a GUI with some buttons and entry, textbox, radiobuttons...
Then there is a mainloop wainting for events.
When the button 1 is pressed on a button, i want to get each content of
these entries... and the state of the radiobuttons...
Then launch a program with the differents values and contents found just
before.
I don't success in associating the event and the function to execute
with the different arguments


All my tkinter widgets are created in a simple main by calling some
functions (no object implementation, this interface is really simple).
Particularly these two functions define naturally before the main:


def make_button(frame, text, color, side, padx, pady):

    button = Button(frame, text=text, fg=color, bg='white')
    button.pack(side=side,padx=padx, pady=pady)
    return button


def make_call(frame_left, frame_right, list_one, list_two,
button_number, button_search, button_language, button_rank,
button_engine):

    ....
    ....
    
    return button_language_content, button_number_content,
button_search_content, list_one, list_two, button_rank_content,
button_engine_content



The goal of the function make_call is:
- to get the differents arguments in the diferents Entry and the state
of different radiobuttons
- then call an other program program with these arguments.



In my main:

...

button_go = make_button(bottom,'GO','black',LEFT, '5m',0)

...
...


button_go.bind("<Button-1>", make_call(frame_left, frame_right,
list_one, list_two, button_number, button_search, button_language,
button_rank, button_engine))  
# the arguments of make_call() are visible and defined in the main when
I do this "bind".

....

root.mainloop()


So, I just want to execute the fonction make_call with some arguments
(which corresponds to the different entries and radiobuttons to check
their content) when the button1 is pressed on my button_go. (this
arguments are visible in my main) 
But the problem is that even if the user doesn't click on the button the
associate function is executed.
I've also problem in giving arguments to make_call() 
(the number of arguments is sometimes wrong ... Is there a default
argument "event" given to the function with some informations ?)


Thanks a lot for your help and your criticm about what i've done wrong.



Aurélien Violet

aurelienviolet at noos.fr





More information about the Python-list mailing list