roberthsu2003 / __2024_09_04_tvdi__

11309職能發展學院 python應用實戰 2024_09_04
Apache License 2.0
17 stars 0 forks source link

請在bottomFrame內加入checkbox #7

Open roberthsu2003 opened 1 week ago

roberthsu2003 commented 1 week ago

checkbox範例

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)

        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()
raykuo7 commented 1 week ago

11郭子睿


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()
Clown-coder commented 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='請多選一',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()
Kojiahleh commented 1 week ago

14葉日勤

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()
DeJungTseng commented 1 week ago

曾德容的check box作業

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()

Result

img
storysky0610 commented 1 week ago

13

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()
8jp6 commented 1 week ago

09文世宏的作業

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()

.py

Sun-Yung commented 1 week ago

04孫榕陽的作業

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()
orange811024 commented 1 week ago

05林采橘


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()
richard20241007 commented 1 week ago

16李啟民

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()

螢幕擷取畫面

Austin-Chang-zz commented 1 week ago

張鐵英 Lesson 5 的作業

hw5


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()


imkobebryant commented 1 week ago

06呂安杰的lesson5作業

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()
joy273609 commented 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.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()
tomisagoodguy commented 1 week ago

image

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()
Andylai888 commented 1 week ago

2024-10-22 124812 賴豐文的lesson5作業

nickjiang2000 commented 4 days ago

江榮展的Checkbox作業 image image

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()
saltyfish1107 commented 2 days ago

邱育霖的lesson5作業

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()