raspberry pi in python

I have this simple function for my raspberry pi and I made a python file it does work

factory = PiGPIOFactory(host='raspberry pi ip address')
Switch_1 = LED(18, pin_factory=factory)
Switch_2 = LED(23, pin_factory=factory)
Switch_3 = LED(24, pin_factory=factory)

Switch_1.on()
Switch_2.on()
Switch_3.on()

I tried to put it into another python file
and put it under a function which I called
def raspberry_pi():
but for whatever reason it doesn’t work I’m having a hard time understanding why

import requests
import webbrowser
from tkinter import *
import tkinter as tk
from tkinter import ttk
from gpiozero import LED
from gpiozero.pins.pigpio import PiGPIOFactory

root = tk.Tk()
root.geometry("484x380+1300+200")  # Size of the window
# admin.resizable(False, False)  # disables resizing only
# admin.attributes("-toolwindow", True)  # True=disables maximum and minimum not x
root.title('Administrative Tools')

statusbar = tk.StringVar()
label_statusbar = Label(root, borderwidth=8, height=1, fg='#000000', bd=1, relief=SUNKEN,
                        anchor=W, textvariable=statusbar, font=('Arial', 15))
label_statusbar.pack(side=BOTTOM, fill=X)


def admin_on_closing():
    # this will ask are you sure yes or no
    # if yes it will terminate the window
    root.destroy()


def esp_easy_0():
    http = "ip address /login"  # this is the HTTP we are calling
    tab = ", new=2"  # this will add a new tab the 2 stands for second tab

    try:
        requests.get(http)
    except requests.ConnectionError:
        statusbar.set("Can't connect to the Device")
        root.after(3000, lambda: statusbar.set(''))
    else:
        webbrowser.open(http + tab)  # this opens up the web browser


def esp_easy_1():
    http = "ip address/login"  # this is the HTTP we are calling
    tab = ", new=2"  # this will add a new tab the 2 stands for second tab

    try:
        requests.get(http)
    except requests.ConnectionError:
        statusbar.set("Can't connect to the Device")
        root.after(3000, lambda: statusbar.set(''))
    else:
        webbrowser.open(http + tab)  # this opens up the web browser


def raspberry_pi():
    factory = PiGPIOFactory(host='raspberry pi ip address')
    Switch_1 = LED(18, pin_factory=factory)
    Switch_2 = LED(23, pin_factory=factory)
    Switch_3 = LED(24, pin_factory=factory)

    Switch_1.on()
    Switch_2.on()
    Switch_3.on()


# Listbox1
label_header1 = Label(root, height=1, width=45, text='Administrative Tools',
                      background="#00FFFF", font=('Arial bold', 13))
label_header1.place(x=10, y=10)
my_listbox1 = tk.Listbox(root, selectmode=SINGLE,
                         height=10, width=50, justify="left",
                         bg='#cccccc', font=('Arial Bold', 13))
my_listbox1.place(x=10, y=37)  # x=justify left to right

# Listbox2 no header and no x y location
# it is not needed here
# ( this is part of Maintenance_admin_Tools.py window
# it allows the calling of 'list_item_values2'
# this could be considered an invisible window )
my_listbox2 = tk.Listbox(root)  # options are not needed here

# when the X is used to close the window it will call on_closing
root.protocol('WM_DELETE_WINDOW', admin_on_closing)

# path = r'C:WindowsSystem32'
# the * is multiplication so *1=1 *2=2
list_Sonoff_config = [r"ESP_EASY_0", r"ESP_EASY_1", r"ESP_EASY_",
                      r"ESP_EASY_", r"ESP_EASY_", r"ESP_EASY_", r"---",
                      r"raspberry_ i", ] * 1

my_listbox1.insert(END, *list_Sonoff_config)


def selecteditem():
    selection = my_listbox1.curselection()
    if selection == (0,):
        esp_easy_0()  # esp_easy_0()
    elif selection == (1,):
        esp_easy_1()
    elif selection == (2,):
        pass
    elif selection == (3,):
        pass
    elif selection == (4,):
        pass
    elif selection == (5,):
        pass
    elif selection == (6,):
        pass
    elif selection == (7,):
        raspberry_pi()


# when selected above the button will take you there
btn = Button(root, text='Select', width=8, borderwidth=8, font=('Arial Bold', 13), command=selecteditem)
btn.place(x=180, y=250)

my_listbox1.bind('<Double-1>', lambda event: selecteditem())

# sets the scrollbar vertically
verscrlbar = ttk.Scrollbar(root, orient='vertical', command=my_listbox1.yview)
# places the scrollbar on the right
verscrlbar.place(x=459 + 3, y=38, height=182 + 20)  # the number after the + is fine-tuning
my_listbox1.configure(yscrollcommand=verscrlbar.set)

root.mainloop()

Under that function I can call the file and it will work
I just can’t put everything under the function I don’t understand what’s going on.

Well first off I posted the whole code because I was requested to

if I didn’t make myself clear I apologize for that

what I’m trying to do just for testing right now is turn on three LEDs on my raspberry pi

so I made this simple code that does so in python and called it lights_on and another one lights_off

and it works perfectly

so I made a another python file a menu and in that menu I called it raspberry pi and generated a function

I called the function raspberry_pi():

I put the contents of lights_on in that function

but for whatever reason it will not work

but if I use a simple command like open(lights_on) to call the lights_on file it will work

so I’m trying to find out why I can’t put the contents of lights_on under the function of raspberry_pi():

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật