-1
나는 tkinter의 기초를 다뤄 다른 어떤 것을 배우려고하기 전에 콘솔에 많은 입력 필드의 내용을 인쇄 할 수 있도록 노력해왔다. . 내가 원하는 방식으로 보였지만 필요한 기능이 없었습니다. 내가 클래스를 생성하고 그런 식으로 할 것을 제안했다. 그 시점에서 나의 GUI는 내가 추가 한 위젯이없는 빈 프레임이다. 왜이 사람이 될 수 있는지 아는 사람 있습니까?tkinter 수업을 성가 시게하고있다
from tkinter import *
class Information:
def __init__(self, master):
frame = Frame(master)
frame.pack()
self.titleLabel = Label(frame, text='Welcome to the Redaction Solutions editor!\nPlease enter the requested filepaths below.')
self.titleLabel.pack(side=TOP)
self.originalLabel = Label(frame, text='File to be edited')
self.originalLabel.pack(side=LEFT)
self.originalEntry = Entry(frame)
self.originalEntry.pack(side=RIGHT)
self.namesLabel = Label(frame, text='Items to be removed')
self.namesLabel.pack(side=LEFT)
self.namesEntry = Entry(frame)
self.namesEntry.pack(side=RIGHT)
self.destinationLabel = Label(frame, text='Edited file')
self.destinationLabel.pack(side=LEFT)
self.destinationEntry = Entry(frame)
self.destinationEntry.pack(side=RIGHT)
self.invoiceLabel = Label(frame, text='Invoice data')
self.invoiceLabel.pack(side=LEFT)
self.invoiceEntry = Entry(frame)
self.invoiceEntry.pack(side=RIGHT)
self.demoButton = Button(frame, text="Test", command=self.test)
self.demoButton.pack(side=LEFT)
self.resetButton = Button(frame, text="Reset Fields", bg="red", fg="black", command=self.reset)
self.resetButton.pack(side=RIGHT)
def test(self):
print(self.originalEntry.get())
print(self.namesEntry.get())
print(self.destinationEntry.get())
print(self.invoiceEntry.get())
def reset(self):
self.originalEntry.delete(0, END)
self.namesEntry.delete(0, END)
self.destinationEntry.delete(0, END)
self.invoiceEntry.delete(0, END)
root = Tk()
root.wm_title("RS")
b = Information
root.iconbitmap(r'c:\Users\pbrow\Documents\logoicon.ico')
root.mainloop()
나는이 프로그램을 작성하는 데 대략 최악의 방법이라고 확신하고 있으며 ... 나는 그걸로 괜찮습니다. 나는 단지 그것이 제대로 작동하기를 원합니다. 나는 (많은) 나중에 최적화에 대해 걱정할 것을 스스로 잊었습니다.
'__init__' 메쏘드는 하나의 인자 ('self'를 넘어서기)를 기대하기 때문에'b = Information (root)'이어야 할 것이라고 확신합니다. – Blckknght
@Blckknght 맞습니다. 답변을 업데이트했습니다. 감사! –