Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
ynef
Jun 12, 2002
Because they're trying to save an extra line. Both the object specific "value" (self.value) and the global variable "value" are affected, and set to "self.value + 1".

Adbot
ADBOT LOVES YOU

ynef
Jun 12, 2002

epswing posted:

Ok so maybe I'm going blind but I don't see any global variables. I see two class definitions, a counter object and a for loop.

See that variable called "value"? That's global: the very same one is used in both classes. Python can be confusing that way, since the variable doesn't need to be declared to be global in a special way.

ynef
Jun 12, 2002

urmomlolzinbed posted:

Here's a quick question. I'm trying to create a gui in python that has a tree view widget (see JTree which is part of Java's swing library). The only experience I have with python and guis are just some quick ones that I've made using basic Tkinter widgets. Does Tkinter have a tree view similar to what I'm asking for or should I used another module? Also, do you guys have any good python gui books or resources you can recommend?

My recommendation, due to me not knowing Tkinter at all, is to simply use Glade to build a GUI (if this is in a Linux environment, you didn't say). Glade spits out an XML file, and like two lines of Python reads that XML file and gives you your GUI. All events that you want to handle are set in the XML file, so you just need to write Python functions for dealing with them.

  • Locked thread