小编Whi*_*mer的帖子

Python:Tkinter bind("<<Modified>>") 只能工作一次

所以我正在尝试 tkinter Text 小部件..并制作了一个小代码来突出显示文本中的“print”一词..代码:

from tkinter import *
def get(*arg):
    print("Highlighting...")
    text.tag_remove('found', '1.0', END)
    s = "print"
    if s:
        idx = '1.0'
        while 1:
            idx = text.search(s, idx, nocase=1, stopindex=END)
            if not idx: break
            lastidx = '%s+%dc' % (idx, len(s))
            text.tag_add('found', idx, lastidx)
            idx = lastidx
            text.see(idx)  # Once found, the scrollbar automatically scrolls to the text
            text.bind('<<Modified>>', get)
            break
        text.tag_config('found', foreground='green')

root = Tk()
text = Text(root)
text.grid()
root.bind('<<Modified>>', get)
root.mainloop()
Run Code Online (Sandbox Code Playgroud)

在此,root.bind('<<Modified>>', get)作品仅一次。我用它只工作了一次的行检查了它,print("Highlighting...")即使我输入了数千个字符..

难道我做错了什么?或者我的方法不好?

SPECS: …
Run Code Online (Sandbox Code Playgroud)

python tkinter

4
推荐指数
1
解决办法
945
查看次数

4
推荐指数
1
解决办法
1020
查看次数

PDFminer - 有没有办法从 pdfminer 将 pdf 转换为 html?

使用 pdfminer 将 pdf 转换为 html 的简单方法是?我见过很多这样的问题,但他们不会给我正确的答案......

我已在 ConEmu 提示符中输入以下内容:

# pdf2txt.py -o output.html -t html sample.pdf
usage: C:\Program Files\Python37-32\Scripts\pdf2txt.py [-P password] [-o output] [-t text|html|xml|tag] [-O output_dir] [-c encoding] [-s scale] [-R rotation] [-Y normal|loose|exact] [-p pagenos] [-m maxpages] [-S] [-C] [-n] [-A] [-V] [-M char_margin] [-L line_margin] [-W word_margin] [-F boxes_flow] [-d] input.pdf ...
Run Code Online (Sandbox Code Playgroud)

我希望这不是我应该从 pdf2txt.py 得到的响应。

有没有可以工作的代码片段?我已经尝试过这个:

from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer.converter import HTMLConverter
from pdfminer.layout import LAParams
from pdfminer.pdfpage import PDFPage
from io import …
Run Code Online (Sandbox Code Playgroud)

python pdf pdf-to-html pdfminer

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

python ×3

tkinter ×2

pdf ×1

pdf-to-html ×1

pdfminer ×1

tabs ×1

ttk ×1