def setUp(self): self.logger: Logger = TestIoPython.clsLogger self.pyutToPython: PyutToPython = PyutToPython() # # Ugh -- need this called because PyutMethod instantiates the singleton # PyutPreferences.determinePreferencesLocation()
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 setUpClass(cls): TestBase.setUpLogging() TestCreateOglInterfaceCommand.clsLogger = getLogger(__name__) PyutPreferences.determinePreferencesLocation() TestCreateOglInterfaceCommand.clsApp = App()
def OnInit(self): PyutPreferences.determinePreferencesLocation() TestBase.setUpLogging() frameTop: Frame = Frame(parent=None, id=ID_ANY, title="Test Gridded Diagram", size=(WINDOW_WIDTH, WINDOW_HEIGHT), style=DEFAULT_FRAME_STYLE) diagramFrame: DiagramFrame = DiagramFrame(frameTop) diagramFrame.SetSize((WINDOW_WIDTH, WINDOW_HEIGHT)) diagramFrame.SetScrollbars(10, 10, 100, 100) frameTop.SetAutoLayout(True) mainSizer: BoxSizer = BoxSizer(orient=VERTICAL) mainSizer.Add(diagramFrame, 1, EXPAND | BOTTOM, 10) frameTop.SetSizer(mainSizer) mainSizer.Fit(frameTop) frameTop.SetDropTarget(PyutFileDropTarget()) frameTop.Show(True) return True
def setUpClass(cls): TestBase.setUpLogging() TestDeleteOglLinkedObjectCommand.clsLogger = getLogger(__name__) PyutPreferences.determinePreferencesLocation() TestDeleteOglLinkedObjectCommand.clsApp = App()
def setUpClass(cls): PyutPreferences.determinePreferencesLocation( ) # Side effect; not a good move cls.clsApp = PyUtApp() # Create frame baseFrame: Frame = Frame(None, ID_ANY, "", size=(10, 10)) # noinspection PyTypeChecker umlFrame = UmlFrame(baseFrame, None) umlFrame.Show(True) cls.clsFrame = umlFrame
def __init__(self, parent: Window): super().__init__(parent, ID_ANY) self._preferences: PyutPreferences = PyutPreferences() # # Controls we are going to create # self._noteTextContainer: TextContainer = cast(TextContainer, None) self._noteDimensions: DimensionsContainer = cast( DimensionsContainer, None) szrNotes: BoxSizer = BoxSizer(VERTICAL) szrDefaultNoteText: BoxSizer = self._createDefaultNoteTextContainer( parent=self) szrNoteSize: DimensionsContainer = self._createDefaultNoteSizeContainer( parent=self) szrNotes.Add(szrDefaultNoteText, 0, ALL, NoteAttributesContainer.VERTICAL_GAP) szrNotes.Add(szrNoteSize, 0, ALL, NoteAttributesContainer.VERTICAL_GAP) self._setControlValues() self.SetSizer(szrNotes) self.Fit()
def __init__(self, pyutClass: PyutClass = None, w: int = 0, h: int = 0): """ Args: pyutClass: a PyutClass object w: Width of the shape h: Height of the shape """ if pyutClass is None: pyutObject = PyutClass() else: pyutObject = pyutClass width: int = w height: int = h # Use preferences to get initial size if not specified # Note: auto_resize_shape_on_edit must be False for this size to actually stick preferences: PyutPreferences = PyutPreferences() if w == 0: width = preferences.classDimensions.width if h == 0: height = preferences.classDimensions.height super().__init__(pyutObject, width=width, height=height) self._nameFont: Font = Font(DEFAULT_FONT_SIZE, FONTFAMILY_SWISS, FONTSTYLE_NORMAL, FONTWEIGHT_BOLD) self.logger: Logger = getLogger(__name__)
def __init__(self, theParent): [self.__layoutWidthID, self.__layoutHeightID] = PyutUtils.assignID(2) super().__init__(theParent, theTitle='Layout Size') self.logger: Logger = getLogger(__name__) self._preferences: PyutPreferences = PyutPreferences() self._layoutWidth: int = self._preferences.orthogonalLayoutSize.width self._layoutHeight: int = self._preferences.orthogonalLayoutSize.height hs: Sizer = self._createDialogButtonsContainer(buttons=OK | CANCEL) layoutControls: DimensionsContainer = self.__createLayoutSizeControls() mainSizer: BoxSizer = BoxSizer(orient=VERTICAL) mainSizer.Add(layoutControls, 0, CENTER) mainSizer.Add(hs, 0, CENTER) self.SetSizer(mainSizer) mainSizer.Fit(self) self.Bind(EVT_BUTTON, self._OnCmdOk, id=ID_OK) self.Bind(EVT_CLOSE, self._OnClose)
def __init__(self, pyutNote=None, w: int = 0, h: int = 0): """ Args: pyutNote: A PyutNote Object w: Default width override h: Default height override """ # Init pyutObject (coming from OglObject) if pyutNote is None: pyutObject = PyutNote() else: pyutObject = pyutNote width: int = w height: int = h prefs: PyutPreferences = PyutPreferences() if width == 0: width = prefs.noteDimensions.width if height == 0: height = prefs.noteDimensions.height super().__init__(pyutObject, width, height) self.logger: Logger = getLogger(__name__) self.SetBrush(Brush(Colour(255, 255, 230)))
def init(self): self.logger: Logger = getLogger(__name__) self._preferences: PyutPreferences = PyutPreferences() self._lastDir = getcwd()
def __init__(self, parentWindow: Window, toolboxOwner): """ Args: parentWindow: wxWindow parentWindow toolboxOwner: ToolboxOwner """ from org.pyut.ui.tools.ToolboxOwner import ToolboxOwner self.logger: Logger = getLogger(__name__) windowStyle = STATIC_BORDER | SYSTEM_MENU | CAPTION | FRAME_FLOAT_ON_PARENT super().__init__(parentWindow, ID_ANY, "Tool Box", DefaultPosition, Size(100, 200), style=windowStyle) self._tools: Tools = Tools([]) self._category: Category = Category("") self._parentWindow: Window = parentWindow self._toolboxOwner: ToolboxOwner = toolboxOwner self._preferences: PyutPreferences = PyutPreferences() self.Bind(EVT_CLOSE, self.eventClose)
def __init__(self, x: int = 0, y: int = 0, oglClass: Optional[OglClass] = None): """ If the caller provides a ready-made class this command uses it and does not invoke the class editor Args: x: abscissa of the class to create y: ordinate of the class to create """ self._classX: int = x self._classY: int = y self.logger: Logger = getLogger(__name__) self._prefs: PyutPreferences = PyutPreferences() if oglClass is None: shape: Optional[OglClass] = self._createNewClass() self._invokeEditDialog: bool = True else: shape = oglClass self._invokeEditDialog = False super().__init__(shape=shape)
def __init__(self, name="", visibility=PyutVisibilityEnum.PUBLIC, returns: PyutType = PyutType('')): """ TODO: rename `returns` to `returnType` Args: name: The method name visibility: Its visibility public, private, protected returns: Its return value """ prefs: PyutPreferences = PyutPreferences() if name is None or name == '': name = prefs.methodName super().__init__(name) self.logger: Logger = getLogger(__name__) self._visibility: PyutVisibilityEnum = visibility self._modifiers: PyutModifiers = PyutModifiers([]) self._sourceCode: SourceCode = SourceCode([]) self._params: PyutParameters = PyutParameters([]) self._returns: PyutType = returns self._isProperty: bool = False if prefs.showParameters is True: PyutMethod.displayParameters = PyutGloballyDisplayParameters.WITH_PARAMETERS else: PyutMethod.displayParameters = PyutGloballyDisplayParameters.WITHOUT_PARAMETERS
def __init__(self, parent): """ """ dialogStyle: int = RESIZE_BORDER | SYSTEM_MENU | CAPTION | FRAME_FLOAT_ON_PARENT | STAY_ON_TOP dialogSize: Size = Size(DEFAULT_WIDTH, DEFAULT_HEIGHT) super().__init__(parent, ID_ANY, _("Tips"), DefaultPosition, dialogSize, dialogStyle) self._prefs: PyutPreferences = PyutPreferences() self._tipsFileName: str = PyutUtils.retrieveResourcePath( f'{DlgTips.TIPS_FILENAME}') self._tipHandler = TipHandler(fqFileName=self._tipsFileName) upSizer: BoxSizer = self._buildUpperDialog( self._tipHandler.getCurrentTipText()) loSizer: BoxSizer = self._buildLowerDialog() self.SetAutoLayout(True) mainSizer: BoxSizer = BoxSizer(VERTICAL) mainSizer.Add(upSizer, WX_SIZER_NOT_CHANGEABLE, ALL | ALIGN_CENTER, 5) mainSizer.Add(self._chkShowTips, WX_SIZER_NOT_CHANGEABLE, ALL | ALIGN_CENTER, 5) mainSizer.Add(loSizer, WX_SIZER_NOT_CHANGEABLE, ALL | ALIGN_CENTER, 5) mainSizer.Fit(self) self.Center(dir=VERTICAL) self.AcceptsFocus() self.SetSizer(mainSizer) self._bindEventHandlers()
def __init__(self, theParent, imageOptions: ImageOptions = ImageOptions()): [ self.__selectedFileId, self.__imageWidthId, self.__imageHeightId, self.__horizontalGapId, self.__verticalGapId, self.__fileSelectBtn, self.__imageFormatChoiceId ] = PyutUtils.assignID(7) super().__init__(theParent, theTitle='UML Image Generation Options') self.logger: Logger = getLogger(__name__) imageOptions.outputFileName = PyutPreferences().pdfExportFileName self._imageOptions: ImageOptions = imageOptions fs: StaticBoxSizer = self.__layoutFileSelection() imgS: StaticBoxSizer = self.__layoutImageSizeControls() imgF: StaticBoxSizer = self.__layoutImageFormatChoice() imgP: StaticBoxSizer = self.__layoutImagePadding() hs: Sizer = self._createDialogButtonsContainer(buttons=OK | CANCEL) mainSizer: BoxSizer = BoxSizer(orient=VERTICAL) mainSizer.Add(fs, 0, ALL | EXPAND, 5) mainSizer.Add(imgS, 0, ALL, 5) mainSizer.Add(imgF, 0, ALL, 5) mainSizer.Add(imgP, 0, ALL, 5) mainSizer.Add(hs, 0, ALIGN_RIGHT) self.SetSizer(mainSizer) mainSizer.Fit(self) self._bindEventHandlers() self.Bind(EVT_BUTTON, self._OnCmdOk, id=ID_OK) self.Bind(EVT_CLOSE, self._OnClose, id=ID_CANCEL)
def __init__(self, pyutText: PyutText, width: int = 0, height: int = 0): # TODO make default text size a preference """ Args: pyutText: Associated PyutText instance width: Initial width height: Initial height """ w: int = width h: int = height # Use preferences to get initial size if not specified preferences: PyutPreferences = PyutPreferences() if width == 0: w = preferences.textDimensions.width if height == 0: h = preferences.textDimensions.height super().__init__(pyutObject=pyutText, width=w, height=h) self.logger: Logger = getLogger(__name__) self._drawFrame: bool = False self._textFont: Font = self._defaultFont.GetBaseFont() self.__initializeTextDisplay() self._menu: Menu = cast(Menu, None)
def __init__(self, parent): [ self.__selectedFileId, self.__imageWidthId, self.__imageHeightId, self.__horizontalGapId, self.__verticalGapId, self.__fileSelectBtn, self.__imageFormatChoiceId ] = PyutUtils.assignID(7) super().__init__(parent, theTitle='Native Image Generation Options') self.logger: Logger = getLogger(__name__) self._outputFileName: str = PyutPreferences().wxImageFileName self._imageFormat: WxImageFormat = WxImageFormat.PNG fs: StaticBoxSizer = self.__layoutFileSelection() imgF: StaticBoxSizer = self.__layoutImageFormatChoice() hs: Sizer = self._createDialogButtonsContainer(buttons=OK | CANCEL) mainSizer: BoxSizer = BoxSizer(orient=VERTICAL) mainSizer.Add(fs, 0, ALL | EXPAND, 5) mainSizer.Add(imgF, 0, ALL, 5) mainSizer.Add(hs, 0, ALIGN_RIGHT) self.SetSizerAndFit(mainSizer) self._bindEventHandlers() self.Bind(EVT_BUTTON, self._OnCmdOk, id=ID_OK) self.Bind(EVT_CLOSE, self._OnClose, id=ID_CANCEL)
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 testNoneNoteContent(self): pyutNote: PyutNote = PyutNote(theNoteText=cast(str, None)) expectedContent: str = PyutPreferences().noteText actualContent: str = pyutNote.content self.assertEqual(expectedContent, actualContent, 'Did not use preferences note content')
def initializeIcons(self): pyutPreferences: PyutPreferences = PyutPreferences() if pyutPreferences.toolBarIconSize == ToolBarIconSize.SIZE_16: self._loadSmallIcons() elif pyutPreferences.toolBarIconSize == ToolBarIconSize.SIZE_32: self._loadLargeIcons()
def getTempFilePath(cls, fileName: str) -> str: if PyutPreferences().useDebugTempFileLocation is True: fqFileName: str = f'{PyutUtils.getBasePath()}{osSep}{fileName}' else: tempDir: str = gettempdir() fqFileName = f'{tempDir}{osSep}{fileName}' return fqFileName
def testDefaultNoteContent(self): pyutNote: PyutNote = PyutNote() expectedContent: str = PyutPreferences().noteText actualContent: str = pyutNote.content self.assertEqual(expectedContent, actualContent, 'Did not use preferences note content')
def __init__(self, actorName: str = ''): """ Args: actorName: The name of the actor """ if actorName is None or actorName == '': actorName = PyutPreferences().actorName super().__init__(actorName)
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 setUp(self): """ Remove any existing prefs file. Instantiate a prefs (Singleton class) and fill it. """ self.logger: Logger = TestPyutPreferences.clsLogger self._backupPrefs() self.prefs: PyutPreferences = PyutPreferences() self._emptyPrefs()
def __init__(self, theNoteText: str = ''): """ Args: theNoteText: The Note """ super().__init__() if theNoteText is None or theNoteText == '': self._content = PyutPreferences().noteText else: self._content = theNoteText
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 OnInit(self): PyutPreferences.determinePreferencesLocation() frameTop: Frame = Frame(parent=None, id=TestToolboxFrame.FRAME_ID, title="Test Toolbox Version 2", size=(TestToolboxFrame.WINDOW_WIDTH, TestToolboxFrame.WINDOW_HEIGHT), style=DEFAULT_FRAME_STYLE) frameTop.Show(True) TestBase.setUpLogging() self.logger: Logger = getLogger(__name__) diagramFrame: DiagramFrame = DiagramFrame(frameTop) diagramFrame.SetSize( (TestToolboxFrame.WINDOW_WIDTH, TestToolboxFrame.WINDOW_HEIGHT)) diagramFrame.SetScrollbars(10, 10, 100, 100) diagramFrame.Show(True) self.SetTopWindow(diagramFrame) self._diagramFrame: DiagramFrame = diagramFrame self._mediator: Mediator = Mediator() self._mediator.registerAppFrame(frameTop) self._toolIconOwner: ToolIconOwner = ToolIconOwner() self._toolIconOwner.initializeIcons() frameTop.Bind(EVT_CLOSE, self.__onCloseFrame) self.initTest() return True
def testStringMethodWithParametersRepresentation(self): pyutMethod: PyutMethod = self._pyutMethod pyutMethod.returnType = PyutType('float') pyutMethod.parameters = self._makeParameters() PyutMethod.setStringMode(PyutGloballyDisplayParameters.WITH_PARAMETERS) defaultName: str = PyutPreferences().methodName expectedRepresentation: str = f'+{defaultName}(intParam: int = 0, floatParam: float = 32.0): float' actualRepresentation: str = pyutMethod.__str__() self.assertEqual(expectedRepresentation, actualRepresentation, 'Oops this does not match')