Python Forum
Button to clear all output labels?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Button to clear all output labels?
#1
from tkinter import *
from random import randint

def rollD4():
    label = Label(root, text=randint(1, 4), font=(None, 12), height=2, width=2).grid(row=0, column=2)
def rollD6():
    label = Label(root, text=randint(1, 6), font=(None, 12), height=2, width=2).grid(row=1, column=2)
def rollD8():
    label = Label(root, text=randint(1, 8), font=(None, 12), height=2, width=2).grid(row=2, column=2)
def rollD10():
    label = Label(root, text=randint(1, 10), font=(None, 12), height=2, width=2).grid(row=3, column=2)
def rollD12():
    label = Label(root, text=randint(1, 12), font=(None, 12), height=2, width=2).grid(row=4, column=2)
def rollD20():
    label = Label(root, text=randint(1, 20), font=(None, 12), height=2, width=2).grid(row=5, column=2)
def rollD100():
    label = Label(root, text=randint(1, 100), font=(None, 12), height=2, width=2).grid(row=6, column=2)


root = Tk()
root.title("Table Top Pal (beta)")
root.geometry("500x392")  # This is how to resize your root box. (width x height)
menubar = Menu(root)
root.config(menu=menubar)

fileMenu = Menu(menubar,tearoff=0)
menubar.add_cascade(label="File",menu=fileMenu)
fileMenu.add_command(label="Exit",command=root.destroy)

button1 = Button(root, text="D4", command=rollD4, width=10, height=3)
button1.grid(row=0, column=0)
button2 = Button(root, text="D6", command=rollD6, width=10, height=3)
button2.grid(row=1, column=0)
button3 = Button(root, text="D8", command=rollD8, width=10, height=3)
button3.grid(row=2, column=0)
button4 = Button(root, text="D10", command=rollD10, width=10, height=3)
button4.grid(row=3, column=0)
button5 = Button(root, text="D12", command=rollD12, width=10, height=3)
button5.grid(row=4, column=0)
button6 = Button(root, text="D20", command=rollD20, width=10, height=3)
button6.grid(row=5, column=0)
button7 = Button(root, text="D100", command=rollD100, width=10, height=3)
button7.grid(row=6, column=0)

root.mainloop()
I am just trying to make a button that clears all of the dice roller outputs.
Reply


Messages In This Thread
Button to clear all output labels? - by AnunnakiKungFu - Dec-07-2020, 09:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Button/output help swittler 4 2,537 Jun-24-2020, 04:59 PM
Last Post: menator01
  [PySimpleGui] How to alter mouse click button of a standard submit button? skyerosebud 3 5,044 Jul-21-2019, 06:02 PM
Last Post: FullOfHelp
  clear button destroy can't work jacklee26 1 4,121 Jul-07-2019, 03:44 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020