I am a teacher. I teach math, but since education is facing human resources crisis, I have some additional duties. I teach kids a bit of programming, they do quite well. Now I’d like to make with them a snake game, but I have a problem achieving multithreading in my GUI app. I found similar cases but no solutions. Like
Tag: tkinter
How to open a Tkinter askopenfilename dialog compatible with Python 2 and Python 3
I’m trying to write a simple Python Tkinter file chooser that is compatible both with Python2.7 and Python3.x Python3 Version Python2.7 Version How can I come up with a unified solution? Answer Try to import Tk and askopenfilename as for Python 3.x at first. If you get an ImportError (there is no tkinter and tkinter.filedialog modules), try to import them
How to get a user input for a column in pandas by creating a GUI using tkinter?
I have a dataframe with 3 columns: Date, attribute_one, attribute_two. The date column is blank but the other two columns are filled with some data. how can I use tkinter package to build a GUI which would prompt the user to enter date which will then be eventually stored in the dataframe. Answer Using the tkinter Entry class, and using
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
Error while creating a menu in Python using TkInter. What am I doing wrong?
I’m having an error while creating a menu in Python using Tkinter. What am I doing wrong? My code and complete error traceback are given below. My code: The error: What does this error mean? What am I doing wrong, and how can I fix it? Thank you so much!! Answer This is a problem. Frame objects do not support
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.