def OnInit(self): PyutPreferences.determinePreferencesLocation() frameTop: Frame = Frame(parent=None, id=TestMiniOglApp.FRAME_ID, title="Test MiniOgl", size=(TestMiniOglApp.WINDOW_WIDTH, TestMiniOglApp.WINDOW_HEIGHT), style=DEFAULT_FRAME_STYLE) frameTop.Show(True) diagramFrame: DiagramFrame = DiagramFrame(frameTop) diagramFrame.SetSize((TestMiniOglApp.WINDOW_WIDTH, TestMiniOglApp.WINDOW_HEIGHT)) diagramFrame.SetScrollbars(10, 10, 100, 100) button = Button(frameTop, 1003, "Draw Me") button.SetPosition((15, 15)) self.Bind(EVT_BUTTON, self.onDrawMe, button) diagramFrame.Show(True) self.SetTopWindow(diagramFrame) self._diagramFrame: DiagramFrame = diagramFrame self.initTest() return True
def OnInit(self): TestBase.setUpLogging() self.logger: Logger = getLogger(__name__) frameTop: Frame = Frame(parent=None, id=TestADialog.FRAME_ID, title="Test A Dialog", size=(600, 400), style=DEFAULT_FRAME_STYLE) frameTop.Show(True) PyutPreferences.determinePreferencesLocation() diagramFrame: DiagramFrame = DiagramFrame(frameTop) diagramFrame.SetSize((1200, 1200)) diagramFrame.SetScrollbars(10, 10, 100, 100) diagramFrame.Show(True) self.SetTopWindow(diagramFrame) self._diagramFrame: DiagramFrame = diagramFrame # # Introduce a mock # fileHandler = MagicMock() self._mediator = Mediator() self._mediator.registerFileHandling(fileHandler) self.initTest() return True
def setUp(self): self.logger: Logger = TestIoPython.clsLogger self.plugin: IoPython = IoPython(oglObjects=None, umlFrame=cast(UmlFrame, None)) self.pyutToPython: PyutToPython = PyutToPython() # # Ugh -- need this called because PyutMethod instantiates the singleton # PyutPreferences.determinePreferencesLocation()
def doExport(self): """ Called by Pyut to begin the export process. """ if self._umlFrame is None: self.displayNoUmlFrame() return outputFormat: Tuple[str, str, str] = self.getOutputFormat() if outputFormat is not None: if not self.setExportOptions(): return None mediator = getMediator() prefs: PyutPreferences = PyutPreferences() if prefs.pyutIoPluginAutoSelectAll is True: mediator.selectAllShapes() self.__oglObjects = mediator.getSelectedShapes() if len(self.__oglObjects) == 0: self.displayNoSelectedUmlObjects() else: # write the file self.write(self.__oglObjects) mediator.deselectAllShapes() else: PyutIoPlugin.clsLogger.info(f'Output format is: {outputFormat}')
def _onOk(self, event: CommandEvent): """ Activated when button OK is clicked. """ strStereotype = self._txtStereotype.GetValue() if strStereotype == "": self._pyutModel.setStereotype(None) else: self._pyutModel.setStereotype(getPyutStereotype(strStereotype)) # Adds all fields in a list self._pyutModel.fields = self._pyutModelCopy.fields # Update display properties self._pyutModel.showFields = self._chkShowFields.GetValue() self._pyutModel.showMethods = self._chkShowMethods.GetValue() self._pyutModel.setShowStereotype(self._chkShowStereotype.GetValue()) from org.pyut.PyutPreferences import PyutPreferences prefs = PyutPreferences() try: if prefs["AUTO_RESIZE"]: oglClass = self._mediator.getOglClass(self._pyutModel) oglClass.autoResize() except (ValueError, Exception) as e: self.logger.warning(f'{e}') fileHandling = self._mediator.getFileHandling() project = fileHandling.getCurrentProject() if project is not None: project.setModified() super()._onOk(event)
def __init__(self, name="", visibility=PyutVisibilityEnum.PUBLIC, returns: PyutType = PyutType('')): """ Args: name: The method name visibility: Its visibility public, private, protected returns: Its return value """ super().__init__(name) self.logger: Logger = getLogger(__name__) self._visibility: PyutVisibilityEnum = visibility self._modifiers: PyutMethod.PyutModifiers = cast( PyutMethod.PyutModifiers, []) self._sourceCode: PyutMethod.SourceCodeType = cast( PyutMethod.SourceCodeType, []) self._params: PyutMethod.PyutParameters = [] self._returns: PyutType = returns prefs = PyutPreferences() if prefs.showParameters is True: PyutMethod.setStringMode(WITH_PARAMS) else: PyutMethod.setStringMode(WITHOUT_PARAMS)
def __init__(self): self._setupSystemLogging() self.logger: Logger = getLogger(__name__) PyutPreferences.determinePreferencesLocation() # Lang.importLanguage() self._exePath: str = self._getExePath() self._userPath: str = getcwd() # where the user launched pyut from PyutUtils.setBasePath(self._exePath) self._cmdLineArgsHandled: bool = False """ If `True` then we handled some command line arguments that do not require the full startup of Pyut. Examples of this are `--help` or `--version`. TODO: Perhaps rename this to `_startupUI` or `_fullStartup` or `_startUI` """ self.handleCommandLineArguments()
def getTempFilePath(cls, fileName: str) -> str: if PyutPreferences().useDebugTempFileLocation is True: fqFileName: str = f'{PyutUtils.getBasePath()}{osSep}{fileName}' else: tempDir: str = gettempdir() fqFileName: str = f'{tempDir}{osSep}{fileName}' return fqFileName
def _backupPrefs(self): prefsFileName: str = PyutPreferences.getPreferencesLocation() source: str = prefsFileName target: str = f"{prefsFileName}{TestPyutPreferences.BACKUP_SUFFIX}" if osPath.exists(source): try: copyfile(source, target) except IOError as e: self.logger.error(f"Unable to copy file. {e}")
def __init__(self, parent): """ Constructor. """ super().__init__(parent, ID_ANY, _("Fast Edit Options")) self.logger: Logger = getLogger(__name__) self.__prefs: PyutPreferences = PyutPreferences() self.__initCtrl() self.Bind(EVT_CLOSE, self.__OnClose)
def _updateOurDirectoryPreferences(self): """ Define last open directory ? - default is current directory - last opened directory for developers (pyut/src present) """ prefs: PyutPreferences = PyutPreferences() # Prefs handler prefs[PyutPreferences.ORG_DIRECTORY] = getcwd() if (self._userPath.find('pyut/src') == -1) and (self._userPath.find('pyut2/src') == -1): self.logger.debug(f'self._userPath: {self._userPath}') prefs[PyutPreferences.LAST_DIRECTORY] = self._userPath self.logger.debug(f'prefs: {prefs}')
def __init__(self, frame: Frame, callbackMap: SharedTypes.CallbackMap, lastOpenFilesID): from org.pyut.plugins.PluginManager import PluginManager # Plugin Manager should not be in plugins directory self._containingFrame: Frame = frame self._callbackMap: SharedTypes.CallbackMap = callbackMap self.lastOpenedFilesID = lastOpenFilesID self.logger: Logger = getLogger(__name__) self._prefs: PyutPreferences = PyutPreferences() self.plugMgr: PluginManager = PluginManager() self._mnuFile: Menu = Menu() self._plugins: SharedTypes.PluginMap = cast(SharedTypes.PluginMap, {}) # To store the plugins self._toolboxesID: SharedTypes.ToolboxIdMap = cast(SharedTypes.ToolboxIdMap, {}) # Association toolbox id
def __init__(self, umlObjects: List[OglClass]): self.logger: Logger = getLogger(__name__) gmlExporter: GMLExporter = GMLExporter() gmlExporter.translate(umlObjects=umlObjects) if PyutPreferences().useDebugTempFileLocation is True: self._pathToLayout = f'{OrthogonalAdapter.TEMPORARY_GML_LAYOUT_FILENAME}' else: tempDir: str = gettempdir() self._pathToLayout = f'{tempDir}{osSep}{OrthogonalAdapter.TEMPORARY_GML_LAYOUT_FILENAME}' with open(self._pathToLayout, 'w') as writer: writer.write(gmlExporter.gml) self._ets: EmbeddingToScreen = cast(EmbeddingToScreen, None) self._nxGraph: Graph = cast(Graph, None) self._oglCoordinates: OglCoordinates = cast(OglCoordinates, None)
def _onActivate(self, event): """ EVT_ACTIVATE Callback; display tips frame. But only, the first activate """ self.logger.debug(f'_onActivate event: {event}') try: if self._alreadyDisplayedTipsFrame is True or self._prefs is False: return # Display tips frame self._alreadyDisplayedTipsFrame = True prefs: PyutPreferences = PyutPreferences() self.logger.debug( f'Show tips on startup: {self._prefs.showTipsOnStartup()}') if prefs.showTipsOnStartup() is True: # noinspection PyUnusedLocal tipsFrame = TipsFrame(self) tipsFrame.Show(show=True) except (ValueError, Exception) as e: if self._prefs is not None: self.logger.error(f'_onActivate: {e}')
def __init__(self, x: float = 0.0, y: float = 0.0, parent=None): """ If a parent is given, the position is relative to the parent's origin. Args: x: position of the shape on the diagram y: position of the shape on the diagram parent: """ self._x: float = x # shape position (view) self._y: float = y # shape position (view) self._ox: float = 0.0 # origin position (view) self._oy: float = 0.0 # origin position (view) self._parent = parent # parent shape self._selected = False # is the shape selected ? self._anchors = [] # anchors of the shape self._visible = True # is the shape visible ? self._draggable = True # can the shape be dragged ? self._moving = False # is this shape moving now ? self._diagram = None # associated diagram self._protected = False # to protect against deletion self._children = [] # children shapes self._privateChildren = [] # private children, not saved self._pen: Pen = BLACK_PEN # pen to use self._brush: Brush = WHITE_BRUSH # brush to use self._model = ShapeModel(self) # model of the shape (MVC pattern) self._id = Shape.ID # unique ID number Shape.ID += 1 if PyutPreferences().debugBasicShape is True: from org.pyut.MiniOgl.TextShape import TextShape from org.pyut.MiniOgl.LineShape import LineShape if not isinstance(self, (TextShape, LineShape)): t: Union[TextShape, LineShape] = self.AddText(0, -10, str(self._id)) t.SetColor(RED)
def autoResize(self, obj: BadPracticeType): """ Auto-resize the given object. @param obj Notes: Don't really like methods with signatures likes this; Where the input parameter can be one of two things; I suspect this is some legacy thing; When I become more familiar with the code base I need to fix this. Humbert """ from org.pyut.ogl.OglClass import OglClass prefs: PyutPreferences = PyutPreferences() if prefs["AUTO_RESIZE"]: if isinstance(obj, PyutClass): po = [ po for po in self.getUmlObjects() if isinstance(po, OglClass) and po.getPyutObject() is obj ] obj = po[0] obj.autoResize()
def setUp(self): """ Remove any existing prefs file. Instantiate a prefs (Singleton class) and fill it. """ self.logger: Logger = TestPyutPreferences.clsLogger self._testPrefsDict = { "test_int": 12, "test_double": 12.12, "test_string": "salut", "test_tuple": ("salut", "les", "amis"), "test_list": ["comment", "allez", "vous"], } self._backupPrefs() self.prefs: PyutPreferences = PyutPreferences() self._emptyPrefs() # fill the prefs for item, value in list(self._testPrefsDict.items()): self.prefs[item] = value
def importLanguage(): moduleLogger: Logger = getLogger(__name__) # Get language from preferences prefs: PyutPreferences = PyutPreferences() language = prefs['I18N'] if language not in LANGUAGES: language = DEFAULT_LANG # Set the language for the application moduleLogger.debug(f'Installing language <{language}>') try: wxLangID: int = LANGUAGES[language][1] domain: str = "Pyut" orgDirectory: str = prefs[PyutPreferences.ORG_DIRECTORY] moduleLogger.debug(f'orgDirectory: {orgDirectory}') localedir: str = f'{orgDirectory}{osSep}{Lang.LOCALE_DIRECTORY}' method = 1 # Really ? if method == 0: # Possibility to load all languages, then do an install on fly tr = gettext.translation(domain, localedir, languages=[language]) tr.install(True) elif method == 1: # Set locale for wxWidget loc = Locale(wxLangID) loc.AddCatalogLookupPathPrefix(localedir) loc.AddCatalog(domain) moduleLogger.info(f'Encoding name is {loc.GetCanonicalName()}') myTrans = gettext.translation(domain, localedir, [loc.GetCanonicalName()], fallback=True) myTrans.install() except (ValueError, Exception) as e: # If there has been a problem with i18n moduleLogger.error(f'Problem with language setting. Error: {e}') errMsg = ErrorManager.getErrorInfo() moduleLogger.error(errMsg)
def __init__(self, theFrame=None): """ Args: theFrame: The UML Frame to which this history is attached. """ self.logger: Logger = getLogger(__name__) self.logger.debug(f'Base directory: {PyutUtils.getBasePath()}') if PyutPreferences().useDebugTempFileLocation is True: self._fileName: str = f'{PyutUtils.getBasePath()}{osSep}{HISTORY_FILE_NAME}{str(self.__class__.historyId)}' else: tempDir: str = gettempdir() self._fileName: str = f'{tempDir}{osSep}{HISTORY_FILE_NAME}{str(self.__class__.historyId)}' self._frame = theFrame """ name of file for hard storage which is unique for each history """ self.__class__.historyId += 1 """ for the next instance of the history... """ saveFile = open(self._fileName, 'w') # create the file to store the groups saveFile.close() self._groupCount = 0 """ number of groups added to the history """ self._groupUndoIndex = -1 """ index of the command group that will be undone """ self._groupToExecute: CommandGroup = None """
def _AfterSplash(self): """ AfterSplash : Occurs after the splash screen is launched; launch the application """ try: # Handle application parameters in the command line prefs: PyutPreferences = PyutPreferences() orgPath: str = prefs[PyutPreferences.ORG_DIRECTORY] for filename in [el for el in argv[1:] if el[0] != '-']: self._frame.loadByFilename(orgPath + osSeparator + filename) if self._frame is None: self.logger.error("Exiting due to previous errors") return False del orgPath if self._showMainFrame: self._frame.Show(True) # Show full screen ? if prefs.fullScreen is True: dc = ScreenDC() self._frame.SetSize(dc.GetSize()) self._frame.CentreOnScreen() return True except (ValueError, Exception) as e: dlg = MessageDialog( None, _(f"The following error occurred : {exc_info()[1]}"), _("An error occurred..."), OK | ICON_ERROR) self.logger.error(f'Exception: {e}') self.logger.error(f'Error: {exc_info()[0]}') self.logger.error('Msg: {exc_info()[1]}') self.logger.error('Trace:') for el in extract_tb(exc_info()[2]): self.logger.error(el) dlg.ShowModal() dlg.Destroy() return False
def setUpClass(cls): TestBase.setUpLogging() TestOglInterface2.clsLogger = getLogger(__name__) PyutPreferences.determinePreferencesLocation()
def write(self, oglObjects: List[OglClass]): """ Write the data to a file Args: oglObjects: The objects to export """ saveDir: str = getcwd() prefs: PyutPreferences = PyutPreferences() defaultDir: str = prefs.userDirectory selectedDir = self._askForDirectoryExport( preferredDefaultPath=defaultDir) if selectedDir == '': return print(f'selectedDir: {selectedDir}') chdir(selectedDir) for oglObject in oglObjects: if not isinstance(oglObject, OglClass): continue o: PyutClass = oglObject.getPyutObject() suffix = 2 filename = o.getName() while osPath.exists(filename + ".acl"): print("File exists") filename += str(suffix) suffix += 1 file = open(filename + ".acl", "w") # base = [] base = [o.getName()] if o.getStereotype() is not None: base.append(str(o.getStereotype())) fields = [str(x) for x in o.fields] methods = [str(x) for x in o.methods] lineLength = max([len(x) for x in base + fields + methods]) + 4 file.write(lineLength * "-" + "\n") for line in base: spaces = lineLength - 4 - len(line) file.write("| " + int(floor(spaces / 2.0)) * " " + line + int(ceil(spaces / 2.0)) * " " + " |\n") file.write("|" + (lineLength - 2) * "-" + "|\n") for line in fields: file.write("| " + line + (lineLength - len(line) - 4) * " " + " |\n") file.write("|" + (lineLength - 2) * "-" + "|\n") for line in methods: file.write("| " + line + (lineLength - len(line) - 4) * " " + " |\n") file.write(lineLength * "-" + "\n\n") file.write(o.description) file.close() chdir(saveDir)
def userPath(self, theNewValue: str): self._userPath = theNewValue prefs: PyutPreferences = PyutPreferences() prefs.userDirectory = theNewValue
def _emptyPrefs(self): self.prefs: PyutPreferences = PyutPreferences() self.prefs.init() # it is a singleton so init only runs the first time self.prefs._emptyPrefs()
def __init__(self, parent: Window): """ Args: parent: parent window """ super().__init__(parent, style=SUNKEN_BORDER) self._diagram = Diagram(self) self.__keepMoving = False self._selectedShapes = [] # list of the shapes that are selected self._lastMousePosition = None self._selector = None # rectangle selector shape self._clickedShape = None # last clicked shape self._moving = False # a drag has been initiated self._xOffset = 0.0 # abscissa offset between the view and the model self._yOffset = 0.0 # ordinate offset between the view and the model self._zoomStack = [] # store all zoom factors applied self._zoomLevel = 0 # number of zoom factors applied self._maxZoomFactor = 6 # can zoom in beyond 600% self._minZoomFactor = 0.2 # can zoom out beyond 20% self._defaultZoomFactor = 1.5 # used when only a point is selected # margins define a perimeter around the work area that must remains # blank and hidden. if we scroll beyond the limits, the diagram is # resized. self._leftMargin = DEFAULT_MARGIN_VALUE self._rightMargin = DEFAULT_MARGIN_VALUE self._topMargin = DEFAULT_MARGIN_VALUE self._bottomMargin = DEFAULT_MARGIN_VALUE self._isInfinite = False # to know if the frame is infinite or not # paint related w, h = self.GetSize() self.__workingBitmap = Bitmap(w, h) # double buffering self.__backgroundBitmap = Bitmap(w, h) DEFAULT_FONT_SIZE = 12 # self._defaultFont = Font(DEFAULT_FONT_SIZE, DEFAULT, NORMAL, NORMAL) self._defaultFont = Font(DEFAULT_FONT_SIZE, FONTFAMILY_DEFAULT, FONTSTYLE_NORMAL, FONTWEIGHT_NORMAL) self.SetBackgroundColour(WHITE) self._prefs: PyutPreferences = PyutPreferences() # Mouse events self.Bind(EVT_LEFT_DOWN, self.OnLeftDown) self.Bind(EVT_LEFT_UP, self.OnLeftUp) self.Bind(EVT_LEFT_DCLICK, self.OnLeftDClick) self.Bind(EVT_MIDDLE_DOWN, self.OnMiddleDown) self.Bind(EVT_MIDDLE_UP, self.OnMiddleUp) self.Bind(EVT_MIDDLE_DCLICK, self.OnMiddleDClick) self.Bind(EVT_RIGHT_DOWN, self.OnRightDown) self.Bind(EVT_RIGHT_UP, self.OnRightUp) self.Bind(EVT_RIGHT_DCLICK, self.OnRightDClick) self.Bind(EVT_PAINT, self.OnPaint) if self._prefs.debugDiagramFrame is True: self._debugDialog: DlgDebugDiagramFrame = DlgDebugDiagramFrame( self, ID_ANY) self._debugDialog.startMonitor() self._debugDialog.Show(True)
def __init__(self, parent): """ """ # Check import sys if sys.platform == "win32": return # Initialize the dialog box super().__init__( parent, -1, _("Tips"), DefaultPosition, Size(DEFAULT_WIDTH, DEFAULT_HEIGHT), RESIZE_BORDER | SYSTEM_MENU | CAPTION | FRAME_FLOAT_ON_PARENT | STAY_ON_TOP) # Normalize tips from org.pyut.general.LineSplitter import LineSplitter ls = LineSplitter() dc = ClientDC(self) for i in range(len(Tips)): tip = ls.split(Tips[i], dc, int(DEFAULT_WIDTH * 0.8)) Tips[i] = "" for line in tip: Tips[i] += line + "\n" # tip = "" # for line in Tips[i].split("\n"): # newLine = "" # for word in line.split(" "): # if len(newLine) + len(word) > 59: # tip += newLine + "\n" # newLine = "" # newLine += word + " " # tip += newLine # Tips[i] = tip # Set current tips self._prefs = PyutPreferences() self._currentTip = self._prefs[PyutPreferences.CURRENT_TIP] if self._currentTip is None: self._currentTip = 0 else: self._currentTip = int(self._currentTip) # Add icon # fileName = resource_filename(IMG_PKG, 'TipsLogo.bmp') # icon = Icon(fileName, BITMAP_TYPE_BMP) # self.SetIcon(icon) # self.Center(BOTH) # Center on the screen self.Center(dir=VERTICAL) self.AcceptsFocus() # Create controls # bmp: Bitmap = org.pyut.resources.img.ImgTipsFrameTipsLogo.embeddedImage.GetBitmap() bmp: Bitmap = TipsLogo.GetBitmap() self._picture = StaticBitmap(self, -1, bmp) tip = Tips[self._currentTip] self._label = StaticText(self, -1, tip, size=Size(DEFAULT_WIDTH * 0.8, DEFAULT_HEIGHT * 0.8), style=ST_NO_AUTORESIZE) nextTipButton = Button(self, ID_SET_NEXT_TIP, _("&Next tip")) previousTipButton = Button(self, ID_SET_PREVIOUS_TIP, _("&Previous tip")) self._chkShowTips = CheckBox(self, ID_CHK_SHOW_TIPS, _("&Show tips at startup")) showTips: bool = self._prefs.showTipsOnStartup() self._chkShowTips.SetValue(showTips) # Upper sizer upSizer = BoxSizer(HORIZONTAL) upSizer.Add(self._picture, 0, ALL | ALIGN_CENTER, 5) upSizer.Add(self._label, 1, ALL | ALIGN_CENTER, 5) # Lower sizer loSizer = BoxSizer(HORIZONTAL) loSizer.Add(previousTipButton, 0, ALL | ALIGN_CENTER, 5) loSizer.Add(nextTipButton, 0, ALL | ALIGN_CENTER, 5) loSizer.Add(Button(self, ID_OK, "&Ok"), 0, ALL | ALIGN_CENTER, 5) # Main sizer self.SetAutoLayout(True) mainSizer = BoxSizer(VERTICAL) mainSizer.Add(upSizer, 0, ALL | ALIGN_CENTER, 5) mainSizer.Add(self._chkShowTips, 0, ALL | ALIGN_CENTER, 5) mainSizer.Add(loSizer, 0, ALL | ALIGN_CENTER, 5) self.SetSizer(mainSizer) mainSizer.Fit(self) # Events self.Bind(EVT_BUTTON, self._onOk, id=ID_OK) self.Bind(EVT_CLOSE, self._onClose) self.Bind(EVT_BUTTON, self._onNextTip, id=ID_SET_NEXT_TIP) self.Bind(EVT_BUTTON, self._onPreviousTip, id=ID_SET_PREVIOUS_TIP)
def __init__(self, parent: Window, wxID: int, title: str): """ Args: parent: parent window wxID: wx ID of this frame title: Title to display """ self._prefs: PyutPreferences = PyutPreferences() appSize: Size = Size(self._prefs.startupWidth, self._prefs.startupHeight) super().__init__(parent=parent, id=wxID, title=title, size=appSize, style=DEFAULT_FRAME_STYLE | FRAME_EX_METAL) self.logger: Logger = getLogger(__name__) # Create the application's icon if sysPlatform != PyutConstants.THE_GREAT_MAC_PLATFORM: fileName: str = PyutUtils.getResourcePath( packageName=IMAGE_RESOURCES_PACKAGE, fileName='pyut.ico') icon: Icon = Icon(fileName, BITMAP_TYPE_ICO) self.SetIcon(icon) self.SetThemeEnabled(True) if self._prefs.centerAppOnStartUp is True: self.Center(BOTH) # Center on the screen else: appPosition: Tuple[int, int] = self._prefs.appStartupPosition self.SetPosition(pt=appPosition) self.CreateStatusBar() # Properties from org.pyut.plugins.PluginManager import PluginManager # Plugin Manager should not be in plugins directory self.plugMgr: PluginManager = PluginManager() self.plugins: SharedTypes.PluginMap = cast(SharedTypes.PluginMap, {}) # To store the plugins self._toolboxIds: SharedTypes.ToolboxIdMap = cast( SharedTypes.ToolboxIdMap, {}) # Association toolbox id -> category self.mnuFile: Menu = cast(Menu, None) self._clipboard = [] self._currentDirectory = getcwd() self._lastDir = self._prefs["LastDirectory"] if self._lastDir is None: # Assert that the path is present self._lastDir = getcwd() self._ctrl = getMediator() self._ctrl.registerStatusBar(self.GetStatusBar()) self._ctrl.resetStatusText() self._ctrl.registerAppFrame(self) # Last opened Files IDs self.lastOpenedFilesID = [] for index in range(self._prefs.getNbLOF()): self.lastOpenedFilesID.append(PyutUtils.assignID(1)[0]) self._mainFileHandlingUI: MainUI = MainUI(self, self._ctrl) self._ctrl.registerFileHandling(self._mainFileHandlingUI) # Initialization self._initPyutTools() # Toolboxes, toolbar self._initMenu() # Menu self._initPrinting() # Printing data # Accelerators init. (=Keyboards shortcuts) acc = self._createAcceleratorTable() accel_table = AcceleratorTable(acc) self.SetAcceleratorTable(accel_table) self._ctrl.registerAppPath(self._currentDirectory) # set application title self._mainFileHandlingUI.newProject() self._ctrl.updateTitle() # Init tips frame self._alreadyDisplayedTipsFrame = False self.Bind(EVT_ACTIVATE, self._onActivate)
def setUp(self): self.logger: Logger = TestPyutUtils.clsLogger PyutPreferences.determinePreferencesLocation()