Beispiel #1
0
class MainFrame(gui.MainFrame):
    """ Main application class. Here are defined all the methods and
        functions that control the entire application """
    def __init__(self):
        # Set info about the application
        self.info = AboutDialogInfo()
        with open('../version.txt', 'r') as version_file:
            self.info.SetVersion(version_file.read().__str__())
        self.info.SetName(u"CNC ToolDB")
        self.info.SetCopyright(
            u"Copyright (c) 2019 Simão Amorim <*****@*****.**>")
        with open('../LICENSE', 'r') as license_file:
            self.info.SetLicence(license_file.read().encode('UTF-8'))
        self.info.SetDevelopers([u"Simão Amorim ([email protected])"])
        # Initialize the window
        super().__init__(parent=None,
                         title=self.info.GetName() + " " +
                         self.info.GetVersion())
        self.DB = sql.DB()
        self.init_binds()
        self.update_chooser()
        self.Show()

    def init_binds(self):
        """Bind GUI events to the appropriate handler methods"""
        self.Bind(wx.EVT_MENU, self.menubar_handler, self.menu_bar)
        self.Bind(wx.EVT_CHOICE, self.set_machine, self.machine_chooser)

    def update_chooser(self):
        for item in self.DB.get_machines():
            self.machine_chooser.Append(item)

    def set_machine(self, event):
        temp_id = event.GetId()
        if temp_id == self.machine_chooser.Id:
            print("Choice: %s" % self.machine_chooser.GetStringSelection())

    def menubar_handler(self, event):
        """Method to handle events from the menu bar in the main frame"""
        temp_id = event.GetId()
        if temp_id == self.file_menu_exit.Id:
            self.Destroy()
        elif temp_id == self.help_menu_about.Id:
            AboutBox(
                info=self.info,
                parent=self,
            )
        event.StopPropagation()
    def show(self, parent):

        if parent:
            self.parent = parent
        if not self.docwriter:
            self.docwriter = self.developer

        info = AboutDialogInfo()
        info.SetName(self.name)
        info.SetVersion(self.version)
        info.SetDescription(self.description)
        info.SetCopyright(self.copyright)
        info.SetWebSite(self.website)
        info.SetLicence(self.licence)
        info.AddDeveloper(self.developer)
        info.AddDocWriter(self.docwriter)
        info.AddArtist(self.artist)
        AboutBox(info)  #,self.parent)