467,926 Members | 1,410 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,926 developers. It's quick & easy.

Modifying TKinter widgets defined in Modules

Sorry if this is an extremely stupid question:

I produced some Python modules with TKinter stuff and now I want to
use that from my main program. The windows have wuite some user
interaction. It's easy to bring them to the screen, but how do I make
the communication (i.e. variables) between the main and the modules
happen?

Currently I call a function from the main and pass all variables in
the function call, but with more then 25 variables this looks odd.

And now I have to change variables in the main from the module and
that doesn work at all, does it?

Or can I access widget definitions from the main??

What is the usual, elegant way to handle that?

Thanks for any hint ;)
Jul 18 '05 #1
  • viewed: 1582
Share:
2 Replies
Marcus,
I have no clear concept of your problem ("nix verstehen"). Newbie? What is a
"main"? What in fact is the overall structure of your software system? You
have first di decide where to put your "variables". In Python you will
generally use an object. This can be made visible as you like. You however
have do decide who instantiates this object ("main" or one of the "moduls")?

The best way seems to do this in your "main":

class Data: pass
myData=Data()

Put all your 25 variables into it (myData.varX=None ....), then you pass
"myData" as a parameter to your moduls...

Is this what helps?
Kindly
Michael P
"Marcus Schneider" <ms************@t-online.de> schrieb im Newsbeitrag
news:3f**************************@posting.google.c om...
Sorry if this is an extremely stupid question:

I produced some Python modules with TKinter stuff and now I want to
use that from my main program. The windows have wuite some user
interaction. It's easy to bring them to the screen, but how do I make
the communication (i.e. variables) between the main and the modules
happen?

Currently I call a function from the main and pass all variables in
the function call, but with more then 25 variables this looks odd.

And now I have to change variables in the main from the module and
that doesn work at all, does it?

Or can I access widget definitions from the main??

What is the usual, elegant way to handle that?

Thanks for any hint ;)

Jul 18 '05 #2
Michael,

that is very interesting; in the meantime I managed for the first time
to create an instance of a class that contains my TKinter widgets in a
module, so I obviously messed around with some basics...

But my questionw as also about "style" of programming Python. Would I
want to use modules just for the widget definition or would I rather
want to put widgets and functions together in one module?

What kind of structure is considered to by "good style" in Python?

Thanks for the patience...

"Michael Peuser" <mp*****@web.de> wrote in message news:<bh*************@news.t-online.com>...
Marcus,
I have no clear concept of your problem ("nix verstehen"). Newbie? What is a
"main"? What in fact is the overall structure of your software system? You
have first di decide where to put your "variables". In Python you will
generally use an object. This can be made visible as you like. You however
have do decide who instantiates this object ("main" or one of the "moduls")?

The best way seems to do this in your "main":

class Data: pass
myData=Data()

Put all your 25 variables into it (myData.varX=None ....), then you pass
"myData" as a parameter to your moduls...

Is this what helps?
Kindly
Michael P
"Marcus Schneider" <ms************@t-online.de> schrieb im Newsbeitrag
news:3f**************************@posting.google.c om...
Sorry if this is an extremely stupid question:

I produced some Python modules with TKinter stuff and now I want to
use that from my main program. The windows have wuite some user
interaction. It's easy to bring them to the screen, but how do I make
the communication (i.e. variables) between the main and the modules
happen?

Currently I call a function from the main and pass all variables in
the function call, but with more then 25 variables this looks odd.

And now I have to change variables in the main from the module and
that doesn work at all, does it?

Or can I access widget definitions from the main??

What is the usual, elegant way to handle that?

Thanks for any hint ;)

Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by srijit | last post: by
2 posts views Thread by Adonis | last post: by
25 posts views Thread by BJŲrn Lindqvist | last post: by
11 posts views Thread by Harlin Seritt | last post: by
1 post views Thread by Richard Lewis | last post: by
5 posts views Thread by H J van Rooyen | last post: by
44 posts views Thread by bg_ie | last post: by
reply views Thread by Guilherme Polo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.