当前位置: 首页>>代码示例>>Python>>正文


Python Tkinter.Canvas方法代码示例

本文整理汇总了Python中Tkinter.Canvas方法的典型用法代码示例。如果您正苦于以下问题:Python Tkinter.Canvas方法的具体用法?Python Tkinter.Canvas怎么用?Python Tkinter.Canvas使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tkinter的用法示例。


在下文中一共展示了Tkinter.Canvas方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __createDisplay

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Canvas [as 别名]
def __createDisplay(self):
        """
        Create the display tkinter canvas to hold the images taken by the
        pi camera.
        
        """
        
        self.display = tk.Canvas(
            self, 
            width = s.PICTURE_RESOLUTION[0],
            height = s.PICTURE_RESOLUTION[1]
            )
        self.display.grid(row = 2, column = 0, rowspan = 1, columnspan = 6)


    # --------------------------------------------------------------------------
    #   Create Options Menu
    # -------------------------------------------------------------------------- 
开发者ID:Humpheh,项目名称:PiPark,代码行数:20,代码来源:pipark_setup.py

示例2: __init__

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Canvas [as 别名]
def __init__(self, host_canvas, data, node_name):
        tk.Canvas.__init__(self, width=20, height=20, highlightthickness=0)

        self._host_canvas = host_canvas
        self._complete = True
        self._marked = False
        self._default_bg = None

        self.bind('<ButtonPress-1>', self._host_event('onNodeButtonPress'))
        self.bind('<ButtonRelease-1>', self._host_event('onNodeButtonRelease'))
        self.bind('<B1-Motion>', self._host_event('onNodeMotion'))

        self.bind('<Button-3>', self._host_event('onTokenRightClick'))

        self.bind('<Key>', self._host_event('onNodeKey'))
        self.bind('<Enter>', lambda e: self.focus_set())
        self.bind('<Leave>', lambda e: self.master.focus())

        # Draw myself
        self.render(data, node_name) 
开发者ID:jsexauer,项目名称:networkx_viewer,代码行数:22,代码来源:tokens.py

示例3: _plot_graph

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Canvas [as 别名]
def _plot_graph(self, graph):
        # Create nodes
        scale = min(self.winfo_width(), self.winfo_height())
        if scale == 1:
            # Canvas not initilized yet; use height and width hints
            scale = int(min(self['width'], self['height']))

        scale -= 50
        if len(graph) > 1:
            layout = self.create_layout(graph, scale=scale, min_distance=50)

            # Find min distance between any node and make sure that is at least
            #  as big as
            for n in graph.nodes():
                self._draw_node(layout[n]+20, n)
        else:
            self._draw_node((scale/2, scale/2), graph.nodes()[0])

        # Create edges
        for frm, to in set(graph.edges()):
            self._draw_edge(frm, to)

        self._graph_changed() 
开发者ID:jsexauer,项目名称:networkx_viewer,代码行数:25,代码来源:graph_canvas.py

示例4: __init__

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Canvas [as 别名]
def __init__(self, parent, property_dict, *args, **kw):
        tk.Frame.__init__(self, parent, *args, **kw)

        # create a canvas object and a vertical scrollbar for scrolling it
        self.vscrollbar = vscrollbar = tk.Scrollbar(self, orient=tk.VERTICAL)
        vscrollbar.pack(fill=tk.Y, side=tk.RIGHT, expand=tk.FALSE)
        self.canvas = canvas = tk.Canvas(self, bd=0, highlightthickness=0,
                        yscrollcommand=vscrollbar.set)
        canvas.pack(side=tk.LEFT, fill=tk.BOTH, expand=tk.TRUE)
        vscrollbar.config(command=canvas.yview)

        # reset the view
        canvas.xview_moveto(0)
        canvas.yview_moveto(0)

        # create a frame inside the canvas which will be scrolled with it
        self.interior = interior = tk.Frame(canvas)
        self.interior_id = canvas.create_window(0, 0, window=interior,
                                           anchor='nw')

        self.interior.bind('<Configure>', self._configure_interior)
        self.canvas.bind('<Configure>', self._configure_canvas)

        self.build(property_dict) 
开发者ID:jsexauer,项目名称:networkx_viewer,代码行数:26,代码来源:viewer.py

示例5: _sb_canvas

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Canvas [as 别名]
def _sb_canvas(self, root, expand='y', 
                   fill='both', side='bottom'):
        """
        Helper for __init__: construct a canvas with a scrollbar.
        """
        cframe =Tkinter.Frame(root, relief='sunk', border=2)
        cframe.pack(fill=fill, expand=expand, side=side)
        canvas = Tkinter.Canvas(cframe, background='#e0e0e0')
        
        # Give the canvas a scrollbar.
        sb = Tkinter.Scrollbar(cframe, orient='vertical')
        sb.pack(side='right', fill='y')
        canvas.pack(side='left', fill=fill, expand='yes')

        # Connect the scrollbars to the canvas.
        sb['command']= canvas.yview
        canvas['yscrollcommand'] = sb.set

        return (sb, canvas) 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:21,代码来源:chart.py

