Python 将数据从main.py导入example.py无法正常工作
我似乎无法正确导入分配的数据。例如,我的脚本是一个带有main.py和ipfunc.py的简单GUI。main.py文件包含TKinter GUI代码,ipfunc.py文件包含每个按钮将执行的所有功能 我让这段代码在旧版本中工作得很好,所有代码都放在一起,没有使用GUI的类和对象,但是现在我在尝试将数据从一个文件导入到另一个文件时遇到了麻烦 这是GUI(main.py)文件Python 将数据从main.py导入example.py无法正常工作,python,class,object,import,Python,Class,Object,Import,我似乎无法正确导入分配的数据。例如,我的脚本是一个带有main.py和ipfunc.py的简单GUI。main.py文件包含TKinter GUI代码,ipfunc.py文件包含每个按钮将执行的所有功能 我让这段代码在旧版本中工作得很好,所有代码都放在一起,没有使用GUI的类和对象,但是现在我在尝试将数据从一个文件导入到另一个文件时遇到了麻烦 这是GUI(main.py)文件 from ipfunc import * from tkinter import * from tkinter.ttk
from ipfunc import *
from tkinter import *
from tkinter.ttk import *
import tkinter as tk
class gui:
def __init__(self, root):
self.root = root
root.title("IPPing")
root.geometry("380x100+900+300")
self.label = Label(root, text="___________").grid(row=1)
self.label2 = Label(root, text="Enter IP Address").grid(row=2)
e1 = tk.Entry(root)
e1.grid(row=2, column=1)
self.button_addip = Button(text='Add New IP', command=newip).grid(row=0, column=0, pady=2)
self.button_list = Button(root, text='List of IPs', command=contents).grid(row=0, column=1, sticky=tk.SE,
pady=2)
self.button_ping = Button(root, text='Ping all servers', command=scanlist).grid(row=0, column=2, sticky=tk.SE,
pady=2)
self.button_quit = Button(root, text='Quit', command=root.quit).grid(row=0, column=3, pady=2)
root = tk.Tk()
ip_gui = gui(root)
root.mainloop()
这是我想在按下按钮时执行的功能,但在使用这些功能时出现的错误我无法解决,请帮助
回答您的问题并显示您的回溯。您想在
模块ipfunc
中使用e1
,它是local
到\uuuuu init\uuuu
。那是不可能的。我怎样才能使它不是本地的呢