tkinter-canvas

Matplotlib setting `axes` object with `imshow` causes y-axis to become variable

依然范特西╮ 提交于 2019-12-24 07:58:28
问题 Description I have began refactoring some code based on the future warning of matplotlib, to re-use the initially defined axes object. However, I noticed that whenever I was re-using my axes object, the image size would be variable. Since, I have managed to isolate the problem to the axes.imshow method as after using imshow , the y-axis of any subsequent drawing on that axes has a y-axis that seems to rescale. The feeling I have is that the y-axis scale is retained from the initial image that

Python3 tkinter.Canvas.move() method makes artifacts on screen

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 04:05:41
问题 I'm trying to execute the code found in one of the Stackoverflow answers. It's a single window application with 2 circles which can be moved with the mouse. When I move circles - I see artifacts. See Sample Program code: import tkinter as tk TOKENWIDTH = 10 class Example(tk.Frame): '''Illustrate how to drag items on a Tkinter canvas''' def __init__(self, parent): tk.Frame.__init__(self, parent) # create a canvas self.canvas = tk.Canvas(width=400, height=400, bg="white") self.canvas.pack(fill=

“tkinter.TclError: invalid command name” error after calling root.destroy()

时光怂恿深爱的人放手 提交于 2019-12-24 00:38:43
问题 I am in the process of learning tkinter on Python 3.X. I am writing a simple program which will get one or more balls (tkinter ovals) bouncing round a rectangular court (tkinter root window with a canvas and rectangle drawn on it). I want to be able to terminate the program cleanly by pressing the q key, and have managed to bind the key to the root and fire the callback function when a key is pressed, which then calls root.destroy() . However, I'm still getting errors of the form _tkinter

How to insert an image in a canvas item?

你离开我真会死。 提交于 2019-12-23 10:18:05
问题 I am working on a game project for school, which look like this : In-game aspect I have created these colored polygons like this : ship = can.create_polygon(410,650,450,600,490,650 , fill= 'red' , outline='black') ennemies = can.create_rectangle(x-r, y-r, x+r, y+r, fill='green') So now i want to fill them with my own image. Is that possible ? And how ? 回答1: from tkinter import * # create the canvas, size in pixels canvas = Canvas(width=300, height=200, bg='black') # pack the canvas into a

Tkinter - Inserting text into canvas windows

ⅰ亾dé卋堺 提交于 2019-12-23 09:17:22
问题 I have a Tkinter canvas populated with text and canvas windows, or widgets, created using the create_text and create_window methods. The widgets I place on the canvas are text widgets, and I want to insert text into them after they are created and placed. I can't figure out how to do this, if it's even possible. I realise you can edit them after creation using canvas.itemconfig(tagOrId, cnf) , but text can't be inserted that way. Is there a solution to this? 回答1: First, lets get the

Converting PostScript to an image [closed]

心不动则不痛 提交于 2019-12-22 13:53:20
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I'm having trouble converting a postscript (.eps) file to any kind of image. Whenever I use PIL to save the loaded .eps file the quality of it is horrible and text rendered in tkinter is unreadable. I think this is because the .eps file is some sort of vector image and saving it using PIL doesn't render the

Tkinter understanding after()

半腔热情 提交于 2019-12-21 17:37:10
问题 First of all, take a look at my previous thread here: Tkinter understanding mainloop After following the advice from there, in GUI programming, infinite loops have to be avoided at all costs, in order to keep the widgets responsive to user input. Instead of using: while 1: ball.draw() root.update() time.sleep(0.01) I managed using self.canvas.after(1, self.draw) inside my draw() function. So my code now looks like this: # Testing skills in game programming from Tkinter import * root = Tk()

How do you delete a Canvas text object?

ぃ、小莉子 提交于 2019-12-19 11:21:39
问题 This is for example a create_text: self.__canvas.create_text(350, lineVotes, text=str(likesPrinted), font=("calibri", 30), fill="#66FF99", anchor=E) How could I delete this with a button? 回答1: One way to do it is by using the object ID that all Canvas object constructors return: self.text_id = self.__canvas.create_text(350, lineVotes, text=str(likesPrinted), font=("calibri", 30), fill="#66FF99", anchor=E) Then afterwards you can use the Canvas object's delete() method list like this: self._

Draw on python tkinter canvas using mouse and obtain points to a list?

被刻印的时光 ゝ 提交于 2019-12-19 09:24:24
问题 I'm working on a Python application using tkinter. What I want to do is to draw on canvas coordinates, and the points will be recorded to a list so I can do calculation later. If it's not possible, would you recommend any other tools or GUI platform that can do this? Edit: What I have so far is an application that can take points from a list and draw on the canvas. I would like the opposite way to work too. from tkinter import * from tkinter.filedialog import askopenfilename from tkinter

Scrollable Frame does not resize properly using tkinter in Python

北战南征 提交于 2019-12-19 09:16:10
问题 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,