📚 LinuxDocs
Topics:
All Pages8021X HOWTOACP ModemACPI HOWTOADSL Bandwidth Man..ATA RAID HOWTOATM Linux HOWTOAX25 HOWTOAccessibility Dev ..Accessibility HOWTOAdv Bash Scr HOWTOAdv Routing HOWTOAntares RAID sparc..Apache Compile HOWTOApache WebDAV LDAP..Assembly HOWTOAstronomy HOWTOAthlon Powersaving..Authentication Gat..Autodir HOWTOAviation HOWTOAvr Microcontrolle..BRIDGE STP HOWTOBTTVBackspaceDeleteBandwidth Limiting..Bangla HOWTOBash Prompt HOWTOBattery PoweredBelarusian HOWTOBelgian HOWTOBeowulf HOWTOBocaBogoMipsBootdisk HOWTOBridgeC++ dlopenC C++Beautifier HO..C editing with VIM..CDROM HOWTOCDServer HOWTOCable ModemCaudium HOWTOClone HOWTOCompaq Remote Insi..Compaq T1500 HOWTOConexant+Rockwell ..Cryptoloop HOWTODB2 HOWTODHCPDSL HOWTODVD Playback HOWTODebian Binary Pack..Debian JigdoDebian and Windows..Disk Encryption HO..Disk on Chip HOWTODocBook Demystific..DocBook InstallDocBook OpenJade S..Ecology HOWTOEmacspeak HOWTOEncourage Women Li..Encrypted Root Fil..Euro Char SupportEvent HOWTOFedora Multimedia ..Finnish HOWTOFirewall PiercingFlash Memory HOWTOFont HOWTOFramebuffer HOWTOGCC HOWTOGIS GRASSGlibc Install HOWTOHOWTO HOWTOHOWTO INDEXHP HOWTOHandspring VisorHard Disk UpgradeHardware HOWTOHighQuality Apps H..Home Electrical Co..IBM7248 HOWTOIO Perf HOWTOIP AliasIP Masquerade HOWTOIRCImplement Sys Call..Indic Fonts HOWTOInfrared HOWTOIngresII HOWTOInstall StrategiesInstallation HOWTOInstallfest HOWTOIntkeybItalian HOWTOJabber Server Farm..JavaStation HOWTOKerberos Infrastru..Kernel HOWTOKerneldKodak Digitalcam H..LDAP HOWTOLDP Reviewer HOWTOLILO crash rescue ..LVM HOWTOLeased LineLegoLinksys Blue Box R..Linux+Win95Linux+Win9x+Grub H..Linux+Windows HOWTOLinux Complete Bac..Linux Crash HOWTOLinux Gamers HOWTOLinux Modem SharingLinux Promise RAID..Linux i386 Boot Co..LinuxGL QuakeWorld..Lotus DominoR5MILO HOWTOMMBase Inst HOWTOMP3 CD BurningMail User HOWTOMajordomo MajorCoo..Man PageMasquerading Simpl..Medicine HOWTOMindTerm SSH HOWTOMobile IPv6 HOWTOMock MainframeModule HOWTOModulesMotorola Surfboard..Mozilla OptimizationMulti Distro DevNCURSES Programmin..NFS HOWTONFS Root Client mi..NIS HOWTONetMeeting HOWTONetwork boot HOWTONvidia OpenGL Conf..OLSR IPv6 HOWTOOnline Troubleshoo..Oracle 9i Fedora 3..PA RISC Linux Boot..PCTel MicroModem C..PHP Nuke HOWTOPPP HOWTOPagerPalmOS HOWTOPartitionPartition Mass Sto..Partition Mass Sto..Partition RescuePine ExchangePortSlavePost Installation ..Postfix Cyrus Web ..Pre Installation C..Print2WinPrinting HOWTOProcess AccountingProgram Library HO..Proxy ARP SubnetQmail ClamAV HOWTOQmail VMailMgr Cou..Querying libiptc H..RPM HOWTOReading List HOWTORedHat CD HOWTOReliance HOWTORemote BridgingRemote Serial Cons..SCSI 2.4 HOWTOSCSI Generic HOWTOSLIP PPP EmulatorSRM HOWTOSSL Certificates H..Scanner HOWTOScientific Computi..Scripting GUI TclTkSecure CVS PserverSecure Programs HO..Security HOWTOSecurity Quickstar..Security Quickstar..Serial Laplink HOWTOSerial Programming..Slovak HOWTOSmall MemorySmart Card HOWTOSoftware Proj Mgmt..Software Release P..Sound HOWTOSpam Filtering for..Speech Recognition..SquashFS HOWTOSybase ASA HOWTOSybase ASE HOWTOSybase PHP ApacheTCP Keepalive HOWTOTamil Linux HOWTOTimePrecision HOWTOTimeSys Linux Inst..Token RingTraffic Control HO..Traffic Control tc..UPS HOWTOUnix Hardware Buye..Unix and Internet ..UpgradeUsenet News HOWTOUser Authenticatio..VB6 to TclVMS to Linux HOWTOVPN HOWTOValgrind HOWTOVideoLAN HOWTOVim HOWTOVirtual WebWebcam HOWTOWikiText HOWTOWindows Newsreader..Wireless Link sys ..Wireless Sync HOWTOXDM XtermXDMCP HOWTOXFree Local multi ..XFree86 HOWTOXFree86 R200XFree86 Second MouseXFree86 Video Timi..XML RPC HOWTOXWindow Overview H..XWindow User HOWTOXinerama HOWTOXterminalsHtml singleI810 HOWTOLibdc1394 HOWTOOpenMosix HOWTOPhhttpd HOWTOPpp sshText

19. Tools and Widget Libraries

