52,705 questions
0
votes
0
answers
31
views
Tkinter image label object is not going to the desired spot
I have this code with an upload image button and an image label.
import tkinter
from tkinter import filedialog, Label, Button
from PIL import Image, ImageTk
# Functions
def upload_image():
...
1
vote
1
answer
112
views
Using tkinter.after() repeatedly
I'm working on a tkinter GUI to ease the operation of some scripts that are meant to both send signals to an Allen-Bradley PLC to write tag values and also read other tags repeatedly in a logging file....
0
votes
2
answers
135
views
Why does the button recognize clicks despite deactivation?
Program outline: show a helpfile (PDF) on button click -> runs well
But if I press the button even though the file is still open, the frontend remembers this and then opens the file as often as it ...
2
votes
1
answer
141
views
How can I make my customtkinter app render all widgets smoothly at once instead of one by one?
i'm working on a Python application using customtkinter and CTkTable to display a paginated table with dynamic resizing and various widgets (frames, labels, buttons, comboboxes, etc.). The code below ...
3
votes
1
answer
113
views
I cannot launch a TopLevel window after FileDialog execution
Why can I not show a TopLevel window after launching the FileDialog module?
I would like to show a window with a waiting message after executing FileDialog code.
If I create the TopLevel window before ...
0
votes
1
answer
89
views
Tkinter app freezes when using filedialog.askdirectory() in scrollable Canvas layout [closed]
I'm building a Python application using Tkinter.
In the main window, I have a Canvas with a scrollable Frame inside it. Within that scrollable frame, I've added several LabelFrame widgets. Each ...
0
votes
1
answer
75
views
How to have a frame scroll both directions (horizontal and vertically) in customtkinter
I want a frame that scrolls both ways (horizontally and vertically). However, a normal CTkScrollableFrame only supports either vertical scrolling or horizontal scrolling, and I'm not sure what other ...
3
votes
1
answer
174
views
How to configure the font used to render IME preview text in tkinter text input fields on Windows?
Problem Description
I'm experiencing a problem concerning font configuration in Tkinter. The constructor of all Tkinter widgets have a font keyword argument which allows you to configure the font used ...
-1
votes
1
answer
122
views
I am using panda and tksheet to create a ledger table which I want to be able to edit by clicking on a cell. Cells don't respond to mouse
my code is as follows -:
import sqlite3
import pandas as pd
import tkinter as tk
from tksheet import Sheet
from tkinter import messagebox
# Connect to SQLite database
conn = sqlite3.connect("...
1
vote
1
answer
77
views
Can label or button act as parent in tkinter?
I always thought that only frame and other container elements can be parent, but recently when I tried the below code, it seemed to work perfectly without any error.
import os
import tkinter as tk
...
0
votes
1
answer
106
views
Setting row colors to a pandastable with setrowcolors
I'm working on a script to collate information from a few utilities and applications. The last part I'm trying to finish up is to take color information and apply it to a table. My issue is that ...
0
votes
2
answers
91
views
Using Tkinter in Python, How Can I Autosize a Canvas to its Parent Frame
I'm trying to build a Tkinter form in Python that has three "frames": a narrow frame across the top (for a title), a thin frame down the left (for buttons), and a main frame (to show content)...
0
votes
0
answers
79
views
Tkinter file dialog appearence is not right
I have a Tkinter project app, but the filedialog.askopenfilename and other file dialog functions show a strange file explorer, as shown in the screenshot. If I open a file dialog before initializing ...
0
votes
0
answers
141
views
Python Tkinter: resizing with .geometry() vs .config(width=..., height=...)
I am using Python 3.11 on Windows.
The code below creates this window:
I want to be able to resize the main window with these contraints:
The dark area must always be a square
The light green area ...
1
vote
1
answer
59
views
Tkinter invokes wm command when window destroyed after CTkMessagebox used
My application uses CustomTkinter and reads data on start up:
import customtkinter as ctk
from CTkMessagebox import CTkMessagebox
class App(ctk.CTk):
def __init__(self) -> None:
super()....
0
votes
1
answer
60
views
Tkinter Text widget with grid management. How to retrieve the edited data? Python 3.12.3
I've discovered the Tkinter Text widget, used with the grid manager. I successfully created a table and populated it with a numpy array. Now I'm trying to figure out how to retrieve the edited ...
0
votes
1
answer
98
views
Python Tkinter: understanding winfo_geometry()
I am using Python 3.11 on Windows.
I don't understand the behaviour of winfo_geometry(), winfo_height(), winfo_x(), etc.
Here is my code:
import tkinter as tk
from tkinter import ttk
class ...
1
vote
0
answers
38
views
Tkinter image label performance issues when updating large image
This is a follow up question from Calling ImageTk.PhotoImage() in a thread causing deadlock
I have so far fixed the deadlock issue following the design in the accepted answer. Now I am working on a ...
0
votes
0
answers
38
views
How to get proper case path from tkinters filedialog.askdirectory
Hy there, im pretty new in python and facing a problem, i cant find the answere.
When receiving a path from tkinters filedialog.askdirectory,
the path is "normcase" but i need to receive it ...
1
vote
1
answer
70
views
Python Tkinter: wait for user input before continuing with the mainloop
I am using Tkinter with Python 3.11 on Windows.
The following program creates a simple window with a menu. The user would click "Game -> Select game directory", whereupon ...
2
votes
1
answer
60
views
How to edit an element inside of a tkinter Grid?
I'm working on a project to design a chessboard.
I have successfully created the board. My goal is to edit the board.
My original idea is to use buttons with the Tkinter grid to make the moves work.
I ...
0
votes
1
answer
82
views
How to make the corners of a text box rounded in Tkinter?
Here is my code -->
import tkinter as tk
from tkinter import ttk
win = tk.Tk()
WIDTH, HEIGHT = 500, 500
win.geometry(f"{WIDTH}x{HEIGHT}")
text = tk.Text(win, height=5, width=10)
text....
0
votes
1
answer
55
views
Interactive Plotly plots with file reader not reading correctly through button function in Python (VS Code/Jupyter)
I have a button function that uses filedialog.askopenfilename to read data from xls, xlsx, dpt, xy, and txt file types into a pandas dataframe. When I use the button and open anything other than xls ...
0
votes
0
answers
51
views
Tkinter button text/image not updating after incrementing a value in another class
I'm working on a Tamagotchi-like app in Python with Tkinter. I detect clicks on a canvas item and increment a "clicks" counter stored in a JSON-backed character object. When the clicks reach ...
2
votes
0
answers
66
views
New Dialog Class Incorrect Button Style
I was trying to make a subclass that acts like the original but its go function returned the string of the text of the button, instead of the index of the button.
My own defined subclass makes the ...
1
vote
1
answer
61
views
How to Fix Python Script Tkinter Buttons/Checkbox Appearing Unfocused on MACOS
I have a script when I run it through idle shell the tkinter Buttons/Checkbox look as I would expect, however when I run the same script through the terminal the Buttons/Checkbox appear as though they ...
0
votes
1
answer
46
views
Showing cursor in Text widget after selecting Listbox option
The following Python code generates a list box and text widget. When I select an option, the cursor should show in the text widget but it does not. However, if I press Tab, the text widget is ...
2
votes
1
answer
126
views
Python Label.config(text=string) leaks memory, but Label["text"]=string doesn't. What's going on here?
I have an example Python program that sets the text of a tkinter label, and the use of Label.config(text=string) is leaking memory. Other techniques for setting the text don't. Is something wrong here?...
1
vote
0
answers
56
views
Python-vlc window freezes after 10 mins of playing/stopping videos
I'm having a problem building a kiosk display system using Python, Tkinter and VLC. In my setup, everything is latest version(only got the Pi 2 weeks ago).
-RPI 5 with latest Bookworm 64 bit.
-Python-...
0
votes
1
answer
77
views
Distinguishing callbacks for different events when using the same function
I am coding minesweeper in python turtle. I have made it generate 10x10 button layout using this script:
position_x = -400
position_y = -200
number_colum = 0
rows_buttons = []
for i in range(10):
...
1
vote
0
answers
47
views
Why can't I change the color and text of a Tkinter GUI? [duplicate]
I want to create a class for a Tk.Button in a Tk.Frame so that the button can have a border color independent of its background color.
I wrote this code
import tkinter as tk
class FramedButton(tk....
0
votes
2
answers
123
views
Creating a bordered Button in Tkinter
I want to create a class for a Tk.Button in a Tk.Frame so that the button can have a border color independent of its background color.
I wrote this code which creates a button in a frame just as I ...
0
votes
0
answers
155
views
In Tksheet cell editing, is it possible to extend the cell instead of adjusting column width?
In tksheet I have a table with fixed hight and width. When I enter text and it is too long the cell extends (during the edit) downwards to show me all the text I put in. After the edit only the ...
0
votes
1
answer
57
views
Tkinter threading with music
I have added a music button to my Tkinter GUI, when I press it, it plays music but the other aspects wont work such as clicking other buttons and moving the window, I have tried threading but still no ...
0
votes
1
answer
54
views
Tkinter: Problem with changing the GUI inside a function
I wrote this silly program in python using tkinter where I show a stickman being hit on the head with a hammer by using a button event to change the label's image to the picture showing the stickman ...
0
votes
1
answer
68
views
Tkinter Canvas-based text widget: scrollbar drag does not scroll to bottom
I'm creating a custom text widget using tk.Canvas in Tkinter to display multiple lines of text, with support for mousewheel and scrollbar scrolling.
What works:
Mouse wheel scrolling scrolls through ...
0
votes
0
answers
61
views
Plotting MatPlotLib Subplots of A Figure Across Two Canvases
I am working on a GUI plotting tool and need to split the contents of one matplotlib Figure object across two tkinter FigureCanvasTkAgg objects. In a previous iteration, I accomplished this by placing ...
1
vote
1
answer
54
views
Connecting CTRL + Right Click to matplotlib FigureCanvasTkAgg
I'm trying to bind CTRL + Right click to a matplotlib FigureCanvasTkAgg. So far, I used mpl_connect to change the state of a ctrl variable when the key is pressed and then checked if it was True when ...
2
votes
2
answers
321
views
Use tkinter in an existing window
I have an existing open window, created by SDL 2 in C/C++. I would like the process to call a python script (using Boost/Python) to add some GUI elements to it.
Here's a non-working example:
import ...
0
votes
0
answers
107
views
Python: Tkinter askdirectory() seems to hang in VSCode
I'm trying to set up some Python scripts to do some file manipulation and I was trying tkinter after some googling of libraries to use.
The following only half works:
from tkinter import filedialog
...
0
votes
1
answer
60
views
Python script using tkinterweb not allowing key binding [duplicate]
I have a simple script that uses tkinterweb to display a search result that is stored as html. When I try to bind the search function to the Enter key using the "button.bind('',function())" ...
2
votes
1
answer
86
views
Calling ImageTk.PhotoImage() in a thread causing deadlock
I am working on a camera applicaiton where I need to get images from camera buffer and display it in a TK label live:
def display_thread_run(self):
while self.is_acquiring:
image_data = ...
3
votes
2
answers
239
views
Python Customtkinter code remains running after GUI window is closed
I'm new to coding/Python started a few weeks ago and am learning by creating a basic app with Customtkinter (for the aesthetic) on Pycharm. The app has 2 Customtkinter windows, a login window (class ...
0
votes
1
answer
122
views
Is there a way to sort a database so that the order will match an alphabetically sorted list box in Tkinter?
I'm using Python, Tkinter in PyCharm.
This is a movie tracker program. It tracks movies I want to watch and have watched. There is a listbox in a frame on the left that contains the titles of movies. ...
2
votes
0
answers
106
views
Tkinter buttons appear outside window when using PyInstaller's --uac-uiaccess flag with topmost=True
I'm developing an accessibility application using Python and Tkinter where I need to use PyInstaller's --uac-uiaccess flag to ensure proper access to UI automation features.
The Problem
When I compile ...
0
votes
1
answer
53
views
How to replace pack() with grid()
The following code enables the status bar to remain at the bottom of the window and expand to fill the window when the window is resized. How can I replace pack() with grid() to do the same thing?
...
0
votes
0
answers
54
views
Python on mac: tkinter button reacts only on deep click
I use python 3.13.3 on a macbook air M1 (2020) with Sequoia 15.5
I am testing the following program:
import tkinter as tk
def button_clicked():
print("Button was clicked!")
window = tk....
0
votes
0
answers
138
views
Is it possible to use ANSI escape characters for color printing in a ScrolledText widget?
I want to redirect output to a ScrolledText wigget in a tkinter environment, and use the print function to display strings with colors in the widget.
My code prints the same string to the terminal and ...
2
votes
1
answer
95
views
Why does my approach to destroy window fail?
I want the EXIT button to close the window but I get the following error:
self.button=ttk.Button(self, text=' EXIT', command=app.exit).grid(column=0, row=0, sticky='ew')
NameError: name 'app' is not ...
2
votes
1
answer
87
views
Issue getting keystroke entries to show up in text fields (Python)
I am spinning my wheels trying to get python to spit the keypad strokes into my textfield Entries. Below is a Min Working Example. If the cursor is within the textfield, any keystroke from the keypad ...