ZDNet UK


Skip to Main Content

ZDNet.co.uk - Winner of Best Business Website 2007
  1. Home
  2. News
  3. Blogs
  4. Reviews
  5. Jobs
  6. Resources
  7. Community
  8. My ZDNet

 

ZDNet UK RSS Feeds


Application development Toolkit

Mandrake Drak tools made easy

Stew Benedict Builder.com

Published: 17 Oct 2002 11:49 BST

  • Email
  • Trackback
  • Clip Link
  • Print friendly
  • Post Comment

You'll see other code in interactive.pm that checks to see whether the app requires root user privileges and if so, asks for the root password. The code in Listing B illustrates how either interactive_gtk or  interactive_newt will be used, based on the $DISPLAY variable and a test for the X environment.

That's all there is to it. If you want to display more text than a simple phrase, say, the contents of a file, you can use the Mandrake toolkit's simple function cat_. To use it, you'll want to include common.pm by adding use common to your code. If you take a look at /usr/lib/libDrakx/common.pm, you'll see a number of useful shortcut functions that will save you some coding work. This time, instead of passing the literal strings to ask_warn, I'll try variables. Look at Listing C. You can use a number of other standard widgets beyond a simple OK box. First, let's allow the user to make a decision without changing the code base. Now, the application will display OK or Cancel and proceed based on the user's choice. Figure C shows the GUI version, and Figure D presents the console version. To see the code, check out Listing D.

Figure C

Figure D

A more complex configuration tool: The list
Lists are also useful for configuration tools, and these too can be done quite easily. The ask_from_list function expects a title, a prompt, a list of selections, and the default value. Listing E shows how you can provide a popup ToolTip. (The ToolTip doesn't work in text mode.)

A more elaborate list might involve a tree or outline type selection. Listing F illustrates this technique.

In Listing F, you declare the pipe symbol [|] as the separator in argument three of ask_from_treelist, and you declare Fruit|Apple as the default, as well as a None option. In the GUI display, the pipe symbol parses the tree display. On the console, the string is displayed as is, without the visual tree effect, as shown in Figures E and F, respectively.

Figure E

Figure F

GUI or text interface?
Combinations of the above widgets, along with the other interfaces in interactive.pm, should be enough to allow you to create a user interface to cover most tasks. The text interface is not quite as sophisticated as the GUI. If you can keep the interface simple, being able to run in both the console and GUI is a definite plus. MandrakeSoft's toolkit is licensed under the GPL, and you are free to use and adapt the code even if you don't use Mandrake Linux.


Have your say instantly in the
Tech Update forum.

Find out what's where in the new Tech Update with our
Guided Tour.

Let the editors know what you think in the
Mailroom.

Next

Previous

1 2


  • Email
  • Trackback
  • Clip Link
  • Print friendlyPrint with Konica

Did you find this article useful?
37 out of 61 people found this useful


Full Talkback thread

0 comments


Company/Topic Alerts

Create a new alert from the list below:











Discussions

sell001 sell001

www.sell-nike-shoes.com colorful nike...

Wednesday 15 October 2008, 5:17 PM

1 post
James B James B

Short throw projection from BenQ

Wednesday 15 October 2008, 4:22 PM

1 comment
Davep Davep

Truly Unbelievable

Wednesday 15 October 2008, 12:10 PM

8 comments
davidross davidross

xG update - money, mystery and more

Wednesday 15 October 2008, 12:05 PM

14 comments

Featured Talkback

In association with Intel
The fact is: Software developers today are really designers and not coders. The reason that business anlaysts exist today to model solutions is because they understand the value of designing software before writing it. All too often developers create code that has little value because they do not understand that business classes interact with other classes within the confines of a working model or pattern.

By: 1000165269

Read full story:
Making sense of agile modelling