<div dir="ltr">Salve a tutti,<br>ho un quesito per l'utilizzo delle librerie grafiche Tkinter.<br>Sto provando ad utilizzare Page (Gui Rad basato su Tcl) ed ho notato che creata la maschera grafica, vengono generati due file:<br>1. descrive la maschera grafica (scritto in codice python)<br>2. l'altra di supporto per i comandi (scritto in codice python)<br><br>Proprio su quella di supporto sui comandi non riesco a capire come accedere ai valori inseriti.<br>Ad esempio, ho creato una GUI per fare la somma tra due numeri, il cui codice è qui riportato ("calcola_somma.py"):<br><br>#! /usr/bin/env python<br>#<br># GUI module generated by PAGE version 4.5<br># In conjunction with Tcl version 8.6<br>#    Aug 18, 2015 06:40:34 PM<br>import sys<br><br>try:<br>    from Tkinter import *<br>except ImportError:<br>    from tkinter import *<br><br>try:<br>    import ttk<br>    py3 = 0<br>except ImportError:<br>    import tkinter.ttk as ttk<br>    py3 = 1<br><br>import calcola_somma_support<br><br>def vp_start_gui():<br>    '''Starting point when module is the main routine.'''<br>    global val, w, root<br>    root = Tk()<br>    root.title('Calcola_la_somma')<br>    geom = "436x450+465+113"<br>    root.geometry(geom)<br>    w = Calcola_la_somma(root)<br>    calcola_somma_support.init(root, w)<br>    root.mainloop()<br><br>w = None<br>def create_Calcola_la_somma(root, param=None):<br>    '''Starting point when module is imported by another program.'''<br>    global w, w_win, rt<br>    rt = root<br>    w = Toplevel (root)<br>    w.title('Calcola_la_somma')<br>    geom = "436x450+465+113"<br>    w.geometry(geom)<br>    w_win = Calcola_la_somma (w)<br>    calcola_Q_support.init(w, w_win, param)<br>    return w_win<br><br>def destroy_Calcola_la_somma():<br>    global w<br>    w.destroy()<br>    w = None<br><br><br>class Calcola_la_somma:<br>    def __init__(self, master=None):<br>        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'<br>        _fgcolor = '#000000'  # X11 color: 'black'<br>        _compcolor = '#d9d9d9' # X11 color: 'gray85'<br>        _ana1color = '#d9d9d9' # X11 color: 'gray85' <br>        _ana2color = '#d9d9d9' # X11 color: 'gray85' <br>        master.configure(highlightcolor="black")<br><br><br>        self.Label1 = Label(master)<br>        self.Label1.place(relx=0.23, rely=0.24, height=19, width=20)<br>        self.Label1.configure(activebackground="#f9f9f9")<br>        self.Label1.configure(text='''a''')<br><br>        self.Label2 = Label(master)<br>        self.Label2.place(relx=0.23, rely=0.36, height=19, width=18)<br>        self.Label2.configure(activebackground="#f9f9f9")<br>        self.Label2.configure(text='''b''')<br><br>        self.Label3 = Label(master)<br>        self.Label3.place(relx=0.23, rely=0.47, height=19, width=13)<br>        self.Label3.configure(activebackground="#f9f9f9")<br>        self.Label3.configure(text='''c''')<br><br>        self.a_text = Text(master)<br>        self.a_text.place(relx=0.34, rely=0.24, relheight=0.06, relwidth=0.38)<br>        self.a_text.configure(background="white")<br>        self.a_text.configure(font="TkTextFont")<br>        self.a_text.configure(selectbackground="#c4c4c4")<br>        self.a_text.configure(width=166)<br>        self.a_text.configure(wrap=WORD)<br><br>        self.b_text = Text(master)<br>        self.b_text.place(relx=0.34, rely=0.36, relheight=0.06, relwidth=0.38)<br>        self.b_text.configure(background="white")<br>        self.b_text.configure(font="TkTextFont")<br>        self.b_text.configure(selectbackground="#c4c4c4")<br>        self.b_text.configure(width=166)<br>        self.b_text.configure(wrap=WORD)<br><br>        self.c_text = Text(master)<br>        self.c_text.place(relx=0.34, rely=0.47, relheight=0.06, relwidth=0.38)<br>        self.c_text.configure(background="white")<br>        self.c_text.configure(font="TkTextFont")<br>        self.c_text.configure(selectbackground="#c4c4c4")<br>        self.c_text.configure(width=166)<br>        self.c_text.configure(wrap=WORD)<br><br>        self.Label4 = Label(master)<br>        self.Label4.place(relx=0.76, rely=0.24, height=19, width=54)<br>        self.Label4.configure(activebackground="#f9f9f9")<br>        self.Label4.configure(text='''-''')<br><br>        self.Label5 = Label(master)<br>        self.Label5.place(relx=0.76, rely=0.36, height=19, width=35)<br>        self.Label5.configure(activebackground="#f9f9f9")<br>        self.Label5.configure(text='''-''')<br><br>        self.Label6 = Label(master)<br>        self.Label6.place(relx=0.76, rely=0.47, height=19, width=19)<br>        self.Label6.configure(activebackground="#f9f9f9")<br>        self.Label6.configure(text='''-''')<br><br>        self.bCalcola = Button(master)<br>        self.bCalcola.place(relx=0.5, rely=0.71, height=27, width=68)<br>        self.bCalcola.configure(activebackground="#d9d9d9")<br>        self.bCalcola.configure(command=calcola_somma_support.calcola)<br>        self.bCalcola.configure(text='''Calcola''')<br><br>        self.bCancella = Button(master)<br>        self.bCancella.place(relx=0.25, rely=0.71, height=27, width=76)<br>        self.bCancella.configure(activebackground="#d9d9d9")<br>        self.bCancella.configure(command=calcola_somma_support.cancella)<br>        self.bCancella.configure(text='''Cancella''')<br><br>        self.bUscita = Button(master)<br>        self.bUscita.place(relx=0.73, rely=0.71, height=27, width=63)<br>        self.bUscita.configure(activebackground="#d9d9d9")<br>        self.bUscita.configure(command=calcola_somma_support.uscita)<br>        self.bUscita.configure(text='''Uscita''')<br><br>        self.Label7 = Label(master)<br>        self.Label7.place(relx=0.18, rely=0.09, height=19, width=299)<br>        self.Label7.configure(activebackground="#f9f9f9")<br>        self.Label7.configure(text='''Calcola la somma tra due numeri''')<br><br><br>    def calcola(self):<br>        DP=float(self.a_text.get("1.0",END))<br>        kv=float(self.b_text.get("1.0",END))<br>        tot=DP+kv<br>        self.c_text.insert(1.0, tot)<br><br><br><br>if __name__ == '__main__':<br>    vp_start_gui()<br><br><br><br><br>Page poi crea un altro file di supporto dove sono elencate le procedure relative ai vari comandi (ovvero nel caso in cui vengano premuti i vari pulsanti che ho messo):<br><br><br>#! /usr/bin/env python<br>#<br># Support module generated by PAGE version 4.5<br># In conjunction with Tcl version 8.6<br>#    Aug 18, 2015 06:41:00 PM<br><br><br>import sys<br><br>try:<br>    from Tkinter import *<br>except ImportError:<br>    from tkinter import *<br><br>try:<br>    import ttk<br>    py3 = 0<br>except ImportError:<br>    import tkinter.ttk as ttk<br>    py3 = 1<br><br><br>def calcola():<br>    print('calcola_somma_support.calcola')   <br>    sys.stdout.flush()<br><br>def cancella():<br>    print('calcola_somma_support.cancella')<br>    sys.stdout.flush()<br><br>def uscita():<br>    print('calcola_somma_support.uscita')<br>    sys.stdout.flush()<br><br>def init(top, gui, arg=None):<br>    global w, top_level, root<br>    w = gui<br>    top_level = top<br>    root = top<br><br>def destroy_window():<br>    # Function which closes the window.<br>    global top_level<br>    top_level.destroy()<br>    top_level = None<br><br><br><br><br>La mia domanda è: come collego al pulsante "Calcola" la procedura "calcola" contenuta nel file "calcola_somma_support.py" ?<br>Qualcuno può aiutarmi a completare il codice per renderlo funzionante ?<br></div>