diff --git a/Components.py b/Components.py index e4aca226..e3641ca0 100644 --- a/Components.py +++ b/Components.py @@ -93,7 +93,6 @@ def GetClass(elem): # else: # DomainClass = clsmembers[os.path.basename(elem).split('.')[0]] # sys.stderr.write(_("Class unknown...")) - # print(DomainClass) # return None ### return only the class that inherite of DomainBehavoir or DomainStructure which are present in the clsmembers dict @@ -373,7 +372,6 @@ def Rename(filename:str, new_name:str)->bool: if temp_file: - #print("Replace %s by %s into %s"%(old_name, new_name, new_temp_file)) ### replace in new_temp_file file replaceAll(new_temp_file, old_name, new_name) @@ -844,7 +842,6 @@ def OnEditor(self, event): # loading file in DEVSimPy editor windows (self.text) try: - editorFrame = Editor.GetEditor(None, wx.NewIdRef(), ''.join([name,' - ',model_path]), obj=self, file_type='block') # if zipfile.is_zipfile(model_path): @@ -975,7 +972,6 @@ def GetModule(filename): # import pkgutil # search_path = [dir_name] # set to None to see all modules importable from sys.path # all_modules = [x[1] for x in pkgutil.iter_modules(path=search_path)] - # print(all_modules) else: sys.stdout.write("Import error 0: " + " module not found") module = None diff --git a/Container.py b/Container.py index 8eb0d51d..e4ba0433 100644 --- a/Container.py +++ b/Container.py @@ -846,10 +846,10 @@ def OnSimulation(self, event): ### Check if models have the same label L = diagram.GetLabelList([]) if len(L)!=len(set(L)): - model_with_same_label = [k for k,v in Counter(L).items() if v>1] + model_with_same_label = [f"-{k}" for k,v in Counter(L).items() if v>1] txt = "\n".join(model_with_same_label) - wx.MessageBox(_("It seems that the flowwing models have same label:\n \ - - %s \n\ + wx.MessageBox(_("It seems that the following models have a same label:\n\ + %s\n\ \nIf you plan to use Flat simulation algorithm, all model must have a unique label.")%txt, _("Simulation Manager")) ### set the name of diagram @@ -1543,6 +1543,7 @@ def __init__(self,\ Subject.__init__(self) self.SetBackgroundColour(wx.WHITE) + self.SetBackgroundStyle(wx.BG_STYLE_PAINT) self.name = name self.parent = parent @@ -1573,6 +1574,7 @@ def __init__(self,\ ### improve drawing with not condsidering the resizeable node when connect blocks self.resizeable_nedeed = True + self.refresh_need = True ### attach canvas to notebook 1 (for update) try: @@ -1770,10 +1772,11 @@ def DoDrawing(self, dc): shapes = self.diagram.shapes nodes = self.nodes + ### resizeable node not nedeed for connection process (dragging mouse with left button pressed - see when self.resizeable_nedeed is False) if not self.resizeable_nedeed: nodes = [n for n in nodes if not isinstance(n,ResizeableNode)] - items = shapes + nodes + items = iter(shapes + nodes) for item in items: try: @@ -1813,13 +1816,15 @@ def OnPaint(self, event): backBrush = wx.Brush(backColour, wx.BRUSHSTYLE_SOLID) pdc.SetBackground(backBrush) pdc.Clear() - + ### to insure the correct redraw when window is scolling ### http://markmail.org/thread/hytqkxhpdopwbbro#query:+page:1+mid:635dvk6ntxsky4my+state:results self.PrepareDC(pdc) self.DoDrawing(pdc) + del pdc + @Post_Undo def OnLock(self, event): """ @@ -1861,7 +1866,7 @@ def OnRightDown(self, event): menu.Destroy() ### Refresh canvas - self.Refresh() + # self.Refresh() ### Focus on canvas #wx.CallAfter(self.SetFocus) @@ -2383,7 +2388,9 @@ def OnLeftDown(self,event): self.CaptureMouse() self.overlay = wx.Overlay() if isinstance(event,wx.MouseEvent): - self.selectionStart = event.Position + # point = event.GetPosition() + point = self.getEventCoordinates(event) + self.selectionStart = point else: @@ -2417,7 +2424,7 @@ def OnLeftDown(self,event): self.__state['canvas'] = self self.notify() - self.Refresh() + # self.Refresh() ### @Post_Undo @@ -2500,7 +2507,7 @@ def OnLeftUp(self, event): ### dont avoid the link remove = False - except AttributeError: + except Exception: ### TODO: I dont now why !!! pass @@ -2521,35 +2528,39 @@ def OnLeftUp(self, event): except: sys.stdout.write(_("Error in Release Mouse!")) else: + self.permRect = None if isinstance(event,wx.MouseEvent): - if wx.VERSION_STRING < '4.0': - self.permRect = wx.RectPP(self.selectionStart, event.Position) - else: - self.permRect = wx.Rect(self.selectionStart, event.Position) - - self.selectionStart = None - self.overlay.Reset() - - self.SetCursor(wx.StockCursor(wx.CURSOR_ARROW)) + point = self.getEventCoordinates(event) + if self.selectionStart != point: + self.permRect = wx.Rect(self.selectionStart, point) - ## gestion des shapes qui sont dans le rectangle permRect - for s in self.diagram.GetShapeList(): - x = s.x[0]*self.scalex - y = s.y[0]*self.scaley - w = (s.x[1]-s.x[0])*self.scalex - h = (s.y[1]-s.y[0])*self.scaley - - recS = wx.Rect(x,y,w,h) - - # si les deux rectangles se chevauche - try: - bool = self.permRect.ContainsRect(recS) if wx.VERSION_STRING < '4.0' else self.permRect.Contains(recS) - if bool: - self.select(s) - except AttributeError as info: - if self.permRect: - raise AttributeError(_("use >= wx-2.8-gtk-unicode library: %s")%info) - #clear out any existing drawing + if self.permRect: + + self.selectionStart = None + self.overlay.Reset() + + self.SetCursor(wx.StockCursor(wx.CURSOR_ARROW)) + + ## gestion des shapes qui sont dans le rectangle permRect + for s in self.diagram.GetShapeList(): + x,y = self.getScalledCoordinates(s.x[0],s.y[0]) + # x = s.x[0]*self.scalex + # y = s.y[0]*self.scaley + w = (s.x[1]-s.x[0])*self.scalex + h = (s.y[1]-s.y[0])*self.scaley + + recS = wx.Rect(x,y,w,h) + + # print(s,x,y,w,h,self.permRect.Contains(recS)) + + # si les deux rectangles se chevauche + try: + if self.permRect.Contains(recS): + self.select(s) + except AttributeError as info: + if self.permRect: + raise AttributeError(_("use >= wx-2.8-gtk-unicode library: %s")%info) + #clear out any existing drawing else: ### shape is None and we remove the connectionShape for item in [s for s in self.select() if isinstance(s, ConnectionShape)]: @@ -2674,7 +2685,8 @@ def ShowQuickAttributeEditor(self, selectedShape:list)->None: def OnIdle(self,event): """ """ - self.Refresh(False) + if self.refresh_need: + self.Refresh(False) ### def OnMotion(self, event): @@ -2686,10 +2698,14 @@ def OnMotion(self, event): sc = self.getSelectedShapes() + self.refresh_need = True + self.resizeable_nedeed = True + if event.Dragging() and event.LeftIsDown(): self.diagram.modify = False - + + if len(sc) == 0: # User is dragging the mouse, check if # left button is down @@ -2707,11 +2723,14 @@ def OnMotion(self, event): ctx.SetBrush(wx.Brush(wx.Colour(229,229,229,80))) try: - ctx.DrawRectangle(*wx.Rect(self.selectionStart, event.Position)) + ctx.DrawRectangle(*wx.Rect(self.selectionStart, event.GetPosition())) except TypeError: pass - + del odc + + ### no need to refresh in order to qhpw the rectangle + self.refresh_need = False # else: # self.Refresh(False) else: @@ -2726,8 +2745,6 @@ def OnMotion(self, event): for s in sc: s.move(x,y) - - self.resizeable_nedeed = True ### change cursor when resizing model if isinstance(s, ResizeableNode) and cursor != wx.StockCursor(wx.CURSOR_SIZING): @@ -2735,7 +2752,7 @@ def OnMotion(self, event): ### change cursor when connectionShape hit a node elif isinstance(s, ConnectionShape): - self.resizeable_nedeed = False + ### dot trace to prepare connection if len(s.pen)>2: s.pen[2]= wx.PENSTYLE_DOT @@ -2746,6 +2763,8 @@ def OnMotion(self, event): for node in [n for n in self.nodes if isinstance(n, ConnectableNode) and n.HitTest(point[0], point[1])]: if cursor != wx.StockCursor(wx.CURSOR_CROSS): cursor = wx.StockCursor(wx.CURSOR_CROSS) + + self.resizeable_nedeed = False ### update the cursor self.SetCursor(cursor) @@ -2901,7 +2920,7 @@ def select(self, item=None): if item.output: block, n = item.output self.nodes.append(INode(block, n, self, block.getInputLabel(n))) - # print(item.input, item.output) + if isinstance(item, Resizeable): self.nodes.extend([ResizeableNode(item, n, self) for n in range(len(item.x))]) @@ -4541,13 +4560,6 @@ def OnRightDown(self, event): ### destroy menu local variable menu.Destroy() - # def OnLeftDClick(self, event): - # if isinstance(self.item, ConnectionShape): - # # print(self.item.getInput(), self.item.getOutput()) - # pass - - # return super().OnLeftDClick(event) - def HitTest(self,x,y): """ Collision detection method. """ diff --git a/Decorators.py b/Decorators.py index c5a20b12..2218bdfe 100644 --- a/Decorators.py +++ b/Decorators.py @@ -87,7 +87,6 @@ def wrapper(*args, **kw): sortby = 'cumulative' ps = pstats.Stats(pr).sort_stats(sortby) ps.dump_stats(prof_name) - #print(s.getvalue()) else: r = func(*args, **kw) diff --git a/Editor.py b/Editor.py index 10c95455..732486a1 100644 --- a/Editor.py +++ b/Editor.py @@ -1072,7 +1072,7 @@ def DoSaveFile(self, code): self.parent.toolbar.EnableTool(self.parent.save.GetId(), False) ### status bar notification - self.parent.Notification(False, _('%s saved') % fic_filename, '', '') + self.parent.Notification(False, _('%s saved') % fic_filename.replace("*",""), '', '') ### NOTE: EditionNotebook :: @WriteFile => Write with correct encode @staticmethod @@ -1732,7 +1732,7 @@ def GetStatusBar(self): """ sb = self.CreateStatusBar() sb.SetFieldsCount(3) - sb.SetStatusWidths([-5, -3, -1]) + sb.SetStatusWidths([-2, -2, -5]) return sb ### NOTE: Editor :: ToggleStatusBar => Event for show or hide status bar @@ -1923,7 +1923,7 @@ def __init__(self, parent, id, title, block): ### choices object is ordderd dict to associate handlers if self.cb: if not self.cb.isCMD(): - self._choices = collections.OrderedDict([(_('New peek'),self.OnPeek), + self._choices = collections.OrderedDict([(_('New peek'),self.OnPeek), (_('New all peek'),self.OnAllPeek), (_('New poke'),self.OnPoke), (_('New hold in state'),self.OnInsertHoldInState), (_('New passivate in state'),self.OnInsertPassivateInState), (_('New passivate state'),self.OnInsertPassivateState), (_('New Phase test'),self.OnInsertPhaseIs), (_('New debugger stdout'),self.OnInsertDebug), (_('Get state'),self.OnInsertGetState), (_('Get sigma'),self.OnInsertGetSigma), (_('Get message value'),self.OnInsertGetMsgValue)]) @@ -1956,8 +1956,8 @@ def OnPeek(self, *args)->None: def OnPoke(self, *args)->None: """Insert the poke statement. """ - sins = list(map(str, list(range(self.cb.input if hasattr(self.cb, 'output') else 10)))) - dlg = wx.SingleChoiceDialog(self, _('Port number'), _('Which port?'), sins, wx.CHOICEDLG_STYLE) + souts = list(map(str, list(range(self.cb.output if hasattr(self.cb, 'output') else 10)))) + dlg = wx.SingleChoiceDialog(self, _('Port number'), _('Which port?'), souts, wx.CHOICEDLG_STYLE) port = dlg.GetStringSelection() if dlg.ShowModal() == wx.ID_OK else None dlg.Destroy() @@ -1966,6 +1966,20 @@ def OnPoke(self, *args)->None: cp.AddText("return self.poke(self.OPorts[%d], Message(<>, self.timeNext))"%int(port)) self.Notification(True, _('%s modified' % (os.path.basename(cp.GetFilename()))), '', '') + def OnAllPeek(self, *args): + """ Insert the loop to peek all input ports. + """ + + txt = """ + for p in self.IPorts: + msg = self.peek(p, *args) + if msg: + v = self.getMsgValue(msg) + """ + cp = self.nb.GetCurrentPage() + cp.AddText(txt) + self.Notification(True, _('%s modified' % (os.path.basename(cp.GetFilename()))), '', '') + def OnCombo(self, event): """ Combobox for the text insert function. """ @@ -2462,7 +2476,7 @@ def __init__(self, parent, id, title, block): EditorPanel.__init__(self, parent, id, title) BlockBase.__init__(self, parent, id, title, block) - + #if not parent: #self.SetIcon(self.MakeIcon(wx.Image(os.path.join(ICON_PATH_16_16, 'pythonFile.png'), wx.BITMAP_TYPE_PNG))) #self.ConfigureGUI() @@ -2477,8 +2491,6 @@ def ConfigureTB(self): #tb = self.GetToolBar() self.toolbar.InsertSeparator(self.toolbar.GetToolsCount()) - - ### combo to insert tips text cbID = wx.NewIdRef() self.toolbar.AddControl(wx.ComboBox(self.toolbar, cbID, _("Choose to insert in place"), choices=self.getChoices(),size=(160,-1), style=wx.CB_DROPDOWN)) diff --git a/Menu.py b/Menu.py index 966f0df9..e07212e6 100644 --- a/Menu.py +++ b/Menu.py @@ -1087,8 +1087,9 @@ def __init__(self, shape, event): Rename_menu = AppendItem(rename) self.AppendSeparator() - # pour tout les model sur le canvas, rangés par ordre alphabetique, ormis les connection et le model que l'on veut connecter (la source) - for label,item in sorted([(a.label,a) for a in self.__canvas.GetDiagram().GetShapeList() if a != shape and not isinstance(a, Container.ConnectionShape)]): + + # pour tout les models sur le canvas, rangés par ordre alphabetique, ormis les connections et le modele que l'on veut connecter (la source) + for label,item in sorted([(a.label,a) for a in self.__canvas.GetDiagram().GetShapeList() if a != shape and not isinstance(a, Container.ConnectionShape)], key = lambda x: x[0]): # avoid connections like: iPort->iPort, oPort->oPort if (isinstance(shape, Container.iPort) and not isinstance(item, Container.iPort)) or (isinstance(shape, Container.oPort) and not isinstance(item, Container.oPort)) or isinstance(shape, Container.Block): new_item = wx.MenuItem(connectable_subMenu, wx.NewIdRef(), label) diff --git a/Mixins/Connectable.py b/Mixins/Connectable.py index a34dd38a..0641aab5 100644 --- a/Mixins/Connectable.py +++ b/Mixins/Connectable.py @@ -74,7 +74,6 @@ def addOutputLabels(self, port:int, label:str)->None: """ add a label to the output port """ self._output_labels[port] = label - print(self._output_labels) ### def getPortXY(self, type:str, num)->tuple: diff --git a/PlotGUI.py b/PlotGUI.py index b6026359..91f9d568 100644 --- a/PlotGUI.py +++ b/PlotGUI.py @@ -69,7 +69,7 @@ def get_limit(d): for c in d: bisect.insort(L1, c[0]) bisect.insort(L2, c[1]) - + ### 0.5 in order to visualize the max and min value correctly return L1[0],L1[-1],L2[0]-0.5,L2[-1]+0.5 @@ -269,21 +269,24 @@ def BuildToolbar(self): if wx.VERSION_STRING < '4.0': tb.AddCheckLabelTool(zoomId, zoomLabel, wx.Bitmap(os.path.join(ICON_PATH_16_16,'toggle-zoom.png')), shortHelp=_('Enable zoom'), longHelp='') - tb.AddCheckLabelTool(titleId, titleLabel, wx.Bitmap(os.path.join(ICON_PATH_16_16,'toggle-title.png')), shortHelp=_('Enable title'), longHelp='') - tb.AddCheckLabelTool(gridId, gridLabel, wx.Bitmap(os.path.join(ICON_PATH_16_16,'toggle-grid.png')), shortHelp='Enable grid', longHelp='') + titletb = tb.AddCheckLabelTool(titleId, titleLabel, wx.Bitmap(os.path.join(ICON_PATH_16_16,'toggle-title.png')), shortHelp=_('Enable title'), longHelp='') + gridtb = tb.AddCheckLabelTool(gridId, gridLabel, wx.Bitmap(os.path.join(ICON_PATH_16_16,'toggle-grid.png')), shortHelp='Enable grid', longHelp='') tb.AddCheckLabelTool(legendId, legendLabel, wx.Bitmap(os.path.join(ICON_PATH_16_16,'toggle-legend.png')), shortHelp=_('Turn on legend'), longHelp='') tb.AddCheckLabelTool(dragId, dragLabel, wx.Bitmap(os.path.join(ICON_PATH_16_16,'toggle-drag.png')), shortHelp=_('Enable drag'), longHelp='') tb.AddCheckLabelTool(pointId, pointLabel, wx.Bitmap(os.path.join(ICON_PATH_16_16,'toggle-point.png')), shortHelp=_('Show closest point'), longHelp='') tb.AddCheckLabelTool(normalizedId, normalizedLabel, wx.Bitmap(os.path.join(ICON_PATH_16_16,'toggle-norm.png')), shortHelp=_('Normalize'), longHelp=_('Normalize Y axis')) else: tb.AddCheckTool(zoomId, zoomLabel, wx.Bitmap(os.path.join(ICON_PATH_16_16,'toggle-zoom.png')), shortHelp=_('Enable zoom'), longHelp='') - tb.AddCheckTool(titleId, titleLabel, wx.Bitmap(os.path.join(ICON_PATH_16_16,'toggle-title.png')), shortHelp=_('Enable title'), longHelp='') - tb.AddCheckTool(gridId, gridLabel, wx.Bitmap(os.path.join(ICON_PATH_16_16,'toggle-grid.png')), shortHelp='Enable grid', longHelp='') + titletb = tb.AddCheckTool(titleId, titleLabel, wx.Bitmap(os.path.join(ICON_PATH_16_16,'toggle-title.png')), shortHelp=_('Enable title'), longHelp='') + gridtb = tb.AddCheckTool(gridId, gridLabel, wx.Bitmap(os.path.join(ICON_PATH_16_16,'toggle-grid.png')), shortHelp='Enable grid', longHelp='') tb.AddCheckTool(legendId, legendLabel, wx.Bitmap(os.path.join(ICON_PATH_16_16,'toggle-legend.png')), shortHelp=_('Turn on legend'), longHelp='') tb.AddCheckTool(dragId, dragLabel, wx.Bitmap(os.path.join(ICON_PATH_16_16,'toggle-drag.png')), shortHelp=_('Enable drag'), longHelp='') tb.AddCheckTool(pointId, pointLabel, wx.Bitmap(os.path.join(ICON_PATH_16_16,'toggle-point.png')), shortHelp=_('Show closest point'), longHelp='') tb.AddCheckTool(normalizedId, normalizedLabel, wx.Bitmap(os.path.join(ICON_PATH_16_16,'toggle-norm.png')), shortHelp=_('Normalize'), longHelp=_('Normalize Y axis')) + titletb.Toggle(True) + gridtb.Toggle(True) + tb.Realize() def OnMove(self, event): @@ -519,6 +522,10 @@ def __init__(self, parent = None, id = wx.NewIdRef(), title = "Time Plotting", d self.Bind(wx.EVT_MENU,self.OnRMSE, menu.Append(wx.NewIdRef(), _('RMSE'), _('Root Mean Square Error'))) self.mainmenu.Append(menu, _('&Error')) + menu = wx.Menu() + self.Bind(wx.EVT_MENU, self.OnMean, menu.Append(wx.NewIdRef(), _('Mean'), _('Mean of the curve'))) + self.mainmenu.Append(menu, _('&Mean')) + ### call self.On() getattr(self,'On%s'%self.typ)() @@ -574,7 +581,7 @@ def OnPlotLine(self, event=None)-> None: if isinstance(data, list): data = [(i if self.step else x[0], x[1]) for i,x in enumerate(data)] - + if self.normalize: data = self.Normalize(data) @@ -606,6 +613,7 @@ def OnPlotLine(self, event=None)-> None: if float(c) < float(yMin): yMin=float(c) if float(d) > float(yMax): yMax=float(d) + self.gc = plot.PlotGraphics(L, self.title, self.xLabel, self.yLabel) self.client.Draw(self.gc, xAxis = (float(xMin),float(xMax)), yAxis = (float(yMin),float(yMax))) @@ -750,13 +758,23 @@ def OnPlotBar(self, event=None): self.client.Draw(self.gc, xAxis = (float(xMin),float(xMax)), yAxis = (float(yMin),float(yMax))) + def OnMean(self, evt): + """ + """ + if isinstance(self.data, dict): + r = 0.0 + else: + r = sum(c[-1] for c in self.data) / len(self.data) + + wx.MessageBox('Mean: %f'%r, _('Info'), wx.OK|wx.ICON_INFORMATION) + def OnRMSE(self,evt): """ Get RMSE. """ if isinstance(self.data, dict): c1,c2 = self.data.values() assert(len(c1)==len(c2)) - diffcarr = list(map(lambda a,b: pow(float(a[-1])-float(b[-1]),2), c1,c2)) + diffcarr = map(lambda a,b: pow(float(a[-1])-float(b[-1]),2), c1,c2) r = sqrt(sum(diffcarr)/len(c1)) wx.MessageBox('RMSE: %f'%r, _('Info'), wx.OK|wx.ICON_INFORMATION) diff --git a/PropertiesGridCtrl.py b/PropertiesGridCtrl.py index 3ea3b9c9..5c7e339a 100644 --- a/PropertiesGridCtrl.py +++ b/PropertiesGridCtrl.py @@ -998,10 +998,14 @@ def SelectProp(self, evt): model = self.parent.model ### for .amd or .cmd - if model.model_path != '': - wcd = _('Atomic DEVSimPy model (*.amd)|*.amd|Coupled DEVSimPy model (*.cmd)|*.cmd|All files (*)|*') - else: + if model.isAMD(): + wcd = _('Atomic DEVSimPy model (*.amd)|*.amd|*.cmd|All files (*)|*') + elif model.isCMD(): + wcd = _('Coupled DEVSimPy model (*.cmd)|*.cmd|All files (*)|*') + elif model.isPY(): wcd = _('Python files (*.py)|*.py|All files (*)|*') + else: + wcd = _('All files (*)|*') default_dir = os.path.dirname(model.python_path) if os.path.exists(os.path.dirname(model.python_path)) else DOMAIN_PATH dlg = wx.FileDialog(self, message=_("Select file ..."), defaultDir=default_dir, defaultFile="", wildcard=wcd, style=wx.OPEN | wx.CHANGE_DIR) @@ -1017,7 +1021,7 @@ def SelectProp(self, evt): self.SetCellValue(row, 1, new_python_path) - # behavioral args update (because depends of the new class coming from new python file) + ### behavioral args update (because depends of the new class coming from new python file) new_cls = Components.GetClass(new_python_path) if inspect.isclass(new_cls): diff --git a/SpreadSheet.py b/SpreadSheet.py index 0cb6ba3f..d8e849aa 100644 --- a/SpreadSheet.py +++ b/SpreadSheet.py @@ -73,8 +73,11 @@ def Populate(self, data): """ """ self._full_flag = False + + size = len(data) + ## load cell - for i in range(len(data)): + for i in range(size): try: d = data[i] self.SetCellValue(i,0,str(d[0])) @@ -428,7 +431,6 @@ def OnGraph(self, event): s = sheet.GetCellValue(i,sheet.GetNumberCols()-1).replace('<< ', '').replace('<<', '').replace('>>','').replace('],','];') else: s = "value = %s; time = %s"%(v,sheet.GetCellValue(i,0)) - try: ### globals containt the time and value variables after exec of the statement exec(str(s), globals()) @@ -438,22 +440,26 @@ def OnGraph(self, event): ### if value is a list, we must choose an index to plot amoung the values of the list if isinstance(value, list): if select == -1: - dlg = wx.TextEntryDialog(self, _('Choose one index between [%d-%d] to plot into the list of values.')%(0,len(value)-1),_('Plotting Manager'), value="0") - if dlg.ShowModal() == wx.ID_OK: - select=int(dlg.GetValue()) - dlg.Destroy() + if len(value) > 1 : + dlg = wx.TextEntryDialog(self, _('Choose one index between [%d-%d] to plot into the list of values.')%(0,len(value)-1),_('Plotting Manager'), value="0") + if dlg.ShowModal() == wx.ID_OK: + select=int(dlg.GetValue()) + dlg.Destroy() + else: + dlg.Destroy() + break else: - dlg.Destroy() - break + select = 0 ### choice is digit else we break - if value[select]: - if select in range(0,len(value)-1) and not isinstance(value[select], str): + # if value[select]: + if select in range(0,len(value)-1): + if not isinstance(value[select], str): data.append((time, float(value[select]))) else: #wx.MessageBox(_('Value to plot must be digit!'), _('Warning'), wx.OK | wx.ICON_WARNING) data.append((time, value[select])) - + ### first if int is digit or if float is digit else: v = str(format(value,'f')).lstrip('-') @@ -462,7 +468,7 @@ def OnGraph(self, event): else: #wx.MessageBox(_('Type of data should be float or int: %s')%str(value), _('Info')) data.append((time, value)) - + if data: ### if the first value of y is str, we plot with tick in y axe if isinstance(data[0][-1], str): diff --git a/devsimpy.py b/devsimpy.py index 859cef44..3bfe2995 100644 --- a/devsimpy.py +++ b/devsimpy.py @@ -80,14 +80,6 @@ import wx -### try to have the latest version of wx -#try: -# import pip - #print(pip.main(['show','wxPython'])) - #pip.main(["install", "--upgrade", 'wxPython']) -#except: -# pass - ### check if an upgrade of wxpython is possible from pip ! sys.stdout.write("Importing wxPython %s%s for python %s on %s (%s) platform...\n"%(wx.version(), " from devsimpy.ini" if ini_exist else '', platform.python_version(), platform.system(), platform.version()))