0
공식적인 프로그래밍 경험이 없으므로 용어와 프로그램 구조가 부족한 부분을 용서해주십시오. Stackoverflow는 엄청난 도움이되었습니다. 이것은 내 첫 번째 질문이므로 부드럽게하십시오.Tkinter python이 별도의 파일에 줄을 덧붙입니다.
나는 GUI를 작성해야한다. 현재로서는 잘 작동하고 3500 줄이 넘는 코드와 여러 파일이 있습니다.
누군가가 내게 약간의 지침을 제공 할 수 있다면 별도의 파일에 추가 선이 필요합니다. 제 질문이 충분히 명확하지 않은 경우 알려주십시오. 고맙습니다.
save_test.py (파이썬 2.7.x & Tkinter를)
(이 난 그냥 아주 클래스 부분 주위에 내 머리를 얻을 수없는 분명한 이유가 작동하지 않습니다)
#!/usr/bin/python
from Tkinter import *
class Application(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.grid()
self.createWidgets()
self.DoIt()
def createWidgets(self):
self.code = []
# Create Frames
self.FileFrame = Frame(self, bd=5)
self.FileFrame.grid(row=0, column=0, padx=10, sticky=N + S + E + W)
self.f10 = Label(self.FileFrame, text='Enter Number', width=15, font="-weight bold")
self.f10.grid(row=0, column=0)
self.entersomething = StringVar()
self.entersomething.set("123")
self.es = Entry(self.FileFrame, textvariable=self.entersomething, width=5)
self.es.grid(row=0, column=1)
self.Send = Button(self.FileFrame, text='Send To File', command=self.SendButton)
self.Send.grid(row=0, column=2,)
def SendButton(self):
self.DoIt()
f = open('c:\Python\code.txt', 'w')
for line in self.code:
f.write(line + '\n')
f.close()
def DoIt(self):
thickness = float(self.es.get())
self.code = []
#something here to make it append the lines in mycode.py
app = Application()
app.mainloop()
mycode.py 당신은 하나의 작은 장을 만들 필요가
self.code.append('(Code Generated)')
self.code.append('#1=%.4f (Thickness)' % thickness)
감사합니다. 바라건대 지금은 조금 더 분명해졌습니다. – Kent