/ operand not working as expected in python 3 -
i'm reading book tkinter gui application development hotshot based on python 2, , have code:
from tkinter import * rows = 5 un = 2 bp = 2 columns = un * bp root = tk() right_frame = frame(root) right_frame.pack() button = [[0 x in range(columns)] x in range(rows)] in range(rows): j in range(columns): active = false color = '#f3f3f3' if (j / bp) % 2 else '#9a72a9' button[i][j] = button(right_frame, bg=color, relief='flat', width=1) button[i][j].grid(row=i, column=j) root.mainloop()
and have result: need this: .
tkinter works when run tkinter , python 2 unexpected result when running in python 3 , tkinter, cause behaviour?
the difference due how python 2.x , python 3.x handle division operator. lengthy description can found here:
Comments
Post a Comment