Tying a GUI to a another module

eric_brake brakedon at hotmail.com
Sat Jul 7 12:56:31 EDT 2001


Does anyone know how to link a module containing the gui (first_gui)
and a another one containing the code to run the program
(fibonaccii_gui). Using the "Fib Calc" button to execute the process.
I want the program to take input from the Entry field process it
through "fibonaccii_gui" and then print the fibonaccii sequence in the
Label field. Here's the involved modules, Thank you for any help.

"first_gui" module
import fibonaccii_gui
from Tkinter import *
class fibon_gui:     
     def __init__(self, master):
          frame_entry = Frame(master)
          frame_entry.pack()
          input = Entry(frame_entry, width=30)
          input.pack()
          output = Label(frame_entry, text="Output goes here")
          output.pack(side=TOP)
          
          frame_button = Frame(master)
          frame_button.pack()
          button_fibcalc = Button(frame_button, text="Fib Calc")
          button_fibcalc.pack(side=LEFT)
          button_quit = Button(frame_button, text="QUIT", fg="red",
command=master.quit)
          button_quit.pack(side=RIGHT)
root = Tk()
root.title('Fibonaccii')
fibgui = fibon_gui(root)
root.mainloop()

Here's "fibonaccii_gui" module
class fibonaccii:
    def fib(self):
        a, b = 0, 1
        while b < fibnumber:
            #print b, fibonaccii sequence is saved in variable "b"
            a, b = b, a+b
fibinstance = fibonaccii()



More information about the Python-list mailing list