Open roberthsu2003 opened 1 week ago
from tkinter import ttk
import tkinter as tk
from ttkthemes import ThemedTk
from tkinter.messagebox import showinfo
class Window(ThemedTk):
def __init__(self,*args, **kwargs):
super().__init__(*args, **kwargs)
self.title('登入')
#==============style===============
style = ttk.Style(self)
style.configure('TopFrame.TLabel',font=('Helvetica',20))
#============end style===============
#==============top Frame===============
topFrame = ttk.Frame(self)
ttk.Label(topFrame,text='check_box多選鈕',style='TopFrame.TLabel').pack()
topFrame.pack(padx=20,pady=20)
#==============end topFrame===============
#==============bottomFrame===============
bottomFrame = ttk.Frame(self)
self.agreement = tk.StringVar()
ttk.Checkbutton(bottomFrame,
text='I agree',
command=self.agreement_changed,
variable=self.agreement,
onvalue='agree',
offvalue='disagree').pack()
bottomFrame.pack(expand=True,fill='x',padx=20,pady=(0,20),ipadx=10,ipady=10)
#==============end bottomFrame===============
def agreement_changed(self):
showinfo(
title='Agreement',
message= self.agreement.get()
)
def main():
window = Window(theme="arc")
window.mainloop()
if __name__ == '__main__':
main()
from tkinter import ttk
import tkinter as tk
from ttkthemes import ThemedTk
from tkinter.messagebox import showinfo
class Window(ThemedTk):
def __init__(self,*args, **kwargs):
super().__init__(*args, **kwargs)
self.title('登入')
#==============style===============
style = ttk.Style(self)
style.configure('TopFrame.TLabel',font=('Helvetica',20))
#============end style===============
#==============top Frame===============
topFrame = ttk.Frame(self)
ttk.Label(topFrame,text='請多選一',style='TopFrame.TLabel').pack()
topFrame.pack(padx=20,pady=20)
#==============end topFrame===============
#==============bottomFrame===============
bottomFrame = ttk.Frame(self)
self.agreement = tk.StringVar()
ttk.Checkbutton(bottomFrame,text='I Agree',variable=self.agreement,onvalue='Agree',offvalue='Disagree',command=self.agreement_change).pack()
bottomFrame.pack(expand=True,fill='x',padx=20,pady=(0,20),ipadx=10,ipady=10)
#==============end bottomFrame===============
def agreement_change(self):
showinfo(title='Result',message=self.agreement.get())
def main():
window = Window(theme="arc")
window.mainloop()
if __name__ == '__main__':
main()
from tkinter import ttk
import tkinter as tk
from ttkthemes import ThemedTk
from tkinter.messagebox import showinfo
class Window(ThemedTk):
def __init__(self,*args, **kwargs):
super().__init__(*args, **kwargs)
self.title('登入')
#==============style===============
style = ttk.Style(self)
style.configure('TopFrame.TLabel',font=('Helvetica',20))
#============end style===============
#==============top Frame===============
topFrame = ttk.Frame(self)
ttk.Label(topFrame,text='check_box多選鈕',style='TopFrame.TLabel').pack()
topFrame.pack(padx=20,pady=20)
#==============end topFrame===============
#==============bottomFrame===============
bottomFrame = ttk.Frame(self)
self.agreement = tk.StringVar()
ttk.Checkbutton(bottomFrame,text='I agree',command=self.agreement_changed,variable=self.agreement,onvalue='agree',offvalue='disagree').pack()
bottomFrame.pack(expand=True,fill='x',padx=20,pady=(0,20),ipadx=10,ipady=10)
#==============end bottomFrame===============
def agreement_changed(self):
tk.messagebox.showinfo(title='Result',message=self.agreement.get())
def main():
window = Window(theme="arc")
window.mainloop()
if __name__ == '__main__':
main()
from tkinter import ttk
import tkinter as tk
from ttkthemes import ThemedTk
from tkinter.messagebox import showinfo
# define a class Window inherited from Themedtk
class Window(ThemedTk):
#initialize this class
def __init__(self,*args,**kwargs):
super().__init__(*args,**kwargs)
#start laypot from here!
self.title('Marry Me!')
#===Style===
style = ttk.Style(self)
style.configure('TopFrame.TLabel',font=('Arial',20))
#===End of Style===
#==Top Frame=====
topFrame = ttk.Frame(self)
ttk.Label(topFrame,text='Marry me!',style='TopFrame.TLabel').pack()
topFrame.pack(padx=20,pady=20)
#==End top Frame====
#=====Button Frame=====
BottonFrame=ttk.Frame(self)
#===Checkbox=====
self.agreement = tk.StringVar()
ttk.Checkbutton(
BottonFrame,
text='Yes',
command=self.agreement_changed,
variable=self.agreement,
onvalue='Yes',
offvalue='No').pack()
#===End of Checkbox===
BottonFrame.pack(expand=True,fill='x',padx=20,pady=(0,20),ipadx=10,ipady=10)
#====End of Button Frame====
#end laypot here
#define instance function below
def agreement_changed(self):
message=self.agreement.get()
showinfo(title="Proposed to her.",message=f"She Said {message}")
# create function of the document
def main():
# create an instance in class Window, named "window"
#give a theme style to this window
window=Window(theme="breeze")
window.mainloop()
if __name__=='__main__':
main()
from tkinter import ttk
import tkinter as tk
from ttkthemes import ThemedTk
from tkinter.messagebox import showinfo
class Window(ThemedTk):
def __init__(self,*args, **kwargs):
super().__init__(*args, **kwargs)
self.title('登入')
#==============style===============
style = ttk.Style(self)
style.configure('TopFrame.TLabel',font=('Helvetica',20))
#============end style===============
#==============top Frame===============
topFrame = ttk.Frame(self)
ttk.Label(topFrame,text='check_box多選鈕',style='TopFrame.TLabel').pack()
topFrame.pack(padx=20,pady=20)
#==============end topFrame===============a
#==============bottomFrame===============
bottomFrame = ttk.Frame(self)
self.agreement = tk.StringVar()
ttk.Checkbutton(bottomFrame,
text='打勾名稱',
command=self.agreement_changed,
variable=self.agreement,
onvalue='以確認打勾',
offvalue='disagree').pack()
bottomFrame.pack(expand=True,fill='x',padx=20,pady=(0,20),ipadx=10,ipady=10)
#==============end bottomFrame===============
def agreement_changed(self):
tk.messagebox.showinfo(title='確認標題',
message=self.agreement.get())
def main():
window = Window(theme="arc")
window.mainloop()
if __name__ == '__main__':
main()
from tkinter import ttk
import tkinter as tk
from ttkthemes import ThemedTk
from tkinter.messagebox import showinfo
class Window(ThemedTk):
def __init__(self,*args, **kwargs):
super().__init__(*args, **kwargs)
self.title('登入')
#==============style===============
style = ttk.Style(self)
style.configure('TopFrame.TLabel',font=('Helvetica',20))
#============end style===============
#==============top Frame===============
topFrame = ttk.Frame(self)
ttk.Label(topFrame,text='請多選一',style='TopFrame.TLabel').pack()
topFrame.pack(padx=20,pady=20)
#==============end topFrame===============
#==============bottomFrame===============
bottomFrame = ttk.Frame(self)
self.IIF = tk.StringVar()
ttk.Checkbutton(bottomFrame,
text='I agree',
command=self.agreement_changed,
variable=self.IIF,
onvalue='agree',
offvalue='disagree').pack()
bottomFrame.pack(expand=True,fill='x',padx=20,pady=(0,20),ipadx=10,ipady=10)
#==============end bottomFrame===============
def agreement_changed(self):
showinfo(title='Result',message=self.IIF.get())
def main():
window = Window(theme="arc")
window.mainloop()
if __name__ == '__main__':
main()
from tkinter import ttk
import tkinter as tk
from ttkthemes import ThemedTk
from tkinter.messagebox import showinfo
class Window(ThemedTk):
def __init__(self,*args, **kwargs):
super().__init__(*args, **kwargs)
self.title('登入')
#==============style===============
style = ttk.Style(self)
style.configure('TopFrame.TLabel',font=('Helvetica',20))
#============end style===============
#==============top Frame===============
topFrame = ttk.Frame(self)
ttk.Label(topFrame,text='是否同意',style='TopFrame.TLabel').pack()
topFrame.pack(padx=20,pady=20)
#==============end topFrame===============
#==============bottomFrame===============
bottomFrame = ttk.Frame(self)
agreement = tk.StringVar()
def agreement_changed():
tk.messagebox.showinfo(title='Result',message=agreement.get())
ttk.Checkbutton(bottomFrame,
text='I agree',
command=agreement_changed,
variable=agreement,
onvalue='agree',
offvalue='disagree').pack()
bottomFrame.pack(expand=True,fill='x',padx=20,pady=(0,20),ipadx=10,ipady=10)
#==============end bottomFrame===============
def main():
window = Window(theme="arc")
window.mainloop()
if __name__ == '__main__':
main()
from tkinter import ttk
import tkinter as tk
from ttkthemes import ThemedTk
from tkinter.messagebox import showinfo
class Window(ThemedTk):
def __init__(self,*args, **kwargs):
super().__init__(*args, **kwargs)
self.title('登入')
#==============style===============
style = ttk.Style(self)
style.configure('TopFrame.TLabel',font=('Helvetica',20))
#============end style===============
#==============top Frame===============
topFrame = ttk.Frame(self)
ttk.Label(topFrame,text='check_box多選鈕',style='TopFrame.TLabel').pack()
topFrame.pack(padx=20,pady=20)
#==============end topFrame===============
#==============bottomFrame===============
bottomFrame = ttk.Frame(self)
self.agreement = tk.StringVar(self)
ttk.Checkbutton(bottomFrame,
text='I agree',
command=self.agreement_changed,
variable=self.agreement,
onvalue='agree',
offvalue='disagree').pack()
bottomFrame.pack(expand=True,fill='x',padx=20,pady=(0,20),ipadx=10,ipady=10)
#==============end bottomFrame===============
def agreement_changed(self):
showinfo(title='Result',message=self.agreement.get())
def main():
window = Window(theme="arc")
window.mainloop()
if __name__ == '__main__':
main()
from tkinter import ttk
import tkinter as tk
from ttkthemes import ThemedTk
from tkinter.messagebox import showinfo
class Window(ThemedTk):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.title('登入')
# ==============style===============
style = ttk.Style(self)
style.configure('TopFrame.TLabel', font=('Helvetica', 20))
# ============end style===============
# ==============top Frame===============
topFrame = ttk.Frame(self)
ttk.Label(topFrame, text='check_box多選鈕',
style='TopFrame.TLabel').pack()
topFrame.pack(padx=20, pady=20)
# ==============end topFrame===============
# ==============bottomFrame===============
bottomFrame = ttk.Frame(self)
self.agreement = tk.StringVar()
ttk.Checkbutton(bottomFrame,
text='do you agree??',
command=self.agreement_change,
variable=self.agreement,
onvalue='You agree!!!',
offvalue='Disagree').pack()
bottomFrame.pack(expand=True, fill='x', padx=20,
pady=(0, 20), ipadx=10, ipady=10)
# ==============end bottomFrame===============
def agreement_change(self):
showinfo(title='Result', message=self.agreement.get())
def main():
window = Window(theme="arc")
window.mainloop()
if __name__ == '__main__':
main()
from tkinter import ttk
import tkinter as tk
from ttkthemes import ThemedTk
from tkinter.messagebox import showinfo
class Window(ThemedTk):
def __init__(self,*args, **kwargs):
super().__init__(*args, **kwargs)
self.title('登入')
#==============style===============
style = ttk.Style(self)
style.configure('TopFrame.TLabel',font=('Helvetica',20))
#============end style===============
#==============top Frame===============
topFrame = ttk.Frame(self)
ttk.Label(topFrame, text='Hi there! It is nice to see you!', style='TopFrame.TLabel').pack()
topFrame.pack(padx=20, pady=20)
#==============end topFrame===============
#==============bottomFrame===============
bottomFrame = ttk.Frame(self)
self.agreement = tk.StringVar()
# Create the checkbutton here, outside of the function
checkbutton = ttk.Checkbutton(bottomFrame,
text='Thanks',
variable=self.agreement,
onvalue='It is wonderful to see you too!',
offvalue='Thanks, but I have had a rough week.',
command=self.agreement_changed)
checkbutton.pack()
bottomFrame.pack(expand=True, fill='x', padx=20, pady=(0, 20), ipadx=10, ipady=10)
#==============end bottomFrame===============
def agreement_changed(self):
# This function is called when the checkbox state changes
showinfo(title='Result', message=self.agreement.get())
def main():
window = Window(theme="arc")
window.mainloop()
if __name__ == '__main__':
main()
from tkinter import ttk
import tkinter as tk
from ttkthemes import ThemedTk
from tkinter.messagebox import showinfo
class Window(ThemedTk):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.title('登入')
#==============style===============
style = ttk.Style(self)
style.configure('TopFrame.TLabel', font=('Helvetica', 20))
#============end style===============
#==============top Frame===============
topFrame = ttk.Frame(self)
ttk.Label(topFrame, text='check_box多選鈕', style='TopFrame.TLabel').pack()
topFrame.pack(padx=20, pady=20)
#==============end topFrame===============
#==============bottomFrame===============
bottomFrame = ttk.Frame(self)
self.agreement = tk.StringVar(value="disagree")
ttk.Checkbutton(bottomFrame,
text='I agree',
command=self.agreement_changed,variable=self.agreement,
onvalue='agree',
offvalue='disagree').pack()
bottomFrame.pack(expand=True, fill='x', padx=20, pady=(0, 20), ipadx=10, ipady=10)
#==============end bottomFrame===============
def agreement_changed(self):
showinfo(title='Result', message=self.agreement.get())
def main():
window = Window(theme="arc")
window.mainloop()
if __name__ == '__main__':
main()
from tkinter import ttk
import tkinter as tk
from ttkthemes import ThemedTk
from tkinter.messagebox import showinfo
class Window(ThemedTk):
def __init__(self,*args, **kwargs):
super().__init__(*args, **kwargs)
self.title('登入')
#==============style===============
style = ttk.Style(self)
style.configure('TopFrame.TLabel',font=('Helvetica',20))
#============end style===============
#==============top Frame===============
topFrame = ttk.Frame(self)
ttk.Label(topFrame,text='check_box多選鈕',style='TopFrame.TLabel').pack()
topFrame.pack(padx=20,pady=20)
#==============end topFrame===============
#==============bottomFrame===============
bottomFrame = ttk.Frame(self)
self.checkbox_var = tk.StringVar()
checkbox = ttk.Checkbutton(
bottomFrame,
text='<I agree>',
command=self.check_changed,
variable=self.checkbox_var,
onvalue='<agree>',
offvalue='<disagree>')
checkbox.pack(fill='x', padx=5, pady=5)
bottomFrame.pack(expand=True,fill='x',padx=20,pady=(0,20),ipadx=10,ipady=10)
#==============end bottomFrame===============
def check_changed(self):
showinfo(title='Result',
message=self.checkbox_var.get())
def main():
window = Window(theme="arc")
window.mainloop()
if __name__ == '__main__':
main()
from tkinter import ttk
import tkinter as tk
from ttkthemes import ThemedTk
from tkinter.messagebox import showinfo
class Window(ThemedTk):
def __init__(self, *args, **kwargs):
super().__init__(*args,**kwargs)
self.title('登入')
#self.geometry('600x400')
#================style==========
style = ttk.Style(self)
style.configure('TopFrame.TLabel',font=("Helvetica",20))
#===============end style========
#==============top Frame========
topFrame = ttk.Frame(self)
ttk.Label(topFrame,text='多選鈕',style='TopFrame.TLabel').pack()
topFrame.pack(padx=20,pady=20)
#==============end top Frame=====
#===============bottomFrame==========
bottomFrame= ttk.Frame(self)
self.agreement = tk.StringVar()
# 在 bottomFrame 中添加複選框
ttk.Checkbutton(bottomFrame,text='我同意條款和條件',
variable=self.agreement,
onvalue='同意',
offvalue='不同意',
command=self.agreement_changed).pack()
# 設置 bottomFrame 的布局
bottomFrame.pack(expand=True,fill='x',padx=20,pady=(0,20),ipadx=10,ipady=10)
#================end bottle Frame=====
def agreement_changed(self):
showinfo(
title='Agreement',
message=self.agreement.get()
)
message =self.agreement.get()
def main():
window = Window(theme='arc')
window.mainloop()
if __name__ == '__main__':
main()
from tkinter import ttk
import tkinter as tk
from ttkthemes import ThemedTk
from tkinter.messagebox import showinfo
class Window(ThemedTk):
def __init__(self,*args, **kwargs):
super().__init__(*args, **kwargs)
self.title('登入')
#==============style===============
style = ttk.Style(self)
style.configure('TopFrame.TLabel',font=('Helvetica',20))
#============end style===============
#==============top Frame===============
topFrame = ttk.Frame(self)
ttk.Label(topFrame,text='國破山河在,城春草木深。',style='TopFrame.TLabel').pack()
topFrame.pack(padx=20,pady=20)
#==============end topFrame===============
#==============bottomFrame===============
# https://www.pythontutorial.net/tkinter/tkinter-checkbox/
bottomFrame = ttk.Frame(self)
self.agreement = tk.StringVar()
ttk.Checkbutton(bottomFrame,
text='I agree',
command=self.agreement_changed,
variable=self.agreement,
onvalue='感時花濺淚,恨別鳥驚心。',
offvalue='峰火連三月,家書抵萬金。').pack()
bottomFrame.pack(expand=True,fill='x',padx=20,pady=(0,20),ipadx=10,ipady=10)
#==============end bottomFrame===============
def agreement_changed(self):
showinfo(
title='Result',
message=self.agreement.get())
def main():
window = Window(theme="arc")
window.mainloop()
if __name__ == '__main__':
main()
from tkinter import ttk
import tkinter as tk
from ttkthemes import ThemedTk
from tkinter.messagebox import showinfo
class Window(ThemedTk):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.title('登入')
style = ttk.Style(self)
style.configure('TopFrame.TLabel', font=('Helvetica', 20))
topFrame = ttk.Frame(self)
ttk.Label(topFrame, text='check_box多選鈕', style='TopFrame.TLabel').pack()
topFrame.pack(padx=20, pady=20)
bottomFrame = ttk.Frame(self)
bottomFrame.pack(expand=True, fill='x', padx=20, pady=(0, 20), ipadx=10, ipady=10)
def main():
window = Window(theme="arc")
window.mainloop()
if __name__ == '__main__':
main()
checkbox範例