Zdravim, v nize uvedenem kodu je nastrel kalkulacky. Problem je, ze kdyz tazenim roztahnu okno, tak se neroztahuji tlacitka, coz by mely, protoze je to v zadani. Klasika v podobe
fill=BOTH, expand=1
zde nefunguje....
Prosim o radu jak to resit zde v gridu, Diky :o)
#------------------------------------------------------------------------------#
# Kalkulacka #
#------------------------------------------------------------------------------#
from Tkinter import *
from math import *
import tkFont
def callback(f, *a):
"""
Vraci funkci f s nastavenym parametrem a.
Tato funkce umi osetrit i vice nez jeden parametr.
Pouziti:
callback(funkce, arg1, arg2, ..., argn )
"""
return lambda: f(*a)
class MyApp:
def big(self):
print "big"
def normal(self):
print "normal"
def insKey(self, znak):
print "insKey"+ znak
def __init__(self, root):
self.fo = StringVar()
root.title("Calculator")
self.font = tkFont.Font(size=10, weight="normal")
self.la = Label(root, text="0", background="#ffffff", anchor=E, relief=SUNKEN, height=2, font=self.font)
self.la.pack(fill=X, side=TOP, padx=8, pady=5)
self.opts = Frame(root, relief=GROOVE)
self.opts.pack()
self.nor = Radiobutton(self.opts, text="big", variable=self.fo, value="big", command=self.big, font=self.font)
self.nor.pack(side=LEFT)
self.nor = Radiobutton(self.opts, text="Normal", variable=self.fo, value="normal", command=self.normal, font=self.font)
self.nor.pack(side=LEFT)
self.numbts = Frame(root)
self.numbts.pack(fill=BOTH, expand=1, padx=4, pady=4)
self.btn_cls = Button(self.numbts, text="Cls",width=5, height=2, font=self.font, command=callback(self.insKey, ""))
self.btn_cls.grid(row=0, column=0, padx=2,sticky=W+N+S+E, pady=2)
self.btn_deleno = Button(self.numbts, text="/",width=5, height=2, font=self.font, command=callback(self.insKey, "/"))
self.btn_deleno.grid(row=0, column=1, padx=2,sticky=W+N+S+E, pady=2)
self.btn_krat = Button(self.numbts, text="*",width=5, height=2, font=self.font, command=callback(self.insKey, "*"))
self.btn_krat.grid(row=0, column=2, padx=2,sticky=W+N+S+E, pady=2)
self.btn_minus = Button(self.numbts, text="-",width=5, height=2, font=self.font, command=callback(self.insKey, "-"))
self.btn_minus.grid(row=0, column=3, padx=2,sticky=W+N+S+E, pady=2)
self.btn7 = Button(self.numbts, text="7",width=5, height=2, font=self.font, command=callback(self.insKey, "7"))
self.btn7.grid(row=1, column=0,sticky=W+N+S+E, padx=2, pady=2)
self.btn8 = Button(self.numbts, text="8",width=5, height=2, font=self.font, command=callback(self.insKey, "8"))
self.btn8.grid(row=1, column=1,sticky=W+N+S+E, padx=2, pady=2)
self.btn9 = Button(self.numbts, text="9",width=5, height=2, font=self.font, command=callback(self.insKey, "9"))
self.btn9.grid(row=1, column=2,sticky=W+N+S+E, padx=2, pady=2)
self.btn4 = Button(self.numbts, text="4",width=5, height=2, font=self.font, command=callback(self.insKey, "4"))
self.btn4.grid(row=2, column=0,sticky=W+N+S+E, padx=2, pady=2)
self.btn5 = Button(self.numbts, text="5",width=5, height=2, font=self.font, command=callback(self.insKey, "5"))
self.btn5.grid(row=2, column=1, padx=2,sticky=W+N+S+E, pady=2)
self.btn6 = Button(self.numbts, text="6",width=5, height=2, font=self.font, command=callback(self.insKey, "6"))
self.btn6.grid(row=2, column=2, padx=2,sticky=W+N+S+E, pady=2)
self.btn1 = Button(self.numbts, text="1",width=5, height=2, font=self.font, command=callback(self.insKey, "1"))
self.btn1.grid(row=3, column=0,sticky=W+N+S+E, padx=2, pady=2)
self.btn2 = Button(self.numbts, text="2",width=5, height=2, font=self.font, command=callback(self.insKey, "2"))
self.btn2.grid(row=3, column=1, padx=2,sticky=W+N+S+E, pady=2)
self.btn3 = Button(self.numbts, text="3",width=5, height=2, font=self.font, command=callback(self.insKey, "3"))
self.btn3.grid(row=3, column=2, padx=2,sticky=W+N+S+E, pady=2)
self.btn0 = Button(self.numbts, text="0",width=5, height=2, font=self.font, command=callback(self.insKey, "0"))
self.btn0.grid(row=4, column=0,sticky=W+N+S+E, columnspan=2, padx=2, pady=2)
self.btn_carka = Button(self.numbts, text=",",width=5, height=2, font=self.font, command=callback(self.insKey, ","))
self.btn_carka.grid(row=4, column=2, padx=2,sticky=W+N+S+E, pady=2)
self.btn_plus = Button(self.numbts, text="+",width=5, height=2, font=self.font, command=callback(self.insKey, "+"))
self.btn_plus.grid(row=1, column=3,rowspan=2, padx=2,sticky=W+N+S+E, pady=2)
self.btn_rovna_se = Button(self.numbts, text="=",width=5, height=2, font=self.font, command=callback(self.insKey, "="))
self.btn_rovna_se.grid(row=3, column=3,rowspan=2, padx=2,sticky=W+N+S+E, pady=2)
self.nor.select()
root = Tk()
app = MyApp(root)
root.mainloop()
root.destroy()