0
votes

I am designing a gui using python Tkinter. I try to wrap my code in classes. I use different class for each frame. The code is more or less like this.

Class GetEntry():
"""This class will acquire the text in entry widget"""

Class Frame1():
"""Consist of all entry widget"""

Class Frame2():
"""Consist of all button widget""" 

Class Main_App()
"""All classes are called here"""

However, I want to call GetEntry class when one of the button in class Frame2 is clicked to acquire the text in entry widget located in class Frame1. Any suggestion to do that?

Thanks in advance.

1

1 Answers

0
votes

I Finally get it works. I simply instantiate the GetEntry command inside Frame2, and add attribute entry from Frame1 when calling Frame2. My code is as follows.

class CommadCallback():
    def __init__(self, object)
         self.object = object

    def function(self):
         self.object.get()

class Frame1():
    #Entry instantiation

class Frame2():
    def __init__(self, object):
        self.object = object
        self.function1()  

    def function1(self):
        self.function = CommandCallback(self.object).function()

Class MainApp():
    .....
    self.frame1 = Frame1(self)
    self.frame2 = Frame2(self, self.frame1.entry)