By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,665 Members | 1,761 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,665 IT Pros & Developers. It's quick & easy.

newbie doubt about MVC,tkinter

P: n/a
hi
i am trying to write a controller that creates a Tkinter gui,takes
userevents from gui and calls another program to do some calculation
and finally returns the results to gui to be displayed.

I tried to separate these three like MVC pattern
however ,being a newbie i have some doubts

sample gui class

class MyGUI:
def __init__(self, parent):
self.controller=MyController()
self.myParent = parent
self.mainframe = Frame(parent,background="grey")
self.mainframe.pack(fill=BOTH,expand=YES)
...

def button1Click(self):
controller.callback(uservalue)

def showResult(resultvalue):
//display on canvas
class MyController:
def createGUI(self):
root = Tk()
root.wm_title("MyGUI")
self.myapp = MyGUI(root)
root.mainloop()

def callback(value):
self.userenteredvalue=value
def callGUI(self,resultvalue):
self.myapp.showResult(resultvalue)

if __name__ == "__main__":
controller=MyController()
controller.createGUI()
resultTodisplay=self.userenteredvalue+1000 # or may be call some
program to do the calc
controller.callGUI(resultTodisplay)

Here,root.mainloop() causes the application to go into Tk event loop
and the controller will not be able to interact with the gui until i
close the window.

I was wondering if i can keep the gui window open and at the same time
call the gui objects methods from my controller.If anyone can help/
advise please do
thanks
gordon
Aug 27 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.