2016-07-04 3 views
1

내가 입력 한 결과를 표시하고 싶습니다. 나는 결과를 콘솔에 표시 할 수 있었지만 tkMessageBox.showinfo에 의해 열린 메시지는 표시하지 않았다. 대신 sme 수치 값을 얻습니다. 어느 이상입니다.메시지 상자에 tkinter 디스플레이 출력

아래 코드는 제 코드입니다. 모든

첫째, 해당 항목의 내용을 삭제하지 않습니다

#!/usr/bin/env python 
from Tkinter import * 
import tkSimpleDialog 
import tkMessageBox 
import time 
import requests 
def show_entry_fields(): 
print("loginS3: %s \n secretpasseS3: %s \n endpointS3: %s \n " % (ChamploginS3.get(), ChampsecretpasseS3.get(), ChampsendpointS3.get())) 
ChamploginS3.delete(0,END) 
ChampsecretpasseS3.delete(0,END) 
ChampsendpointS3.delete(0,END) 
tkMessageBox.showinfo (title='inputs for S3', message="are those inputs correct ? " '\n' 'loginS3: %s \n secretpasseS3: %s \n endpointS3: %s \n ' %(ChamploginS3,ChampsecretpasseS3,ChampsendpointS3)) 
fenetre0 = Tk() 
fenetre0.title('S3 brower perso') 
fenetre0.geometry("380x100") 
Label1 = Label(fenetre0, text = 'loginS3', fg = 'blue').grid (row=0) 
Label2 = Label(fenetre0, text = 'secretpasseS3', fg = 'red').grid (row=1) 
Label3 = Label(fenetre0, text = 'endpointS3', fg = 'purple').grid (row=2) 
loginS3= StringVar() 
ChamploginS3 = Entry(fenetre0, textvariable= loginS3, bg ='bisque', fg='maroon') 
secretpasseS3= StringVar() 
ChampsecretpasseS3 = Entry(fenetre0, textvariable= secretpasseS3, show='*', bg ='bisque', fg='maroon') 
endpointS3= StringVar() 
ChampsendpointS3 = Entry(fenetre0, textvariable= endpointS3, bg ='bisque', fg='maroon') 
ChamploginS3.grid(row=0, column=1) 
ChampsecretpasseS3.grid(row=1, column=1) 
ChampsendpointS3.grid(row=2, column=1) 
Bouton1 = Button(fenetre0, text = 'END', command = fenetre0.destroy).grid(row=3, column=0, sticky=W, pady=4) 
Bouton2 = Button(fenetre0, text = 'SHOW', command = show_entry_fields).grid(row=3, column=1, sticky=W, pady=4) 
fenetre0.mainloop() 
+2

코드를 들여 씁니다. – shivsn

답변

1

당신이 해결해야 할 두 가지가 있습니다.

ChamploginS3.delete(0,END) 
    ChampsecretpasseS3.delete(0,END) 
    ChampsendpointS3.delete(0,END) 

둘째, 엔트리 위젯의 내용이 get() 방법을 사용하여 액세스 :이 3 선를 멀리 제거해야합니다 이것은 의미한다. 당신은 당신이 기대하는 것을 얻을 것이다, 위에서 언급 한 일을 후에

:

tkMessageBox.showinfo (title='inputs for S3', message="are those inputs correct ? " '\n' 'loginS3: %s \n secretpasseS3: %s \n endpointS3: %s \n ' %(ChamploginS3,ChampsecretpasseS3,ChampsendpointS3)) 

하려면 :

tkMessageBox.showinfo (title='inputs for S3', message="are those inputs correct ? " '\n' 'loginS3: %s \n secretpasseS3: %s \n endpointS3: %s \n ' %(ChamploginS3.get(),ChampsecretpasseS3.get(),ChampsendpointS3.get())) 

데모이이 라인을 변경해야 의미

enter image description here

+1

Azul Billal, Merci! 효과가있다. – MouIdri