Пример #1
0
class GUI(Tk):
    "represents GUI"
    def __init__(self):
        super().__init__()
   
        self.title("CM Manager " + ".".join(version()))
        self.option_add("*tearOff", FALSE)
        self.resizable(FALSE, FALSE)
        
        '''
        # used when size of the window is changed for placeWindow arguments     
        self.after(250, lambda: print(self.winfo_width()))
        self.after(250, lambda: print(self.winfo_height()))
        '''
        placeWindow(self, 1010, 834)

        # notebook
        self.selectFunction = ttk.Notebook(self)
        self.selectFunction.grid()

        # FileStorage is associated with the Notebook
        self.selectFunction.fileStorage = FileStorage()
        
        self.processor = Processor(self.selectFunction)
        self.explorer = Explorer(self.selectFunction)
        self.controller = Controller(self.selectFunction)

        notepageWidth = 20
        self.selectFunction.add(self.processor, text = "{:^{}}".format("Process", notepageWidth))
        self.selectFunction.add(self.explorer, text = "{:^{}}".format("Explore", notepageWidth))
        self.selectFunction.add(self.controller, text = "{:^{}}".format("Control", notepageWidth))

        self.selectFunction.bind("<<NotebookTabChanged>>", lambda e: self.checkProcessing(e))
            
        # menu
        self["menu"] = MenuCM(self)

        if not optionGet("Developer", False, 'bool'):
            self.protocol("WM_DELETE_WINDOW", self.closeFun)

        self.mainloop()


    def closeFun(self):
        "ask for saving files on exit"
        if doesFileStorageRequiresSave(self):
            answ = messagebox.askyesno(message = "Do you want to save files before leaving?",
                                       icon = "question", title = "Save files?")
            if answ:
                saveFileStorage(self)                
        self.destroy()


    def checkProcessing(self, event):
        """checks whether it is possible for processor and controller to process files and change
        states of buttons accordingly"""
        self.processor.checkProcessing()
        self.controller.checkProcessing()
        self.explorer.checkProcessing()
Пример #2
0
class GUI(Tk):
    "represents GUI"

    def __init__(self):
        super().__init__()

        self.title("CM Manager " + ".".join(version()))
        self.option_add("*tearOff", FALSE)
        self.resizable(FALSE, FALSE)
        '''
        used when size of the window is changed for placeWindow arguments     
        self.after(50, lambda: print(self.winfo_width()))
        self.after(50, lambda: print(self.winfo_height()))
        '''
        placeWindow(self, 1010, 786)

        # notebook
        self.selectFunction = ttk.Notebook(self)
        self.selectFunction.grid()

        # FileStorage is associated with the Notebook
        self.selectFunction.fileStorage = FileStorage()

        self.processor = Processor(self.selectFunction)
        self.explorer = Explorer(self.selectFunction)
        self.controller = Controller(self.selectFunction)

        notepageWidth = 20
        self.selectFunction.add(self.processor,
                                text="{:^{}}".format("Process", notepageWidth))
        self.selectFunction.add(self.explorer,
                                text="{:^{}}".format("Explore", notepageWidth))
        self.selectFunction.add(self.controller,
                                text="{:^{}}".format("Control", notepageWidth))

        self.selectFunction.bind("<<NotebookTabChanged>>",
                                 lambda e: self.checkProcessing(e))

        # menu
        self["menu"] = MenuCM(self)

        # checks for new messages and versions on the web
        if optionGet("CheckMessages", True, "bool"):
            self.onStart()

        self.mainloop()

    def onStart(self):
        "checks web for new version and post"
        try:
            self.checkNewVersion()
        except Exception:
            pass

        try:
            self.checkNewPost()
        except Exception:
            pass

    def checkNewVersion(self):
        "checks whether there is a new version available"
        newVersion = self.returnSiteContent("http://www.cmmanagerweb.appspot.com/version").\
                     split(".")
        versionSeen = optionGet("DontShowVersion", version(), "list")
        for i in range(3):
            if int(newVersion[i]) > int(versionSeen[i]):
                DialogBox(
                    self,
                    title="New version available",
                    message=self.returnSiteContent(
                        "http://www.cmmanagerweb.appspot.com/version/message"),
                    dontShowOption="DontShowVersion",
                    optionValue=newVersion)
                break

    def checkNewPost(self):
        "checks whether there is some post with new information on the web"
        currentPost = optionGet("WebPostNumber", 0, "int")
        webPostNumber = int(
            self.returnSiteContent("http://www.cmmanagerweb.appspot.com/post"))
        if webPostNumber > currentPost:
            DialogBox(
                self, "New information",
                self.returnSiteContent(
                    "http://www.cmmanagerweb.appspot.com/post/message"))
            optionWrite("WebPostNumber", webPostNumber)

    def returnSiteContent(self, link):
        "return text obtained from web site"
        site = urlopen(link)
        text = site.read()
        site.close()
        text = str(text)[2:-1]
        return text

    def checkProcessing(self, event):
        """checks whether it is possible for processor and controller to process files and change
        states of buttons accordingly"""
        self.processor.checkProcessing()
        self.controller.checkProcessing()
        self.explorer.checkProcessing()
