Desisti do Tk pois achei mais graça ao glade que trabalha com GTK (assim ja vou aprendendo para quando começar a fazer screenlets) ja fiz a maior parte mas ainda tenho um problema, não sei como fazer o equivalente ao print mas graficamente, ele faz tudo graficamente menos apresentar resultado que só dá na consola.
aqui fica o código( nao sei se ajuda muito sem o ficheiro .glade):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Generated with glade2py script
# glade2py script can be found at hocr web site http://hocr.berlios.de
import pygtk
pygtk.require('2.0')
import gtk, gtk.glade
class MainWindow:
def __init__(self):
# create widget tree ...
xml = gtk.glade.XML('gui2.glade')
# connect handlers
xml.signal_autoconnect(self)
# widgets
self.dialog1 = xml.get_widget('dialog1')
self.dialog_vbox1 = xml.get_widget('dialog_vbox1')
self.menubar1 = xml.get_widget('menubar1')
self.menuitem1 = xml.get_widget('menuitem1')
self.menu1 = xml.get_widget('menu1')
self.imagemenuitem5 = xml.get_widget('imagemenuitem5')
self.scrolledwindow1 = xml.get_widget('scrolledwindow1')
self.table1 = xml.get_widget('table1')
self.entry3 = xml.get_widget('entry3')
self.entry2 = xml.get_widget('entry2')
self.entry1 = xml.get_widget('entry1')
self.A = xml.get_widget('A')
self.B = xml.get_widget('B')
self.C = xml.get_widget('C')
self.dialog_action_area1 = xml.get_widget('dialog_action_area1')
self.calcula = xml.get_widget('calcula')
self.Sair = xml.get_widget('Sair')
# signal handlers
def menubar1_activate_current_cb(self, obj, event = None):
"menubar1_activate_current_cb activated"
print 'menubar1_activate_current_cb activated'
def on_imagemenuitem5_destroy(self, obj, event = None):
"on_imagemenuitem5_destroy activated"
print 'on_imagemenuitem5_destroy activated'
def gtk_widget_destroy(self, obj, event = None):
"gtk_widget_destroy activated"
gtk.main_quit()
def on_entry3_activate(self, obj, event = None):
c = float(self.entry3.get_text())
print c
def on_entry2_activate(self, obj, event = None):
b = float(self.entry2.get_text())
print b
def on_entry1_activate(self, obj, event = None):
a = float(self.entry1.get_text())
print a
def on_calcula_clicked(self, obj, event = None):
c = float(self.entry3.get_text())
b = float(self.entry2.get_text())
a = float(self.entry1.get_text())
d=b**2-4*a*c
if d < 0:
print 'Impossível'
else:
x1=(-b+d**0.5)/(2*a)
x2=(-b-d**0.5)/(2*a)
print 'Discriminante', d
print "X1=", x1
print 'X2=', x2
def button1_clicked_cb(self, obj, event = None):
"button1_clicked_cb activated"
gtk.main_quit()
def on_Sair_destroy(self, obj, event = None):
"on_Sair_destroy activated"
print 'on_Sair_destroy activated'
# run main loop
def main():
main_window = MainWindow()
main_window.dialog1.show()
gtk.main()
if __name__ == "__main__":
main()