Following is very simple code to create a frame and label as a class: class FrameWithLabel(tk.Frame): def __init__(self, parent): super().__init__(self, parent) self.label = tk.Label(self) I have two questions: In an earlier post, it was explained to me why the super init was required (in this case, referring to the tk.Frame), and that without the super… Read More Python/Tkinter: fine points about super init and self
This is my first time ever writing here. Also my first time actually coding. I’ve made a code but have issues running it due to tKinter not seeming to exist, even though I’ve specifically installed python from the official webpage and also ticked the tcl/tk options. When trying to launch my code i get this… Read More Issues with tKinter
I am trying to make a variable that stores the input inside a textbox on the press of the button. As an example: when button1 pressed: a = textbox1.input My current code so far is: import tkinter as tk window = tk.Tk() window.title("A simple window") window.geometry("150×150") def save_textbox_input(): # Code goes here button = tk.Button(text="Click… Read More How to pass the input of a textbox to a variable in python tkinter?
I have some code that repeats that I would like to compress into a loop somehow. The code is meant to show a series of rectangles that change color when your mouse hovers over them, and because I have numerous rectangles, all of the code repeating is the same except for 2 coordinates for the… Read More How do I compress repeating tkinter code into a loop so it displays rectangles without having to write out each individual rectangle's coordinates?
I’m trying to replace sleep() with after() but I need to create a function which will give me a return value that I can store and I can’t figure out how. Let’s take this code : import tkinter root = tkinter.Tk() def test(i): o=i*2 return o print(root.after(5000,test,6)) root.mainloop() This results in this output: after#2914 which… Read More function passed in tkinter after() method can't give return value
I need to limit the entry to a maximum of 5 digits. def validate(S): try: float(S) return True except ValueError: messagebox.showerror(message="Datos erroneos, únicamente números.", title="ERROR") return False e1 = tk.Entry(master, validate="key", validatecommand=(master.register(validate), ‘%S’)) I have this method to receive and validate that it’s just numbers at the entry, but i would like to know how… Read More How to limit the character in Entry
import tkinter top = tkinter.Tk() class Person: def __init__ (self): self.health = 100 def sword(self): self.health = self.health – 10 print(self.health) n = Person() sh = tkinter.Label(top, text=str(n.health)).place(x = .5, y = .5) button = tkinter.Button(top, text="sword", command=n.sword) button.place(relx=0.015, rely=0.5, relheight=0.3, relwidth=0.3) top.mainloop() I am trying to make a mini app that whenever I click… Read More How do I update a label with information that changes based on a button click
I’m trying to show a list of elements from a data set in a tkinter window. I want to able to manipulate the elements, by highlighting, deleting etc. I have this code: from tkinter import * window = Tk() window.geometry("100×100") #data from API data_list = [ ["1", "Lorem"], ["2", "Lorem"], ["3", "Lorem"], ["4", "Lorem"] ]… Read More Python dictionary, list and for-loop bug
I’m quite new to Python. I’m trying to update the image periodically. I’ve searched around but I’m still struggling to make this work how I want. I’m just going to paste the whole .py file I have. Right now, It seems as though it’s incrementing properly. I know the __init__ function in the Window class… Read More Attempting to make a photo slide
I’m encountering difficulties when trying to use the entrybox within tkinter, i’ve tried a few online resources and none seem to help my exact issue. So my interface is mainly complete, but I couldn’t cover everything. Terefor wanted to add a small entry box, which allowed users to type in custom code and commands. The… Read More Creating a Entry box which outputs to a textbox in tkinter, python