Làm cách nào để tạo cửa sổ bật lên trong Tkinter khi nhấn nút? Khi nút 'Giới thiệu' được nhấp vào, tôi muốn một cửa sổ bật lên với tuyên bố từ chối trách nhiệm + về văn bản.Làm cách nào để tạo cửa sổ bật lên trong Tkinter khi nhấn nút?
Tôi đã cố gắng thiết lập phương pháp def nhưng nó phải rất sai vì nó không hoạt động như tôi muốn. Bất kỳ trợ giúp sẽ được rất nhiều đánh giá cao.
Cảm ơn bạn
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()
Cảm ơn bạn, đó là một vĩ đại help –
@Bob: Bạn có thể muốn thêm một 'toplevel.focus_force()' vào cuối hàm 'clickAbout()' để kích hoạt cửa sổ mới (đó là những thứ như thế này hoạt động như thế nào trong hầu hết các ứng dụng). – martineau