Skip to content
Advertisement

Tag: tkinter

How to stop the location of one grid element from changing due to the update of the content of another grid element in python tkinter?

I have written code for a small python tkinter application which goes as follows As soon as button_1 is clicked and the label_directory gets updated with the string for directory, the position of button_1 gets pushed towards the right and goes outside the application window. How can I stop this from happening? Answer The problem is that when you are

Unable to exit tkinter app when using “wait_variable()”

I have a python code that includes tkinter window and other running tasks. I’ve been trying to bind “WM_DELETE_WINDOW” event to a function that exits my python code when I close the window but can’t achieve that. This is what I try: The window is destroyed successfully but the python code doesn’t exit. Any possible reason for sys.exit() not to

How to remove a keybind after it has done its job

I created a keybind, and want to delete it after it is activated. How do I do this? I have tried this in my code: However, this does not work, as Python displays an error message stating that deletecommand() takes 2 positional arguments but 3 were given, when I only gave two arguments. I also tried root.delete(‘<Key>’, testing), but this

Keybind that binds to every key in tkinter

I am creating an interactive game with Python, and I am trying to make an introduction with the instruction “Press any key to continue.” I am having some difficulty with binding all the keys to a single action. I have tried binding to ‘<Any>’, but it displays an error message. As mentioned before, the ‘<Any>’ keybind results in an error

How to delete a label from tkinter after a countdown

I am trying to create a ten-second countdown that removes itself after it reaches zero. How and where do I put code to remove the label? I have experimented with label.destroy() and label.forget(), but they do not work, creating an error message, most likely because they do not exist. I was hoping for the program to delete the label after

Labels with no background tkinter

I’m making a tkinter app with a background image and three labels. The problem that I have is that these labels have a white background and I don’t want that. I want to make like a “png” label, with no background. First, I tried to put this line of code: But it didn’t work, literally, the label was a hole.

Advertisement