小编gmo*_*onz的帖子

有没有办法在Mac上的应用程序窗口中显示菜单栏?

我正在按照一个教程进行操作,并且完全按照说的话得到了不同的结果。

我希望菜单栏像在教程中一样显示在实际的tkinter应用程序窗口中。他正在使用Windows。而是显示在计算机的实际顶部菜单栏上。如果使用Mac,那我会有所作为。有没有办法解决这个问题?

这是我的代码:

from tkinter import *


def doNothing():
    label1 = Label(root, text="Doing nothing")
    label1.pack()

root = Tk()

mainmenu = Menu(root)
root.config(menu=mainmenu)

filemenu = Menu(mainmenu)
mainmenu.add_cascade(label="File", menu=filemenu)
filemenu.add_command(label="New Project", command=doNothing)
filemenu.add_command(label="New", command=doNothing)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=doNothing)

editmenu=Menu(mainmenu)
mainmenu.add_cascade(label="Edit", menu=editmenu)
editmenu.add_command(label="Redo", command=doNothing)


root.mainloop()
Run Code Online (Sandbox Code Playgroud)

python tk-toolkit tkinter python-3.x python-3.6

5
推荐指数
1
解决办法
1359
查看次数

Pytesseract 转换期间出现“ValueError:无法过滤调色板图像”

遇到有关 Pytesseract 的以下代码的此错误代码的问题。(Python 3.6.1,Mac OSX)

从 PIL 导入 pytesseract 导入请求 从 PIL 导入图像 从 io 导入 ImageFilter 导入 StringIO, BytesIO

def process_image(url):
    image = _get_image(url)
    image.filter(ImageFilter.SHARPEN)
    return pytesseract.image_to_string(image)


def _get_image(url):
    r = requests.get(url)
    s = BytesIO(r.content)
    img = Image.open(s)
    return img

process_image("https://www.prepressure.com/images/fonts_sample_ocra_medium.png")
Run Code Online (Sandbox Code Playgroud)

错误:

/usr/local/Cellar/python3/3.6.0_1/Frameworks/Python.framework/Versions/3.6/bin/python3.6 /Users/g/pyfo/reddit/ocr.py
Traceback (most recent call last):
  File "/Users/g/pyfo/reddit/ocr.py", line 20, in <module>
    process_image("https://www.prepressure.com/images/fonts_sample_ocra_medium.png")
  File "/Users/g/pyfo/reddit/ocr.py", line 10, in process_image
    image.filter(ImageFilter.SHARPEN)
  File "/usr/local/lib/python3.6/site-packages/PIL/Image.py", line 1094, in filter
    return self._new(filter.filter(self.im))
  File "/usr/local/lib/python3.6/site-packages/PIL/ImageFilter.py", line 53, in filter
    raise ValueError("cannot …
Run Code Online (Sandbox Code Playgroud)

python ocr tesseract typeerror pytesser

2
推荐指数
1
解决办法
1628
查看次数