/ 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: img1 need this: img2.

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:

http://legacy.python.org/dev/peps/pep-0238/


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

python - Django-cities exits with "killed" -

python - How to get a widget position inside it's layout in Kivy? -