472,983 Members | 2,509 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,983 software developers and data experts.

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
2 1804
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: srijit | last post by:
Hello, Any idea - why the following code crashes on my Win 98 machine with Python 2.3? Everytime I run this code, I have to reboot my machine. I also have Win32all-157 installed. from Tkinter...
2
by: Adonis | last post by:
I am creating some widgets by inheriting from Tkinter.Frame and populating the frame with whatever the widget will be then creating certain attributes/methods to be accessed later. My question is,...
25
by: BJörn Lindqvist | last post by:
See: http://www.wxpython.org/quotes.php. especially: "wxPython is the best and most mature cross-platform GUI toolkit, given a number of constraints. The only reason wxPython isn't the standard...
11
by: Harlin Seritt | last post by:
There are certain options for Tkinter widgets that have default values that I don't much care for (borderwidth, font come to mind) and continuously change when I'm building interfaces. With a bit...
1
by: Richard Lewis | last post by:
Hi there, I've just started my first project with Tkinter. I've already coded all the data handling classes and have a nice interface to work with (it happens to be a wrapper around the DOM of...
5
by: H J van Rooyen | last post by:
Hi, I am struggling to get the pack method to do what I intend. I am trying to display user input in a seperate window, along with a little description of the field, something like this: ...
32
by: Kevin Walzer | last post by:
I'm a Tcl/Tk developer who has been working, slowly, at learning Python, in part because Python has better support for certain kinds of applications that I want to develop than Tcl/Tk does....
44
by: bg_ie | last post by:
Hi, I'm in the process of writing some code and noticed a strange problem while doing so. I'm working with PythonWin 210 built for Python 2.5. I noticed the problem for the last py file...
0
by: Guilherme Polo | last post by:
On 10/29/08, Olrik Lenstra <o.lenstra@gmail.comwrote: It will be a combination of commands, not a single one. Initially I considered this as "probably without solution", since tcl acquired a...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.