tkinter-canvas

Vertical and Horizontal Scrollbars on Tkinter Widget

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-06 11:14:08
问题 I am trying to output the contents of a database to a Tkinter widget. The database has enough rows and columns to where I need to have both horizontal and vertical scrollbars enabled, but I am having a hard time getting horizontal and vertical scrolling to work simultaneously. I am agnostic about which Tkinter widget is used but here is my current implementation: # Create root self.root = Tk() self.root.geometry('1000x500+0+0') # Create canvas self.canvas = Canvas(self.root) self.canvas.pack

Vertical and Horizontal Scrollbars on Tkinter Widget

ぃ、小莉子 提交于 2021-02-06 11:13:52
问题 I am trying to output the contents of a database to a Tkinter widget. The database has enough rows and columns to where I need to have both horizontal and vertical scrollbars enabled, but I am having a hard time getting horizontal and vertical scrolling to work simultaneously. I am agnostic about which Tkinter widget is used but here is my current implementation: # Create root self.root = Tk() self.root.geometry('1000x500+0+0') # Create canvas self.canvas = Canvas(self.root) self.canvas.pack

tkinter doesn't open image via function

自作多情 提交于 2021-02-05 10:50:50
问题 Tkinter doesn't open the image. We can ask the opening incorrectly, we need help. I need it to open the image through the menu. be sure to use pil, as the image can be anything. There are no errors in the syntax. Thank you = ) from tkinter import Tk, Frame, Menu, Canvas, PhotoImage import easygui from PIL import Image, ImageFilter, ImageTk def input_file(): a = easygui.fileopenbox(filetypes=["*.jpg"]) original = Image.open(a) original = original.resize((799, 799), Image.ANTIALIAS) photoimg =

How to create an image displayer using Python Tkinter more efficiently? [duplicate]

北城余情 提交于 2021-01-29 11:23:46
问题 This question already has answers here : Why does Tkinter image not show up if created in a function? (3 answers) Closed 5 months ago . import tkinter as tk from PIL import ImageTk, Image root = tk.Tk() def photogetter(): ###global photo photo= ImageTk.PhotoImage(Image.open("smiley.png").resize((320,240))) label =tk.Label(root,image=photo) canv.create_window((320,240),window=label) canv = tk.Canvas(root,width=640,height=480) canv.grid(row=0,column=0) button = tk.Button(root,text="Button"

tkinter canvas create_text size (python3)

谁说胖子不能爱 提交于 2021-01-29 06:20:59
问题 I understand that it is possible to get the size of text on a canvas: t = canvas.create_text(x, y, text='Hello StackOverflow') print(canvas.bbox(t)) but I want to decide where to draw the text based on its size, so I need to know the size before the text is drawn. How to do that? 回答1: A possible solution is tk.font.Font(size=9, family='Helvetica').measure('HelloStackoverflow') 回答2: Use that line of code. canvas.create_text(245,100, fill = 'red', font = "Times 20 italic bold", text = "Hello

Tkinter, Label/Text in canvas.rectangle [python]

寵の児 提交于 2021-01-28 19:45:16
问题 I need to place a text/label centred in a canvas rectangle in tkinter. First I have a canvas covering the whole screen(800, 600). And then I have a couple of rectangles which I made using the: create_rectangle(...) The first X of the first rectangle is 275 and the second X is 525. The first Y of the first rectangle is 265 and the second Y is 315. menuBtn1 = canvas.create_rectangle(275, 165, 525, 215, fill="#C2B6BF") Now how I can place a text/label in the center of this rectangle? 回答1: You

Tkinter - memory leak with canvas

冷暖自知 提交于 2021-01-28 12:53:07
问题 I have a Python script that handles Modbus communications. One feature I added was a "graph" that shows the response times along with a color coded line that indicates if the response was successful, had an exception, or an error. The graph is just a scrollable canvas widget from Tkinter. After graphing a certain number of lines old lines will be deleted and then a new one will be added to the end. For this example I have it set to 10, which means there will never be more than 10 lines on the

Tkinter - memory leak with canvas

柔情痞子 提交于 2021-01-28 12:53:00
问题 I have a Python script that handles Modbus communications. One feature I added was a "graph" that shows the response times along with a color coded line that indicates if the response was successful, had an exception, or an error. The graph is just a scrollable canvas widget from Tkinter. After graphing a certain number of lines old lines will be deleted and then a new one will be added to the end. For this example I have it set to 10, which means there will never be more than 10 lines on the

Tkinter - memory leak with canvas

放肆的年华 提交于 2021-01-28 12:52:39
问题 I have a Python script that handles Modbus communications. One feature I added was a "graph" that shows the response times along with a color coded line that indicates if the response was successful, had an exception, or an error. The graph is just a scrollable canvas widget from Tkinter. After graphing a certain number of lines old lines will be deleted and then a new one will be added to the end. For this example I have it set to 10, which means there will never be more than 10 lines on the

Tkinter window in canvas doesn't fill its parent in height

我的梦境 提交于 2021-01-27 20:28:18
问题 I would like to have my scrollbar in the bottom of the frame and my text widgets filling the whole frame above the scrollbar. I found some solution about the width configuration here but when I try to replace width with height, it does not work correctly. from tkinter import * from tkinter import ttk class MainView(Frame): def FrameHeight(self, event): canvas_height = event.height self.canvas.itemconfig(self.canvas_frame, height=canvas_height) def OnFrameConfigure(self, event): self.canvas