Questions tagged [tkinter]

Tkinter serves as the official Python binding to the "tcl/tk" graphical user interface toolkit. Notably, in Python 3, the module was renamed from Tkinter to tkinter.

Python - My CTkRadioButtons now have the ability to select multiple options at once

I am currently facing an issue with the three radio buttons. They all allow multiple selections at once. How can I prevent this behavior and make it so that when one button is pressed, the selection switches from the previously selected one? pen_size ...

The reference to the global name 'start' is not recognized: Tkinter

Encountering the error message "Global name 'start' is not defined" from the code snippet provided. Interestingly, the call to start(panel) within displayImage(img) is responsible for displaying the desired image in the GUI; without it, no image appears. D ...

I'm encountering a problem while attempting to upload an image in tkinter using a label

Whenever I attempt to upload an image using tkinter, I encounter an error. I have fetched a gif image and stored it in a file named "image.gif", and saved the picture as "image". #Displaying image using label logo = PhotoImage(file="img.gif") w1 = Label(n ...

Preserve the status of the main page in tkinter

I have been working on creating a selection page at the top of my root page in an App using the tk.Toplevel() function in tkinter. The new page features an add button which generates new options on the selection page. Here is a simplified version of my cod ...

Can I choose multiple rows at once in a treeview widget?

Can you select multiple rows in a treeview widget and how do you retrieve the selected rows? I've created a treeview, but I can't seem to figure out how to select multiple rows at once. https://i.stack.imgur.com/lH43J.png If selecting multiple ...

Getting rid of the unnecessary border on a Text widget in Tkinter using Python

I am facing an issue with two Text widgets placed in a tkinter window. The empty border of the second line is obscuring part of the first line. Even after checking http://effbot.org/tkinterbook/text.htm, I found that all default border settings are set to ...

Learn how to extract the last segment of a directory path in Python using Tkinter without losing access to the complete directory structure

My main objective at the moment is to have the last section of the directory displayed in a drop-down menu as text, while still being able to open the image through the complete directory path. Currently, my drop-down menu only displays the full directory ...

Customize default key bindings for functions in tkinter Listbox

I have designed a listbox feature and I am seeking to adjust the functionality of the Left and Right arrow keys. Currently, these keys are programmed to navigate horizontally within the listbox, but I want them to move up and down the list instead. How can ...

Creating a scrollable text box in Python Tkinter

I created this code with the intention of quickly pulling and displaying data from Wikipedia. Everything functions well unless the summary from Wiki is too extensive for the box to present all at once. I believed that including sticky = N+S+E+W would resol ...

The tkinter library is unable to locate the specified function

As a beginner in tkinter, I find myself struggling to grasp the concepts of frame, self, and so on. This is what I currently have: class ScalesPage(Frame): def GetNotes(): key = KeyEntry.get() intervals = ScaleEntr ...

What causes the discrepancy in height options for tkinter buttons between OSX and Windows operating systems?

I'm encountering an issue with my code that involves the following line: self.button = Button(frame, text="CALCOLA", width=28, height=2, command=callback) When running the code on OSX, the button appears as a single line separated above and below from ot ...

The Pyinstaller exe-generated tkinter GUI is not functioning properly

I recently used Pyinstaller to convert my Python script into a stand-alone executable program. However, I encountered an issue where the exe version of the program did not work as expected, even though it ran perfectly fine in spyder during testing. Progr ...

Python tkinter infinite loop causing program to become unresponsive

Currently, I am developing a tkinter application that automatically backs up files by monitoring the last modification time of the file. The code for this app is provided below. from tkinter import * from tkinter import filedialog import shutil import os f ...

Python game where snake refuses to eat food

