本文整理汇总了Python中MainWindow.MainWindow.init方法的典型用法代码示例。如果您正苦于以下问题:Python MainWindow.init方法的具体用法?Python MainWindow.init怎么用?Python MainWindow.init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MainWindow.MainWindow
的用法示例。
在下文中一共展示了MainWindow.init方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GuiController
# 需要导入模块: from MainWindow import MainWindow [as 别名]
# 或者: from MainWindow.MainWindow import init [as 别名]
class GuiController(object):
def __init__(self,controller):
self.__mainWindow = None
self.__encodingWindow = None
self.__decryptWindow = None
self.__root = None
# Points to the currently displayed frame
self.__currentFrame = None
# The process model
self.__processModel = None
#The application controller
self.__controller = controller
def init(self,model):
""" Creates the Tk root, and initializes the view with the MainWindow frame"""
#Create the model
self.__processModel = model
#Initializes GUI
self.__root = Tkinter.Tk()
self.__root.wm_geometry("500x300")
self.__root.columnconfigure(0,weight=1)
self.__root.rowconfigure(0,weight=1)
self.__root.title("ENCRYPTION/DECRYPTION TOOL")
self.__changeFrame(self.__getMainWindow().frame)
#Link model with listeners
self.__processModel.addListener(self.__getEncodingWindow())
self.__processModel.addListener(self.__getDecryptWindow())
self.__root.mainloop()
"""SERIES OF COMMANDS CALLABLE FROM THE DIFFERENT GUI PARTS"""
def goToEncodeWindow(self):
print "GO TO ENCODE WINDOW"
self.__changeFrame(self.__getEncodingWindow().frame)
def goToDecodeWindow(self):
print "GO TO DECODE WINDOW"
self.__changeFrame(self.__getDecryptWindow().frame)
def goToMainWindow(self):
print "GO TO MAIN WINDOW"
self.__changeFrame(self.__getMainWindow().frame)
self.__processModel.reset()
def setSource(self,text):
self.__controller.setSource(text)
def setDestination(self,text):
self.__controller.setDestination(text)
def encrypt(self,password):
self.__controller.encrypt(password)
def decrypt(self,password):
self.__controller.decrypt(password)
""" A bunch of methods for lazy initialization"""
def __getMainWindow(self):
"""Returns the main windows controlled by this controller.
Implements lazy initialization"""
if self.__mainWindow is None:
self.__mainWindow = MainWindow(self.__root,self)
self.__mainWindow.init()
return self.__mainWindow
def __getEncodingWindow(self):
"""Returns the main windows controlled by this controller.
Implements lazy initialization"""
if self.__encodingWindow is None:
self.__encodingWindow = EncodingWindow(self.__root,self)
self.__encodingWindow.init()
return self.__encodingWindow
def __getDecryptWindow(self):
"""Returns the main windows controlled by this controller.
Implements lazy initialization"""
if self.__decryptWindow is None:
self.__decryptWindow = DecryptWindow.DescryptWindow(self.__root,self)
self.__decryptWindow.init()
return self.__decryptWindow
def __changeFrame(self,newFrame):
if not self.__currentFrame is None:
self.__currentFrame.grid_remove()
newFrame.grid(column = 0, row = 0, sticky=Tkinter.NSEW);
self.__currentFrame = newFrame