def __init__(self): ''' Constructor ''' logging.info("generating screen-1") wx.Frame.__init__(self, None, wx.ID_ANY,"screen 1") #some custom fonts p = wx.Panel(self) #nb = wx.Notebook(p) style = self.GetBookStyles() nb = LB.LabelBook(p, -1, agwStyle = style) # create the page windows as children of the notebook #nb.SetFontBold(True) nb.SetFontSizeMultiple(2) page1 = PageOne(nb) page2 = PageTwo(nb) page3 = PageThree(nb) # add the pages to the notebook with the label to show on the tab nb.AddPage(page1, "Page 1") nb.AddPage(page2, "Page 2") nb.AddPage(page3, "Page 3") # finally, put the notebook in a sizer for the panel to manage # the layout sizer = wx.BoxSizer() sizer.Add(nb, 1, wx.EXPAND) p.SetSizer(sizer) self.InitUI()
def __init__(self, parent): wx.Dialog.__init__(self, parent, size=(600, 585), title=L('GRAPHIC_CONFIG')) pub().subscribe(self.update_language, T.LANGUAGE_CHANGED) # ---- variable de configuración de Figura conf = parent.fig_config a_conf = parent.ax_conf rd_config = parent.radar_chard_con ag_st = LB.INB_FIT_LABELTEXT | LB.INB_LEFT | LB.INB_DRAW_SHADOW ag_st = ag_st | LB.INB_GRADIENT_BACKGROUND | LB.INB_SHOW_ONLY_TEXT ag_st = ag_st | LB.INB_BOLD_TAB_SELECTION notebook = LB.LabelBook(self, -1, agwStyle=ag_st) notebook.SetFontBold(False) notebook.SetColour(LB.INB_TAB_AREA_BACKGROUND_COLOUR, wx.Colour(132, 164, 213)) imagelist = wx.ImageList(32, 32) imagelist.Add(my_bitmap.GetBitmap()) notebook.AssignImageList(imagelist) # ---- Panel de Figuras notebook.AddPage(FigureConfigPanel(notebook, self, conf), L('FIGURE'), 1, 0) # ---- Panel de Ejes self.ax_panel = AxesConfigPanel(notebook, self, a_conf) notebook.AddPage(self.ax_panel, L('AXES'), 0, 0) # ---- Panel de Radar Chart self.rc_panel = RadarChartConfigPanel(notebook, self, rd_config) notebook.AddPage(self.rc_panel, 'RadarChard', 1, 0) self.nb = notebook sbuttons = self.set_buttons() sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.nb, 1, wx.EXPAND | wx.ALL, 2) sizer.Add(sbuttons, flag=wx.ALIGN_RIGHT | wx.TOP | wx.BOTTOM, border=10) self.SetSizer(sizer) self.Bind(wx.EVT_CLOSE, self.on_close) self.CenterOnScreen() self.ShowModal()
def test_lib_agw_labelbookPages(self): nb = LB.LabelBook(self.frame) p1 = wx.Panel(nb) nb.AddPage(p1, "Page1") p2 = wx.Panel(nb) nb.AddPage(p2, "Page2") nb.SetSelection(0) nb = LB.FlatImageBook(self.frame) p1 = wx.Panel(nb) nb.AddPage(p1, "Page1") p2 = wx.Panel(nb) nb.AddPage(p2, "Page2") nb.SetSelection(0)
def test_lib_agw_labelbookDeletePages(self): nb = LB.LabelBook(self.frame) p1 = wx.Panel(nb) nb.AddPage(p1, "Page1") p2 = wx.Panel(nb) nb.AddPage(p2, "Page2") nb.DeleteAllPages() nb = LB.FlatImageBook(self.frame) p1 = wx.Panel(nb) nb.AddPage(p1, "Page1") p2 = wx.Panel(nb) nb.AddPage(p2, "Page2") for index in range(nb.GetPageCount() - 1, -1, -1): nb.DeletePage(index)
def test_lib_agw_labelbookTabPosition(self): nb = LB.LabelBook(self.frame) p1 = wx.Panel(nb) nb.AddPage(p1, "Page1") p2 = wx.Panel(nb) nb.AddPage(p2, "Page2") for style in [LB.INB_LEFT, LB.INB_RIGHT]: nb.SetAGWWindowStyleFlag(style) nb = LB.FlatImageBook(self.frame) p1 = wx.Panel(nb) nb.AddPage(p1, "Page1") p2 = wx.Panel(nb) nb.AddPage(p2, "Page2") for style in [LB.INB_LEFT, LB.INB_RIGHT, LB.INB_TOP, LB.INB_BOTTOM]: nb.SetAGWWindowStyleFlag(style)
def __init__(self, *args, **kw): super(TitleFrame, self).__init__(*args, **kw) frame = wx.Panel.__init__(self, None, title="Integrated Process Control Framework", size=(650, 650)) ico = wx.Icon('./images/logo.ico', wx.BITMAP_TYPE_ICO) self.SetIcon(ico) self.makeMenuBar() self.CreateStatusBar() self.SetStatusText("Ecole des Mines de Saint-Etienne 2020") self.notebook = LB.LabelBook( self, -1, agwStyle=LB.INB_FIT_LABELTEXT | LB.INB_LEFT | LB.INB_BOLD_TAB_SELECTION | LB.INB_GRADIENT_BACKGROUND | LB.INB_BORDER | LB.INB_USE_PIN_BUTTON | LB.INB_DRAW_SHADOW)
def CreateLabelBook(self): if not self.initializing: self.Freeze() self.book.Destroy() else: self.imagelist = self.CreateImageList() self.book = LB.LabelBook(self, -1) self.book.SetFontSizeMultiple(1.0) self.book.SetFontBold(False) self.book.SetSelection(0) self.book.AssignImageList(self.imagelist) self.CreatePages() self.book.SetSize(self.book.GetClientSize()) if not self.initializing: self.GetSizer().Layout() self.Layout() self.Thaw() self.SendSizeEvent()
def __init__(self, version_full, nobins=False, restrictions=None, force_restrictions=False): self.prefsdir = user_data_dir("HondaECU", "MCUInnovationsInc") if not os.path.exists(self.prefsdir): os.makedirs(self.prefsdir) self.configfile = os.path.join(self.prefsdir, 'hondaecu.ini') self.config = configparser.ConfigParser() if os.path.isfile(self.configfile): self.config.read(self.configfile) if not "retries" in self.config['DEFAULT']: self.config['DEFAULT'] = {'retries': '1'} self.nobins = nobins self.restrictions = restrictions self.force_restrictions = force_restrictions self.run = True self.active_ftdi_device = None self.ftdi_devices = {} self.__clear_data() if getattr(sys, 'frozen', False): self.basepath = sys._MEIPASS else: self.basepath = os.path.dirname(os.path.realpath(__file__)) self.version_full = version_full self.version_short = self.version_full.split("-")[0] self.apps = { "flash": { "label": "Flash", "panel": HondaECU_FlashPanel, }, # "hrc": { # "label":"HRC Data Settings", # "panel":HondaECU_HRCDataSettingsPanel, # }, "data": { "label": "Data Logging", "panel": HondaECU_DatalogPanel, }, "dtc": { "label": "Trouble Codes", "panel": HondaECU_ErrorPanel, }, } self.appanels = {} wx.Frame.__init__(self, None, title="HondaECU %s" % (self.version_short), style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER, size=(500, 300)) ib = wx.IconBundle() ib.AddIcon(os.path.join(self.basepath, "images", "honda.ico")) self.SetIcons(ib) self.menubar = wx.MenuBar() self.SetMenuBar(self.menubar) fileMenu = wx.Menu() self.menubar.Append(fileMenu, '&File') quitItem = wx.MenuItem(fileMenu, wx.ID_EXIT, '&Quit\tCtrl+Q') self.Bind(wx.EVT_MENU, self.OnClose, quitItem) fileMenu.Append(quitItem) helpMenu = wx.Menu() self.menubar.Append(helpMenu, '&Help') debugItem = wx.MenuItem(helpMenu, wx.ID_ANY, 'Show debug log') self.Bind(wx.EVT_MENU, self.OnDebug, debugItem) helpMenu.Append(debugItem) helpMenu.AppendSeparator() detectmapItem = wx.MenuItem(helpMenu, wx.ID_ANY, 'Detect map id') self.Bind(wx.EVT_MENU, self.OnDetectMap, detectmapItem) helpMenu.Append(detectmapItem) checksumItem = wx.MenuItem(helpMenu, wx.ID_ANY, 'Validate bin checksum') self.Bind(wx.EVT_MENU, self.OnBinChecksum, checksumItem) helpMenu.Append(checksumItem) self.statusicons = [ wx.Image(os.path.join(self.basepath, "images/bullet_black.png"), wx.BITMAP_TYPE_ANY).ConvertToBitmap(), wx.Image(os.path.join(self.basepath, "images/bullet_yellow.png"), wx.BITMAP_TYPE_ANY).ConvertToBitmap(), wx.Image(os.path.join(self.basepath, "images/bullet_green.png"), wx.BITMAP_TYPE_ANY).ConvertToBitmap(), wx.Image(os.path.join(self.basepath, "images/bullet_blue.png"), wx.BITMAP_TYPE_ANY).ConvertToBitmap(), wx.Image(os.path.join(self.basepath, "images/bullet_purple.png"), wx.BITMAP_TYPE_ANY).ConvertToBitmap(), wx.Image(os.path.join(self.basepath, "images/bullet_red.png"), wx.BITMAP_TYPE_ANY).ConvertToBitmap() ] self.statusbar = ESB.EnhancedStatusBar(self, -1) self.SetStatusBar(self.statusbar) self.statusbar.SetSize((-1, 28)) self.statusicon = wx.StaticBitmap(self.statusbar) self.statusicon.SetBitmap(self.statusicons[0]) self.ecmidl = wx.StaticText(self.statusbar) self.flashcountl = wx.StaticText(self.statusbar) self.dtccountl = wx.StaticText(self.statusbar) self.statusbar.SetFieldsCount(4) self.statusbar.SetStatusWidths([32, 170, 130, 110]) self.statusbar.AddWidget(self.statusicon, pos=0) self.statusbar.AddWidget(self.ecmidl, pos=1, horizontalalignment=ESB.ESB_ALIGN_LEFT) self.statusbar.AddWidget(self.flashcountl, pos=2, horizontalalignment=ESB.ESB_ALIGN_LEFT) self.statusbar.AddWidget(self.dtccountl, pos=3, horizontalalignment=ESB.ESB_ALIGN_LEFT) self.statusbar.SetStatusStyles( [wx.SB_SUNKEN, wx.SB_SUNKEN, wx.SB_SUNKEN, wx.SB_SUNKEN]) self.outerp = wx.Panel(self) self.adapterboxp = wx.Panel(self.outerp) self.adapterboxsizer = wx.StaticBoxSizer(wx.VERTICAL, self.adapterboxp, "FTDI Devices:") self.adapterboxp.SetSizer(self.adapterboxsizer) self.adapterlist = wx.Choice(self.adapterboxp, wx.ID_ANY, size=(-1, 32)) self.adapterboxsizer.Add(self.adapterlist, 1, wx.ALL | wx.EXPAND, border=10) self.labelbook = LB.LabelBook(self.outerp, agwStyle=LB.INB_FIT_LABELTEXT | LB.INB_LEFT | LB.INB_DRAW_SHADOW | LB.INB_GRADIENT_BACKGROUND) self.bookpages = {} maxdims = [0, 0] for a, d in self.apps.items(): enablestates = None if "enable" in self.apps[a]: enablestates = self.apps[a]["enable"] self.bookpages[a] = d["panel"](self, a, self.apps[a], enablestates) x, y = self.bookpages[a].GetSize() if x > maxdims[0]: maxdims[0] = x if y > maxdims[1]: maxdims[1] = y self.labelbook.AddPage(self.bookpages[a], d["label"], False) for k in self.bookpages.keys(): self.bookpages[k].SetMinSize(maxdims) self.modelp = wx.Panel(self.outerp, style=wx.BORDER_SUNKEN) self.modelbox = wx.BoxSizer(wx.VERTICAL) self.modell = wx.StaticText(self.modelp, label="", style=wx.ALIGN_CENTRE_HORIZONTAL | wx.ALIGN_CENTRE_VERTICAL) self.ecupnl = wx.StaticText(self.modelp, label="", style=wx.ALIGN_CENTRE_HORIZONTAL | wx.ALIGN_CENTRE_VERTICAL) font1 = self.GetFont().Bold() font2 = self.GetFont().Bold() font1.SetPointSize(font1.GetPointSize() * 1.25) font2.SetPointSize(font2.GetPointSize() * 2) self.modell.SetFont(font2) self.ecupnl.SetFont(font1) self.modelbox.AddSpacer(5) self.modelbox.Add(self.modell, 0, wx.CENTER) self.modelbox.Add(self.ecupnl, 0, wx.CENTER) self.modelbox.AddSpacer(5) self.modelp.SetSizer(self.modelbox) self.outersizer = wx.BoxSizer(wx.VERTICAL) self.outersizer.Add(self.adapterboxp, 0, wx.EXPAND | wx.ALL, 5) self.outersizer.Add(self.modelp, 0, wx.EXPAND | wx.ALL, 5) self.outersizer.Add(self.labelbook, 2, wx.EXPAND | wx.ALL, 5) self.outerp.SetSizer(self.outersizer) self.mainsizer = wx.BoxSizer(wx.VERTICAL) self.mainsizer.Add(self.outerp, 1, wx.EXPAND) self.mainsizer.SetSizeHints(self) self.SetSizer(self.mainsizer) self.adapterlist.Bind(wx.EVT_CHOICE, self.OnAdapterSelected) self.Bind(wx.EVT_CLOSE, self.OnClose) self.debuglog = HondaECU_LogPanel(self) dispatcher.connect(self.USBMonitorHandler, signal="USBMonitor", sender=dispatcher.Any) dispatcher.connect(self.AppPanelHandler, signal="AppPanel", sender=dispatcher.Any) dispatcher.connect(self.KlineWorkerHandler, signal="KlineWorker", sender=dispatcher.Any) self.usbmonitor = USBMonitor(self) self.klineworker = KlineWorker(self) self.Layout() self.Center() self.Show() self.usbmonitor.start() self.klineworker.start() self.powercycle = PowerCycleDialog(None)
def __init__(self, parent): wx.Dialog.__init__(self, parent, -1, name="DLG_Stats", style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.MAXIMIZE_BOX|wx.MINIMIZE_BOX) self.parent = parent self.couleurFond = wx.SystemSettings.GetColour(30) self.dictParametres = {} ####Liste d'objets ici self.listeObjets = [ {"nom" : _(u"Individus"), "code" : "individus", "image" : None, "ctrl_notebook" : None, "visible" : True, "pages" : [ {"nom" : _(u"Nombre"), "code" : "individus_nombre", "image" : None, "ctrl_html" : None, "visible" : True, "objets" : [ INDIVIDUS.Texte_nombre_individus(), INDIVIDUS.Tableau_nombre_individus(), INDIVIDUS.Graphe_nombre_individus(), ]}, {"nom" : _(u"Ancienneté"), "code" : "individus_anciennete", "image" : None, "ctrl_html" : None, "visible" : True, "objets" : [ INDIVIDUS.Tableau_nouveaux_individus(), INDIVIDUS.Graphe_nouveaux_individus(), INDIVIDUS.Graphe_arrivee_individus(), ]}, {"nom" : _(u"Genre"), "code" : "individus_genre", "image" : None, "ctrl_html" : None, "visible" : True, "objets" : [ INDIVIDUS.Tableau_repartition_genre(), INDIVIDUS.Graphe_repartition_genre(), ]}, {"nom" : _(u"Âge"), "code" : "individus_age", "image" : None, "ctrl_html" : None, "visible" : True, "objets" : [ INDIVIDUS.Tableau_repartition_ages(), INDIVIDUS.Graphe_repartition_ages(), INDIVIDUS.Tableau_repartition_annees_naiss(), INDIVIDUS.Graphe_repartition_annees_naiss(), ]}, {"nom" : _(u"Coordonnées"), "code" : "individus_coordonnees", "image" : None, "ctrl_html" : None, "visible" : True, "objets" : [ INDIVIDUS.Tableau_repartition_villes(), INDIVIDUS.Graphe_repartition_villes(), ]}, {"nom" : _(u"Scolarité"), "code" : "individus_scolarite", "image" : None, "ctrl_html" : None, "visible" : True, "objets" : [ INDIVIDUS.Tableau_repartition_ecoles(), INDIVIDUS.Graphe_repartition_ecoles(), INDIVIDUS.Tableau_repartition_niveaux_scolaires(), INDIVIDUS.Graphe_repartition_niveaux_scolaires(), ]}, {"nom" : _(u"Profession"), "code" : "individus_profession", "image" : None, "ctrl_html" : None, "visible" : True, "objets" : [ INDIVIDUS.Tableau_activites_professionnelles(), INDIVIDUS.Graphe_activites_professionnelles(), ]}, ]}, {"nom" : _(u"Familles"), "code" : "familles", "image" : None, "ctrl_notebook" : None, "visible" : True, "pages" : [ {"nom" : _(u"Nombre"), "code" : "familles_nombre", "image" : None, "ctrl_html" : None, "visible" : True, "objets" : [ FAMILLES.Texte_nombre_familles(), FAMILLES.Tableau_nombre_familles(), FAMILLES.Graphe_nombre_familles(), ]}, {"nom" : _(u"Caisse"), "code" : "familles_caisse", "image" : None, "ctrl_html" : None, "visible" : True, "objets" : [ FAMILLES.Tableau_repartition_caisses(), FAMILLES.Graphe_repartition_caisses(), ]}, {"nom" : _(u"Composition"), "code" : "familles_composition", "image" : None, "ctrl_html" : None, "visible" : True, "objets" : [ FAMILLES.Tableau_nombre_membres(), FAMILLES.Graphe_nombre_membres(), ]}, {"nom" : _(u"Quotient familial"), "code" : "familles_qf", "image" : None, "ctrl_html" : None, "visible" : True, "objets" : [ FAMILLES.Tableau_qf_tarifs(), FAMILLES.Graphe_qf_tarifs(), FAMILLES.Tableau_qf_defaut(), FAMILLES.Graphe_qf_defaut(), ]}, ]}, ] # Bandeau intro = _(u"Vous pouvez ici consulter des statistiques complètes sur les activités et la période de votre choix. Ces informations sont présentées sous forme de rubrique, de pages et d'items que vous pouvez choisir d'afficher ou non. Vous pouvez ensuite imprimer ces informations sous forme de rapport hierarchisé. Cliquez sur les graphes pour accéder aux outils spécifiques.") titre = _(u"Statistiques") self.SetTitle(titre) self.ctrl_bandeau = CTRL_Bandeau.Bandeau(self, titre=titre, texte=intro, hauteurHtml=30, nomImage="Images/32x32/Barres.png") # Labelbook self.box_informations_staticbox = wx.StaticBox(self, -1, _(u"Informations")) self.ctrl_labelbook = LB.LabelBook(self, -1, agwStyle=LB.INB_DRAW_SHADOW | LB.INB_LEFT) self.baseHTML = MODELES.HTML(liste_objets=self.listeObjets) self.InitLabelbook() self.ctrl_labelbook.SetSelection(0) # Paramètres self.box_parametres_staticbox = wx.StaticBox(self, -1, _(u"Paramètres")) self.ctrl_parametres = CTRL_Parametres(self) self.ctrl_parametres.MAJ() self.hyper_parametres = Hyperlien(self, label=_(u"Modifier les paramètres"), infobulle=_(u"Modifier les paramètres"), URL="parametres") # impression self.box_impression_staticbox = wx.StaticBox(self, -1, _(u"Impression")) self.ctrl_impression = CTRL_Stats_objets.CTRL_Objets(self, liste_objets=self.listeObjets) self.ctrl_impression.MAJ() self.hyper_selectionner = Hyperlien(self, label=_(u"Tout sélectionner"), infobulle=_(u"Tout sélectionner"), URL="selectionner") self.label_separation = wx.StaticText(self, -1, u"|") self.hyper_deselectionner = Hyperlien(self, label=_(u"Tout dé-sélectionner"), infobulle=_(u"Tout dé-sélectionner"), URL="deselectionner") self.bouton_imprimer = CTRL_Bouton_image.CTRL(self, texte=_(u"Imprimer"), cheminImage="Images/32x32/Imprimante.png") # Boutons self.bouton_aide = CTRL_Bouton_image.CTRL(self, texte=_(u"Aide"), cheminImage="Images/32x32/Aide.png") self.bouton_fermer = CTRL_Bouton_image.CTRL(self, texte=_(u"Fermer"), cheminImage="Images/32x32/Fermer.png") self.__set_properties() self.__do_layout() # Binds self.Bind(LB.EVT_IMAGENOTEBOOK_PAGE_CHANGED, self.OnChangeLabelbook, self.ctrl_labelbook) self.Bind(wx.EVT_BUTTON, self.OnBoutonAide, self.bouton_aide) self.Bind(wx.EVT_BUTTON, self.OnBoutonImprimer, self.bouton_imprimer) self.Bind(wx.EVT_BUTTON, self.OnBoutonFermer, self.bouton_fermer)
def test_lib_agw_labelbookCtor(self): book = LB.LabelBook(self.frame) self.assertEqual(book.GetPageCount(), 0) book = LB.FlatImageBook(self.frame) self.assertEqual(book.GetPageCount(), 0)
def __init__(self): # Init window wx.Frame.__init__(self, None, -1, "GeneRoster", size=(1200, 1000)) # Create panel p = wx.Panel(self) self.nb = LB.LabelBook(p, -1, size=(400, 200), style=wx.NB_LEFT, agwStyle=INB_LEFT | INB_FIT_LABELTEXT | INB_FIT_BUTTON | INB_SHOW_ONLY_TEXT | INB_USE_PIN_BUTTON) vertSizer = wx.BoxSizer(wx.VERTICAL) # Create initial notebook page self.base = UnitTab(self.nb) self.nb.AddPage(self.base, "New Faction") self.base.initTab("", "", 0, "New Faction") self.base.DrawTab() vertSizer.Add(self.nb, 1, wx.EXPAND, 0) p.SetSizer(vertSizer) ### Pass self.nb to save/delete routines menuBar = wx.MenuBar() fileMenu = wx.Menu() # File Menu under Menubar fileNew = fileMenu.Append(-1, "New", "New Faction") self.Bind(wx.EVT_MENU, self.onNew, fileNew) fileMenu.AppendSeparator() fileOpen = fileMenu.Append(-1, "Open", "Open Faction") self.Bind(wx.EVT_MENU, self.onOpen, fileOpen) fileMenu.AppendSeparator() fileSave = fileMenu.Append(-1, "Save", "Save Faction") self.Bind(wx.EVT_MENU, self.onSave, fileSave) fileMenu.AppendSeparator() fileExit = fileMenu.Append(-1, "Exit", "Exit the Application") self.Bind(wx.EVT_MENU, self.onExit, fileExit) menuBar.Append(fileMenu, "&File") # Add File Menu to Menubar optsMenu = wx.Menu() optsShow = optsMenu.Append(-1, "Display", "Configure Default Display") optsPath = optsMenu.Append(-1, "Path", "Configure Default Paths") optsXLSX = optsMenu.Append(-1, "Export Loadouts", "Export Loadouts to spreadsheet") self.Bind(wx.EVT_MENU, self.onOutput, optsXLSX) menuBar.Append(optsMenu, "&Settings") self.SetMenuBar(menuBar) # Attach menubar to frame # Add everything to the sizers to show p.Layout() # Initial data load self.DomainList = self.readfile( 'main.csv') # dict for domain construction info self.TraitList = self.readfile('traits.csv') # dict for traits self.GearList = self.readfile('gear.csv') # dict for gear self.AdvGear = self.readfile( 'opt_gear.cvs') # dict for gear added via traits self.OptList = {} self.OptList["HideBase"] = 0
def __init__(self, version_full, nobins=False, restrictions=None, force_restrictions=False): self.stats = { "retries": 0, "checksum_errors": 0, } adirs = AppDirs("HondaECU", "MCUInnovationsInc", version=__VERSION__) self.prefsdir = adirs.user_config_dir if not os.path.exists(self.prefsdir): os.makedirs(self.prefsdir) self.configfile = os.path.join(self.prefsdir, 'hondaecu.ini') self.config = configparser.ConfigParser() if os.path.isfile(self.configfile): self.config.read(self.configfile) if "retries" not in self.config['DEFAULT']: self.config['DEFAULT']['retries'] = "3" if "timeout" not in self.config['DEFAULT']: self.config['DEFAULT']['timeout'] = "0.2" if "klinemethod" not in self.config['DEFAULT']: self.config['DEFAULT']['klinemethod'] = "loopback_ping" else: if self.config['DEFAULT']['klinemethod'] == "poll_modem_status": self.config['DEFAULT']['klinemethod'] = "loopback_ping" if "kline_timeout" not in self.config['DEFAULT']: self.config['DEFAULT']['kline_timeout'] = "0.1" if "kline_wait" not in self.config['DEFAULT']: self.config['DEFAULT']['kline_wait'] = "0.002" if "kline_testbytes" not in self.config['DEFAULT']: self.config['DEFAULT']['kline_testbytes'] = "1" with open(self.configfile, 'w') as configfile: self.config.write(configfile) self.nobins = nobins self.restrictions = restrictions self.force_restrictions = force_restrictions self.run = True self.active_ftdi_device = None self.ftdi_devices = {} self.warned = [] self.__clear_data() if getattr(sys, 'frozen', False): self.basepath = sys._MEIPASS else: self.basepath = os.path.dirname(os.path.realpath(__file__)) self.version_full = version_full self.version_short = self.version_full.split("-")[0] self.apps = { "flash": { "label": "Flash", "panel": HondaECUFlashPanel, }, "eeprom": { "label": "EEPROM", "panel": HondaECUEEPROMPanel, }, # "hrc": { # "label":"HRC Data Settings", # "panel":HondaECUHRCDataSettingsPanel, # }, "data": { "label": "Data Logging", "panel": HondaECUDatalogPanel, }, "dtc": { "label": "Trouble Codes", "panel": HondaECUErrorPanel, }, } self.appanels = {} wx.Frame.__init__(self, None, title="HondaECU %s" % self.version_full, style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER, size=(500, 300)) ib = wx.IconBundle() ib.AddIcon(os.path.join(self.basepath, "images", "honda.ico")) self.SetIcons(ib) self.menubar = wx.MenuBar() self.SetMenuBar(self.menubar) filemenu = wx.Menu() self.menubar.Append(filemenu, '&File') settingsitem = wx.MenuItem(filemenu, wx.ID_ANY, 'Settings') self.Bind(wx.EVT_MENU, self.OnSettings, settingsitem) filemenu.Append(settingsitem) filemenu.AppendSeparator() quititem = wx.MenuItem(filemenu, wx.ID_EXIT, '&Quit\tCtrl+Q') self.Bind(wx.EVT_MENU, self.OnClose, quititem) filemenu.Append(quititem) helpmenu = wx.Menu() self.menubar.Append(helpmenu, '&Help') debugitem = wx.MenuItem(helpmenu, wx.ID_ANY, 'Show debug log') self.Bind(wx.EVT_MENU, self.OnDebug, debugitem) helpmenu.Append(debugitem) helpmenu.AppendSeparator() detectmapitem = wx.MenuItem(helpmenu, wx.ID_ANY, 'Detect map id') self.Bind(wx.EVT_MENU, self.OnDetectMap, detectmapitem) helpmenu.Append(detectmapitem) checksumitem = wx.MenuItem(helpmenu, wx.ID_ANY, 'Validate bin checksum') self.Bind(wx.EVT_MENU, self.OnBinChecksum, checksumitem) helpmenu.Append(checksumitem) statsitem = wx.MenuItem(helpmenu, wx.ID_ANY, 'Adapter stats') self.Bind(wx.EVT_MENU, self.OnStats, statsitem) helpmenu.Append(statsitem) self.statusicons = [ wx.Image(os.path.join(self.basepath, "images/bullet_black.png"), wx.BITMAP_TYPE_ANY).ConvertToBitmap(), wx.Image(os.path.join(self.basepath, "images/bullet_yellow.png"), wx.BITMAP_TYPE_ANY).ConvertToBitmap(), wx.Image(os.path.join(self.basepath, "images/bullet_green.png"), wx.BITMAP_TYPE_ANY).ConvertToBitmap(), wx.Image(os.path.join(self.basepath, "images/bullet_blue.png"), wx.BITMAP_TYPE_ANY).ConvertToBitmap(), wx.Image(os.path.join(self.basepath, "images/bullet_purple.png"), wx.BITMAP_TYPE_ANY).ConvertToBitmap(), wx.Image(os.path.join(self.basepath, "images/bullet_red.png"), wx.BITMAP_TYPE_ANY).ConvertToBitmap() ] self.statusbar = EnhancedStatusBar.EnhancedStatusBar(self, -1) self.SetStatusBar(self.statusbar) self.statusbar.SetSize((-1, 28)) self.statusicon = wx.StaticBitmap(self.statusbar) self.statusicon.SetBitmap(self.statusicons[0]) self.ecmidl = wx.StaticText(self.statusbar) self.flashcountl = wx.StaticText(self.statusbar) self.dtccountl = wx.StaticText(self.statusbar) self.statusbar.SetFieldsCount(4) self.statusbar.SetStatusWidths([32, 170, 130, 110]) self.statusbar.AddWidget(self.statusicon, pos=0) self.statusbar.AddWidget( self.ecmidl, pos=1, horizontalalignment=EnhancedStatusBar.ESB_ALIGN_LEFT) self.statusbar.AddWidget( self.flashcountl, pos=2, horizontalalignment=EnhancedStatusBar.ESB_ALIGN_LEFT) self.statusbar.AddWidget( self.dtccountl, pos=3, horizontalalignment=EnhancedStatusBar.ESB_ALIGN_LEFT) self.statusbar.SetStatusStyles( [wx.SB_SUNKEN, wx.SB_SUNKEN, wx.SB_SUNKEN, wx.SB_SUNKEN]) self.outerp = wx.Panel(self) self.adapterboxp = wx.Panel(self.outerp) self.securebutton = wx.Button(self.adapterboxp, label="Security Access") self.securebutton.Enable(False) self.adapterboxsizer = wx.StaticBoxSizer(wx.HORIZONTAL, self.adapterboxp, "FTDI Devices:") self.adapterboxp.SetSizer(self.adapterboxsizer) self.adapterlist = wx.Choice(self.adapterboxp, wx.ID_ANY, size=(-1, 32)) self.adapterboxsizer.Add(self.adapterlist, 1, wx.ALL | wx.EXPAND, border=5) self.adapterboxsizer.Add(self.securebutton, 0, wx.ALL, border=5) self.labelbook = lb.LabelBook(self.outerp, agwStyle=self.lbstyle) self.bookpages = {} maxdims = [0, 0] for a, d in self.apps.items(): enablestates = None if "enable" in self.apps[a]: enablestates = self.apps[a]["enable"] self.bookpages[a] = d["panel"](self, a, self.apps[a], enablestates) x, y = self.bookpages[a].GetSize() if x > maxdims[0]: maxdims[0] = x if y > maxdims[1]: maxdims[1] = y self.labelbook.AddPage(self.bookpages[a], d["label"], False) for k in self.bookpages.keys(): self.bookpages[k].SetMinSize(maxdims) self.modelp = wx.Panel(self.outerp, style=wx.BORDER_SUNKEN) self.modelbox = wx.BoxSizer(wx.VERTICAL) self.modell = wx.StaticText(self.modelp, label="", style=wx.ALIGN_CENTRE_HORIZONTAL | wx.ALIGN_CENTRE_VERTICAL) self.ecupnl = wx.StaticText(self.modelp, label="", style=wx.ALIGN_CENTRE_HORIZONTAL | wx.ALIGN_CENTRE_VERTICAL) font1 = self.GetFont().Bold() font2 = self.GetFont().Bold() font1.SetPointSize(font1.GetPointSize() * 1.25) font2.SetPointSize(font2.GetPointSize() * 2) self.modell.SetFont(font2) self.ecupnl.SetFont(font1) self.modelbox.AddSpacer(5) self.modelbox.Add(self.modell, 0, wx.CENTER) self.modelbox.Add(self.ecupnl, 0, wx.CENTER) self.modelbox.AddSpacer(5) self.modelp.SetSizer(self.modelbox) self.outersizer = wx.BoxSizer(wx.VERTICAL) self.outersizer.Add(self.adapterboxp, 0, wx.EXPAND | wx.ALL, 5) self.outersizer.Add(self.modelp, 0, wx.EXPAND | wx.ALL, 5) self.outersizer.Add(self.labelbook, 2, wx.EXPAND | wx.ALL, 5) self.outerp.SetSizer(self.outersizer) self.mainsizer = wx.BoxSizer(wx.VERTICAL) self.mainsizer.Add(self.outerp, 1, wx.EXPAND) self.mainsizer.SetSizeHints(self) self.SetSizer(self.mainsizer) self.securebutton.Bind(wx.EVT_BUTTON, self.OnSecure) self.adapterlist.Bind(wx.EVT_CHOICE, self.OnAdapterSelected) self.Bind(wx.EVT_CLOSE, self.OnClose) self.debuglog = HondaECULogPanel(self) dispatcher.connect(self.USBMonitorHandler, signal="USBMonitor", sender=dispatcher.Any) dispatcher.connect(self.kline_worker_handler, signal="KlineWorker", sender=dispatcher.Any) dispatcher.connect(self.ecu_stats_handler, signal="ecu.stats", sender=dispatcher.Any) self.usbmonitor = USBMonitor(self) self.klineworker = KlineWorker(self) self.Layout() self.Center() self.Show() self.usbmonitor.start() self.klineworker.start() self.settings = SettingsDialog(self) self.passwordd = PasswordDialog(self)