示例6: draw

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Canvas [as 别名]
def draw(self):
        self.title_canvas = tk.Canvas(self, bg=self.bgcolor, width=width, height=90, bd=0, highlightthickness=0, relief='ridge')
        self.title_pic = self._resize_ads_qrcode(RES_APP_TITLE, size=(260, 90))
        self.title_canvas.create_image(0, 0, anchor='nw', image=self.title_pic)
        self.title_canvas.pack(padx=35, pady=15)

        self.qrcode = tk.Canvas(self, bg=self.bgcolor, width=200, height=200)
        #self.qrcode_pic = self._resize_ads_qrcode('qrcode.png', size=(200, 200))
        #self.qrcode.create_image(0, 0, anchor='nw', image=self.qrcode_pic)
        self.qrcode.pack(pady=30)


        # 提示
        self.lable_tip = tk.Label(self,
                     text='请稍等',  # 标签的文字
                     bg=self.bgcolor,  # 背景颜色
                     font=('楷体',12),  # 字体和字体大小
                     width=15, height=2  # 标签长宽
                     )
        self.lable_tip.pack(pady=2,fill=tk.BOTH)  # 固定窗口位置 
开发者ID:newbietian,项目名称:WxConn,代码行数:22,代码来源:main.py

示例7: __forwardmethods

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Canvas [as 别名]
def __forwardmethods(fromClass, toClass, toPart, exclude = ()):
    """Helper functions for Scrolled Canvas, used to forward
    ScrolledCanvas-methods to Tkinter.Canvas class.
    """
    _dict = {}
    __methodDict(toClass, _dict)
    for ex in _dict.keys():
        if ex[:1] == '_' or ex[-1:] == '_':
            del _dict[ex]
    for ex in exclude:
        if ex in _dict:
            del _dict[ex]
    for ex in __methods(fromClass):
        if ex in _dict:
            del _dict[ex]

    for method, func in _dict.items():
        d = {'method': method, 'func': func}
        if type(toPart) == types.StringType:
            execString = \
                __stringBody % {'method' : method, 'attribute' : toPart}
        exec execString in d
        fromClass.__dict__[method] = d[method] 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:25,代码来源:turtle.py

示例8: __init__

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Canvas [as 别名]
def __init__(self, master, width=500, height=350,
                                          canvwidth=600, canvheight=500):
        TK.Frame.__init__(self, master, width=width, height=height)
        self._rootwindow = self.winfo_toplevel()
        self.width, self.height = width, height
        self.canvwidth, self.canvheight = canvwidth, canvheight
        self.bg = "white"
        self._canvas = TK.Canvas(master, width=width, height=height,
                                 bg=self.bg, relief=TK.SUNKEN, borderwidth=2)
        self.hscroll = TK.Scrollbar(master, command=self._canvas.xview,
                                    orient=TK.HORIZONTAL)
        self.vscroll = TK.Scrollbar(master, command=self._canvas.yview)
        self._canvas.configure(xscrollcommand=self.hscroll.set,
                               yscrollcommand=self.vscroll.set)
        self.rowconfigure(0, weight=1, minsize=0)
        self.columnconfigure(0, weight=1, minsize=0)
        self._canvas.grid(padx=1, in_ = self, pady=1, row=0,
                column=0, rowspan=1, columnspan=1, sticky='news')
        self.vscroll.grid(padx=1, in_ = self, pady=1, row=0,
                column=1, rowspan=1, columnspan=1, sticky='news')
        self.hscroll.grid(padx=1, in_ = self, pady=1, row=1,
                column=0, rowspan=1, columnspan=1, sticky='news')
        self.reset()
        self._rootwindow.bind('<Configure>', self.onResize) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:26,代码来源:turtle.py

示例9: gui_pages_create

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Canvas [as 别名]
def gui_pages_create(self, parent, side, create = {}):
                self.pagewidgets.update({side : {"PageWin" : create,
                                                 "BtnWin"  : None,
                                                 "BtnAni"  :  {"Left"  : None,
                                                               "Right" : None},
                                                 "AniWin"  :  {"Left"  : None,
                                                               "Right" : None},
                                                 "LblAni"  :  {"Left"  : None,
                                                               "Right" : None},
                                                 }
                                         })

                for pagename in self.pagewidgets[side]["PageWin"].keys():
                        page = tk.Canvas(parent, background = self.customcolors['white'], borderwidth = 3, relief = 'ridge')
                        self.pagewidgets[side]["PageWin"][pagename] = page
                        page.grid(row = 0, column = 2, padx = 2, pady = 2, sticky = "nsew")
                        page.grid_columnconfigure(1, weight = 1)
                self.gui_pages_buttons(parent = parent, side = side)
                self.gui_pages_show("PageStart", side = side) 
