首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >tkinter stipple选项在OS X中运行不正常

tkinter stipple选项在OS X中运行不正常
EN

Stack Overflow用户
提问于 2016-03-15 02:13:38
回答 1查看 816关注 0票数 2

我在Windows和OS上运行这个示例code来测试stipple,但结果不同。怎么一回事?

WindowsOS X

代码语言:javascript
复制
# semi-transparent-stipple-demo.py
# note: stipple only works for some objects (like rectangles)
# and not others (like ovals).  But it's better than nothing...

from Tkinter import *

def redrawAll(canvas):
    canvas.delete(ALL)
    # draw a red rectangle on the left half
    canvas.create_rectangle(0, 0, 250, 600, fill="red")
    # draw semi-transparent rectangles in the middle
    canvas.create_rectangle(200,  75, 300, 125, fill="blue", stipple="")
    canvas.create_rectangle(200, 175, 300, 225, fill="blue", stipple="gray75")
    canvas.create_rectangle(200, 275, 300, 325, fill="blue", stipple="gray50")
    canvas.create_rectangle(200, 375, 300, 425, fill="blue", stipple="gray25")
    canvas.create_rectangle(200, 475, 300, 525, fill="blue", stipple="gray12")

def init(canvas):
    redrawAll(canvas)

########### copy-paste below here ###########

def run():
    # create the root and the canvas
    root = Tk()
    canvas = Canvas(root, width=500, height=600)
    canvas.pack()
    # Store canvas in root and in canvas itself for callbacks
    root.canvas = canvas.canvas = canvas
    # Set up canvas data and call init
    canvas.data = { }
    init(canvas)
    # set up events
    # root.bind("<Button-1>", mousePressed)
    # root.bind("<Key>", keyPressed)
    # timerFired(canvas)
    # and launch the app
    root.mainloop()  # This call BLOCKS (so your program waits until you close the window!)

run()
EN

回答 1

Stack Overflow用户

发布于 2016-03-15 04:21:07

据我所知,点画从未在OSX上工作过--它可能在OS9下工作过,但直到2011年,这个问题还被讨论过,并在Tk8.5的OSX Tk stipple ticket discussion中标记为“已关闭,不会修复”

如果你看一下Tk 8.6的当前源代码,事情看起来仍然很严峻:

代码语言:javascript
复制
void *
TkMacOSXMakeStippleMap(
    Drawable drawable,      /* Window to apply stipple. */
    Drawable stipple)       /* The stipple pattern. */
{
    return NULL;
}

虽然我见过其他的Tk sources where this function is defined,但我不知道它们是否对应于任何官方版本。

这不仅仅是在OSX中实现点画的问题,他们似乎有一个问题,简单地记录点画在OSX中不起作用!

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35994986

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档