---
# System prepended metadata

title: Untitled

---

```
from cgi import test
import tkinter as tk
from tkinter import *

root = tk.Tk()
root.title('電力模擬系統')
root.geometry('2000x800')

state1 = '閉合'
state0 = '斷開'
uev01_state = [0,1]
uev02_state = [0,1]
uhv05_state = [0,1]
uhv03_state = [0,1]
uhv06_state = [0,1]#系統:自動0、手動1  開關:斷開0、閉合1
uhv07_state = [0,1]
uhv08_state = [0,1]
uhv13_state = [0,1]
uhv14_state = [0,1]
uhv15_state = [0,1]


uhv02 = tk.Button(root,text='UHV02',bg='yellow',width=10,height=2,font='10',state='disabled')


uhv09 = tk.Button(root,text='UHV09',bg='#EAC100',width=10,height=2,font='10',state='disabled')


uhv12 = tk.Button(root,text='UHV12',bg='#EAC100',width=10,height=2,font='10',state='disabled')

def uev01_openNewWindow(): #建立新的視窗，內有button
    def uev01_manual_fuc():
        uev01_state[0] = 1 
        uev01_btn_manul.config(bg='#FA0200')   
        uev01_btn_auto.config(bg='#E0E0E0') 
        if uev01_state[1] ==1:
            uev01_btn_manul_on.config(bg='#FA0200')
        else :
            uev01_btn_manul_off.config(bg='#FA0200')
        return uev01_state
    def uev01_auto_fuc():
        uev01_state[0] = 0
        uev01_btn_auto.config(bg='#FA0200') 
        uev01_btn_manul_on.config(bg='#E0E0E0')
        uev01_btn_manul_off.config(bg='#E0E0E0')
        uev01_btn_manul.config(bg='#E0E0E0')
        return uev01_state
    def uev01_manul_off_fuc():
        uev01_state[1] = 0
        uev01_btn_manul_off.config(bg='#FA0200')
        uev01_btn_manul_on.config(bg='#E0E0E0')
        uev01_state_show.config(text=state0)
        return uev01_state
    def uev01_manul_on_fuc():
        uev01_state[1] = 1
        uev01_btn_manul_off.config(bg='#E0E0E0')
        uev01_btn_manul_on.config(bg='#FA0200')
        uev01_state_show.config(text=state1)
        return uev01_state
    newwindow = Toplevel(root)
    newwindow.title("New window")
    tk.Label(newwindow,text='狀態',font=(40),bg='yellow').grid(row=1,column=1) #狀態標籤
    uev01_state_show = tk.Label(newwindow, text=state1,font=(40),bg='blue') #按鈕連動狀態
    uev01_state_show.grid(row=1,column=2)
    newwindow.geometry('500x300')
    uev01_btn_auto =tk.Button(newwindow,text='自動',width='20', height='2',bg='#E0E0E0',command=uev01_auto_fuc)     #自動按鈕
    uev01_btn_auto.grid(row=2,column=1)
    uev01_btn_manul = tk.Button(newwindow,text='手動',width='20', height='2',bg='#E0E0E0',command=uev01_manual_fuc)    #手動按鈕
    uev01_btn_manul.grid(row=2,column=2)
    uev01_btn_manul_on = tk.Button(newwindow,text=state1,width='20', height='2',bg='#E0E0E0',command=uev01_manul_on_fuc) #閉合按鈕
    uev01_btn_manul_on.grid(row=3,column=1)
    uev01_btn_manul_off = tk.Button(newwindow,text=state0,width='20', height='2',bg='#E0E0E0',command=uev01_manul_off_fuc) #斷開按鈕
    uev01_btn_manul_off.grid(row=3,column=2)
    print('uev01目前狀態:'+str(uev01_state)+'這裡是判斷手動與自動按鈕部分')
    def test_uev01():
        if uev01_state[0] ==1 :
            uev01_btn_manul.config(bg='#FA0200')
        else:
            uev01_btn_auto.config(bg='#FA0200')
        if uev01_state[1] ==1:
            uev01.config(bg='#FA0200')
            uev01_btn_manul_on.config(bg='#FA0200')
            uev01_state_show.config(text=state1)
        else:
            uev01_btn_manul_off.config(bg='#FA0200')
            uev01.config(bg='#00FF00')
            uev01_state_show.config(text=state0)
        # root.after(1,test_uev01)
    return uev01_state
uev01 = tk.Button(root, text='UEV01', command=uev01_openNewWindow,width=10,height=2,font='10')
def task_uev01():
    if uev01_state[1] ==0:
        uev01.config(bg='#00FF00')
        uev02_state[1] = 0
    else :
        uev01.config(bg='#FA0200')
    root.after(1, task_uev01)


def uev02_openNewWindow(): #建立新的視窗，內有button
    def uev02_manual_fuc():
        uev02_state[0] = 1 
        uev02_btn_manul.config(bg='#FA0200')   
        uev02_btn_auto.config(bg='#E0E0E0') 
        if uev02_state[1] ==1:
            uev02_btn_manul_on.config(bg='#FA0200')
        else :
            uev02_btn_manul_off.config(bg='#FA0200')
        return uev02_state
    def uev02_auto_fuc():
        uev02_state[0] = 0
        uev02_btn_auto.config(bg='#FA0200') 
        uev02_btn_manul_on.config(bg='#E0E0E0')
        uev02_btn_manul_off.config(bg='#E0E0E0')
        uev02_btn_manul.config(bg='#E0E0E0')
        return uev02_state
    def uev02_manul_off_fuc():
        uev02_state[1] = 0
        uev02_btn_manul_off.config(bg='#FA0200')
        uev02_btn_manul_on.config(bg='#E0E0E0')
        uev02_state_show.config(text=state0)
        return uev02_state
    def uev02_manul_on_fuc():
        uev02_state[1] = 1
        uev02_btn_manul_off.config(bg='#E0E0E0')
        uev02_btn_manul_on.config(bg='#FA0200')
        uev02_state_show.config(text=state1)
        return uev02_state
    newwindow = Toplevel(root)
    newwindow.title("New window")
    tk.Label(newwindow,text='狀態',font=(40),bg='yellow').grid(row=1,column=1) #狀態標籤
    uev02_state_show = tk.Label(newwindow, text=state1,font=(40),bg='blue') #按鈕連動狀態
    uev02_state_show.grid(row=1,column=2)
    newwindow.geometry('500x300')
    uev02_btn_auto =tk.Button(newwindow,text='自動',width='20', height='2',bg='#E0E0E0',command=uev02_auto_fuc)     #自動按鈕
    uev02_btn_auto.grid(row=2,column=1)
    uev02_btn_manul = tk.Button(newwindow,text='手動',width='20', height='2',bg='#E0E0E0',command=uev02_manual_fuc)    #手動按鈕
    uev02_btn_manul.grid(row=2,column=2)
    uev02_btn_manul_on = tk.Button(newwindow,text=state1,width='20', height='2',bg='#E0E0E0',command=uev02_manul_on_fuc) #閉合按鈕
    uev02_btn_manul_on.grid(row=3,column=1)
    uev02_btn_manul_off = tk.Button(newwindow,text=state0,width='20', height='2',bg='#E0E0E0',command=uev02_manul_off_fuc) #斷開按鈕
    uev02_btn_manul_off.grid(row=3,column=2)
    print('uev02目前狀態:'+str(uev02_state)+'這裡是判斷手動與自動按鈕部分')
    def test_uev02():
        if uev02_state[0] ==1 :
            uev02_btn_manul.config(bg='#FA0200')
        else:
            uev02_btn_auto.config(bg='#FA0200')
        if uev02_state[1] ==1:
            uev02.config(bg='#FA0200')
            uev02_btn_manul_on.config(bg='#FA0200')
            uev02_state_show.config(text=state1)
        else:
            uev02_btn_manul_off.config(bg='#FA0200')
            uev02.config(bg='#00FF00')
            uev02_state_show.config(text=state0)
    root.after(1,test_uev02)
    return uev02_state
uev02 = tk.Button(root, text='uev02', command=uev02_openNewWindow,width=10,height=2,font='10')
def task_uev02():
    if uev02_state[1] ==0:
        uev02.config(bg='#00FF00')
        uhv05_state[1] = 0
    else :
        uev02.config(bg='#FA0200')
    root.after(1, task_uev02)

def uhv05_openNewWindow(): #建立新的視窗，內有button
    def uhv05_manual_fuc():
        uhv05_state[0] = 1 
        uhv05_btn_manul.config(bg='#FA0200')   
        uhv05_btn_auto.config(bg='#E0E0E0') 
        if uhv05_state[1] ==1:
            uhv05_btn_manul_on.config(bg='#FA0200')
        else :
            uhv05_btn_manul_off.config(bg='#FA0200')
        return uhv05_state
    def uhv05_auto_fuc():
        uhv05_state[0] = 0
        uhv05_btn_auto.config(bg='#FA0200') 
        uhv05_btn_manul_on.config(bg='#E0E0E0')
        uhv05_btn_manul_off.config(bg='#E0E0E0')
        uhv05_btn_manul.config(bg='#E0E0E0')
        return uhv05_state
    def uhv05_manul_off_fuc():
        uhv05_state[1] = 0
        uhv05_btn_manul_off.config(bg='#FA0200')
        uhv05_btn_manul_on.config(bg='#E0E0E0')
        uhv05_state_show.config(text=state0)
        return uhv05_state
    def uhv05_manul_on_fuc():
        uhv05_state[1] = 1
        uhv05_btn_manul_off.config(bg='#E0E0E0')
        uhv05_btn_manul_on.config(bg='#FA0200')
        uhv05_state_show.config(text=state1)
        return uhv05_state
    newwindow = Toplevel(root)
    newwindow.title("New window")
    tk.Label(newwindow,text='狀態',font=(40),bg='yellow').grid(row=1,column=1) #狀態標籤
    uhv05_state_show = tk.Label(newwindow, text=state1,font=(40),bg='blue') #按鈕連動狀態
    uhv05_state_show.grid(row=1,column=2)
    newwindow.geometry('500x300')
    uhv05_btn_auto =tk.Button(newwindow,text='自動',width='20', height='2',bg='#E0E0E0',command=uhv05_auto_fuc)     #自動按鈕
    uhv05_btn_auto.grid(row=2,column=1)
    uhv05_btn_manul = tk.Button(newwindow,text='手動',width='20', height='2',bg='#E0E0E0',command=uhv05_manual_fuc)    #手動按鈕
    uhv05_btn_manul.grid(row=2,column=2)
    uhv05_btn_manul_on = tk.Button(newwindow,text=state1,width='20', height='2',bg='#E0E0E0',command=uhv05_manul_on_fuc) #閉合按鈕
    uhv05_btn_manul_on.grid(row=3,column=1)
    uhv05_btn_manul_off = tk.Button(newwindow,text=state0,width='20', height='2',bg='#E0E0E0',command=uhv05_manul_off_fuc) #斷開按鈕
    uhv05_btn_manul_off.grid(row=3,column=2)
    print('uhv05目前狀態:'+str(uhv05_state)+'這裡是判斷手動與自動按鈕部分')
    def test_uhv05():
        if uhv05_state[0] ==1 :
            uhv05_btn_manul.config(bg='#FA0200')
        else:
            uhv05_btn_auto.config(bg='#FA0200')
        if uhv05_state[1] ==1:
            uhv05.config(bg='#FA0200')
            uhv05_btn_manul_on.config(bg='#FA0200')
            uhv05_state_show.config(text=state1)
        else:
            uhv05_btn_manul_off.config(bg='#FA0200')
            uhv05.config(bg='#00FF00')
            uhv05_state_show.config(text=state0)
    root.after(1,test_uhv05)
    return uhv05_state
uhv05 = tk.Button(root, text='UHV05', command=uhv05_openNewWindow,width=10,height=2,font='10')
def task_uhv05():
    if uhv05_state[1] ==0:
        uhv05.config(bg='#00FF00')
        uhv03_state[1] = 0
    else :
        uhv05.config(bg='#FA0200')
    root.after(1, task_uhv05)

def uhv03_openNewWindow(): #建立新的視窗，內有button
    def uhv03_manual_fuc():
        uhv03_state[0] = 1 
        uhv03_btn_manul.config(bg='#FA0200')   
        uhv03_btn_auto.config(bg='#E0E0E0') 
        if uhv03_state[1] ==1:
            uhv03_btn_manul_on.config(bg='#FA0200')
        else :
            uhv03_btn_manul_off.config(bg='#FA0200')
        return uhv03_state
    def uhv03_auto_fuc():
        uhv03_state[0] = 0
        uhv03_btn_auto.config(bg='#FA0200') 
        uhv03_btn_manul_on.config(bg='#E0E0E0')
        uhv03_btn_manul_off.config(bg='#E0E0E0')
        uhv03_btn_manul.config(bg='#E0E0E0')
        return uhv03_state
    def uhv03_manul_off_fuc():
        uhv03_state[1] = 0
        uhv03_btn_manul_off.config(bg='#FA0200')
        uhv03_btn_manul_on.config(bg='#E0E0E0')
        uhv03_state_show.config(text=state0)
        return uhv03_state
    def uhv03_manul_on_fuc():
        uhv03_state[1] = 1
        uhv03_btn_manul_off.config(bg='#E0E0E0')
        uhv03_btn_manul_on.config(bg='#FA0200')
        uhv03_state_show.config(text=state1)
        return uhv03_state
    newwindow = Toplevel(root)
    newwindow.title("New window")
    tk.Label(newwindow,text='狀態',font=(40),bg='yellow').grid(row=1,column=1) #狀態標籤
    uhv03_state_show = tk.Label(newwindow, text=state1,font=(40),bg='blue') #按鈕連動狀態
    uhv03_state_show.grid(row=1,column=2)
    newwindow.geometry('500x300')
    uhv03_btn_auto =tk.Button(newwindow,text='自動',width='20', height='2',bg='#E0E0E0',command=uhv03_auto_fuc)     #自動按鈕
    uhv03_btn_auto.grid(row=2,column=1)
    uhv03_btn_manul = tk.Button(newwindow,text='手動',width='20', height='2',bg='#E0E0E0',command=uhv03_manual_fuc)    #手動按鈕
    uhv03_btn_manul.grid(row=2,column=2)
    uhv03_btn_manul_on = tk.Button(newwindow,text=state1,width='20', height='2',bg='#E0E0E0',command=uhv03_manul_on_fuc) #閉合按鈕
    uhv03_btn_manul_on.grid(row=3,column=1)
    uhv03_btn_manul_off = tk.Button(newwindow,text=state0,width='20', height='2',bg='#E0E0E0',command=uhv03_manul_off_fuc) #斷開按鈕
    uhv03_btn_manul_off.grid(row=3,column=2)
    print('uhv03目前狀態:'+str(uhv03_state)+'這裡是判斷手動與自動按鈕部分')
    def test_uhv03():
        if uhv03_state[0] ==1 :
            uhv03_btn_manul.config(bg='#FA0200')
        else:
            uhv03_btn_auto.config(bg='#FA0200')
        if uhv03_state[1] ==1:
            uhv03.config(bg='#FA0200')
            uhv03_btn_manul_on.config(bg='#FA0200')
            uhv03_state_show.config(text=state1)
        else:
            uhv03_btn_manul_off.config(bg='#FA0200')
            uhv03.config(bg='#00FF00')
            uhv03_state_show.config(text=state0)
    root.after(1,test_uhv03)
    return uhv03_state
uhv03 = tk.Button(root, text='UHV03', command=uhv03_openNewWindow,width=10,height=2,font='10')
def task_uhv03():
    if uhv03_state[1] ==0:
        uhv03.config(bg='#00FF00')
        uhv06_state[1] = 0
        uhv07_state[1] = 0
        uhv08_state[1] = 0
        uhv13_state[1] = 0
        uhv14_state[1] = 0
        uhv15_state[1] = 0
    else :
        uhv03.config(bg='#FA0200')
    root.after(1, task_uhv03)

def uhv06_openNewWindow(): #建立新的視窗，內有button
    def uhv06_manual_fuc():
        uhv06_state[0] = 1 
        uhv06_btn_manul.config(bg='#FA0200')   
        uhv06_btn_auto.config(bg='#E0E0E0') 
        if uhv06_state[1] ==1:
            uhv06_btn_manul_on.config(bg='#FA0200')
        else :
            uhv06_btn_manul_off.config(bg='#FA0200')
        return uhv06_state
    def uhv06_auto_fuc():
        uhv06_state[0] = 0
        uhv06_btn_auto.config(bg='#FA0200') 
        uhv06_btn_manul_on.config(bg='#E0E0E0')
        uhv06_btn_manul_off.config(bg='#E0E0E0')
        uhv06_btn_manul.config(bg='#E0E0E0')
        return uhv06_state
    def uhv06_manul_off_fuc():
        uhv06_state[1] = 0
        uhv06_btn_manul_off.config(bg='#FA0200')
        uhv06_btn_manul_on.config(bg='#E0E0E0')
        uhv06_state_show.config(text=state0)
        return uhv06_state
    def uhv06_manul_on_fuc():
        uhv06_state[1] = 1
        uhv06_btn_manul_off.config(bg='#E0E0E0')
        uhv06_btn_manul_on.config(bg='#FA0200')
        uhv06_state_show.config(text=state1)
        return uhv06_state
    newwindow = Toplevel(root)
    newwindow.title("New window")
    tk.Label(newwindow,text='狀態',font=(40),bg='yellow').grid(row=1,column=1) #狀態標籤
    uhv06_state_show = tk.Label(newwindow, text=state1,font=(40),bg='blue') #按鈕連動狀態
    uhv06_state_show.grid(row=1,column=2)
    newwindow.geometry('500x300')
    uhv06_btn_auto =tk.Button(newwindow,text='自動',width='20', height='2',bg='#E0E0E0',command=uhv06_auto_fuc)     #自動按鈕
    uhv06_btn_auto.grid(row=2,column=1)
    uhv06_btn_manul = tk.Button(newwindow,text='手動',width='20', height='2',bg='#E0E0E0',command=uhv06_manual_fuc)    #手動按鈕
    uhv06_btn_manul.grid(row=2,column=2)
    uhv06_btn_manul_on = tk.Button(newwindow,text=state1,width='20', height='2',bg='#E0E0E0',command=uhv06_manul_on_fuc) #閉合按鈕
    uhv06_btn_manul_on.grid(row=3,column=1)
    uhv06_btn_manul_off = tk.Button(newwindow,text=state0,width='20', height='2',bg='#E0E0E0',command=uhv06_manul_off_fuc) #斷開按鈕
    uhv06_btn_manul_off.grid(row=3,column=2)
    print('uhv6目前狀態:'+str(uhv06_state)+'這裡是判斷手動與自動按鈕部分')
    if uhv06_state[0] ==1 :
        uhv06_btn_manul.config(bg='#FA0200')
    else:
        uhv06_btn_auto.config(bg='#FA0200')
    if uhv06_state[1] ==1:
        uhv06.config(bg='#FA0200')
        uhv06_btn_manul_on.config(bg='#FA0200')
        uhv06_state_show.config(text=state1)
    else:
        uhv06_btn_manul_off.config(bg='#FA0200')
        uhv06.config(bg='#00FF00')
        uhv06_state_show.config(text=state0)
    return uhv06_state
uhv06 = tk.Button(root, text='UHV06', command=uhv06_openNewWindow,width=10,height=2,font='10')
def task_uhv06():
    if uhv06_state[1] ==0:
        uhv06.config(bg='#00FF00')
    else :
        uhv06.config(bg='#FA0200')
    root.after(1, task_uhv06)

def uhv07_openNewWindow(): #建立新的視窗，內有button
    def uhv07_manual_fuc():
        uhv07_state[0] = 1 
        uhv07_btn_manul.config(bg='#FA0200')   
        uhv07_btn_auto.config(bg='#E0E0E0') 
        if uhv07_state[1] ==1:
            uhv07_btn_manul_on.config(bg='#FA0200')
        else :
            uhv07_btn_manul_off.config(bg='#FA0200')
        return uhv07_state
    def uhv07_auto_fuc():
        uhv07_state[0] = 0
        uhv07_btn_auto.config(bg='#FA0200') 
        uhv07_btn_manul_on.config(bg='#E0E0E0')
        uhv07_btn_manul_off.config(bg='#E0E0E0')
        uhv07_btn_manul.config(bg='#E0E0E0')
        return uhv07_state
    def uhv07_manul_off_fuc():
        uhv07_state[1] = 0
        uhv07_btn_manul_off.config(bg='#FA0200')
        uhv07_btn_manul_on.config(bg='#E0E0E0')
        uhv07_state_show.config(text=state0)
        return uhv07_state
    def uhv07_manul_on_fuc():
        uhv07_state[1] = 1
        uhv07_btn_manul_off.config(bg='#E0E0E0')
        uhv07_btn_manul_on.config(bg='#FA0200')
        uhv07_state_show.config(text=state1)
        return uhv07_state
    newwindow = Toplevel(root)
    newwindow.title("New window")
    tk.Label(newwindow,text='狀態',font=(40),bg='yellow').grid(row=1,column=1) #狀態標籤
    uhv07_state_show = tk.Label(newwindow, text=state1,font=(40),bg='blue') #按鈕連動狀態
    uhv07_state_show.grid(row=1,column=2)
    newwindow.geometry('500x300')
    uhv07_btn_auto =tk.Button(newwindow,text='自動',width='20', height='2',bg='#E0E0E0',command=uhv07_auto_fuc)     #自動按鈕
    uhv07_btn_auto.grid(row=2,column=1)
    uhv07_btn_manul = tk.Button(newwindow,text='手動',width='20', height='2',bg='#E0E0E0',command=uhv07_manual_fuc)    #手動按鈕
    uhv07_btn_manul.grid(row=2,column=2)
    uhv07_btn_manul_on = tk.Button(newwindow,text=state1,width='20', height='2',bg='#E0E0E0',command=uhv07_manul_on_fuc) #閉合按鈕
    uhv07_btn_manul_on.grid(row=3,column=1)
    uhv07_btn_manul_off = tk.Button(newwindow,text=state0,width='20', height='2',bg='#E0E0E0',command=uhv07_manul_off_fuc) #斷開按鈕
    uhv07_btn_manul_off.grid(row=3,column=2)
    print('uhv07目前狀態:'+str(uhv07_state)+'這裡是判斷手動與自動按鈕部分')
    def test_uhv07():
        if uhv07_state[0] ==1 :
            uhv07_btn_manul.config(bg='#FA0200')
        else:
            uhv07_btn_auto.config(bg='#FA0200')
        if uhv07_state[1] ==1:
            uhv07.config(bg='#FA0200')
            uhv07_btn_manul_on.config(bg='#FA0200')
            uhv07_state_show.config(text=state1)
        else:
            uhv07_btn_manul_off.config(bg='#FA0200')
            uhv07.config(bg='#00FF00')
            uhv07_state_show.config(text=state0)
    root.after(1,test_uhv07)
    return uhv07_state
uhv07 = tk.Button(root,text='UHV07',bg='red',width=10,height=2,font='10',command=uhv07_openNewWindow)
def task_uhv07():
    if uhv07_state[1] ==0:
        uhv07.config(bg='#00FF00')
    else :
        uhv07.config(bg='#FA0200')
    root.after(1, task_uhv07)

def uhv08_openNewWindow(): #建立新的視窗，內有button
    def uhv08_manual_fuc():
        uhv08_state[0] = 1 
        uhv08_btn_manul.config(bg='#FA0200')   
        uhv08_btn_auto.config(bg='#E0E0E0') 
        if uhv08_state[1] ==1:
            uhv08_btn_manul_on.config(bg='#FA0200')
        else :
            uhv08_btn_manul_off.config(bg='#FA0200')
        return uhv08_state
    def uhv08_auto_fuc():
        uhv08_state[0] = 0
        uhv08_btn_auto.config(bg='#FA0200') 
        uhv08_btn_manul_on.config(bg='#E0E0E0')
        uhv08_btn_manul_off.config(bg='#E0E0E0')
        uhv08_btn_manul.config(bg='#E0E0E0')
        return uhv08_state
    def uhv08_manul_off_fuc():
        uhv08_state[1] = 0
        uhv08_btn_manul_off.config(bg='#FA0200')
        uhv08_btn_manul_on.config(bg='#E0E0E0')
        uhv08_state_show.config(text=state0)
        return uhv08_state
    def uhv08_manul_on_fuc():
        uhv08_state[1] = 1
        uhv08_btn_manul_off.config(bg='#E0E0E0')
        uhv08_btn_manul_on.config(bg='#FA0200')
        uhv08_state_show.config(text=state1)
        return uhv08_state
    newwindow = Toplevel(root)
    newwindow.title("New window")
    tk.Label(newwindow,text='狀態',font=(40),bg='yellow').grid(row=1,column=1) #狀態標籤
    uhv08_state_show = tk.Label(newwindow, text=state1,font=(40),bg='blue') #按鈕連動狀態
    uhv08_state_show.grid(row=1,column=2)
    newwindow.geometry('500x300')
    uhv08_btn_auto =tk.Button(newwindow,text='自動',width='20', height='2',bg='#E0E0E0',command=uhv08_auto_fuc)     #自動按鈕
    uhv08_btn_auto.grid(row=2,column=1)
    uhv08_btn_manul = tk.Button(newwindow,text='手動',width='20', height='2',bg='#E0E0E0',command=uhv08_manual_fuc)    #手動按鈕
    uhv08_btn_manul.grid(row=2,column=2)
    uhv08_btn_manul_on = tk.Button(newwindow,text=state1,width='20', height='2',bg='#E0E0E0',command=uhv08_manul_on_fuc) #閉合按鈕
    uhv08_btn_manul_on.grid(row=3,column=1)
    uhv08_btn_manul_off = tk.Button(newwindow,text=state0,width='20', height='2',bg='#E0E0E0',command=uhv08_manul_off_fuc) #斷開按鈕
    uhv08_btn_manul_off.grid(row=3,column=2)
    print('uhv08目前狀態:'+str(uhv08_state)+'這裡是判斷手動與自動按鈕部分')
    def test_uhv08():
        if uhv08_state[0] ==1 :
            uhv08_btn_manul.config(bg='#FA0200')
        else:
            uhv08_btn_auto.config(bg='#FA0200')
        if uhv08_state[1] ==1:
            uhv08.config(bg='#FA0200')
            uhv08_btn_manul_on.config(bg='#FA0200')
            uhv08_state_show.config(text=state1)
        else:
            uhv08_btn_manul_off.config(bg='#FA0200')
            uhv08.config(bg='#00FF00')
            uhv08_state_show.config(text=state0)
    root.after(1,test_uhv08)
    return uhv08_state
uhv08 = tk.Button(root, text='UHV08', command=uhv08_openNewWindow,width=10,height=2,font='10')
def task_uhv08():
    if uhv08_state[1] ==0:
        uhv08.config(bg='#00FF00')
    else :
        uhv08.config(bg='#FA0200')
    root.after(1, task_uhv08)


def uhv13_openNewWindow(): #建立新的視窗，內有button
    def uhv13_manual_fuc():
        uhv13_state[0] = 1 
        uhv13_btn_manul.config(bg='#FA0200')   
        uhv13_btn_auto.config(bg='#E0E0E0') 
        if uhv13_state[1] ==1:
            uhv13_btn_manul_on.config(bg='#FA0200')
        else :
            uhv13_btn_manul_off.config(bg='#FA0200')
        return uhv13_state
    def uhv13_auto_fuc():
        uhv13_state[0] = 0
        uhv13_btn_auto.config(bg='#FA0200') 
        uhv13_btn_manul_on.config(bg='#E0E0E0')
        uhv13_btn_manul_off.config(bg='#E0E0E0')
        uhv13_btn_manul.config(bg='#E0E0E0')
        return uhv13_state
    def uhv13_manul_off_fuc():
        uhv13_state[1] = 0
        uhv13_btn_manul_off.config(bg='#FA0200')
        uhv13_btn_manul_on.config(bg='#E0E0E0')
        uhv13_state_show.config(text=state0)
        return uhv13_state
    def uhv13_manul_on_fuc():
        uhv13_state[1] = 1
        uhv13_btn_manul_off.config(bg='#E0E0E0')
        uhv13_btn_manul_on.config(bg='#FA0200')
        uhv13_state_show.config(text=state1)
        return uhv13_state
    newwindow = Toplevel(root)
    newwindow.title("New window")
    tk.Label(newwindow,text='狀態',font=(40),bg='yellow').grid(row=1,column=1) #狀態標籤
    uhv13_state_show = tk.Label(newwindow, text=state1,font=(40),bg='blue') #按鈕連動狀態
    uhv13_state_show.grid(row=1,column=2)
    newwindow.geometry('500x300')
    uhv13_btn_auto =tk.Button(newwindow,text='自動',width='20', height='2',bg='#E0E0E0',command=uhv13_auto_fuc)     #自動按鈕
    uhv13_btn_auto.grid(row=2,column=1)
    uhv13_btn_manul = tk.Button(newwindow,text='手動',width='20', height='2',bg='#E0E0E0',command=uhv13_manual_fuc)    #手動按鈕
    uhv13_btn_manul.grid(row=2,column=2)
    uhv13_btn_manul_on = tk.Button(newwindow,text=state1,width='20', height='2',bg='#E0E0E0',command=uhv13_manul_on_fuc) #閉合按鈕
    uhv13_btn_manul_on.grid(row=3,column=1)
    uhv13_btn_manul_off = tk.Button(newwindow,text=state0,width='20', height='2',bg='#E0E0E0',command=uhv13_manul_off_fuc) #斷開按鈕
    uhv13_btn_manul_off.grid(row=3,column=2)
    print('uhv13目前狀態:'+str(uhv13_state)+'這裡是判斷手動與自動按鈕部分')
    def test_uhv13():
        if uhv13_state[0] ==1 :
            uhv13_btn_manul.config(bg='#FA0200')
        else:
            uhv13_btn_auto.config(bg='#FA0200')
        if uhv13_state[1] ==1:
            uhv13.config(bg='#FA0200')
            uhv13_btn_manul_on.config(bg='#FA0200')
            uhv13_state_show.config(text=state1)
        else:
            uhv13_btn_manul_off.config(bg='#FA0200')
            uhv13.config(bg='#00FF00')
            uhv13_state_show.config(text=state0)
    root.after(1,test_uhv13)
    return uhv13_state
uhv13 = tk.Button(root, text='UHV13', command=uhv13_openNewWindow,width=10,height=2,font='10')
def task_uhv13():
    if uhv13_state[1] ==0:
        uhv13.config(bg='#00FF00')
    else :
        uhv13.config(bg='#FA0200')
    root.after(1, task_uhv13)

def uhv14_openNewWindow(): #建立新的視窗，內有button
    def uhv14_manual_fuc():
        uhv14_state[0] = 1 
        uhv14_btn_manul.config(bg='#FA0200')   
        uhv14_btn_auto.config(bg='#E0E0E0') 
        if uhv14_state[1] ==1:
            uhv14_btn_manul_on.config(bg='#FA0200')
        else :
            uhv14_btn_manul_off.config(bg='#FA0200')
        return uhv14_state
    def uhv14_auto_fuc():
        uhv14_state[0] = 0
        uhv14_btn_auto.config(bg='#FA0200') 
        uhv14_btn_manul_on.config(bg='#E0E0E0')
        uhv14_btn_manul_off.config(bg='#E0E0E0')
        uhv14_btn_manul.config(bg='#E0E0E0')
        return uhv14_state
    def uhv14_manul_off_fuc():
        uhv14_state[1] = 0
        uhv14_btn_manul_off.config(bg='#FA0200')
        uhv14_btn_manul_on.config(bg='#E0E0E0')
        uhv14_state_show.config(text=state0)
        return uhv14_state
    def uhv14_manul_on_fuc():
        uhv14_state[1] = 1
        uhv14_btn_manul_off.config(bg='#E0E0E0')
        uhv14_btn_manul_on.config(bg='#FA0200')
        uhv14_state_show.config(text=state1)
        return uhv14_state
    newwindow = Toplevel(root)
    newwindow.title("New window")
    tk.Label(newwindow,text='狀態',font=(40),bg='yellow').grid(row=1,column=1) #狀態標籤
    uhv14_state_show = tk.Label(newwindow, text=state1,font=(40),bg='blue') #按鈕連動狀態
    uhv14_state_show.grid(row=1,column=2)
    newwindow.geometry('500x300')
    uhv14_btn_auto =tk.Button(newwindow,text='自動',width='20', height='2',bg='#E0E0E0',command=uhv14_auto_fuc)     #自動按鈕
    uhv14_btn_auto.grid(row=2,column=1)
    uhv14_btn_manul = tk.Button(newwindow,text='手動',width='20', height='2',bg='#E0E0E0',command=uhv14_manual_fuc)    #手動按鈕
    uhv14_btn_manul.grid(row=2,column=2)
    uhv14_btn_manul_on = tk.Button(newwindow,text=state1,width='20', height='2',bg='#E0E0E0',command=uhv14_manul_on_fuc) #閉合按鈕
    uhv14_btn_manul_on.grid(row=3,column=1)
    uhv14_btn_manul_off = tk.Button(newwindow,text=state0,width='20', height='2',bg='#E0E0E0',command=uhv14_manul_off_fuc) #斷開按鈕
    uhv14_btn_manul_off.grid(row=3,column=2)
    print('uhv14目前狀態:'+str(uhv14_state)+'這裡是判斷手動與自動按鈕部分')
    def test_uhv14():
        if uhv14_state[0] ==1 :
            uhv14_btn_manul.config(bg='#FA0200')
        else:
            uhv14_btn_auto.config(bg='#FA0200')
        if uhv14_state[1] ==1:
            uhv14.config(bg='#FA0200')
            uhv14_btn_manul_on.config(bg='#FA0200')
            uhv14_state_show.config(text=state1)
        else:
            uhv14_btn_manul_off.config(bg='#FA0200')
            uhv14.config(bg='#00FF00')
            uhv14_state_show.config(text=state0)
    root.after(1,test_uhv14)
    return uhv14_state
uhv14 = tk.Button(root, text='UHV14', command=uhv14_openNewWindow,width=10,height=2,font='10')
def task_uhv14():
    if uhv14_state[1] ==0:
        uhv14.config(bg='#00FF00')
    else :
        uhv14.config(bg='#FA0200')
    root.after(1, task_uhv14)
def uhv15_openNewWindow(): #建立新的視窗，內有button
    def uhv15_manual_fuc():
        uhv15_state[0] = 1 
        uhv15_btn_manul.config(bg='#FA0200')   
        uhv15_btn_auto.config(bg='#E0E0E0') 
        if uhv15_state[1] ==1:
            uhv15_btn_manul_on.config(bg='#FA0200')
        else :
            uhv15_btn_manul_off.config(bg='#FA0200')
        return uhv15_state
    def uhv15_auto_fuc():
        uhv15_state[0] = 0
        uhv15_btn_auto.config(bg='#FA0200') 
        uhv15_btn_manul_on.config(bg='#E0E0E0')
        uhv15_btn_manul_off.config(bg='#E0E0E0')
        uhv15_btn_manul.config(bg='#E0E0E0')
        return uhv15_state
    def uhv15_manul_off_fuc():
        uhv15_state[1] = 0
        uhv15_btn_manul_off.config(bg='#FA0200')
        uhv15_btn_manul_on.config(bg='#E0E0E0')
        uhv15_state_show.config(text=state0)
        return uhv15_state
    def uhv15_manul_on_fuc():
        uhv15_state[1] = 1
        uhv15_btn_manul_off.config(bg='#E0E0E0')
        uhv15_btn_manul_on.config(bg='#FA0200')
        uhv15_state_show.config(text=state1)
        return uhv15_state
    newwindow = Toplevel(root)
    newwindow.title("New window")
    tk.Label(newwindow,text='狀態',font=(40),bg='yellow').grid(row=1,column=1) #狀態標籤
    uhv15_state_show = tk.Label(newwindow, text=state1,font=(40),bg='blue') #按鈕連動狀態
    uhv15_state_show.grid(row=1,column=2)
    newwindow.geometry('500x300')
    uhv15_btn_auto =tk.Button(newwindow,text='自動',width='20', height='2',bg='#E0E0E0',command=uhv15_auto_fuc)     #自動按鈕
    uhv15_btn_auto.grid(row=2,column=1)
    uhv15_btn_manul = tk.Button(newwindow,text='手動',width='20', height='2',bg='#E0E0E0',command=uhv15_manual_fuc)    #手動按鈕
    uhv15_btn_manul.grid(row=2,column=2)
    uhv15_btn_manul_on = tk.Button(newwindow,text=state1,width='20', height='2',bg='#E0E0E0',command=uhv15_manul_on_fuc) #閉合按鈕
    uhv15_btn_manul_on.grid(row=3,column=1)
    uhv15_btn_manul_off = tk.Button(newwindow,text=state0,width='20', height='2',bg='#E0E0E0',command=uhv15_manul_off_fuc) #斷開按鈕
    uhv15_btn_manul_off.grid(row=3,column=2)
    print('uhv15目前狀態:'+str(uhv15_state)+'這裡是判斷手動與自動按鈕部分')
    def test_uhv15():
        if uhv15_state[0] ==1 :
            uhv15_btn_manul.config(bg='#FA0200')
        else:
            uhv15_btn_auto.config(bg='#FA0200')
        if uhv15_state[1] ==1:
            uhv15.config(bg='#FA0200')
            uhv15_btn_manul_on.config(bg='#FA0200')
            uhv15_state_show.config(text=state1)
        else:
            uhv15_btn_manul_off.config(bg='#FA0200')
            uhv15.config(bg='#00FF00')
            uhv15_state_show.config(text=state0)
    root.after(1,test_uhv15)
    return uhv15_state
uhv15 = tk.Button(root, text='UHV15', command=uhv15_openNewWindow,width=10,height=2,font='10')
def task_uhv15():
    if uhv15_state[1] ==0:
        uhv15.config(bg='#00FF00')
    else :
        uhv15.config(bg='#FA0200')
    root.after(1, task_uhv15)

uhv10 = tk.Button(root,text='UHV10',width=10,height=2,font='10')


uhv11 = tk.Button(root,text='UHV11',width=10,height=2,font='10')




uev01.place(x=600, y=25)
uev02.place(x=600, y=125)
uhv05.place(x=600, y=225)
uhv02.place(x=400, y=225)
uhv09.place(x=200, y=225)
uhv12.place(x=800, y=225)
uhv03.place(x=500, y=320)
uhv06.place(x=100, y=400)
uhv07.place(x=250, y=400)
uhv08.place(x=400, y=400)
uhv10.place(x=550, y=400)
uhv11.place(x=700, y=400)
uhv13.place(x=850, y=400)
uhv14.place(x=1000, y=400)
uhv15.place(x=1150, y=400)

root.after(1, task_uev01)
root.after(1, task_uev02)
root.after(1, task_uhv03)
root.after(1, task_uhv05)
root.after(1, task_uhv06)
root.after(1, task_uhv07)
root.after(1, task_uhv08)
root.after(1, task_uhv13)
root.after(1, task_uhv14)
root.after(1, task_uhv15)



root.mainloop()
```