使用tkinter点击时如何获得显示标签的按钮?

时间:2015-07-16 02:52:32

标签: python python-2.7 tkinter

我想制作一个单击时显示标签的按钮。这是我的想法:

$ java -jar pdfbox-app-1.8.9.jar ExtractText da1059.pdf
Jul 15, 2015 10:41:38 PM org.apache.pdfbox.pdfparser.PDFParser parse
INFO: Document is encrypted
ExtractText failed with the following exception:
org.apache.pdfbox.exceptions.WrappedIOException
    at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:375)
    at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptString(SecurityHandler.java:577)
    at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decrypt(SecurityHandler.java:429)
    at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptDictionary(SecurityHandler.java:530)
    at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decrypt(SecurityHandler.java:437)
    at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptObject(SecurityHandler.java:403)
    at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.proceedDecryption(SecurityHandler.java:221)
    at org.apache.pdfbox.pdmodel.encryption.StandardSecurityHandler.decryptDocument(StandardSecurityHandler.java:158)
    at org.apache.pdfbox.pdmodel.PDDocument.openProtection(PDDocument.java:1602)
    at org.apache.pdfbox.ExtractText.startExtraction(ExtractText.java:216)
    at org.apache.pdfbox.ExtractText.main(ExtractText.java:85)
    at org.apache.pdfbox.PDFBox.main(PDFBox.java:58)
Caused by: javax.crypto.BadPaddingException: Given final block not properly padded
    at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:966)
    at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:824)
    at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:436)
    at javax.crypto.Cipher.doFinal(Cipher.java:2004)
    at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:351)
    ... 11 more

有人能够很好地指导我完成这件事吗?我很新。

1 个答案:

答案 0 :(得分:1)

您在之前调用write_hello函数甚至创建了按钮,因此您可能看到的是在UI上的按钮之前显示的标签(并且没有单击它)。你想要做的是将函数传递给Button构造函数而不是函数的返回值:

button = Button(root, text = "Hello!", command = write_hello)