I'm trying to build a GUI for a random dice simulator, with the intended goal of the simulator being to change the die size to different polyhedral dice (ex. a 20 sided die, a 10 sided die, etc.). My problem is that for the random.randint (1, b), I'm having trouble using a button to change the variable to a different number. What can I do?
I've tried having a command for the button such as:
def d4():
b = 4
and
def d4():
b.set(4)
Code setup:
a = 1
b = 20
def rollagain():
result = random.randint(a, b)
def d4():
b = 4
# a bunch of buttons and labels
b_d4 = Button(bones, text = "D4", height = 1, width = 8, command = d4)
b_roll = Button(bones, text = "Roll Dice", width = 8, command = rollagain)
# button placements
bones.mainloop
The starting value for b is 20, as I would like the result to be a value for a 20 sided die. When I click the d4 button, I would like to change b to 4, to represent a 4-sided die. But everything I've tried so far has resulted