tkinter-canvas

Scrollable Frame does not resize properly using tkinter in Python

北城以北 提交于 2019-12-01 06:27:32
Based on the example from Dynamically changing scrollregion of a canvas in Tkinter , I am trying to implement a Frame where you can add and delete entries in a scrollable Frame using tkinter. My Problem is that the Frame holding items does not resize after deleting entries. When adding entries, it resizes correctly. I call update_layout() in both cases: from tkinter import * class ScrollableContainer(Frame): """A scrollable container that can contain a number of messages""" def __init__(self, master, **kwargs): Frame.__init__(self, master, **kwargs) #holds canvas & scrollbars # configure row

How to make a Button using the tkinter Canvas widget?

狂风中的少年 提交于 2019-11-30 20:48:20
I want to obtain a button out of a Canvas. I've tried to pack the canvas in the button widget, but that didn't work. Googling a bit, I've found (here: How do you create a Button on a tkinter Canvas? ) that the Canvas method create_window might help. But there should be something wrong in the way I'm using it. import Tkinter DIM = 100 root = Tkinter.Tk() frame = Tkinter.Frame(root) button = Tkinter.Button(None, width=DIM, height=DIM, command=root.quit) circle = Tkinter.Canvas(frame, width=DIM, height=DIM) circle.create_oval(5, 5, DIM-5, DIM-5, fill="red") circle.create_window(0, 0, window

Can you change the attributes of a Canvas object after creation?

爷,独闯天下 提交于 2019-11-30 20:47:15
I'm trying to simulate an American traffic light, with 3 circles on a rectangle, all drawn on a set Canvas. The simulation is supposed to mirror "animation" by changing which light is displayed every 2 seconds in the following order: green > yellow > red > green, etc forever. The only way I can think of to do this is by using a canvas.move(), canvas.after(), canvas.update() pattern to move a filled oval object to superimpose one unfilled circle at a time. I've gotten the logic down to move a circle at the proper speed and in the correct order. The thing is, I just instantiate a circle filled

Tkinter Canvas create_window()

微笑、不失礼 提交于 2019-11-30 10:08:26
I'm trying to use Tkinter Canvas ( self._canvas ) to create window using create_window function. The window field for that function is a Tkinter Frame ( self._tableFrame ). Can someone please help me out on how to make self._tableFrame to expand to size of self._canvas automatically (Even after the window size changed by user)? Code: from Tkinter import Scrollbar as tkScrollBar from Tkinter import Frame as tkFrame from Tkinter import Canvas as tkCanvas from Tkinter import Entry as tkEntry from Tkinter import StringVar as tkStringVar from Tkinter import Tk, HORIZONTAL, N, S, E, W, RIGHT, LEFT,

Can you change the attributes of a Canvas object after creation?

安稳与你 提交于 2019-11-30 04:55:28
问题 I'm trying to simulate an American traffic light, with 3 circles on a rectangle, all drawn on a set Canvas. The simulation is supposed to mirror "animation" by changing which light is displayed every 2 seconds in the following order: green > yellow > red > green, etc forever. The only way I can think of to do this is by using a canvas.move(), canvas.after(), canvas.update() pattern to move a filled oval object to superimpose one unfilled circle at a time. I've gotten the logic down to move a

How to make a Button using the tkinter Canvas widget?

旧城冷巷雨未停 提交于 2019-11-30 04:02:12
问题 I want to obtain a button out of a Canvas. I've tried to pack the canvas in the button widget, but that didn't work. Googling a bit, I've found (here: How do you create a Button on a tkinter Canvas?) that the Canvas method create_window might help. But there should be something wrong in the way I'm using it. import Tkinter DIM = 100 root = Tkinter.Tk() frame = Tkinter.Frame(root) button = Tkinter.Button(None, width=DIM, height=DIM, command=root.quit) circle = Tkinter.Canvas(frame, width=DIM,

Tkinter Canvas create_window()

十年热恋 提交于 2019-11-29 14:24:17
问题 I'm trying to use Tkinter Canvas ( self._canvas ) to create window using create_window function. The window field for that function is a Tkinter Frame ( self._tableFrame ). Can someone please help me out on how to make self._tableFrame to expand to size of self._canvas automatically (Even after the window size changed by user)? Code: from Tkinter import Scrollbar as tkScrollBar from Tkinter import Frame as tkFrame from Tkinter import Canvas as tkCanvas from Tkinter import Entry as tkEntry

Tkinter: Scaling items on a canvas

荒凉一梦 提交于 2019-11-29 12:13:31
I was trying to understand how the scaling of canvas works. Take for example, the following code. Why is that canvas.scale("all", ...) , which is bind to mouse wheel, is scaling all the rectangles and not the text as well. How can I achieve scaling of text along with the rectangles? import Tkinter as tk import random pressed = False class Example(tk.Frame): def __init__(self, root): tk.Frame.__init__(self, root) self.canvas = tk.Canvas(self, width=400, height=400, background="bisque") self.xsb = tk.Scrollbar(self, orient="horizontal", command=self.canvas.xview) self.ysb = tk.Scrollbar(self,

How to update the contents of a FigureCanvasTkAgg

你。 提交于 2019-11-29 07:16:20
问题 I'm plotting some data in a Tkinter FigureCanvasTkagg using matplotlib . I need to clear the figure where I plot data and draw new data when a button is pressed. Here is the plotting part of the code (there's an App class defined before): self.fig = figure() self.ax = self.fig.add_subplot(111) self.ax.set_ylim( min(y), max(y) ) self.line, = self.ax.semilogx(x, y, '.-') #tuple of a single element self.canvas = FigureCanvasTkAgg(self.fig, master=master) self.ax.semilogx(x, y, 'o-') self.canvas

Tkinter: How to get frame in canvas window to expand to the size of the canvas?

拈花ヽ惹草 提交于 2019-11-28 23:31:17
So I've been using the canvas widget in tkinter to create a frame full of labels which has a scrollbar. All is working good except that the frame only expands to the size of the labels placed in it - I want the frame to expand to the size of the parent canvas. This can easily be done if I use pack(expand = True) (which I have commented out in the code below) for the frame in the canvas but then then the scrollbar doesn't work. Here's the appropriate bit of code: self.canvas = Canvas(frame, bg = 'pink') self.canvas.pack(side = RIGHT, fill = BOTH, expand = True) self.mailbox_frame = Frame(self