FAQ
Hi!!
I'm trying to program an application which have multiple windows and
is capable of executing method defined inside class of one another, i
tries a simpel frame work here and am creating Toplevel inside method
as the new window to be genereated, and again want another window to
be loaded when the widget inside toplevel is executed as
necessary..but am feeling lost to either create a class for such new
window or write function again..

also, when running clearentry() it is not working...have i missed
something here..

Programming with multiple window is main task for me..so how it can be
done???

the code i tried is here,

from Tkinter import *
import sys
import os

class toplevel1(Tk):
def __init__(self,parent):
Tk.__init__(self,parent)
self.parent=parent
self.initialize()

def initialize(self):
label=Label(self, text="Toplevel Practice").pack(side=TOP)
button1=Button(self,text="Child
1",command=self.openchild1).pack(side=LEFT)
button2=Button(self,text="Child
2",command=self.openchild2).pack(side=LEFT)
self.resizable(width=NO,height=YES)
self.geometry('300x300')

def openchild1(self):
c1 Toplevel(self,bg="#aabbcc",height00,width00,borderwidth=1)
c1.title("Child One")

c1.resizable(width=NO,height=NO)
F = Frame(c1,height@,width00)
F.pack(side=TOP,fill=X,expand=1)
llb=Label(F,text="Enter command..")
llb.pack(side=LEFT,padx=1)
ent = Entry(F,widthP)
ent.pack(side=LEFT,padx=2,expand=1)
bCl = Button(F,text="Clear Text",command=self.clearentry)
bCl.pack(side=LEFT,padx=2, pady=0)
bQt = Button(F,text="Quit", command=F.quit)
bQt.pack(side=RIGHT,padx=1, pady=0)

F1=Frame(c1,relief=SUNKEN,height30,width00)
txt=Text(F1)

scr=Scrollbar(F1,orient=VERTICAL,command=txt.yview,bg="green",width )
txt.insert(END,"inside txt...")
txt.config(yscrollcommand=scr.set)
F1.pack(side=TOP,fill=X,expand=1)
txt.pack(side=LEFT,fill=BOTH,padx=1)
scr.pack(side=RIGHT,fill=Y)

F2=Frame(c1,height0,width00,relief=RAISED)
F2.pack(side=BOTTOM,fill=X,expand=1)
llb1=Label(F2,text=" Low Down statusbar")
llb1.pack(side=LEFT)

def clearentry(self):
self.ent.delete(0,END)

def openchild2(self):
c2 Toplevel(self,bg="red",height 0,width 0,borderwidth=1)
c2.geometry('200x200')
c2.resizable(width=NO,height=NO)
c2.title("Child Two")
Label(c2, text="This is a regular toplevel
window.").pack(side=TOP)


if __name__=="__main__":
obj=toplevel1(None)
obj.title('Main Window')
obj.mainloop()

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedSep 1, '08 at 1:10p
activeSep 1, '08 at 1:10p
posts1
users1
websitepython.org

1 user in discussion

Anish Chapagain: 1 post

People

Translate

site design / logo © 2022 Grokbase