Modifying TKinter widgets defined in Modules

Discussion in 'Python' started by Marcus Schneider, Aug 15, 2003.

  1. 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 ;)
     
    Marcus Schneider, Aug 15, 2003
    #1
    1. Advertising

  2. 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" <> schrieb im Newsbeitrag
    news:...
    > 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 ;)
     
    Michael Peuser, Aug 16, 2003
    #2
    1. Advertising

  3. 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" <> wrote in message news:<bhko0o$das$02$-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" <> schrieb im Newsbeitrag
    > news:...
    > > 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 ;)
     
    Marcus Schneider, Aug 16, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?ISO-8859-1?Q?Mickel_Gr=F6nroos?=

    Placing entry widgets on a canvas in Tkinter

    =?ISO-8859-1?Q?Mickel_Gr=F6nroos?=, Jun 30, 2003, in forum: Python
    Replies:
    0
    Views:
    444
    =?ISO-8859-1?Q?Mickel_Gr=F6nroos?=
    Jun 30, 2003
  2. =?ISO-8859-1?Q?Mickel_Gr=F6nroos?=

    Re: Placing entry widgets on a canvas in Tkinter

    =?ISO-8859-1?Q?Mickel_Gr=F6nroos?=, Jun 30, 2003, in forum: Python
    Replies:
    0
    Views:
    1,023
    =?ISO-8859-1?Q?Mickel_Gr=F6nroos?=
    Jun 30, 2003
  3. Dean

    XP styled Tkinter widgets

    Dean, Oct 20, 2003, in forum: Python
    Replies:
    1
    Views:
    421
    Jeff Hobbs
    Oct 20, 2003
  4. spohle
    Replies:
    1
    Views:
    327
    Simon Forman
    Jun 24, 2006
  5. Oodini
    Replies:
    1
    Views:
    1,822
    Keith Thompson
    Sep 27, 2005
Loading...

Share This Page