I am working on a python GTK project and was wondering if it is possible to generate random variable names for naming widget objects and returning them so that it could be used in other parts of program like :
#Class AppGUI:
def createButton(self, buttonlabel):
RandombuttonObjectName = gtk.Button(self.buttonlabel)
RandombuttonObjectName.show()
return RandombuttonObjectName
#Main Program
Button1 = AppGUI.createButton("Button 1")
Button2 = AppGUI.createButton("Button 2")
Kindly suggest how to achieve this random object naming and returning from class to main program.
As you've written it,
createButton
already returns unique, essentially random references to widgets.(To be more precise, it returns the widgets themselves, but I find it clearer to think of them as references.)