-3
AND、ORボタンをウィンドウの中央に移動したいのですが、適切な方法はありません。 また、ラベルが中央に表示されません。 私は(パックを使用したくない)グリッドを使ってPythonのボタンを中央に配置する方法は?
from Tkinter import *
root = Tk()
root.title("BITWISE & and |")
Label(root,text='This program will calculate BITWISE AND OR',relief='ridge',font='times 20 bold italic',bg='red',fg='white').grid(row=0,columnspan=5)
Label(root, text='Enter 1st Bit ').grid(row=1, column=0)
e1 = Entry(root)
e1.grid(row=1, column=1)
Label(root, text='Enter 2nd Bit').grid(row=2)
e2 = Entry(root)
e2.grid(row=2, column=1)
def andr():
a = int(e1.get())
b = int(e2.get())
an = a & b
Label(root, text='The \'AND\' of the above Bits is = ' + str(an)).grid(row=5)
def ors():
a = int(e1.get())
b = int(e2.get())
o = a | b
Label(root, text='The \'OR\' of the above Bits is = ' + str(o)).grid(row=5)
Button(root, text="AND", command=andr).grid(row=3)
Button(root, text="OR", command=ors).grid(row=4)
root.mainloop()