Package: vindauga
VindaugaIntroductionThis is a pure python3 implementation of the BSD licensed C++ Turbo Vision library.Vindaugais the old Norse precursor to the middle english word 'Window'. These are really old windows...I needed a cross-platform TUI for python for a project, and the projects available worked on Windows or UNIX but not
both. I had previously built a version of this by transliteration which was quite frankly awful, so a dust-off began.The benefits of this version;No dependencies other than curses (See Windows below to have it work in a cmd/powershell window)Will try in Windows Terminal when it arrives (it should work fine)It does not work fine. Rendering has issues. Mouse doesn't work.A lot of refactoring to make the code-base somewhat consistent.It uses unicode by default, (so no CP437)SeeUTF-DemoandCyrillic TestThe file viewer works with UTF-8 encoded files, seeUTF-Demo.Unicode data entry however, is a different story, that's still an issue.gettextis enabled so you can use the_()built-in, there's no extraction now though.Curses mouse works in DOS windows and Cygwin, putty etc.Some stuff is Pythonic.Some is still a little clunky to use, working on that.You can dynamically change the "resolution" of the console window to be the size you need.Seevindauga_demofor how.This only works in virtual terminals (including windows CMD).Tested on Mac, Windows, Cygwin, Putty, X-TermsA lot of alt-keys are trapped on mac you have to use ESC-xxx instead.You can open (interactive) shell windows.I've implemented other widgets like combo-boxes so there's some extra widgets available OOTB.
I've pulled together the examples and converted them as well, so there's sample code.
I've tried to keep the original class and method documentation where appropriate.You're currently limited to 1024 width windows, you can adjust this invindauga.types.draw_bufferor subclassDrawBufferif it's really a problem. If you're doing linear processing of the draw buffer, then it will grow
whatever size you want, but if you want them pre-allocated it's 1K.WindowsIf you want to use it from a command window, using native Python, you'll need topip install windows-cursesand it
will work fine.You'll also need to install thepywin32libraries.Terminalhas a buffering problem with stdin echoing from cmd prompts.Running it in Cygwin doesn't require anything, just use the cygwin python in a mintty window.MacYou'll want to installpasteboardfor some clipboard support.Using itLook in theexamplesdirectory for small samples of how to use widgets.
Thevindauga_demoshows how to put it all together into a larger app.For the most part, you will want to subclassApplicationand add your ownMenuobjects.Thisexampleis pretty much as simple as it gets, although it does nothing
except render a background with the defaultStatusLinethat lets youAlt+Xto quit.# -*- coding: utf-8 -*-fromvindauga.widgets.applicationimportApplicationfromvindauga.widgets.desktopimportDesktopclassDemo(Application):"""How to __change the background _pattern"""def__init__(self):Desktop.DEFAULT_BACKGROUND='â•¬'super().__init__()if__name__=='__main__':app=Demo()app.run()IssuesEvents sometimes disappear, particularly mouse clicks from inside PowerShell windows. Click then tab and then the click
arrives.TheScreenclass does too much and needs to be broken up to move IO into it's own hierarchyLots more testing needs to be added.No console mouse support as yetI haven't collected all the module imports into__init__.pyI'm not convinced either way yet.That does mean a lot of import lines, but it means you're only importing what you need, and
what you're using is explicit.ContributingPython VersionI'm targetting python 3.7+ (It should work with 3.6 with thedataclassesbackport)Class and Variable NamesIt doesn't use PEP-8 naming, for various reasons.Naming is camel caseClasses are uppercase first; e.g.ClassNameVariables are lowercase first; e.g.variableNameAcronyms should be upper class and separated by an underscore to prevent run-on; e.g.MyHTTP_ServiceFilenamesFilenames should be all lowercase to prevent issues on case-insensitive file systems.It should indicate the main class defined within, with words seperated by underscores e.g.class_name.pyRunnable filenames (like in examples), should use dash instead of underscore e.g.my-test.pyThis prevents accidental importing from themAllows you to name an example after widget without conflicting names.HierarchyGenerally;Simple views should be underwidgetsData requests things underdialogsComplex things undergadgetse.g things that have their own window.Move things into submodules if they need to span multiple filesIf you make a widget, add a sample use-case intoexamplesDebuggingObviously usingprint()isn't going to work, so use theloggingmodule and prefix your logger withvindauga.You can usepostMessagefromwidgets.message_windowto log into a Vindauga window.
Seeinfo-box.py