salve a tutti da pochissimi giorni ho iniziato l'approccio con python per la cronaca mi sono gia letto la guida di introduzione con non molte difficoltà provengo da un approccio con il gwbasic del vecchio dos 5.2 e di gambas (visual basic per unix)
mi sono cimentato in 2 programmini molto semplici ma ho delle lacune enormi e tanti problemi 1) non conosco la lingua inglese e molti manuali non esistono in italiano 2) l'help di python è in inglese 3)nelle introduzioni che ho letto non si parla mai di interfacce grafiche sbirciando qua e la tra i codici sono riuscito a fare il programmino allegato se qualcuno ha un pò di tempo e voglia potrebbe spiegarmi come posso fare a creare un menu in una finestra e a metterci un immagine P.S io conosco la lib tkinter ma da tutte le parti trovo scritto che non esiste una traduzione è vero? in questa libreria ci sono tutti gli oggetti che sono abituato ad usare con gambas grazie di tutto (mi avevano detto che il basic non era un gran che maq questo è un casino!!) from Tkinter import * import random class valore: """definizione di variabili""" risultato= 0 vtext='' idbt='' tabellina=1 moltiplicatore=0 indice=[1,0,0,0,0,0,0,0,0,0,0] conttab=0 def numero(): """assegnazione random del numero""" cont='s' a=0 while cont == 's': a=random.randrange(11) if valore.conttab == 10 : cont = 'n' if valore.indice[a] == 0 : valore.moltiplicatore=a valore.indice[a] = 1 cont = 'n' valore.conttab =valore.conttab +1 return 1 def reset(): valore.conttab=0 valore.indice[1]=0 valore.indice[2]=0 valore.indice[3]=0 valore.indice[4]=0 valore.indice[5]=0 valore.indice[6]=0 valore.indice[7]=0 valore.indice[8]=0 valore.indice[9]=0 valore.indice[10]=0 class tester(): """definizione della form""" def __init__(self): self.__root = tk = Tk() self.__root.title('mia') self.__root.maxsize(1000,400) self.__root.minsize (800, 300) label2 = Label(tk,bg='white',fg='red',text='tabellina del ') label2.place(x=150,y=10,height=20,width=100) self.btabellina = Button(tk, text='1', command=self.__clikbuttontabellina) self.btabellina.place(x=250,y=0,height=40,width=40) label3 = Label(tk,bg='white',fg='red',text='clik per sel la tabellina') label3.place(x=300,y=10,height=20,width=100) self.label1 = Label(tk,relief=SUNKEN,bg='white',fg='red',text='scegli la tabellina') self.label1.place(x=10,y=10,height=20,width=130) b1 = Button(tk, text='1', command=self.__clikbutton1) b1.place(x=10,y=40,height=40,width=40) b2 = Button(tk, text='2', command=self.__clikbutton2) b2.place(x=50,y=40,height=40,width=40) b3 = Button(tk, text='3', command=self.__clikbutton3) b3.place(x=90,y=40,height=40,width=40) b4 = Button(tk, text='4', command=self.__clikbutton4) b4.place(x=10,y=80,height=40,width=40) b5 = Button(tk, text='5', command=self.__clikbutton5) b5.place(x=50,y=80,height=40,width=40) b6 = Button(tk, text='6', command=self.__clikbutton6) b6.place(x=90,y=80,height=40,width=40) b7 = Button(tk, text='7', command=self.__clikbutton7) b7.place(x=10,y=120,height=40,width=40) b8 = Button(tk, text='8', command=self.__clikbutton8) b8.place(x=50,y=120,height=40,width=40) b9 = Button(tk, text='9', command=self.__clikbutton9) b9.place(x=90,y=120,height=40,width=40) b0 = Button(tk, text='0', command=self.__clikbutton0) b0.place(x=10,y=160,height=40,width=40) bcls = Button(tk, text='c', command=self.__clikbuttoncls) bcls.place(x=50,y=160,height=40,width=40) bok = Button(tk, text='ok', command=self.__clikbuttonok) bok.place(x=90,y=160,height=40,width=40) self.lt1 = Label(tk,bg='white',fg='red',text='1x1') self.lt1.place(x=210,y=90,height=20,width=40) self.bt1 = Button(tk, text='', command=self.__clikbutton1) self.bt1.place(x=210,y=110,height=40,width=40) self.lt2 = Label(tk,bg='white',fg='red',text='1x2') self.lt2.place(x=250,y=90,height=20,width=40) self.bt2 = Button(tk, text='', command=self.__clikbutton1) self.bt2.place(x=250,y=110,height=40,width=40) self.lt3 = Label(tk,bg='white',fg='red',text='1x3') self.lt3.place(x=290,y=90,height=20,width=40) self.bt3 = Button(tk, text='', command=self.__clikbutton1) self.bt3.place(x=290,y=110,height=40,width=40) self.lt4 = Label(tk,bg='white',fg='red',text='1x4') self.lt4.place(x=330,y=90,height=20,width=40) self.bt4 = Button(tk, text='', command=self.__clikbutton1) self.bt4.place(x=330,y=110,height=40,width=40) self.lt5 = Label(tk,bg='white',fg='red',text='1x5') self.lt5.place(x=370,y=90,height=20,width=40) self.bt5 = Button(tk, text='', command=self.__clikbutton1) self.bt5.place(x=370,y=110,height=40,width=40) self.lt6 = Label(tk,bg='white',fg='red',text='1x6') self.lt6.place(x=410,y=90,height=20,width=40) self.bt6 = Button(tk, text='', command=self.__clikbutton1) self.bt6.place(x=410,y=110,height=40,width=40) self.lt7 = Label(tk,bg='white',fg='red',text='1x7') self.lt7.place(x=450,y=90,height=20,width=40) self.bt7 = Button(tk, text='', command=self.__clikbutton1) self.bt7.place(x=450,y=110,height=40,width=40) self.lt8 = Label(tk,bg='white',fg='red',text='1x8') self.lt8.place(x=490,y=90,height=20,width=40) self.bt8 = Button(tk, text='', command=self.__clikbutton1) self.bt8.place(x=490,y=110,height=40,width=40) self.lt9 = Label(tk,bg='white',fg='red',text='1x9') self.lt9.place(x=530,y=90,height=20,width=40) self.bt9 = Button(tk, text='', command=self.__clikbutton1) self.bt9.place(x=530,y=110,height=40,width=40) self.lt10 = Label(tk,bg='white',fg='red',text='1x10') self.lt10.place(x=570,y=90,height=20,width=40) self.bt10 = Button(tk, text='', command=self.__clikbutton1) self.bt10.place(x=570,y=110,height=40,width=40) self.lt11 = Label(tk,bg='white',fg='red',text='1x10') self.lt11.place(x=210,y=160,height=40,width=80) def __clikbutton1(self, event=None): text = valore.vtext+'1' valore.vtext = text self.label1.configure(text=text,fg='blue') def __clikbutton2(self, event=None): text = valore.vtext+'2' valore.vtext = text self.label1.configure(text=text,fg='blue') def __clikbutton3(self, event=None): text = valore.vtext+'3' valore.vtext = text self.label1.configure(text=text,fg='blue') def __clikbutton4(self, event=None): text = valore.vtext+'4' valore.vtext = text self.label1.configure(text=text,fg='blue') def __clikbutton5(self, event=None): text = valore.vtext+'5' valore.vtext = text self.label1.configure(text=text,fg='blue') def __clikbutton6(self, event=None): text = valore.vtext+'6' valore.vtext = text self.label1.configure(text=text,fg='blue') def __clikbutton7(self, event=None): text = valore.vtext+'7' valore.vtext = text self.label1.configure(text=text,fg='blue') def __clikbutton8(self, event=None): text = valore.vtext+'8' valore.vtext = text self.label1.configure(text=text,fg='blue') def __clikbutton9(self, event=None): text = valore.vtext+'9' valore.vtext = text self.label1.configure(text=text,fg='blue') def __clikbutton0(self, event=None): text = valore.vtext+'0' valore.vtext = text self.label1.configure(text=text,fg='blue') def __clikbuttoncls(self, event=None): text = '' valore.vtext = text self.label1.configure(text=text,fg='blue') def __clikbuttontabellina(self, event=None): reset() valore.tabellina=valore.tabellina+1 if valore.tabellina==10 : valore.tabellina=1 self.lt1.configure(text=str(valore.tabellina)+'x1') self.lt2.configure(text=str(valore.tabellina)+'x2') self.lt3.configure(text=str(valore.tabellina)+'x3') self.lt4.configure(text=str(valore.tabellina)+'x4') self.lt5.configure(text=str(valore.tabellina)+'x5') self.lt6.configure(text=str(valore.tabellina)+'x6') self.lt7.configure(text=str(valore.tabellina)+'x7') self.lt8.configure(text=str(valore.tabellina)+'x8') self.lt9.configure(text=str(valore.tabellina)+'x9') self.lt10.configure(text=str(valore.tabellina)+'x10') self.bt1.configure(text='') self.bt2.configure(text='') self.bt3.configure(text='') self.bt4.configure(text='') self.bt5.configure(text='') self.bt6.configure(text='') self.btabellina.configure(text=str(valore.tabellina)) numero() self.lt11.configure(text=str(valore.tabellina)+'x'+ str(valore.moltiplicatore)) def __clikbuttonok(self, event=None) : valore.risultato=valore.moltiplicatore*valore.tabellina if valore.vtext == str(valore.risultato): if valore.moltiplicatore == 1: self.bt1.configure(text=str(valore.risultato)) elif valore.moltiplicatore == 2: self.bt2.configure(text=str(valore.risultato)) elif valore.moltiplicatore == 3: self.bt3.configure(text=str(valore.risultato)) elif valore.moltiplicatore == 4: self.bt4.configure(text=str(valore.risultato)) elif valore.moltiplicatore == 5: self.bt5.configure(text=str(valore.risultato)) elif valore.moltiplicatore == 6: self.bt6.configure(text=str(valore.risultato)) elif valore.moltiplicatore == 7: self.bt7.configure(text=str(valore.risultato)) elif valore.moltiplicatore == 8: self.bt8.configure(text=str(valore.risultato)) elif valore.moltiplicatore == 9: self.bt9.configure(text=str(valore.risultato)) elif valore.moltiplicatore == 10: self.bt10.configure(text=str(valore.risultato)) numero() text='' valore.vtext=text self.label1.configure(text=text,fg='blue') self.lt11.configure(text=str(valore.tabellina)+'x'+str(valore.moltiplicatore)) elif valore.vtext <> str(valore.risultato): valore.vtext='' self.label1.configure(text='errore',fg='blue') def run(self): self.__root.mainloop() t = tester() t.run()
pu.py
Description: application/python
_______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python