tkinter-canvas

tkinter grid not working correctly

倖福魔咒の 提交于 2019-11-28 14:29:11
when I try to make a window using tkinter in python 3.4.2, the windows opens, but the ..grid method doesnt function properly. The label and entry box dont move even though I change the row and column parameters. Please help: from tkinter import * root = Tk() root.geometry("1024x768") root.resizable(width=FALSE, height=FALSE) label_title = Label(root, text="Past paper helper") entry_1 = Entry(root) label_title.grid(row=0, column=5) entry_1.grid(row=16, column=1) root.mainloop() Empty rows and columns have zero size. Column 1000 will give the same effect as column 0, if columns 0-999 are empty.

Vertical scrollbar for frame in Tkinter, Python

醉酒当歌 提交于 2019-11-28 14:18:50
My aim is to have a scrollbar that stays at the right-side of a full-screen window, allowing the user to scroll up and down through various different widgets (such as labels & buttons). From other answers I've seen on this site, I've come to the conclusion that a scrollbar has to be assigned to a canvas in order for it to function properly, which I have tried to include in my code but have not had much success with. The below code shows a simplified version of what I've managed to accomplish so far: from tkinter import * root = Tk() root.state("zoomed") root.title("Vertical Scrollbar") frame =

Method for having animated movement for canvas objects python

回眸只為那壹抹淺笑 提交于 2019-11-28 14:05:47
I have been trying to learn how move canvas items from google, however the method shown most places doesnt seem to work for me as intended. right now i am just trying to get a ball move from one side of the screen to the other over the period of 1 second from tkinter import * root = Tk() c = Canvas(root, width = 200, height = 100) c.pack() ball = c.create_oval(0, 25, 50, 75) for i in range(25): c.move(ball, 6, 0) root.after(40) root.mainloop() when run, this seems to move the ball before opening the window, however if i call upon mainloop first, the window opens but the ball doesn't move.

How to bind a click event to a Canvas in Tkinter? [closed]

余生颓废 提交于 2019-11-28 12:12:33
I was just wondering if there was any possible way to bind a click event to a canvas in Tkinter. I would like to be able to click anywhere on a canvas and have an object move to it. I am able to make the motion, yet I have not found a way to bind a click event on a canvas. Malik Brahimi Taken straight from an example from an Effbot tutorial on events. In this example, we use the bind method of the frame widget to bind a callback function to an event called . Run this program and click in the window that appears. Each time you click, a message like “clicked at 44 63” is printed to the console

Error in matplotlib popup window (AttributeError: 'NoneType' object has no attribute 'set_canvas')

痞子三分冷 提交于 2019-11-28 10:47:28
问题 I tried to plot the graph in pop up window. It pops up. But there is an error. import tkinter as tk window = tk.Tk() window.configure(background='white') label_1 = tk.Label(window, text="Conpyright 123456789123456798", anchor=tk.S) label_1.pack() ws = window.winfo_screenwidth() hs = window.winfo_screenheight() w = 980 # width for the Tk root h = 600 # height for the Tk root x = (ws / 2) - (w / 2) y = (hs / 2) - (h / 2) window.geometry('%dx%d+%d+%d' % (w, h, x, y)) canvas = tk.Canvas(window,

Move a tkinter canvas with Mouse

我只是一个虾纸丫 提交于 2019-11-28 08:43:39
I would like to move a whole tkinter Canvas with Mouse Click (hold) + Motion of the mouse. I tried with canvas.move but it doesn't work unfortunately. How can I scroll in the whole canvas ? (not move each element of the canvas, but rather scroll the displayed area of the canvas) import Tkinter as Tk oldx = 0 oldy = 0 def oldxyset(event): global oldx, oldy oldx = event.x oldy = event.y def callback(event): # How to move the whole canvas here? print oldx - event.x, oldy - event.y root = Tk.Tk() c = Tk.Canvas(root, width=400, height=400, bg='white') o = c.create_oval(150, 10, 100, 60, fill='red')

Tkinter: Scaling items on a canvas

☆樱花仙子☆ 提交于 2019-11-28 05:57:47
问题 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

How to bind events to Canvas items?

别来无恙 提交于 2019-11-27 19:23:25
If I'm using a canvas to display data and I want the user to be able to click on various items on the canvas in order to get more information or interact with it in some way, what's the best way of going about this? Searching online I can find information about how to bind events to tags but that seems to be more indirect then what I want. I don't want to group items with tags, but rather have specific function calls when the user clicks specific items on the canvas. tdedecko To interact with objects contained in a Canvas object you need to use tag_bind() which has this format: tag_bind(item,

Tkinter canvas zoom + move/pan

泄露秘密 提交于 2019-11-27 08:26:40
Tkinter's canvas widget has built-in features to: move/pan the canvas (for example with Click + Drag) with canvas.scan_mark and canvas.scan_dragto , see this question zoom the vector elements on the canvas with canvas.scale , but sadly, this doesn't work for bitmap images on the canvas Fortunately, this method allows zooming of images (by manually redrawing the zoomed portion of the image). But: As we are redrawing a particular portion of the canvas, move/pan feature won't work anymore... We absolutely need to render more than the currently displayed area, to allow move/pan. Let's say we have

tkinter grid not working correctly

爷,独闯天下 提交于 2019-11-27 08:25:32
问题 when I try to make a window using tkinter in python 3.4.2, the windows opens, but the ..grid method doesnt function properly. The label and entry box dont move even though I change the row and column parameters. Please help: from tkinter import * root = Tk() root.geometry("1024x768") root.resizable(width=FALSE, height=FALSE) label_title = Label(root, text="Past paper helper") entry_1 = Entry(root) label_title.grid(row=0, column=5) entry_1.grid(row=16, column=1) root.mainloop() 回答1: Empty rows