Kommander Basics
Prev
Next

Kommander Basics

Tamara King

Eric Laffoon

Concepts

Kommander was originally designed around a simple concept that has proven somewhat revolutionairy among visual design tools. Typically these tools allow you to create dialogs and possibly mainwindow interfaces. Of course a mainwindow interface is the main program window which typically has menus, toolbars, statusbar and the application area. Dialogs are child windows which typically don't have menus and are so named because their purpose is to “have a dialog” or exchange information between you and the main application. The elements on a dialog are called “widgets” and you hook your program into these widgets. Kommander is different because it is inherently nonprogrammatic here. It uses the concept of associating text with the widgets on the dialog. Initially this was called “Associated Text” but now it is called “Kommander Text”. Widgets on Kommander dialogs can include the content of other widgets by reference and a widget can reference its own content by use of a “Special” that looks like this, @widgetText. Specials are commands with special meaning in Kommander. So if you created a dialog with two LineEdit widgets and named the first “FirstName” and the second “LastName” you could create a button and set its Kommander Text to “My name is @FirstName @LastName”. You would need to set @widgetText in the first and last name widgets. Remember? We need to tell Kommander to reference the text in them. You could run this from a Konsole and it would output the string for you. So it would reference the first name like so: @FirstName -> get the widget named FirstName(@FirstName) -> @widgetText -> get the contents of the LineEdit widget. So in this case @FirstName returns “Eric”: @FirstName -> @widgetText -> “Eric”.

That is the simple core of Kommander. What you can do with this is where it gets interesting. First of all it is worth noting that compared to the normal approach of a language based tool Kommander does not need programming statements to define these operations. This makes Kommander quick for developers. For end users it's much simpler than learning language constructs. For everyone it means you can focus on your task instead of having your reference material eternally at hand. Initially when people are exposed to a tool like Kommander the first question is “Where could I find a use for this cool tool?” As it turns out, manipulating strings is used just about anywhere you look.

So what can Kommander do? Here is the list distilled to the base operations. Kommander can:

  1. Pass strings to the calling program via stdout.

  2. Call executable programs.

  3. Use DCOP to interact with KDE programs

If you're not a programmer you may want that in laymans terms. In number one, if you launch Kommander from a console then the console is the calling program. There is a parent child relationship there. Sending a message to console is done with the standard output (stdout) of the child program, so named because there is also error output. This is interesting because some programs, like Quanta Plus, use stdout to receive information from programs they launch. So Kommander dialogs can output their text strings directly into Quanta Plus's editor if they are called from Quanta Plus. This means Kommander dialogs can be useful extentions to programs.

The second case is calling an executable. Any program that runs on your system is an executable. Even a script program is run by the script's interpreter so technically it's executed too. Kommander can run commands just like the console even if you run it from the menu. So for instance if you wanted it to open The GIMP you would have a button derive the string “gimp” and put it in a special like so: @exec(gimp). Just like that you will see The GIMP open when using this. You could also exec “ls -l” too but you would only see the output if you were running from a console.

The third case is very interesting indeed. DCOP is short for KDE's Desktop COmmunication Protocol and it is very powerful. Go ahead and run the kdcop program and have a look around. You'll quickly see that any KDE application that is built to standards has things happening in DCOP and the well designed ones have a lot going on. With DCOP you can query information of all sorts as well as set widget values and more. There is a section on using DCOP in this manual. Kommander can send DCOP to any KDE program as well as be controlled by DCOP. In fact you can send DCOP from the command line to any KDE program. So what's the big deal? The deal is, if you want to do any volume of commands you begin to realized that command line DCOP is adequate for short commands, but it can cause delays for instance being called from a loop several hundred times. This is why Kommander has a @dcop special, because this is roughly 1000 times faster. Because Kommander can send and receive DCOP, DCOP can be used to script Kommander. That is why we also have a local DCOP special, @ldcop, that allows you to type a lot less to issue a command.

Is that all the core concepts in Kommander? No, but it should help you to make sense of how it works so that what is covered does not look like a foreign language to you. There are a few more. Signals and slots are how Kommander handles events. An event in a program basically means “something happened” like a widget was created or had its text changed. These changes “emit signals” and you can connect those signals to a receiving slot which will then do something when the event happens. One use of this in Kommander is the sibling of Kommander Text, “Population Text”. Population Text will populate a widget when called. Just like Kommander Text, Population Text can contain text strings or scripts.

That should give you the base concepts to begin using Kommander. We try to keep the number of Specials low and we use DCOP a lot. The idea is that we want to keep the power of Kommander as consistent and streamlined as possible. You will find that you can incorporate any scripting language into Kommander where ever you need to and even multiple scripting languages in a dialog. The rest of the information in this document assumes you are familiar with the concepts and terms presented here. The examples and tutorials are also very useful to understanding what can be done with Kommander.

Prev
Next
Home


Would you like to comment or contribute an update to this page?
Send feedback to the TDE Development Team