I'm making a framework for building GUI apps with tkinter
and in my code I have a Scene class that has a
add(widget,params)
function which creates a tkinter
widget and adds it to the Scenes widget dictionary.
But I can only add a widget that I have built an add()
function for because different widgets have different named parameters.
how would I make a function that takes a dictionary in the form {paramName,value}
which would then pass it to the widget function
for example
scene.add(button, {'command':Click, "text":"click me"} )
my current code is
import tkinter as tk
class scene():
def __init__(self, title, width, height):
self.widgets = {}
self.title = title
self.width = width
self.height = height
def add(self, name, type, widget, root, params):
if name in self.widgets.keys():
return
else:
if type == "button":
width = params[0]
height = params[1]
text = params[2]
self.widgets[name] = [widget(root,width=width, height=height,text=text),params[2:]]
def get(self,name):
if name in self.widgets.keys():
return self.widgets[name][0]