You are not logged in.

#1 2011-03-13 19:27:42

marxav
Member
From: Gatineau, PQ, Canada
Registered: 2006-09-24
Posts: 386

[Solved] Python Tkinter Frame interaction

I am trying to have a form talk to another one as per exemple below.  I cannot find a way to make this work.  What am I doing wrong or missing

from tkinter import *
from tkinter import ttk

class FirstFrame():
    def __init__(self,root):
        self.root=root
        self.frame=Frame(self.root)
        self.PlaceLeftButton()
        self.PlaceLabel()
        
    def PlaceLeftButton(self):
        self.btn=ttk.Button(self.root,text='Open Child Form',command=self.OpenChild)
        self.btn.grid(column=0,row=0)
    def PlaceLabel(self):
        self.lbl=ttk.Label(self.root, text='At Start')
        self.lbl.grid(column=1,row=0)

    def OpenChild(self):
        top=Toplevel(self.root)
        self.child=ChildFrame(top)

class ChildFrame():
    def  __init__(self, root):
        self.root=root
        self.childframe=Frame(self.root)
        self.PlaceLeftButton()
        self.PlaceEntryField()
    def PlaceLeftButton(self):
        self.btn=Button(self.root,text='Reset parent form', command=self.SetParentValue)
        self.btn.grid(column=0,row=0)
    def PlaceEntryField(self):
        self.entry=Entry(self.root)
        self.entry.grid(column=0, row=1)
    def SetParentValue(self):
        self.root.lbl(text='Parent has been reset')
        
if  __name__=='__main__':
    root = Tk()
    root.option_add('*font', ('verdana', 12, 'bold'))
    root.title("Class Interaction")
    display = FirstFrame(root)
    root.mainloop()

I should add, it is the SetParentValue method I have no clue how to handle.

Last edited by marxav (2011-03-14 16:21:45)

Offline

#2 2011-03-14 16:20:58

marxav
Member
From: Gatineau, PQ, Canada
Registered: 2006-09-24
Posts: 386

Re: [Solved] Python Tkinter Frame interaction

Offline

Board footer

Powered by FluxBB