1

我正在尝试使用一个条目来附加 shapefile 的 dbf 部分。到目前为止,我只能通过直接为变量赋值来更改 dbf 文件。我只能让输入框打印一个变量。我错过了什么?我正在使用 python 3.3。

import shapefile
from tkinter import filedialog 
import tkinter as tk
class application:
    def __init__(self,window):
        """ Initalize the Application """
        self.myentrybox = tk.Entry(window)
        self.myentrybox.pack()
        self.myentrybox.insert(0,"some default value")
        self.myentrybox.bind("<Return>",self.Enter)

    def Enter(self,event):
       """ Someone Pressed Enter """
       print  (self.myentrybox.get())
aep = 'self.myentrybox.get()'
root=tk.Tk()
myapp = application(root)
r = shapefile.Reader('Mississippi')
w = shapefile.Writer()
w.fields = list(r.fields)
w.field (aep, 'C', '40')
i=1

for rec in r.records():
 rec.append(i)
 i+=1
 w.records.append(rec)
w._shapes.extend(r.shapes())
w.save('AMissl6KM')
root.mainloop()
4

0 回答 0