开发者ID:SystemRage,项目名称:py-kms,代码行数:21,代码来源:pykms_GuiBase.py

示例10: make_canvas

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Canvas [as 别名]
def make_canvas(self):
        root = Tkinter.Tk()
        size = (self._blocksize + self._padding) * settings.board_size + \
            self._padding * 2 + 40

        self._canvas = Tkinter.Canvas(root, width=size, height=size)
        self._rect_items = []
        self._colors = []
        self._pressed = False

        self.prepare_backdrop(size)
        self.load_map()
        self.set_color('black')
        self.bind_events()

        self._canvas.pack()
        root.title('Robot Game Map Editor')
        root.mainloop() 
开发者ID:RobotGame,项目名称:rgkit,代码行数:20,代码来源:mapeditor.py

示例11: __init__

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Canvas [as 别名]
def __init__(self, master, im, value=128):
        tkinter.Frame.__init__(self, master)

        self.image = im
        self.value = value

        self.canvas = tkinter.Canvas(self, width=im.size[0], height=im.size[1])
        self.backdrop = ImageTk.PhotoImage(im)
        self.canvas.create_image(0, 0, image=self.backdrop, anchor=tkinter.NW)
        self.canvas.pack()

        scale = tkinter.Scale(self, orient=tkinter.HORIZONTAL, from_=0, to=255,
                              resolution=1, command=self.update_scale,
                              length=256)
        scale.set(value)
        scale.bind("<ButtonRelease-1>", self.redraw)
        scale.pack()

        # uncomment the following line for instant feedback (might
        # be too slow on some platforms)
        # self.redraw() 
开发者ID:awslabs,项目名称:mxnet-lambda,代码行数:23,代码来源:thresholder.py

示例12: __init__

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Canvas [as 别名]
def __init__(self, master, image):
        tkinter.Canvas.__init__(self, master,
                                width=image.size[0], height=image.size[1])

        # fill the canvas
        self.tile = {}
        self.tilesize = tilesize = 32
        xsize, ysize = image.size
        for x in range(0, xsize, tilesize):
            for y in range(0, ysize, tilesize):
                box = x, y, min(xsize, x+tilesize), min(ysize, y+tilesize)
                tile = ImageTk.PhotoImage(image.crop(box))
                self.create_image(x, y, image=tile, anchor=tkinter.NW)
                self.tile[(x, y)] = box, tile

        self.image = image

        self.bind("<B1-Motion>", self.paint) 
开发者ID:awslabs,项目名称:mxnet-lambda,代码行数:20,代码来源:painter.py

示例13: _SaveRenderedShapefile

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Canvas [as 别名]
def _SaveRenderedShapefile(self, savepath):
        if RENDERER == "tkinter":
            raise AttributeError("The Tkinter map renderer does not have a function to save the map as an image \
due to the limited options of the Tkinter Canvas. If possible try using any of the other renderers instead")
        else:
            self.renderer.SaveImage(savepath)







############## FINALLY, DEFINE FRONT-END USER FUNCTIONS

#INTERACTIVE INPUT HELPERS 
开发者ID:karimbahgat,项目名称:GeoVis,代码行数:18,代码来源:__init__.py

示例14: _sb_canvas

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Canvas [as 别名]
def _sb_canvas(self, root, expand='y',
                   fill='both', side='bottom'):
        """
        Helper for __init__: construct a canvas with a scrollbar.
        """
        cframe =Tkinter.Frame(root, relief='sunk', border=2)
        cframe.pack(fill=fill, expand=expand, side=side)
        canvas = Tkinter.Canvas(cframe, background='#e0e0e0')

        # Give the canvas a scrollbar.
        sb = Tkinter.Scrollbar(cframe, orient='vertical')
        sb.pack(side='right', fill='y')
        canvas.pack(side='left', fill=fill, expand='yes')

        # Connect the scrollbars to the canvas.
        sb['command']= canvas.yview
        canvas['yscrollcommand'] = sb.set

        return (sb, canvas) 
开发者ID:blackye,项目名称:luscan-devel,代码行数:21,代码来源:chartparser_app.py

示例15: get_canvas

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Canvas [as 别名]
def get_canvas():
    """ Creates a Tkinter canvas. """

    from Tkinter import Tk, Canvas, BOTH

    root = Tk()
    root.title('LED bot simulator')
    root.geometry("%sx%s" % (screen_width, screen_height))

    canvas = Canvas(root)
    canvas.pack(fill=BOTH, expand=1)
    canvas.create_rectangle(
        0, 0, screen_width, screen_height, outline="#000", fill="#000"
    )

    return canvas 
开发者ID:marqsm,项目名称:LED-bot,代码行数:18,代码来源:simulator.py


注:本文中的Tkinter.Canvas方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。