import Tkinter as tk
P_width = 1000
P_height = 600
pborder = 20
def main():
root = tk.Tk()
w, h = root.winfo_screenwidth(), root.winfo_screenheight()
root.overrideredirect(0)
root.geometry("%dx%d+0+0" % (w, h))
P_width = w - pborder*2
P_height = h - pborder*2
root.title("SOCIAL NETWORK VISUALIZATION")
P = tk.Canvas(root, width=P_width+2*pborder, height=P_height+2*pborder, bg='black')
P.pack()
P.focus_set()
b = Button(root, text="Next Layer View", command=start,bg="orange")
b.pack()
P.mainloop()
def start():
from force_directed_graph_layout import *
if __name__ == "__main__":
main()
(TypeError: init ()得到了一个意外的关键字参数'text') 运行此代码时,未定义的名称按钮显示为错误。请求帮助
答案 0 :(得分:1)
对于您当前的问题, -
运行此代码时,未定义的名称按钮显示为错误
问题是您要导入Tkinter
作为 -
import Tkinter as tk
但是,您尝试直接使用Button
,但尚未直接导入。您需要使用tk.Button()
-
b = tk.Button(root, text="Next Layer View", command=start,bg="orange")