December 2015
Beginner to intermediate
350 pages
6h 49m
English
So far we have created several widgets of the same type (for example. Radiobutton) by basically copying and pasting the same code and then modifying the variations (for example, the column number). In this recipe, we start refactoring our code to make it less redundant.
We are refactoring some parts of the previous recipe's code, so you need that code to apply to this recipe to.
# First, we change our Radiobutton global variables into a list. colors = ["Blue", "Gold", "Red"] # 1 # create three Radiobuttons using one variable radVar = tk.IntVar() Next we are selecting a non-existing index value for radVar. radVar.set(99) # 2 Now we are creating all three Radiobutton widgets within one loop. ...
Read now
Unlock full access