[Python] problema su TKinter

2015-08-18 Per discussione Riccardo mancuso
Salve a tutti,
ho un quesito per l'utilizzo delle librerie grafiche Tkinter.
Sto provando ad utilizzare Page (Gui Rad basato su Tcl) ed ho notato che
creata la maschera grafica, vengono generati due file:
1. descrive la maschera grafica (scritto in codice python)
2. l'altra di supporto per i comandi (scritto in codice python)

Proprio su quella di supporto sui comandi non riesco a capire come accedere
ai valori inseriti.
Ad esempio, ho creato una GUI per fare la somma tra due numeri, il cui
codice è qui riportato ("calcola_somma.py"):

#! /usr/bin/env python
#
# GUI module generated by PAGE version 4.5
# In conjunction with Tcl version 8.6
#Aug 18, 2015 06:40:34 PM
import sys

try:
from Tkinter import *
except ImportError:
from tkinter import *

try:
import ttk
py3 = 0
except ImportError:
import tkinter.ttk as ttk
py3 = 1

import calcola_somma_support

def vp_start_gui():
'''Starting point when module is the main routine.'''
global val, w, root
root = Tk()
root.title('Calcola_la_somma')
geom = "436x450+465+113"
root.geometry(geom)
w = Calcola_la_somma(root)
calcola_somma_support.init(root, w)
root.mainloop()

w = None
def create_Calcola_la_somma(root, param=None):
'''Starting point when module is imported by another program.'''
global w, w_win, rt
rt = root
w = Toplevel (root)
w.title('Calcola_la_somma')
geom = "436x450+465+113"
w.geometry(geom)
w_win = Calcola_la_somma (w)
calcola_Q_support.init(w, w_win, param)
return w_win

def destroy_Calcola_la_somma():
global w
w.destroy()
w = None


class Calcola_la_somma:
def __init__(self, master=None):
_bgcolor = '#d9d9d9'  # X11 color: 'gray85'
_fgcolor = '#00'  # X11 color: 'black'
_compcolor = '#d9d9d9' # X11 color: 'gray85'
_ana1color = '#d9d9d9' # X11 color: 'gray85'
_ana2color = '#d9d9d9' # X11 color: 'gray85'
master.configure(highlightcolor="black")


self.Label1 = Label(master)
self.Label1.place(relx=0.23, rely=0.24, height=19, width=20)
self.Label1.configure(activebackground="#f9f9f9")
self.Label1.configure(text='''a''')

self.Label2 = Label(master)
self.Label2.place(relx=0.23, rely=0.36, height=19, width=18)
self.Label2.configure(activebackground="#f9f9f9")
self.Label2.configure(text='''b''')

self.Label3 = Label(master)
self.Label3.place(relx=0.23, rely=0.47, height=19, width=13)
self.Label3.configure(activebackground="#f9f9f9")
self.Label3.configure(text='''c''')

self.a_text = Text(master)
self.a_text.place(relx=0.34, rely=0.24, relheight=0.06,
relwidth=0.38)
self.a_text.configure(background="white")
self.a_text.configure(font="TkTextFont")
self.a_text.configure(selectbackground="#c4c4c4")
self.a_text.configure(width=166)
self.a_text.configure(wrap=WORD)

self.b_text = Text(master)
self.b_text.place(relx=0.34, rely=0.36, relheight=0.06,
relwidth=0.38)
self.b_text.configure(background="white")
self.b_text.configure(font="TkTextFont")
self.b_text.configure(selectbackground="#c4c4c4")
self.b_text.configure(width=166)
self.b_text.configure(wrap=WORD)

self.c_text = Text(master)
self.c_text.place(relx=0.34, rely=0.47, relheight=0.06,
relwidth=0.38)
self.c_text.configure(background="white")
self.c_text.configure(font="TkTextFont")
self.c_text.configure(selectbackground="#c4c4c4")
self.c_text.configure(width=166)
self.c_text.configure(wrap=WORD)

self.Label4 = Label(master)
self.Label4.place(relx=0.76, rely=0.24, height=19, width=54)
self.Label4.configure(activebackground="#f9f9f9")
self.Label4.configure(text='''-''')

self.Label5 = Label(master)
self.Label5.place(relx=0.76, rely=0.36, height=19, width=35)
self.Label5.configure(activebackground="#f9f9f9")
self.Label5.configure(text='''-''')

self.Label6 = Label(master)
self.Label6.place(relx=0.76, rely=0.47, height=19, width=19)
self.Label6.configure(activebackground="#f9f9f9")
self.Label6.configure(text='''-''')

self.bCalcola = Button(master)
self.bCalcola.place(relx=0.5, rely=0.71, height=27, width=68)
self.bCalcola.configure(activebackground="#d9d9d9")
self.bCalcola.configure(command=calcola_somma_support.calcola)
self.bCalcola.configure(text='''Calcola''')

self.bCancella = Button(master)
self.bCancella.place(relx=0.25, rely=0.71, height=27, width=76)
self.bCancella.configure(activebackground="#d9d9d9")
self.bCancella.configure(command=calcola_somma_support.cancella)
self.bCancella.configure(text='''Cancella''')

self.bUscita = Button(master)
self.bUscita.place(relx=0.73, rely=0.71, hei

Re: [Python] problema su TKinter

2015-08-18 Per discussione Massimiliano Pippi
Ciao Riccardo,

se metti di nuovo questo muro di codice in un solo messaggio lo marco
come letto senza passare dal Via.
O lo riduci all'essenziale o (meglio) usi un servizio esterno tipo
pastebin, ce ne sono un tot nell'Internet.

Detto ciò,

2015-08-18 20:08 GMT+02:00 Riccardo mancuso :
>
> Proprio su quella di supporto sui comandi non riesco a capire come accedere
> ai valori inseriti.
>
> def calcola():
> print('calcola_somma_support.calcola')
> sys.stdout.flush()
>
non conosco il tool, ma a guardare come viene istanziata la classe
Calcola_la_somma ti serve una cosa così:

def calcola():
global w
print(w.a_text.get(1.0, END) + w.b_text.get(1.0, END))


Ciao

-- 
M.

@maxpippi :: http://dev.pippi.im/
___
Python mailing list
Python@lists.python.it
http://lists.python.it/mailman/listinfo/python