I am trying to make a class to display checkbox on calling that class again and again without rewriting the whole code but just by providing the basic variable values using tkinter with python version 3.7.2. Got stuck in this problem.
# easyfunc.py
import tkinter as tk
class checkButton:
"""docstring for checkButton"""
def __init__(self, title, bg, command):
super(checkButton, self).__init__()
self.title = title
self.bg = bg
self.command = command
var = IntVar()
checkbutton = Checkbutton(master, title=title, bg=bg, command=command, variable=var)
checkbutton.pack()
------------------------------------------------------------------------------
# try.py
import easyfunc
def helloworld():
print("helllo")
gui.checkButton("BUTTON", "white", "helloworld")
Traceback (most recent call last):
File "try.py", line 6, in <module>
gui.checkButton("BUTTON", "white", "helloworld")
File "C:\...\easyfunc.py", line 55, in __init__
checkbutton = Checkbutton(master, title=title, bg=bg, command=command, variable=var)
File "C:\...\Python\Python37\lib\tkinter\__init__.py", line 2646, in __init__
Widget.__init__(self, master, 'checkbutton', cnf, kw)
File "C:\...\Python\Python37\lib\tkinter\__init__.py", line 2299, in __init__
(widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: unknown option "-title"
Aucun commentaire:
Enregistrer un commentaire