No jako jo, ale ja myslel n?co v tom smyslu, ?e bych donutil Entry, aby zapisovalo zprava, ch?p??? Zat?m jsem vymyslel toto:
# -*- coding: utf-8 -*-.
#autor: vojtech
#zacatek vyvoje: 23. 9. 2006
#final release:
#import:
from Tkinter import*
#definicni cast:
#definice zapisovani cislic:
def jednicka_fce():
jedna=1
stavovy_radek.insert(0, jedna)
def dvojka_fce():
dva=2
stavovy_radek.insert(0, dva)
def trojka_fce():
tri=3
stavovy_radek.insert(0,tri)
def ctyrka_fce():
ctyri=4
stavovy_radek.insert(0,ctyri)
def petka_fce():
pet=5
stavovy_radek.insert(0,pet)
def sestka_fce():
sest=6
stavovy_radek.insert(0,sest)
def sedmicka_fce():
sedm=7
stavovy_radek.insert(0,sedm)
def osmicka_fce():
osm=8
stavovy_radek.insert(0,osm)
def devitka_fce():
devet=9
stavovy_radek.insert(0,devet)
def nula_fce():
zero=0
stavovy_radek.insert(0,zero)
#definice pocetnich vykonu:
def vymazat_fce():
stavovy_radek.delete(0,"end")
#telo programu (viditelna cast):
hlavni_okno=Tk()
hlavni_okno.title("Kalkula?ka")
#stavovy radek:
stavovy_radek=Entry(hlavni_okno, width=30)
stavovy_radek.pack(padx=4, pady=4)
#ramecky:
ramecek1=Frame(hlavni_okno)
ramecek1.pack()
ramecek2=Frame(hlavni_okno)
ramecek2.pack()
ramecek3=Frame(hlavni_okno)
ramecek3.pack()
ramecek4=Frame(hlavni_okno)
ramecek4.pack()
#prvni radek buttonu
sedmicka=Button(ramecek1, text='7', width=5, command=sedmicka_fce)
sedmicka.pack(side=LEFT, padx=4, pady=4)
osmicka=Button(ramecek1, text='8', width=5, command=osmicka_fce)
osmicka.pack(side=LEFT, padx=4, pady=4)
devitka=Button(ramecek1, text='9', width=5, command=devitka_fce)
devitka.pack(side=LEFT, padx=4, pady=4)
vymazat=Button(ramecek1, text='Vymazat', width=9, command=vymazat_fce)
vymazat.pack(side=LEFT, padx=4, pady=4)
#druhy radek buttonu
ctyrka=Button(ramecek2, text='4', width=5, command=ctyrka_fce)
ctyrka.pack(side=LEFT, padx=4, pady=4)
petka=Button(ramecek2, text='5', width=5, command=petka_fce)
petka.pack(side=LEFT, padx=4, pady=4)
sestka=Button(ramecek2, text='6', width=5, command=sestka_fce)
sestka.pack(side=LEFT, padx=4, pady=4)
deleno=Button(ramecek2, text='/', width=3)
deleno.pack(side=LEFT, padx=4, pady=4)
krat=Button(ramecek2, text='*', width=3)
krat.pack(side=LEFT, padx=4, pady=4)
#treti radek buttonu
jednicka=Button(ramecek3, text='1', width=5, command=jednicka_fce)
jednicka.pack(side=LEFT, padx=4, pady=4)
dvojka=Button(ramecek3, text='2', width=5, command=dvojka_fce)
dvojka.pack(side=LEFT, padx=4, pady=4)
trojka=Button(ramecek3, text='3', width=5, command=trojka_fce)
trojka.pack(side=LEFT, padx=4, pady=4)
minus=Button(ramecek3, text='-', width=3)
minus.pack(side=LEFT, padx=4, pady=4)
plus=Button(ramecek3, text='+', width=3)
plus.pack(side=LEFT, padx=4, pady=4)
#ctvrty radek buttonu
nula=Button(ramecek4, text='0', width=5)
nula.pack(side=LEFT, padx=4, pady=4)
rovna_se=Button(ramecek4, text='=', width=5)
rovna_se.pack(side=LEFT, padx=4, pady=4)
#mainloop
hlavni_okno.mainloop()
prost? donutit Entry zapisovat zprava :-)