tkinter-canvas

tkinter canvas item configure

大兔子大兔子 提交于 2019-12-11 06:29:42
问题 I'm trying to make a dice object, and I want to be able to control the pip colors. I created the pips with a black fill, and I tried to change one to red using self.canvas.itemconfigure(self.pip1, fill='red') but it seems to have no effect. There is no error so I'm wondering why the change doesn't show up. Minimum working example: from tkinter import * from tkinter import ttk class Dice: #the x and y instancing variables are for the x and y coordinates of the top left corner of the rectangle

Draggable Tkinter Label With Transparent Image Still Covers Image from Parent Canvas

对着背影说爱祢 提交于 2019-12-11 06:26:42
问题 I am working on adding drag-able labels on top of a background image, where the labels are images with a transparent background. The images used for the label themselves are transparent, but the Label itself is not transparent in relation to its parent canvas. Since the labels are drag-able, I can't easily use the parent image for label, and paste the transparent image on top. The dragon is a drag-able label, with a transparent background, but you see that the label itself is not transparent,

delete method on canvas tkinter

偶尔善良 提交于 2019-12-11 06:05:20
问题 Trying to delete a random shape on canvas by clicking the "remove rect" button created. but my method doesn't seem to work. I keep getting this error, must be small but I can't seem to find it. TypeError: removeRects() missing 1 required positional argument: 'canvas' from tkinter import * import random root = Tk() class Recta: def __init__(self, height=60, width=80): self.height = height self.width = width self.create_buttons() self.canvas = Canvas(root) self.canvas.pack() def removeRects

Matplotlib tkagg backend performance

醉酒当歌 提交于 2019-12-11 04:46:25
问题 I have a tkinter application that can plot a large number of data, where I have noticed poor pan and zoom performance when there is a large number of data on the canvas. Looking into the tkagg_backend (as suggested by this and several other questions), the function and documentation suggests that the canvas should only be redrawn once the user is idle. However, from current and previous experience the canvas has always been updating(redrawing) mid zoom/pan. Therefore, I was looking at the

Tkinter canvas & scrollbar with grid

泪湿孤枕 提交于 2019-12-11 02:16:47
问题 I have a canvas in a frame photoFrame = Frame(centerFrame, width=250, height=190, bg="#EBEBEB") photoFrame.grid(row=0, column=1, sticky="nsew") photoCanvas = Canvas(photoFrame, bg="#EBEBEB") photoCanvas.grid(row=0, column=0, sticky="nsew") and I try to put a scrollbar to my canvas with this photoScroll = Scrollbar(photoFrame, orient=VERTICAL) photoScroll.config(command=photoCanvas.yview) photoCanvas.config(yscrollcommand=photoScroll.set) photoScroll.grid(row=0, column=1, sticky="ns") The

Change mouse pointer speed in Windows using python

我与影子孤独终老i 提交于 2019-12-11 00:27:16
问题 I'm using a Windows10 system. I have a Tkinter canvas which has an image drawn on it. Is there any way to slow down mouse pointer speed when it is hovering over the canvas? I've checked out this link and this link but the answer seems unstable.. To be more specific, is it possible to slow down mouse pointer speed in plain Python/Tkinter? 回答1: On windows system you can use native SystemParametersInfo to change speed of the mouse pointer. It's possible to implement via ctype, which is part of

Python 3 unicode codec error binding mousewheel in tkinter

自作多情 提交于 2019-12-10 20:39:34
问题 Using Python 3.6/tkinter on MacOS, I created a frame within a canvas and bound a scrollbar to it. This all works fine. The problem is when I try to snag MouseWheel events when the cursor is in the scrollable frame. I set up a binding: main_window.bind("<MouseWheel>",on_mousewheel) and created a short dummy event handler: def on_mousewheel(event): print(event.delta) Every time I use the scroll wheel, Python responds with: Traceback (most recent call last): File "/Users/Gary/IPPS/opendb.py",

Tkinter canvas create_image and create_oval optimization

对着背影说爱祢 提交于 2019-12-10 18:31:35
问题 Background I am trying - and succeeding - in creating a simple plot using using the Canvas object within tkinter . I am trying to use as many tools that are installed with Python3 as possible. Matplotlib and others are great, but they are pretty large installs for something that I'm trying to keep a bit smaller. The plots are updated every 0.5s based on input from a hardware device. The previous 128 points are deleted and the current 128 points are drawn. See my most recent blog post for a

Changing image in tkinter canvas in while loop

烈酒焚心 提交于 2019-12-10 17:11:59
问题 Entirety of my code is here. Using tkinter's canvas, I am trying to create a small game that allows people to practice learning the notes on the treble clef. A random note is initially displayed and the user must select the correct note. I am unable to edit the canvas to display a new note's image if the student got the correct answer. Can somebody please explain what the problem is with my code? while True: randomNote = randint(0, 11) path = noteFiles[randomNote] correctNote = notes

(Tkinter, py3) How to make a rotation animation?

久未见 提交于 2019-12-10 11:34:41
问题 I want to rotate an oval around it's center. Currently I can display the static object witohut rotation, and I can't seem to find what to do wit it. EDIT: I made a rotation function based on complex number multiplication, which seemed to work on lower polygons but the ellipse kinda looks the same. A potato-level noob C.S. student. also, the code: from tkinter import* import cmath, math import time def poly_rot(tup, deg): rad=deg*0.0174533 crot=cmath.exp(rad*1j) rotpol=[] i=0 while i < len(tup