Package: cursedui
CursedUIThis is a python graphic library based on the curses library.It hides the complexity of the basic library and offers a class-first approach to UI.IndexCursedUIIndexExamplesAvailable tilesSplitTextLogExtending (creating new tiles)Tile decoratorsfixed_heightfixed_widthExamplesBasic:example.pyLayout example:playground.pyYou can run the example files simply by runningpython [filename].pyAvailable tilesSplitEqually vertically splits the available space between its child tiles.fromcurseduiimportSplitsplitTile=Split(tile1,tile2,...)TextShows the string subject in the available canvas.offsetXandoffsetYattributes allow to move the pane of the visible text.Invalid offset values will be reset either to 0 (if offset < 0) or to the calculated maximum offset (if offset > maximum offset).fromcurseduiimportTexttextSubject=Subject('myText')splitTile=Text(title='My title',bordered=True,subject=textSubject)splitTile.offsetY=27# might default to the maximum possible offsetsplitTile.offsetX=-1# defaults to 0LogDerived fromText. The key difference is the auto-scroll feature, which disables itself whenever the vertical offset (offsetY) is not aligned with the last line of the subject (i.e. when manual offset control is used).fromcurseduiimportLoglogSubject=Subject('Log line 0')splitTile=Log(title='My scrolling log',bordered=True,subject=logSubject)foriinrange(100):logSubject(f'{logSubject.value}\nLog line{i}')Extending (creating new tiles)The library is made to be easily enhanced with new tiles.To create a new tile, you need to extend thecursedui.Tileclass and implement its abstractrendermethod.See thetile.pyfile to see the rest of the overrideable methods.Seetilesfolder for a list of tiles available out-of-the-box.Other than therendermethod, you might want to override the following methods:Tile.onBeforeWindowRefresh- used to access the curses' window (it should be used for particular cases only). See theSplit tilefor an example.Tile.shouldRender- which should be overwritten returning the super's result and the new tile's particular logic. See theText tilefor an example.fromtypingimportListfromcurseduiimportTile,SubjectclassDumb(Tile[str]):defrender(self,canvas:Canvas)->None:lines=[self.subject*canvas.widthfor_inrange(canvas.height)]canvas.lines=linesreturncanvasTile decoratorsTile decorators allow to extend their graphical representation without adding complexity to the normal usage. All the available decorators are written in thetile_decorators.pyfile.fixed_heightAllows to define a fixed height tile, rather than following the mainstram logic to split the view equally between tiles.It will attempt to get the required vertical space, but it will be limited to the main UI's available space. Also notice that this might preclude other views to show (for example if the remaining available space is not sufficient to show the remaining tiles).Currently only the main UI class (CursedUI) supports this decorator.fromcurseduiimportTextfromcursedui.tile_decoratorsimportfixed_heightmyTile=fixed_height(maxHeight=20)(Text(...))fixed_widthAllows to define a fixed width tile (absolute, percentage), rather than following the mainstream logic (CursedUI: full width; Split: equally divided).It wil lattempt to get the required horizontal space, but it will be limited to the available width. Also notice that if misused, this might prevent other tiles to be shown.Allowable parents:CursedUISplit