2013-06-23 4 views
8

जब बटन क्लिक किया जाता है तो मैं टिंकर में पॉप-अप कैसे बना सकता हूं? जब 'के बारे में' बटन क्लिक किया जाता है, तो मैं अस्वीकरण के साथ पॉप अप चाहता हूं + पाठ के बारे में।जब बटन क्लिक किया जाता है तो मैं टिंकर में पॉप अप कैसे करूं?

मैंने एक डीफ़ विधि स्थापित करने का प्रयास किया है लेकिन यह बहुत गलत होना चाहिए क्योंकि यह काम नहीं कर रहा है। किसी भी मदद को बहुत, बहुत सराहा जाएगा। आप, एक नई विंडो पर पाठ प्रदर्शित तो एक उच्चस्तरीय विजेट बना सकते हैं और के बारे में पाठ और त्याग के लिए लेबल की मूल रूप में इसका इस्तेमाल करना चाहते हैं

आप

import sys 
from Tkinter import * 

def clickAbout(): 
    name = ("Thanks for the click") 
    return 

app = Tk() 
app.title("SPIES") 
app.geometry("500x300+200+200") 

labelText = StringVar() 
labelText.set ("Please browse to the directory you wish to scan") 


labelText2 = StringVar() 
labelText2.set ("About \n \n \ 
SPIES will search your chosen directory for photographs containing \n \ 
GPS information. SPIES will then plot the co-ordinates on Google \n \ 
maps so you can see where each photograph was taken.") 

labelText3 = StringVar() 
labelText3.set ("\n Disclaimer \n \n \ 
Simon's Portable iPhone Exif-extraction Software (SPIES) \n \ 
software was made by Simon. This software \n \ 
comes with no guarantee. Use at your own risk") 

label1 = Label(app, textvariable=labelText, height=0, width=100) 
label1.pack() 

label1 = Label(app, textvariable=labelText2, height=0, width=100) 
label1.pack() 

label = Label(app, textvariable=labelText3, height=0, width=100) 
label.pack() 

b = Button(app, text="Quit", width=20, command=app.destroy) 
b.pack(side='bottom',padx=0,pady=0) 

button1 = Button(app, text="About SPIES", width=20, command=clickAbout) 
button1.pack(side='bottom',padx=5,pady=5) 

app.mainloop() 

उत्तर

14

धन्यवाद।

वैसे, Tkinter चर यदि आप, स्थिर पाठ है इसलिए इस मामले में आप बस उनमें से छुटकारा पाने के लिए और उन्हें बहु तार से बदल सकते हैं आवश्यक नहीं हैं:

import sys 
from Tkinter import * 

ABOUT_TEXT = """About 

SPIES will search your chosen directory for photographs containing 
GPS information. SPIES will then plot the co-ordinates on Google 
maps so you can see where each photograph was taken.""" 

DISCLAIMER = """ 
Disclaimer 

Simon's Portable iPhone Exif-extraction Software (SPIES) 
software was made by Simon. This software 
comes with no guarantee. Use at your own risk""" 

def clickAbout(): 
    toplevel = Toplevel() 
    label1 = Label(toplevel, text=ABOUT_TEXT, height=0, width=100) 
    label1.pack() 
    label2 = Label(toplevel, text=DISCLAIMER, height=0, width=100) 
    label2.pack() 


app = Tk() 
app.title("SPIES") 
app.geometry("500x300+200+200") 

label = Label(app, text="Please browse to the directory you wish to scan", height=0, width=100) 
b = Button(app, text="Quit", width=20, command=app.destroy) 
button1 = Button(app, text="About SPIES", width=20, command=clickAbout) 
label.pack() 
b.pack(side='bottom',padx=0,pady=0) 
button1.pack(side='bottom',padx=5,pady=5) 

app.mainloop() 
+0

धन्यवाद, कि एक महान था मदद –

+1

@ बॉब: नई विंडो को सक्रिय करने के लिए आप 'क्लिकऑबआउट()' फ़ंक्शन के अंत में 'toplevel.focus_force() 'जोड़ना चाह सकते हैं (इस तरह अधिकांश चीजों में इस तरह की चीजें कैसे काम करती हैं)। – martineau

संबंधित मुद्दे