-2

I am working on a simple Dice Roller for my D&D games and the code is working and everything, I just do not know how to make an output box for when the button is pressed. I want to press the button and have the randint output in the output box next to the button.

My code

1 Answers1

1

You can create an empty label right before/after your button.

result_label = Label(root, text = "")
result_label.grid(row = 0, column =1)

Then, you can update the text by adding the following inside your function :

result_label.config(text = randint(1,6))

This will replace the empty text of the label by a random number. If you want to keep the print output you'll have to save the value of randint(1,6) in a variable and use it as an input for both the text label and the print function.

Anthony D
  • 11
  • 3
  • 1
    I appreciate your helping but your variable naming style is making me twitch. Python names should be lower_snake_case. Please read PEP8. – Novel Dec 01 '20 at 00:26
  • Variable naminge style corrected. Was not aware of PEP8. Thanks for the tip. – Anthony D Dec 01 '20 at 00:34