Python Tkinter异常

时间:2017-10-13 07:00:56

标签: python tkinter

我的脚本中出现了tkinter异常: 这是代码:

def readconf(startmenu):
    gui_mainmenu (wlc_current, wlcsession, startmenu)

def gui_startmenu():
startmenu=Tk()
startmenu.title ( "Netcloud WLC-Config" )
logo = PhotoImage ( file="nc-logo.ppm" )
w1 = Label ( startmenu, image=logo ).pack ()
explanation = """Welcome to the Netcloud WLC-Sripting Tool"""
w2 = Label ( startmenu,
             justify=LEFT,
             pady=20,
             text=explanation ).pack ()
btn_menu1 = Button ( startmenu, text='Login to WLC', command=lambda: readconf(startmenu)).pack ( fill=X )
btn_menu6 = Button ( startmenu, text='Exit', command=lambda: sys.exit ( 0 ) ).pack ( fill=X, padx=100, pady=50 )
startmenu.mainloop ()

def gui_mainmenu(wlc, wlcsession, startmenu):
    startmenu.destroy ()  # Destroy the Startmenu
    set_APInfos ( wlc, wlcsession )

if __name__ == "__main__":
    # Start Menu
    gui_startmenu()

当我调用函数set_APInfos()时,我得到了这个异常:

Exception in Tkinter callback
Traceback (most recent call last):
  File "/Users/burgener/Documents/Scripting/scripts/WLC-Config/WLC-configurator.py", line 191, in set_APInfos
    wlcsession.sendcommand ( "config ap name '" + ap_new_name[i] + "' " + apnames[i] )
  File "/Users/burgener/Documents/Scripting/scripts/WLC-Config/libCuwn.py", line 101, in sendcommand
    self.cli.send(command+"\n")
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/paramiko/channel.py", line 716, in send
    return self._send(s, m)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/paramiko/channel.py", line 1082, in _send
    raise socket.error('Socket is closed')
OSError: Socket is closed

在处理上述异常期间,发生了另一个异常:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/__init__.py", line 1538, in __call__
    return self.func(*args)
  File "/Users/burgener/Documents/Scripting/scripts/WLC-Config/WLC-configurator.py", line 593, in <lambda>
    btn_menu1 = Button ( startmenu, text='Login to WLC', command=lambda: readconf(startmenu)).pack ( fill=X )
  File "/Users/burgener/Documents/Scripting/scripts/WLC-Config/WLC-configurator.py", line 116, in readconf
    gui_mainmenu (wlc_current, wlcsession, startmenu)
  File "/Users/burgener/Documents/Scripting/scripts/WLC-Config/WLC-configurator.py", line 600, in gui_mainmenu
    set_APInfos ( wlc, wlcsession )
  File "/Users/burgener/Documents/Scripting/scripts/WLC-Config/WLC-configurator.py", line 195, in set_APInfos
    print ( "Error: Connection failed to WLC: %s\n" % wlcsession.hostname )
AttributeError: 'WlcSession' object has no attribute 'hostname'

0 个答案:

没有答案