471,575 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,575 software developers and data experts.

Multiple window handling

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",height=300,width=300,bo rderwidth=1)
c1.title("Child One")

c1.resizable(width=NO,height=NO)
F = Frame(c1,height=40,width=300)
F.pack(side=TOP,fill=X,expand=1)
llb=Label(F,text="Enter command..")
llb.pack(side=LEFT,padx=1)
ent = Entry(F,width=50)
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,height=330,width=300)
txt=Text(F1)

scr=Scrollbar(F1,orient=VERTICAL,command=txt.yview ,bg="green",width=20)
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,height=30,width=300,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=200,width=200,border width=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()
Sep 1 '08 #1
0 902

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by john | last post: by
3 posts views Thread by Disco-181 | last post: by
32 posts views Thread by Eli | last post: by
26 posts views Thread by yb | last post: by
4 posts views Thread by johkar | last post: by
5 posts views Thread by Pete Verdon | last post: by
1 post views Thread by Thomas 'PointedEars' Lahn | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by lumer26 | last post: by
1 post views Thread by lumer26 | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.