During code execution, when the snake and food coordinates are identical, the expected behavior is to delete the food item, increase the score by 1, add another square to the snake, and create a new food object. However, the `if` statement in the `next_t ...

Searching for a specific record in a SQLite database using a tkinter entry box in Python and retrieving the result

My latest project involves creating a library program that uses a database to store information about books, complete with tkinter for the graphical user interface. One highlight is a feature where users can input a book's name in order to search the datab ...

The submit button in Python 3 seems to be malfunctioning. What steps can I take to fix this issue

import tkinter as tk from tkinter import * import tkinter.ttk class main_window(Frame): def __init__(self): tk.Frame.__init__(self) self.pack() self.master.title("MANAGEMENT") self.entry_button = But ...

Tips for accessing the topmost heading in the Tkinter Python treeview

After working diligently on this code, I have come up with the following structure: def fee_foo(): fee_screen = tk.Tk() fee_screen.title("Fee Information") fee_screen.geometry("500x500") # Running the SELECT statement and ...

Utilizing regular expressions to replace patterns in Tkinter

Disclaimer: I have modified code found on the internet by adding a Regex function. I am interested in identifying numbers within text and replacing them with a 'number' tag using Regex. The code below accomplishes this task, utilizing tkinter to ...

Having difficulty displaying retrieved data from sqlite in a tkinter entry widget

Having a bit of an issue here. The goal of my project is to sum up certain columns from the SQLite database and display the results in an entry box based on the checkboxes (representing months and years) selected by the user in the main GUI. I am able to g ...

Is it possible to customize the text in a label by tracking mouse movements in Python using Tkinter?

I am having trouble updating my label based on the position of the mouse. Currently, it only works once when I run the code. How can I make sure the label updates every time my mouse changes position? The following code snippet is what I have so far, but i ...

Is it possible to alter the color by simply clicking on three Canvas circles using the same mouse button?

How can I modify the structure to recolor the circle when clicked with the mouse? import tkinter as tk class CanvasEvents(tk.Tk): def __init__(self): super().__init__() self.geometry('510x510+700+100') self.title("Event&qu ...

Retrieving information from various tkinter frames in a data object

My Current Project At the moment, I am developing a graph-viewing application. The user experience starts with opening the app and clicking on 'Import' in the sidebar to choose a CSV file. Once selected, the user can view the graph embedded with ...

The Tkinter calculator is limited to performing only a single operation at a time

import tkinter import tkinter.messagebox import sys top=tkinter.Tk() from tkinter import* def clear(): e1.delete(0,END) return def seven(): v.set(v.get()+str("7")) v.get() def eight(): v.set(v.get()+str("8")) v.get() def ni ...

Issue with lack of data refresh upon button click in tkinter with Python 3

How can I modify this code to make it functional? import os import time import random import sys import string import tkinter as tk root = tk.Tk() root.geometry("400x400") root.title("RandomPass v1.0") welcome = tk.Label(root, text="Welcome to RandomPas ...

Issue with tkcalendar's get_date() method results in AttributeError

I am encountering an issue where I am trying to retrieve the selected date from a tkcalendar calendar, but it keeps throwing an error that says AttributeError: 'NoneType' object has no attribute 'get_date'. I am unsure of what is causing this problem. Can ...

Check if a specific index in a Tkinter text widget contains a specific tag

I am looking to enhance my program by checking if an index in a Text widget has a tag attached to it. If a tag is present, I want the program to insert a different character based on that tag. This issue arose from my previous question which can be found h ...

Using Python 3 to switch window background on button press

After spending some time utilizing this website, I must say it has been incredibly beneficial for my Linux and Python needs - so thank you :) Recently, I embarked on the journey of adding a background to an application window. I created a button that trigg ...

Instructions for accessing a weblink by simply double clicking it within a tkinter list box

I am attempting to open web links from a list box by double clicking on them. Currently, I have code that would work if a button was used to call the function. However, I now want to simply double click on the link: def internet(): weblink = lb2.get( ...

Exploring the World of Buttons and Canvas in tkinter

My code is intended to display a keyboard design with 4 rows and 16 columns. https://i.stack.imgur.com/Guu5r.png In the provided image, there seems to be an issue with one of the buttons ('A') missing from its expected position in the top right corner. Ca ...

What is the best way to showcase a list or dictionary with proper formatting in a text window using tkinter?

Recently, I developed a basic Tkinter program to assist in grading students' tests. The program is designed to calculate the points for a specific grade based on the maximum number of points provided. While I have managed to create a list or dictionary ma ...

Live Plot of Data in Matplotlib - Time Series Visualization with Time on the x-axis

Is it possible to use time as x-axis values for a live matplotlib graph? If so, how should it be implemented? Despite trying various methods, I keep encountering errors. Below is my current code: update_label(label): def getvoltage(): f=ope ...

Using Python Selenium web-driver to hide console windows within a tkinter application

After creating a basic GUI using the tkinter library, I implemented a feature that opens a new thread with Selenium when the user clicks on a button: In the start_button3_callback method: # Initiating a new thread to run the button3_callback function in t ...

Issue with Tkinter's OptionMenu

Encountering a problem with my OptionMenu where it's not working unless I use a placeholder label to get it to function. In the example below, it only works when using TaxYear as the master, not TaxYearLi. The second issue is that for some reason w.s ...

"Troubleshooting blurriness in images due to Tkinter canvas scaling

After implementing a Tkinter canvas object with a zoom feature, based on guidance from another post on Stack Exchange and making some modifications, I encountered an issue. The zoom function in question is as follows: def wheel(self, event): ' ...

Obtaining input from a button module in tkinter using Python

I'm currently working on a project involving buttons and I want to ensure it is modular. However, I've encountered an issue regarding detecting button presses from different files. - File 1 from tkinter import* class app2: def __init__(self) ...

What is the best way to create a grid made up of rectangles, allowing each rectangle to be easily referenced by its position, represented by a tuple of row and column, for future use

Here is a sample code snippet: from tkinter import * import numpy as np rows = 10 columns = 10 width, height = rows*18, columns*18 window = Tk() window.geometry(str(width)+"x"+str(height)) window.resizable(width=False, height=False) window.confi ...

Adding additional text to a tkinter label

Currently facing an issue with a Python 3 script. My goal is to add more text to an already existing label in tkinter. This is what I tried: def labelConfig(string,append=False): if append: label.configure(text+=string) else: labe ...

"What is the total count of numbers and letters in the input provided by the user

I have this code snippet as the base of my program: from tkinter import * def click(event=None): global text_input user_text = text_input.get("1.0",'end-1c') # what should I do next? window = Tk() text_input = Text(window, height= ...

Error encountered while searching for module 'tkinter' during the installation of Python version 3.12.0 with pyenv on Fedora 38

Trying to install the latest version of Python 3.12.0 on Fedora 38 using pyenv with the command pyenv install 3.12.0 Encountering the following error - ~ pyenv install 3.12.0 Downloading Python-3.12.0.tar.xz... -> https://www.python.org/ftp/pytho ...

Multithreading and queuing in Python 3

I've been having troubles understanding the concepts of threading, queuing, and passing data between two classes. Despite my efforts to search online and get help here, I still can't grasp the necessary information. Essentially, I have a piece o ...

Creating a message that says "Item Not Found" when the input provided by the user does not correspond to any items in a given list (Tkinter)

A project I am working on involves developing an F1 Tkinter GUI application. This app allows users to input a driver's name either by typing it out or selecting from a listbox, and then relevant statistics are displayed. My current focus is on handli ...

What are the benefits of incorporating "from tkinter import ttk" in your Python code?

When working with Python applications that use TK GUIs, it is common to see the following import statements being used: from tkinter import * from tkinter import ttk Now, one might wonder if calling from tkinter import ttk is redundant since ttk should a ...

Creating spinboxes in Python and retrieving integer data from them instead of strings

I'm currently working on developing a calculator application that provides an estimate of annual gas expenses. In order to execute the program, I need to use an algorithm that retrieves input data from spinboxes as integers. However, when attempting to run ...

Every time I attempt to create an instance of the Font class in Tkinter, I encounter an error

When running this line: my_font = tk.font.Font(size=20) I encounter the error below: The module tkinter does not have the attribute font Any suggestions on how to resolve this issue? ...

Combining Graphical User Interface with Scripting

I am facing a challenge while trying to integrate two separate scripts, one with a GUI and the other being a bot script. Individually, both scripts run as expected but when combined, the bot function gets called immediately without displaying the user in ...

What is the best way to change the color of text within a tkinter text widget?

Is there a way to change the color of specific parts of a tkinter text widget? Here's a snippet of my code for a chat application where I need to distinguish between the sender and the message: T = Text(window, bg="black", fg="white", font=("bold", 1 ...

Updating Image by Clicking a Button using Python Tkinter

Is there a way to change the displayed image when a button is clicked in Tkinter? I have two images and corresponding buttons, but using the configure function does not seem to work. How can I achieve this functionality successfully? Thank you for your h ...

How can I display live terminal output in a tkinter Text widget?

Hey there, I'm currently working on a project that involves using Selenium. My goal is to have my program input the terminal responses (i.e. my print statements). For each page that loads, I print out the name of the page - for example, "forum homepage" or ...

Having some trouble transferring a string to the clipboard using Python3 and tkinter on Linux. Can't seem to get it to work as intended

Currently in search of a code snippet that can successfully append a string to the clipboard and retrieve text from the clipboard using Python3 along with tkinter. After some research, I came across an insightful post. I tried out the following code excerp ...

Incorporating a custom image in a tkinter interface using PIL

I am attempting to utilize a tkinter button in order to display an ERD diagram using sqlalchemy and PIL. I have successfully achieved this by saving the generated image to a file and then reopening that file to display it in a label. Is there a method to ...

The ttk Progressbar is designed to only be visible once the process has reached its conclusion

After some reflection, I realized that the progress bar in my code only displays at the end of the completion of the for loop. However, I would like it to show the progress of each cycle step by step. from tkinter import ttk from tkinter import * import ...

Ensure that the tkinter submit button handle function is executed only once, unless new and different input is provided

I'm a beginner in tkinter and I'm struggling with a simple method. I want to create a submit button that disables if the same user input is submitted again, but carries out its function when new input is provided. Can anyone provide some assistan ...

Navigating the complex world of Tkinter Text Widgets Indexing Mechanism

Is there a way to divide a decimal number into its whole and fractional parts? For example : 1.24345 should be separated into 1 and 24345 1455.24 should be divided into 1455 and 24 1455.0 should result in 1455 as the whole number and 0 as the fractiona ...

Capturing selenium screenshots and showcasing them on a tkinter graphical user interface (GUI

I'm attempting to capture a screenshot of a page using selenium and display it on a canvas in my tkinter interface. However, I keep encountering the following error: TypeError: __str__ returned non-string (type bytes) Here is the code snippet. Any assist ...

Design a new class that features a graphical user interface, but facing challenges with the syntax

class AutoGUI: def __init__(self): import tkinter, re, uuid from tkinter.constants import * import tkinter.messagebox import socket, os, subprocess, multiprocessing, sys from getmac import get_mac_address as gma ...

Basic paddleball game with an unresponsive ball

I've been learning Python through a course designed for kids, and one of the projects we worked on was creating a simple paddleball game. I managed to get the ball bouncing off the walls earlier, but now it's not working as expected after complet ...

Exploring the World of GUIs with Python's Tk

I am in search of a helpful resource to guide me on how to connect TKinter with JSON. I would like to input a word, search for that word in the JSON file, and then display the result of the search. Currently, I have my python application running smoothly ...

Typing in a tkinter entry box effortlessly without the need to first click on it

Every time I launch my tkinter program, I find myself having to click on the entry box before I can start typing. Is there a way to configure it so that I can type without the need to click on the entry box? Thanks in advance. ...

Linking a function to multiple labels with the same name - tkinter

I need to create a feature that allows users to generate multiple labels by pressing the "Enter" key: def new_line(event): global Row_n Row_n = Row_n + 1 Choose= tk.Label(frame, text="Choose option", background = "white",fo ...

Is there a way to reset my Pong game without losing my score?

For my first fully developed Python project, I have created a Pong game using tkinter for most of the functionality. However, I encountered an issue with restarting the program using the restart button without affecting the score counter in the top left ...

Issues with sv_ttk and pyinstaller

Hey everyone, I'm having trouble getting this code in .py to work when compiling it to .exe with PyInstaller, even with the --onefile option. #imports > from tkinter import * from tkinter import ttk import sv_ttk as sv #< imports #definitions ...

Updating a complete segment in Python using Tkinter

I am facing an issue with my GUI where I have a segment that generates multiple labels using a for loop. There is also a button intended to delete all these labels and initiate the for loop again with new data. However, I am struggling to make the button ...

The Python tkmacosx is throwing an error related to the "systemWindowBackgroundColor" property

Currently, I am facing a challenge with changing the foreground color of a button on my Mac running Big Sur. I have attempted to resolve this by installing tkmacosx, but it seems there may be an issue with the package. Whenever I run the code below or att ...

I'm encountering an attribute error in tkinter that is preventing me from utilizing my method associated with a button

I am having trouble linking the button "calculate_button" to the method I created called "calculate()". The method should simply print "you've just clicked", but an error is raised saying there's no attribute 'calculate'. I'm confu ...

"Engagingly verifying the content of Entry widgets in Tkinter through inter

What is the best approach for dynamically validating content in a tkinter Entry widget? I have researched using validate=True and validatecommand=command, but it seems that these methods have limitations as they are cleared when the validatecommand modifi ...

Python version 3.6 is throwing an error in tkinter when it says that GROOVE is

Just a few minutes ago, the program below was working perfectly fine. But then I made a small change, ran the code, encountered an error which caused Spyder to crash. Now, it's unable to find Frame or Groove or some other element. Right now, it's ...

Guidelines for requesting integer input from the user with Python's tkinter library

I'm facing an issue with getting the correct integer value input from a user in Python tkinter. I've tried using a=n.get() and then converting it to an integer using a=int(a), but it's not working as expected. Below is the code snippet I used: def selectpa ...

Troubleshooting Matplotlib and Pyplot Import Problem in Python with Tkinter

Having an issue here where the 'pyplot' element of 'matplotlib' cannot be called. In the given code snippet, I had to include "TkAgg" for the matplotlib element to function properly, as it is a common problem. import matplotlib matplotlib.use("TkAgg") Bu ...

Python code stuck trying to match hashed passcodes

I'm working on an interesting project where I'm developing a secret coding program with a Tkinter GUI to encrypt text, although not highly secure. The main goal of the program is to have a password that is linked to a text file. Initially, I've set the def ...

Creating a tkinter application where a button performs different actions based on the selection from a dropdown menu

Is there a way to create a button that performs different actions based on the selection from a dropdown menu? I attempted the following approach but it did not yield the desired results: import tkinter as tk from tkinter import ttk root = tk.Tk() root.g ...

The variable "display" in the global scope was not located

Currently working on a troubleshooting code, I've encountered an issue. When I select "other" and try to input data into the form, upon hitting continue, an error is displayed: Exception in Tkinter callback Traceback (most recent call last): File "C: ...

Is it possible to collaborate on the same tkinter window from separate Python files?

Suppose you have a main.py file with a line root = tk.Tk() creating the main window of a GUI. In addition, there is another file named menu.py that you wish to utilize to add a menu bar to the root window in main.py. ...

How can I store a date from a calendar using tkcalendar in Python?

I'm looking to save the selected dates from a calendar to variables. I found this code, but I'm unsure of how to save the date. import tkinter as tk from tkinter import ttk from tkcalendar import Calendar def example1(): def print_sel(): ...

Tips for extracting file paths correctly from the tkinterDND2 event object

Looking to add a "drop files here" feature to my GUI application built with tkinter in Python. I discovered the TkinterDnD2 library after finding this useful Stack Overflow response. After dropping a file, event.data returns the file name within curly br ...

What is the best way to simultaneously close an existing window while opening a new one?

I am encountering an issue with a button that links to another button in my code. The second button is able to close itself, but the first button cannot both close itself and open a new button simultaneously. How can I resolve this problem? import tkint ...