Trouble incrementing variables in Python 3.4.3 Tkinter with labels and buttons
Question: So I have started making a survival game, but ran into a problem pretty fast.
I wanted to make a button that should will go and collect a certain time, (as
in shrubs), and when hit, the amount of shrub shown on the screen will
increment by 15. But every time I try to make it, the amount of shrub goes
from 0 to 15, which is good, but then it won't go any higher. Here is the code
I have currently:

    
    
    import tkinter as tk
    
    root = tk.Tk()                  # have root be the main window
    root.geometry("550x300")        # size for window
    root.title("SURVIVE")           # window title
    
    shrubcount = 0
    
    
    def collectshrub():
        global shrubcount
        shrubcount += 15
        shrub.config(text=str(shrubcount))
    
    def shrub():
        shrub = tk.Label(root, text='Shrub: {}'.format(shrubcount),
                 font=("Times New Roman", 16)).place(x=0, y=0)
    
    
    def shrubbutton():
        shrubbutton = tk.Button(root, command=collectshrub, text="Collect shrub",
                                font=('Times New Roman', 16)).place(x=0, y=200)
    
    
    shrub()             # call shrub to be shown
    
    root.mainloop()     # start the root window
    

Any help would be nice! Thanks tons Getting these errors

    
    
    shrub.config(text=str(shrub count))
    AttributeError: 'NoneType' object has no attribute 'config'
    


Answer: Inkblot has the right idea.

Your shrub function sets the number of shrubs at 0.

Clicking "Collect Shrub" calls forces shrub to output shrubcount but at no
time is the shrubcount variable updated.

A cleaner version of your code, that does what you want may look like this:

    
    
    import ttk
    from Tkinter import *
    
    
    class Gui(object):
        root = Tk()
        root.title("Survive")
        shrubs = IntVar()
    
        def __init__(self):
            frame = ttk.Frame(self.root, padding="3 3 12 12")
            frame.grid(column=0, row=0, sticky=(N, W, E, S))
            frame.columnconfigure(0, weight=1)
            frame.rowconfigure(0, weight=1)
    
            ttk.Label(frame, text="Shrubs:").grid(column=0, row=0, sticky=W)
            ttk.Entry(frame, textvariable=self.shrubs, width=80).grid(column=0, row=2, columnspan=4, sticky=W)
            ttk.Button(frame, command=self.add_shrubs, text="Get Shrubs").grid(column=6, row=3, sticky=W)
    
        def add_shrubs(self):
            your_shrubs = self.shrubs.get()
            self.shrubs.set(your_shrubs + 15)
    
    go = Gui()
    go.root.mainloop()
    

Notice that all add_shrub does is increment shrubcount by 15. Displaying the
number of shrubs is handled by the shrubs label object.

