I am working on creating a LabelFrame class using Tkinter, which creates a wrapper around a group of items I wish to include one by one, by pressing an add button, that calls a function to create more of that item.
I have the code running, where I can see the LabelFrame and addbuttun. But once I press the button the function being called I get an error:
addmeter() takes exactly 1 argument (0 given)
I need to this function to add a class inside the LabelFrame, and this is where I am stuck.
I have listed my code below.
from Tkinter import *
root = Tk()
root.title("LabelFrame with embedded add voltmeters")
root.geometry("600x200+400+400")
def addmeter(self):
#Create frame for the voltmeter
voltsmet1 = LabelFrame(self.master, text = "Volts")
#add Text box for the serial output.
voltinfo = Text(voltsmet1, bg="BLACK", height=10, width =20 )
#add in reg command to find our data from queue and display it
#packs the widgets on the grid for display
voltsmet1.pack(side=LEFT, expand=True)
voltinfo.pack(side=LEFT, expand=True)
class wrapper(LabelFrame):
def __init__(self,master):
self.master = master
self.create_wrapper()
def create_wrapper(self):
wrapper = LabelFrame(self.master, text = "Volt Meters")
add_button = Button(wrapper, text="add", command=addmeter)
wrapper.pack()
add_button.pack()
new= wrapper(root)
root.mainloop()