Пример #3
0
class GUI(Tk):
    "represents GUI"
    def __init__(self):
        super().__init__()
   
        self.title("CM Manager " + ".".join(version()))
        self.option_add("*tearOff", FALSE)
        self.resizable(FALSE, FALSE)
        
        '''
        used when size of the window is changed for placeWindow arguments     
        self.after(50, lambda: print(self.winfo_width()))
        self.after(50, lambda: print(self.winfo_height()))
        '''
        placeWindow(self, 1010, 786)

        # notebook
        self.selectFunction = ttk.Notebook(self)
        self.selectFunction.grid()

        # FileStorage is associated with the Notebook
        self.selectFunction.fileStorage = FileStorage()
        
        self.processor = Processor(self.selectFunction)
        self.explorer = Explorer(self.selectFunction)
        self.controller = Controller(self.selectFunction)

        notepageWidth = 20
        self.selectFunction.add(self.processor, text = "{:^{}}".format("Process", notepageWidth))
        self.selectFunction.add(self.explorer, text = "{:^{}}".format("Explore", notepageWidth))
        self.selectFunction.add(self.controller, text = "{:^{}}".format("Control", notepageWidth))

        self.selectFunction.bind("<<NotebookTabChanged>>", lambda e: self.checkProcessing(e))
            
        # menu
        self["menu"] = MenuCM(self)

        # checks for new messages and versions on the web
        if optionGet("CheckMessages", True, "bool"):
            self.onStart()

        self.mainloop()



    def onStart(self):
        "checks web for new version and post"
        try:
            self.checkNewVersion()
        except Exception:
            pass

        try:
            self.checkNewPost()
        except Exception:
            pass       


    def checkNewVersion(self):
        "checks whether there is a new version available"
        newVersion = self.returnSiteContent("http://www.cmmanagerweb.appspot.com/version").\
                     split(".")
        versionSeen = optionGet("DontShowVersion", version(), "list")
        for i in range(3):
            if int(newVersion[i]) > int(versionSeen[i]):
                DialogBox(self, title = "New version available", message =
                          self.returnSiteContent(
                                        "http://www.cmmanagerweb.appspot.com/version/message"),
                          dontShowOption = "DontShowVersion", optionValue = newVersion)
                break            


    def checkNewPost(self):
        "checks whether there is some post with new information on the web"
        currentPost = optionGet("WebPostNumber", 0, "int")
        webPostNumber = int(self.returnSiteContent("http://www.cmmanagerweb.appspot.com/post"))
        if  webPostNumber > currentPost:
            DialogBox(self, "New information", self.returnSiteContent(
                "http://www.cmmanagerweb.appspot.com/post/message"))
            optionWrite("WebPostNumber", webPostNumber)


    def returnSiteContent(self, link):
        "return text obtained from web site"
        site = urlopen(link)
        text = site.read()
        site.close()
        text = str(text)[2:-1]
        return text       


    def checkProcessing(self, event):
        """checks whether it is possible for processor and controller to process files and change
        states of buttons accordingly"""
        self.processor.checkProcessing()
        self.controller.checkProcessing()
        self.explorer.checkProcessing()