Why does my FOR loop in Python's time module only display the last random image selected instead of random images every time?

Advertisements I am working on the bare bones of a slot machine game for a coding class and I am running into an issue with the function I am making for the slot rolling. The FOR loop is supposed to pick a random image, wait some time, do that 3 times and then move on.… Read More Why does my FOR loop in Python's time module only display the last random image selected instead of random images every time?

Incorrect value returned by tkinter method canvas.winfo_width

Advertisements I’ve just started learning how to create a game with tkinter. I found it so difficult to find information for all the available methods in the module. This website seemed comprehensive but was difficult to navigate to find relevant info for a specific method (for example winfo_width). I then tried to find the purpose… Read More Incorrect value returned by tkinter method canvas.winfo_width

Tkinter pack with anchor/side not filling all available space

Advertisements import tkinter as tk from tkinter import ttk class App(tk.Frame): def __init__(self, master=None): super().__init__(master) self.master = master self.create_widgets() def create_widgets(self): self.notebook = ttk.Notebook(self.master) self.notebook.pack(side="top", anchor="n", expand=True) # create tabs self.tabs = {} self.tabs["tab1"] = tk.Frame(self.notebook, width=420, height=420, borderwidth=0) self.tabs["tab2"] = tk.Frame(self.notebook, width=420, height=420, borderwidth=0) self.tab_headers = ["tab1", "tab2"] self.tabs["tab1"].pack() self.tabs["tab2"].pack() # add frame with… Read More Tkinter pack with anchor/side not filling all available space

tkinter: get index of a clicked widget inside a list of widget objects

Advertisements The following code creates a list of tk entry widgets and then displays them in a tk root window. Each entry includes a binding to a left mouse click that calls an event handler. The event handler identifies which entry widget was clicked using event.widget. def event_handler(event): clicked_entry = event.widget print(clicked_entry) # Create list… Read More tkinter: get index of a clicked widget inside a list of widget objects

Tkinter updating label fails with "AttributeError: 'Frame' object has no attribute 'label1' "

Advertisements I’m trying to put together my first tkinter application, showing values recieved from Arduino serial port, I successfully managed to make console application, but I’m novice in GUI. raw0 is string with ‘NR’ raw 1 – 4 are int compatible values raw5 is string ‘EOR’ here is my code: #!/usr/bin/python3 import tkinter as tk… Read More Tkinter updating label fails with "AttributeError: 'Frame' object has no attribute 'label1' "