tkinter

size/coordinates of wrapped text object in tkinter Canvas

家住魔仙堡 提交于 2021-01-29 12:32:50
问题 How do I get coordinates of a wrapped text object in Tkinter Canvas? I know I can use canvas.bbox(text_object) but it will give me only box coordinates. But if the text is wrapped I need to get coordinates of last char in the last line. I want to put a polygon under text so as to make background color for text only. I got this using canvas.bbox(text_object) I want it to be like this : 回答1: You can use canvas.find_overlapping(x, y, x+1, y+1) to find the boundaries of your text: import tkinter

Keeping Up With Camera Frame Rate in Tkinter GUI

只谈情不闲聊 提交于 2021-01-29 12:19:55
问题 My goal is to display a real time feed from a USB camera in a Tkinter Window. My problem is that I can't seem to update the GUI fast enough to keep up with the frame rate of the camera. I'm interfacing with the camera using the uvclite python wrapper around the libuvc C library. uvclite is a lightweight ctypes wrapper around the underlying C library, so I don't think that piece is my bottleneck. Here is my code: import tkinter as tk from PIL import ImageTk, Image import uvclite import io

Python tkinter cut down path but open as full directory

旧城冷巷雨未停 提交于 2021-01-29 11:52:29
问题 Here is my full Python code: from tkinter import * import glob import os from PIL import Image, ImageTk, ImageGrab import tkinter as tk import pyautogui import datetime #date & time now = datetime.datetime.now() root = tk.Tk() root.title("SIGN OFF") root.minsize(840, 800) # Add a grid mainframe = tk.Frame(root) mainframe.columnconfigure(0, weight=1) mainframe.rowconfigure(0, weight=1) mainframe.pack(pady=100, padx=100) # Create a Tkinter variable tkvar = tk.StringVar(root) # Directory

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"

how do I create entry fields and buttons to get the content from the entry field using iteration in tkinter for python?

为君一笑 提交于 2021-01-29 11:22:12
问题 I'm trying to make a tkinter GUI with a certain amount of buttons and entry fields that is specified by the user, so in this code below for example if the user specifies the variable number to be 3 I want there to be 3 entry boxes and , and I want to set it up so that if I type a value into the first field and click the button next to it, I want that button to read the value from the entry field next to it. I also need to assign each entry field to a variable that will be created through the

How to add a CV2 tracking bar in a tkinter window

蹲街弑〆低调 提交于 2021-01-29 11:16:07
问题 How to add a cv2 trackbar to a Tkinter window? I have 2 snippets of code that my teammates have made, but it is difficult to integrate them in the same window. I am able to use them in separate windows but I want to use them in the same window. CODE FOR THE VIDEO PLAYING IN TKINTER: import cv2 import tkinter as tk from tkinter import * # from tkinter import ttk # from ttk import Frame # import ImageTk white = "#ffffff" lightBlue2 = "#adc5ed" font = "Constantia" fontButtons = (font, 12)

Combobox doesn't display the populated values

被刻印的时光 ゝ 提交于 2021-01-29 11:11:10
问题 I created a combobox to show a list of values out of a sqlite database. If I sent the values to the combobox, the list will shown. The problem is, that the field will not filled with the first value and stay empty until I select on item of out of the drop menu. Could I set a value to be displayed directly? Here my code snippet: self.e_business = ttk.Combobox(address_frame, width = 40) self.e_business.grid(row=3, column=1, columnspan=2, padx=(5,20), pady=(15,5), sticky='WE') The function which

I can't organize interaction between two classes, belonging to different frames in tkinter

你。 提交于 2021-01-29 11:08:22
问题 The two classes belong to different frames. The challenge is to read data from the window ʻent_data class a parent of ForLeftFrame in a descendant class of ForRightFrameChild`. When calling the parent class, a message appears in the console: "name 'left_frame' is not defined". Can't figure out why? Everything works in one frame. Please help me figure it out. The code is as follows: import tkinter as tk #----------- class ForLeftFrame(): def __init__(self, left_frame): self.left_frame = left

tkinter frame inside of canvas not expanding to fill area

喜夏-厌秋 提交于 2021-01-29 10:44:28
问题 I have a scrollable frame class that I borrowed from some code I found, and I'm having trouble adjusting it to fit my needs. It was managed by .pack(), but I needed to use .grid(), so I simply packed a frame ( self.region ) into it so I could grid my widgets inside of that. However, the widgets inside of this frame won't expand to meet the edges of the container and I'm not sure why. Theres a lot of issues similar to mine out there, but none of the solutions seemed to help. I tried using

Two functions don't work properly in tkinter python with sqlite3

≯℡__Kan透↙ 提交于 2021-01-29 10:24:13
问题 I've got a problem w with my program "phonebook" with sqlite3. There are 2 functions doesn't work properly with treeview in tkinter. When I try to update one selected row it updated all rows/records in sqlite but in treeview is correctly one updated record, and when I try delete one selected row it deletes all datas from sqlite whereas in treeview is deleted one selected row. I suppose there is no connection between treeview and sqlite3. I don't know what the problem is. from tkinter import*