Импорт переменной из другого .py
при запуске пишет:
Traceback (most recent call last):
File "d:\Projects\NP4\Folder1\src\main.py", line 2, in from other_sites
import site1
ImportError: cannot import name 'site1' from 'other_sites' (d:\Projects\NP4\Folder1\src\other_sites.py)
Не могу понять почему код не видит переменную в другом файле.
main.py
и other_sites.py
находятся в одной директории.
main.py
:
from tkinter import Tk, Frame, Button
from other_sites import site1
import webbrowser
window = Tk()
window.title("W")
window.geometry("267x1040+{:d}+0".format(window.winfo_screenwidth()-267)) # Установка размеров и положения окна
window.overrideredirect(1)
def open_site(site_url):
if site_url:
webbrowser.open(site_url)
frame = Frame(window)
frame.pack()
button1 = Button(frame, text="STOP", width=25, height=3, command=window.destroy)
button1.grid(row=0, column=0, columnspan=3, padx=5, pady=5)
button2 = Button(frame, text="Button 1", width=9, height=3, command=lambda: open_site(site1))
button2.grid(row=1, column=0, padx=5, pady=35)
window.mainloop()
other_sites.py
:
site1 = "https://learn-anything.xyz/"
site2 = "https://learn-anything.xyz/"
site3 = "https://learn-anything.xyz/"
site4 = "https://learn-anything.xyz/"
site5 = "https://learn-anything.xyz/"
site6 = ""
site7 = ""
site8 = ""
site9 = ""
site10 = ""
site11 = ""
site12 = ""
site13 = ""
site14 = ""
site15 = ""
site16 = ""
site17 = ""
site18 = ""
site19 = ""
site20 = ""
site21 = ""