Home » , , » AttributeError: 'NoneType' object has no attribute 'config' | tombol di tkinter

AttributeError: 'NoneType' object has no attribute 'config' | tombol di tkinter

Written By SBlog on Sunday, June 19, 2022 | June 19, 2022

Berikut ini error python untuk tombol tkinter seperti ini

 C:\Python> python.exe myFiles\testBed.py

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python\lib\lib-tk\Tkinter.py", line 1403, in __call__
    return self.func(*args)
  File "myFiles\testBed.py", line 10, in grabText
    self.btn_disconn["state"] = "normal"
AttributeError: 'NoneType' object  has  no attribute 'config'

solusi dilakukan perubahan struktur seperti berikut:
Program awal.

        self.btn_con = Button(
            self.frame1,
            text='Connection',
            command=self.conn_server
            #state=NORMAL
        ).grid(row=7, column=3, sticky=W + E)

        self.btn_discon = Button(
            self.frame1,
            text='Disconnect',
            command=self.conn_serveroff,
            state=DISABLED
        ).grid(row=8, column=3, sticky=W + E)

berubah menjadi.

        self.btn_con = Button(
            self.frame1,
            text='Connection',
            command=self.conn_server
            #state=NORMAL
        )
        self.btn_con.grid(row=7, column=3, sticky=W + E)

        self.btn_discon = Button(
            self.frame1,
            text='Disconnect',
            command=self.conn_serveroff,
            state=DISABLED
        )
        self.btn_discon.grid(row=8, column=3, sticky=W + E)

sumber: https://stackoverflow.com/questions/1101750/tkinter-attributeerror-nonetype-object-has-no-attribute-attribute-name

0 comments:

Post a Comment

(^_^) [o_o] (^.^) (".") ($.$)