2

Here is my code snippet:

    class Window(ttk.Frame):  
        def __init__(self, master=None):
            super().__init__(master)
            global T1 
            self.frame = ttk.Frame(padding="3 3")
            self.frame = ttk.Frame(borderwidth = 5, relief = 'ridge')
            self.frame.grid(column=1,row=1, sticky=('news'))
            self.frame.grid_columnconfigure(0, weight=1)
            self.frame.grid_rowconfigure(0, weight=1)
            style = ttk.Style()
            style.configure('my.TButton', font=('Helvetica', 46))
            T1 = ttk.Button(self.frame, text="Test 1", style='my.TButton',
                    command=start1).grid(column=1,row=1, sticky=())
    window = Window()
    window.master.title("Recording")
    window.master.mainloop()

When I call the 'start1' function:

    def start1():
        global running, f
        running = True
        T1.configure(state="disabled")
        f = open("Test_1.txt", "w")
        recording() 

I always get the following error message:

Exception in Tkinter callback Traceback (most recent call last): File "/usr/lib/python3.4/tkinter/init.py", line 1536, in __call__return self.func(*args) File "/home/pi/Public/Test_DataRecording.py", line 40, in start1 T1.configure(state="disabled") AttributeError: 'NoneType' object has no attribute 'configure'

Somehow T1 is not recognized as a button... Please take care in your answer as I am a bloody Python-beginner

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
Hans
  • 29
  • 1
  • `.grid` returns None. Save the button object to `T1`, _then_ call `.grid` on it. – Aran-Fey Apr 14 '17 at 22:20
  • Just because you are a beginner doesn't make you exempt from the rules. Please do a little research before asking such a basic question. – Bryan Oakley Apr 15 '17 at 14:44

0 Answers0