I'm working on code for an assessment, parts at a time and I've made two classes so far. One of the classes holds all the information in lists, and the other class is for the visual part of a GUI. I want to have an option menu on this GUI and get the information for that option menu from one of the lists in the other class. How do I access a list from another class to put onto an option menu??
The code below is different to my assessment because I have to be careful about cheating etc. But all I really want to know is how to get those movie names into the option menu in the different class. PLEASE HELP!?
from tkinter import * #used to develop GUI
class Details: #name of class to store the lists
def __init__(self):
self.movie = ["The Hunger Games", "Catching Fire", "Mockingjay"]
class GuiVisible: #class name
def __init__(self, parent): #initilises instance variables
issueLabel = Label(parent, text = "ISSUE", font = ("Arial", "10", "underline")).grid(row = 0, columnspan = 1, sticky = N) #label for that part of the GUI
self.valuestr = DoubleVar()
labelName = Label(parent, text = "Name:", font = ("Arial", "9")).grid(row = 9, columnspan = 2, sticky = W)
self.variable1 = StringVar(parent)
self.variable1 = self.Name.get()
listMenu1 = OptionMenu(parent, self.variable1)
listMenu1.grid(row = 9, column = 5)
#main routine
if __name__ == "__main__":
root = Tk()
interface = GuiVisible(root)
root.mainloop()
From what I understand you are trying to pull information from one class to another.
I made this quick example:.
Class test1 defines the information then class test2 prints the information.
Hope this helps.