python - How to get grid information from pressed Button in tkinter? -


i need create table of buttons using tkinter in python 2.7, has n rows , n columns, , has no button in bottom right corner.

problem when press button, in place, need create free space , move button space empty before, , cannot because don't know how grid (x , y axes) information of pressed button use create free space.

this current code:

from tkinter import *  #input: n=int(raw_input("input whole positive number: ")) l = range(1,n+1) k = n m = n  #program: root = tk() in l:     j in l:         frame = frame(root)         frame.grid(row = i, column = j)         if j == k , == m:             pass         else:             button = button(frame)             button.grid(row = i, column = j)   root.mainloop() 

it this, wanted button grid position, , use change k , m variables make empty space in position pressed button was.

you can pass row , column using lambda expression button:

button = button(..., command=lambda row=i, column=j: dosomething(row, column)) 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -