제목에서 알 수 있듯이 필터링 된 DataFrame을 표시하는 GUI (Tkinter 포함)에서 버튼을 만들어야합니다.
DataFrame 가져 오기
df = pd.read_csv (r'C:\Users\shold\Downloads\df.csv')
df = df[['A', 'B', 'C', 'D', 'E', 'F', 'G']]
필터링 된 DataFrame
FIltered_df= df.drop_duplicates(subset=['G'])
FIltered_df= FIltered_df.iloc[:,[0,6]]
GUI를 만들려고했지만 코드를 실행하면 인쇄 기능이 GUI가 아닌 IDE (Jupyter) 내에서 실행됩니다.이 문제를 어떻게 해결할 수 있습니까? 아이디어는 필터링 된 모든 결과가 표시되는 기존 600x600 창 내에 새 창 또는 목록을 만드는 것입니다.
window = tk.Tk()
window.geometry("600x600")
window.title("GUI")
def first_print():
text ="Filter the df"
text_output = tk.Label(window, text=text)
text_output.grid(row=0, column=1, padx = 50)
print(FIltered_df)
first_button = tk.Button(text="Filter the df", command=first_print)
first_button.grid(row=0, column=0)
감사
이것을 시도하십시오. GUI에 무언가를 표시하려면 Label
.
함수에서 이러한 변경을 수행하십시오.
def first_print():
text ="Filter the df"
text_output = tk.Label(window, text=text)
text_output.grid(row=0, column=1, padx = 50)
text = tk.Label(window,text=Filtered_df,font=('monospace',11)) #font=(family,size)
text.grid(row=1,column=1)
그것이 당신의 의심을 없애기를 바랍니다.
건배
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다