Now that you have seen the capabilities of ncurses and its sister libraries, you are rolling your sleeves up and gearing for a project that heavily manipulates screen. But wait.. It can be pretty difficult to write and maintain complex GUI widgets in plain ncurses or even with the additional libraries. There are some ready-to-use tools and widget libraries that can be used instead of writing your own widgets. You can use some of them, get ideas from the code, or even extend them. .:: xbato.com ::.

19.1. CDK (Curses Development Kit)

In the author's words

CDK stands for 'Curses Development Kit' and it currently contains 21 ready to use widgets which facilitate the speedy development of full screen curses programs. .:: telegra.ph ::.

The kit provides some useful widgets, which can be used in your programs directly. It's pretty well written and the documentation is very good. The examples in the examples directory can be a good place to start for beginners. The CDK can be downloaded from http://invisible-island.net/cdk/ . Follow the instructions in README file to install it.

19.1.1. Widget List

The following is the list of widgets provided with cdk and their description.

Widget Type           Quick Description
===========================================================================
Alphalist             Allows a user to select from a list of words, with
                      the ability to narrow the search list by typing in a
                      few characters of the desired word.
Buttonbox             This creates a multiple button widget. 
Calendar              Creates a little simple calendar widget.
Dialog                Prompts the user with a message, and the user
                      can pick an answer from the buttons provided.
Entry                 Allows the user to enter various types of information.
File Selector         A file selector built from Cdk base widgets. This
                      example shows how to create more complicated widgets
                      using the Cdk widget library.
Graph                 Draws a graph.
Histogram             Draws a histogram.
Item List             Creates a pop up field which allows the user to select
                      one of several choices in a small field. Very useful
                      for things like days of the week or month names.
Label                 Displays messages in a pop up box, or the label can be
                      considered part of the screen.
Marquee               Displays a message in a scrolling marquee.
Matrix                Creates a complex matrix with lots of options.
Menu                  Creates a pull-down menu interface.
Multiple Line Entry   A multiple line entry field. Very useful
                      for long fields. (like a description
                      field)
Radio List            Creates a radio button list.
Scale                 Creates a numeric scale. Used for allowing a user to
                      pick a numeric value and restrict them to a range of 
                      values.
Scrolling List        Creates a scrolling list/menu list.
Scrolling Window      Creates a scrolling log file viewer. Can add 
                      information into the window while its running. 
                      A good widget for displaying the progress of
                      something. (akin to a console window)
Selection List        Creates a multiple option selection list.
Slider                Akin to the scale widget, this widget provides a
                      visual slide bar to represent the numeric value.
Template              Creates a entry field with character sensitive 
                      positions. Used for pre-formatted fields like
                      dates and phone numbers.
Viewer                This is a file/information viewer. Very useful
                      when you need to display loads of information.
===========================================================================

A few of the widgets are modified by Thomas Dickey in recent versions. [Research on Scikit-learn]

19.1.2. Some Attractive Features

Apart from making our life easier with readily usable widgets, cdk solves one frustrating problem with printing multi colored strings, justified strings elegantly. Special formatting tags can be embedded in the strings which are passed to CDK functions. For Example

If the string

"</B/1>This line should have a yellow foreground and a blue
background.<!1>"

given as a parameter to newCDKLabel(), it prints the line with yellow foreground and blue background. There are other tags available for justifying string, embedding special drawing characters etc.. Please refer to the man page cdk_display(3X) for details. The man page explains the usage with nice examples. [Microsoft SQL Server History]

19.1.3. Conclusion

All in all, CDK is a well-written package of widgets, which if used properly can form a strong frame work for developing complex GUI.

19.2. The dialog

Long long ago, in September 1994, when few people knew linux, Jeff Tranter wrote an article on dialog in Linux Journal. He starts the article with these words..

Linux is based on the Unix operating system, but also features a number of unique and useful kernel features and application programs that often go beyond what is available under Unix. One little-known gem is "dialog", a utility for creating professional-looking dialog boxes from within shell scripts. This article presents a tutorial introduction to the dialog utility, and shows examples of how and where it can be used

As he explains, dialog is a real gem in making professional-looking dialog boxes with ease. It creates a variety of dialog boxes, menus, check lists etc.. It is usually installed by default. If not, you can download it from .:: telegra.ph ::. Thomas Dickey's site.

The above-mentioned article gives a very good overview of its uses and capabilites. The man page has more details. It can be used in variety of situations. One good example is building of linux kernel in text mode. Linux kernel uses a modified version of dialog tailored for its needs.

dialog was initially designed to be used with shell scripts. If you want to use its functionality in a c program, then you can use libdialog. The documentation regarding this is sparse. Definitive reference is the dialog.h header file which comes with the library. You may need to hack here and there to get the required output. The source is easily customizable. I have used it on a number of occasions by modifying the code. .:: bn.quora.com ::.

19.3. Perl Curses Modules CURSES::FORM and CURSES::WIDGETS

The perl module Curses, Curses::Form and Curses::Widgets give access to curses from perl. If you have curses and basic perl is installed, you can get these modules from CPAN All Modules page. Get the three zipped modules in the Curses category. Once installed you can use these modules from perl scripts like any other module. For more information on perl modules see perlmod man page. The above modules come with good documentation and they have some demo scripts to test the functionality. Though the widgets provided are very rudimentary, these modules provide good access to curses library from perl. .:: www.devglan.com ::.

Some of my code examples are converted to perl by Anuradha Ratnaweera and they are available in the .:: telegra.ph ::. perl directory.

For more information see man pages Curses(3) , Curses::Form(3) and Curses::Widgets(3). These pages are installed only when the above modules are acquired and installed. .:: www.hulkshare.com ::.

Share or Research:

Share on FB Post to X LinkedIn 🤖 Ask AI about this