52,705 questions
1
vote
2
answers
111
views
How can I make a square Tkinter Entry widget if width only accepts integers?
I'm trying to create a square tk.Entry widget in Tkinter, but the width parameter only accepts integers which represent a number of characters instead of pixels.
Setting width=2 makes the box too ...
-1
votes
1
answer
63
views
Placing text box next to text in tkinter
I'm attempting to learn tkinter, how can i edit this code so that the text box is directly next to the input statement ? I've tried putting the text box in the first column with an alignment to the ...
1
vote
0
answers
55
views
Python Customtkinter: Getting real widget size
I seem to be always getting 120 for both height and width, I don't know why it refuses to give me the real value for the width so I can make the maintain the height in a 16:9 ratio
# Monitor frame
...
1
vote
0
answers
71
views
text moves vertically when exiting text boxes in Tkinter form
I'm trying to create a short form in tkinter python but am new to the language. Whenever I click off of the text box the text underneath moves down vertically and the error message displayed has a ...
0
votes
1
answer
46
views
Tkinter image will not change [duplicate]
import tkinter as tk
from tkinter import ttk
root = tk.Tk()
def change():
img2 = tk.PhotoImage(file = "img2.png")
label.configure(image = img2)
img1 = tk.PhotoImage(file = "...
0
votes
1
answer
99
views
Tkinter ttk.button background is leaking color outside the button border
Button is created like:
style.configure('Dark.TButton', background=button_base, foreground=colors['text'], borderwidth=1,
bordercolor=edge, lightcolor=edge, darkcolor=edge, padding=...
1
vote
3
answers
67
views
How can I update a text name on a label on Tkinter:
I want that when I upload a file, the label changes its name to file name to filename name.
#File class
class File:
def __init__(self):
self.filename = None
def getFile(self):
...
Best practices
2
votes
1
replies
34
views
How can I save a local file using tkinter with filedialog.askopenfilename
How can I treat a file when the client imports a local file as a variable and using it later?
def getFile():
return filedialog.askopenfilename()
from operation.encryption import getFile
...
Best practices
0
votes
3
replies
63
views
Trying to make it CTk, but STATE not working
I have this script in Tk and it works fine. I wanted to make it dark and add hover options, so I changed it to CTk, but now it's not working. Can someone please help me fix this? I have both scripts ...
0
votes
1
answer
51
views
How can I put the label in the frame on the left side on Tkinter? [duplicate]
I want to put the "Selecto a file to encrypt" on the left site, a try it separate too and it didn't work.
tk.Label(frame, text="Select a file to encrypt: ", fg="black")....
0
votes
3
answers
66
views
How can I put the Label into the frame?
I'm new into tkinter and I don't know how to put this Label:
tk.Label(frame, text="Select a file to encrypt: ", fg="black").pack()
Into that frame:
frame = tk.Frame(root, width=...
0
votes
1
answer
60
views
Tkinter grid propagation and scrolling
I have a tkinter window that runs script, with this general layout:
┌─────────────────────────────────────┐
│ Op Buttons │ ← Row 0 (fixed)
├───────────────────────────────────...
0
votes
0
answers
84
views
Why won't the file dialog open when I use withdraw() early in the program?
I'm in a CS class for college right now, and we've gotten to the part in our Python course where we learn how to read, write, and append to external files. We were given some class work where we have ...
-1
votes
0
answers
51
views
My toplevel window shuts down entire app on toplevel.destroy
This happens after selecting a date from the DateEntry popup. If you type a date into the DateEntry widget the exit routine shuts the toplevel correctly. Select a date from the popup and the exit ...
0
votes
2
answers
78
views
Horizontal and vertical scrollbars using TKinter and Python almost working
I wanted to try to use tkinter for the first time, and had a little program I wanted to try.
It needed some text in a "table" and because of the number of rows and columns, I needed ...
0
votes
0
answers
66
views
Why does the Tkinter canvas-enter event behave differently in Windows 11 and Linux Mint?
I bind the enter-event to a Tkinter canvas widget. But it seems that Tkinter on Windows 11 and Tkinter on Linux Mint handle the event differently. In my example the enter-event is bound to the green ...
1
vote
1
answer
66
views
Alt, Shift and Control key bindings in Tkinter
I am struggling with some key bindings in Tkinter.
In my application, to avoid having to make each widget get the focus prior to having the opportunity of capturing KeyPress events, I decided to use ...
0
votes
1
answer
70
views
Tkinter not display window; declared as part of class
Running VSCode with MS Python extension and my window will not display
here's my code
import tkinter as tk
class FormMain:
def __init_(self):
self.build_controls()
def build_controls(...
1
vote
0
answers
41
views
Removing the box surrounding the down arrow of a ttkinter.ComboBox
I want to remove the box surrounding the arrow of a combobox, seen below
I am using ttkinter with the theme "Clam", and styling it like this:
combobox_style = ttk.Style()
...
1
vote
3
answers
105
views
Force a widget to be a square
I am using Python 3.14 on Windows 11.
I have 2 frames (left and right) inside a top Frame, and there is also a bottom Frame that will act as a status bar.
I want the left frame to be a square, giving ...
0
votes
0
answers
36
views
Pytubefix seems to only partially work, on_progress_callback does not run
from tkinter import *
from tkinter import filedialog
from tkinter.ttk import Progressbar
import pytubefix.exceptions
from pytubefix import YouTube
import time
def openFile():
global filepath
...
2
votes
0
answers
57
views
Tkinter messageboxes opened from a pystray menu appear unfocused or behind other windows on Windows 11
I'm building a Python desktop app that uses both pystray (for a system tray icon) and Tkinter (for message boxes and dialogs). Everything works fine except for one issue on Windows 11: when I open a ...
0
votes
1
answer
31
views
ttkbootstrap Messagebox does not display message under linux Mint but ok in windows
The Messagebox shows up as it does under windows - but only shows the title not the message.
I have created a simple piece of code to illustrate the problem:
from tkinter import *
import ttkbootstrap ...
1
vote
1
answer
128
views
Tkinter window shrinks after embedding Matplotlib canvas — how to prevent it?
I'm building a multi-frame Tkinter app for a school project (NEA dashboard). One of the frames displays a Matplotlib scatter plot using FigureCanvasTkAgg. The issue is that after switching to the ...
0
votes
1
answer
140
views
I cannot set tkinter frame width
I want to have fixed width frames with tkinter.
The main idea is to have a dynamic number of fixed width columns (in this example 2) and within each columns a dynamic number of entries (in this case a ...
1
vote
2
answers
104
views
Buttons in tkinter are not visible
import tkinter,time
canvas=tkinter.Canvas(width=500,height=500,bg="white")
canvas.pack()
canvas.create_text(250,250,text="0:0:0",font="Arial 70 bold")
global b
def ...
2
votes
2
answers
86
views
How to catch Tkinter text widget state/data before it is destroyed?
I'm trying to catch/save the text widget state (for use later) before it is destroyed by binding it to the <Destroy> event, for example:
import tkinter as tk
root = tk.Tk()
text = tk.Text()
text....
1
vote
2
answers
101
views
How to stop this game for seconds and start from where it was stopped?
I wrote a game with python tkinter but i don't know def stop??
I want to stop the game for seconds and then start again from where it was stopped.
I want to press SPACE key and then the game stops and ...
0
votes
1
answer
106
views
Why do all my declared windows open when I start in my tkinter application? [closed]
I am working with tkinter and I want to use three windows:
startWindow
addWindow
deleteWindow
I want to start them separately, but when I run my code, all three windows start immediately.
How can I ...
0
votes
1
answer
134
views
Horizontal scrollbar on tkinter treeview is not working
I am using tkinter, pandas and treeview.
The treeview is to display an excel file via filedialog with 15 columns, which is very lengthy, hence I needed a horizontal scrollbar.
However the scrollbar ...
2
votes
2
answers
101
views
Python Tkinter Labelframe strange behaviour
My program gets a list of messages and displays them on a Tkinter widget.
"Previous" and "Next" buttons let me read through the message list.
I can read all the messages and ...
1
vote
2
answers
115
views
Tkinter loading user Data from a file not in directory
I want to make a Tkinter program where separate users can load their data, (a dictionary) from a sub-folder within the main project directory.
My_project
|_main.py
|
|_User_data
|
|_ Data.py
...
0
votes
1
answer
89
views
Why is the order of my tkinter windows changed, when the "last" window executes another tkinter program by popen?
I have an tkinter application with several windows, which often are placed over each other in a window stack, so that only a topmost window is visible. In this topmost window I can press a button ...
2
votes
1
answer
80
views
Tkinter call another window with a button
Good evening,
I would like to build a tkinter interface with several buttons leading to differents script. Those script are functions in another folder.
In the example I built to explain my problem, ...
1
vote
2
answers
113
views
How to make sure a user can't submit an entry if it has the same ID number? [closed]
I'm trying to make a Student Information System, the information will be stored in a text file, and will be shown through a table.
Submit button function:
def submit():
if idEntry.get() == "&...
3
votes
1
answer
104
views
Tkinter Load data from another directory
In Tkinter want to import variables stored on a file in a sub directory of the main project but am having trouble. I can read the file, but cannot import variables. Please Help.
def change_dir():
...
0
votes
0
answers
54
views
Tkinter: treeview inner lines' styling
I managed to style a treeview control to this nice gridview:
container = tk.Frame(self, relief='sunken', borderwidth=1, bg='white')
container.grid(column=0, row=0, sticky='nsew')
container....
5
votes
1
answer
74
views
How can I set 25-25-50 ratio between grid children?
In tkinter I wish to achieve the above goal.
I can perfectly get 50-50, and 25-25-25-25. But tried everything to get 25-25-50 without success:
import tkinter as tk
root = tk.Tk()
root.geometry("...
2
votes
2
answers
128
views
How to sort 1 list over 2 frames
Is it possible to sort 0:5 to frame 1, and sort 5:10 to frame 2 using one list?
Now it is clicking both radiobuttons in frame 1 and 2. I would like that only one can be selected at the time.
My code:
...
1
vote
1
answer
79
views
expected integer but got "none"
I have two lists, but I want them to work as one. So only one radiobutton can be activated at the time. I am trying to get them to print something without an error, but I keep getting an error because ...
9
votes
1
answer
410
views
List isn't expanding
These lists aren't expanding, only the last thing on the list is visible. My list works when I use it as pack. But I want to have 3 lists right next to each other with radiobuttons using grid. But I ...
1
vote
1
answer
53
views
I'm having trouble adding items to a combobox with a textbox and pushboton in GUIzero
I'm trying to add items to the combobox in GUIzero getting the value from a textbox when a button is pressed, but when the button is pressed I get the following error:
Exception in Tkinter callback
...
1
vote
1
answer
163
views
List value options for widget configure keys
How can I get the value options for config attributes? Especially those that take set values, i.e. anchor, relief, etc.
Call the configure method on some widget, say a label:
label = tk.Label(root, ...
4
votes
1
answer
144
views
Python tkinter not executing button commands on Raspberry Pi
I am developing an app to select and play a mp3 clip from a list. It will be run on a Pi4 with 7” touch display and piAMP+ hat. The GUI is in tkinter with pygame for the sound plus a pair of GPIO pins ...
-1
votes
2
answers
115
views
Python tkinter stops while loop?
I want to creates buttons in a while loop, but when the app starts running, my program stops. It might be a beginner problem, but I cannot figure it out.
My code looks like this:
import tkinter as tk
...
0
votes
1
answer
116
views
Why does my Python game pauses everytime tkSnack plays an audio file?
I'm new here and this is my first question!
So I have this simple Python snake game that uses tkinter and tkSnack and it's working as intended graphics and controls wise except that the game or frame ...
-2
votes
1
answer
83
views
Tkinter Volume scale/slider doesn't set volume
I have a slider to change the volume on my PC when I change the scale. However, it doesn't set the volume at the moment and I don't know why. Can someone please help me?
My code:
from tkinter import *
...
0
votes
1
answer
121
views
How to add a border to tkinter frame?
so I'm a bit of a beginner in python and wanted to make a GUI for a script I'm using to make it easier. For the data input I created a frame in which I placed the filedialog button etc., and ...
0
votes
0
answers
93
views
How do I completely remove the border from a Tkinter Button with an image on macOS?
I’m building a flashcard app with Tkinter in Python on macOS (macOS 26 + Python 3.13). I’m trying to make an x_button that shows only an image without any border, background, or focus ring.
Here’s a ...
1
vote
1
answer
111
views
Python static code analysis complains about kw argument 'font' in Event.widget.configure
I have a callback
from tkinter import font, ttk
class Foo(ttk.Frame):
def set_font_cb(self, event: tk.Event) -> None:
event.widget.configure(font=font.Font(...))
And this creates in ...