【发布时间】:2014-05-19 01:11:30
【问题描述】:
我有这个代码:
from Tkinter import *
def get_info(key):
pass#do more later
def create_new():
create = Toplevel(root)
create.title('Create A New Contact')
Label(create, text='Name: ').grid(row=0, sticky=W+E)
name = Entry(create, width=8).grid(row=1, sticky=W+E)
Label(create, text='Address(ex. 1111 Main St, MyCity, Anystate 12345): ', wraplength=1).grid(row=2, sticky=W+E)
address = Entry(create, width=8).grid(row=3, sticky=W+E)
def access():
access_window = Toplevel(root)
access_window.title("Access a Contact")
Label(access_window, text="Enter a first name: ").grid(row=0, sticky=W+E)
access_key = Entry(access_window, width=8).grid(row=1, sticky=W+E)
Button(access_window, text="Submit", command=lambda: get_info(access_key.get('0.0', 'end-1c'))).grid(row=2, sticky=W+E)
root = Tk()
root.title('Address Book')
button1 = Button(root, text="Create New", command=create_new)
button1.grid(row=0, column=0)
button2 = Button(root, text="Access Person", command=access)
button2.grid(row=0, column=1)
此行有错误:
button2.grid(row=0, column=1)
它给了我这个错误:
Segmentation fault: 11
为什么会出现这种情况?什么是分段错误?
【问题讨论】:
-
顺便说一下,我使用的是 Python 2.7。
-
你用的是什么库?我的意思是,Button 类是从哪里来的?
-
我的第一行代码:
-
from Tkinter import * -
access命令中有什么内容?
标签: python button error-handling tkinter