Feb-07-2021, 11:09 PM
So, I keep having trouble with this and when I ask on the Python FB groups, they can't seem to get what I am asking. Maybe I am asking it wrong? Anyway, in this code, every time I switch the columns, it never moves to where I want it to. Like, say I want a button in row 0 and column 6, well, when I type in that code in my button, it only moves over one space. No matter what I do. What exactly am I doing wrong?
from random import randint from tkinter import * def d4_roll(): label=Label(root, text=randint(1,4), font=(None, 12), height=2, width=2).grid(row=0, column=2) def d6_roll(): label=Label(root, text=randint(1,6), font=(None, 12), height=2, width=2).grid(row=1, column=2) def d8_roll(): label=Label(root, text=randint(1,8), font=(None, 12), height=2, width=2).grid(row=2, column=2) def d10_roll(): label=Label(root, text=randint(1,10), font=(None, 12), height=2, width=2).grid(row=3, column=2) def d12_roll(): label=Label(root, text=randint(1,12), font=(None, 12), height=2, width=2).grid(row=4, column=2) def d20_roll(): label=Label(root, text=randint(1,20), font=(None, 12), height=2, width=2).grid(row=5, column=2) def d100_roll(): label=Label(root, text=randint(1,100), font=(None, 12), height=2, width=2).grid(row=6, column=2) def init_roll(): label=Label(root, bg='red', text=randint(1,20), font=(None, 12), height=2, width=2).grid(row=7, column=2) root = Tk() root.title("BasicBitchRoller") root.geometry("500x448") button1 = Button(root, text="D4", command=d4_roll, width=10, height=3).grid(row=0, column=0) button2 = Button(root, text="D6", command=d6_roll, width=10, height=3).grid(row=1, column=0) button3 = Button(root, text="D8", command=d8_roll, width=10, height=3).grid(row=2, column=0) button4 = Button(root, text="D10", command=d10_roll, width=10, height=3).grid(row=3, column=0) button5 = Button(root, text="D12", command=d12_roll, width=10, height=3).grid(row=4, column=0) button6 = Button(root, text="D20", command=d20_roll, width=10, height=3).grid(row=5, column=0) button7 = Button(root, text="D100", command=d100_roll, width=10, height=3).grid(row=6, column=0) buttonInit = Button(root, bg='red', text='INITIATIVE', command=init_roll, width=10, height=3).grid(row=7, column=0) # exit_button = Button(root, text="Exit", command=root.destroy, width=10, height=3).grid(row=7, column=0) <--- Exit button code if we need it. root.mainloop()