Go Back   CodingForums.com > :: Server side development > Other server side languages/ issues > Python

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-25-2007, 08:48 AM   PM User | #1
alibaloch1
New to the CF scene

 
Join Date: Jul 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
alibaloch1 is an unknown quantity at this point
Python GUI

Can any body help me with Python..

The problem is I am making a sample GUI script I included a button which opens a new window the problem is when I click the exit button on new window it closes both windows the code is
Code:
from Tkinter import *
from tkMessageBox import showinfo

def reply( ):
    showinfo(title='Pressed!', message='Button is pressed')

def button1( ):
    showinfo(title='Button1', message='Button1 pressed!')

def button2( ):
    showinfo(title='Button2', message='Button2 pressed!')

def button3( ):
    showinfo(title='Button3', message='Button3 pressed!')

def new():
    new = Toplevel()
    new.iconbitmap('favicon.ico')
    Label(new, text='new window').pack()
    Button(new, text='close', command=new.quit).pack(side=BOTTOM)
    

def showname(name):
    if name == '':
    	showinfo(title='your name', message='Please enter your name')
    else:
    	showinfo(title='your name', message='Hi %s!' % name)


window = Tk( )
window.title('Sample')
window.iconbitmap('favicon.ico')

button = Button(window, text='press', command=reply)
button.pack( )

btn1 = Button(window, text='Button1', command=button1)
btn1.pack()

btn2 = Button(window, text='Button2', command=button2)
btn2.pack()

btn3 = Button(window, text='Button3', command=button3)
btn3.pack()

btn5 = Button(window, text='New Window', command=new)
btn5.pack()

Label(window, text="Enter your name:").pack()
ent = Entry(window)
ent.pack()

btn4 = Button(window, text='Submit', command=(lambda: showname(ent.get( ))))
btn4.pack(side=BOTTOM)

window.mainloop( )
Thanx in advance
alibaloch1 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:15 AM.


Advertisement
Log in to turn off these ads.