The kdialog class allows to quickly and easily build a simplified KDE dialog box directly from a wwlisp application or shell script. The wwlisp language is thoroughly documented here As a typical example of such a script under Linux, let us imagine that we would like to display the result of the traceroute command in a terminal window, but we do not want the hassle to open a terminal and type the command; let us write the following script and make it executable: #!/usr/local/bin/wwlisp (call(make-instance library "/usr/local/bin/wwlispkdialogwwlisp")"int initialize(void)") (setq dlg(make-instance kdialog nil nil 250 40 "Trace Route")) (addedit dlg 1 10 10 180 20 "") (addbutton dlg 2 200 8 40 24 "ok") (display dlg) (if(getvalue dlg 2)(command(concat "/usr/sbin/traceroute " (getvalue dlg 1)))) (destroy-instance dlg) Then we have to create a shortcut on the desktop in order to execute the script, and specify that the window must remain open at finish. That's all. When clicking on the shortcut, the script will execute, a KDE dialogbox will appear and allow the input of the IP address or the URL; when the input is done, we just have to press the ok button to see the result. The class allows to build more complicated dialogs, with callbacks, change of status or content of widgets during the dialog, and recursive invocation of other dialogs. To be able to invoke the kdialog class, the shared object wwlispkdialog must be loaded into the wwlisp interpreter. This is done via the form: (setq klib(make-instance library "/usr/local/bin/wwlispkdialog")) (call klib "int initialize(void)") or, still shorter: (call(make-instance library "/usr/local/bin/wwlispkdialog")"int initialize(void)") In addition to the methods of the class, the shared object wwlispkdialog contains also the functions openfilenamedialog and savefilenamedialog , which return a file name and use an optional filter parameter, like "*.*" . |
Function Type | subr | |
Arguments | kdialog object, integer index, integer x, integer y, integer w, integer h, optional string text | |
Return Value | t or nil | |
Description | adds a button to the kdialog object; the index identifies the widget and must be unique in the dialog; the index allows to set and retrieve the status of the widget; the button is placed at the x,y pixels coordinates of the dialog window, and has w width and h height; the optional text given as last argument appears as button name; | |
Example | (setq dlg(make-instance kdialog nil nil 100 50 "Hi!" ) ) (addbutton dlg 1 10 10 80 30 "OK" ) (display dlg)
|
Function Type | subr | |
Arguments | kdialog object, integer index, integer x, integer y, integer w, integer h, string text or nil, optional t or nil | |
Return Value | t or nil | |
Description | adds a checkbox to the kdialog object; the index identifies the widget and must be unique in the dialog; the index allows to set and retrieve the status of the widget; the checkbox is placed at the x,y pixels coordinates of the dialog window, and has w width and h height; the next argument must be a string or nil and appears as the widget label; the initial checked state is given by the optional last argument | |
Example | (setq dlg(make-instance kdialog nil nil 100 50 "Hi!" )) (addcheckbox dlg 1 10 10 80 30 "option 1" t) (display dlg)
|
Function Type | subr | |
Arguments | kdialog object, integer index, integer x, integer y, integer w, integer h, list of strings | |
Return Value | t or nil | |
Description | adds a combobox to the kdialog object; the index identifies the widget and must be unique in the dialog; the index allows to set and retrieve the status of the widget; the combobox is placed at the x,y pixels coordinates of the dialog window, and has w width and h height; the next argument must be a list of string which will appear as the elements of the combobox; the initial state is such that the first elementis selected; | |
Example | (setq dlg(make-instance kdialog nil nil 120 50 "Hi!" )) (addcombobox dlg 1 10 10 100 30 '("option 1" "option 2" "option 3" )) (display dlg)
(getvalue dlg 1) => "option 1" |
Function Type | subr | |
Arguments | kdialog object, integer index, integer x, integer y, integer w, integer h, integer low, integer high, integer step, integer val | |
Return Value | t or nil | |
Description | adds a dial control to the kdialog object; the index identifies the widget and must be unique in the dialog; the index allows to set and retrieve the status of the widget; the dial is placed at the x,y pixels coordinates of the dialog window, and has w width and h height; arguments low, high, step and val indicate respectively the lowest value, the highest, the stepping and the initial position; | |
Example | (setq dlg(make-instance kdialog nil nil 100 100 "Hi!" )) (adddial dlg 1 10 10 80 80 0 100 1 50) (display dlg)
(getvalue dlg 1) => 50 |
Function Type | subr | |
Arguments | kdialog object, integer index, integer x, integer y, integer w, integer h, optional string text | |
Return Value | t or nil | |
Description | adds an editable field to the kdialog object; the index identifies the widget and must be unique in the dialog; the index allows to set and retrieve the status of the widget; the edit field is placed at the x,y pixels coordinates of the dialog window, and has w width and h height; the optional text given as last argument appears as initial text; | |
Example | (setq dlg(make-instance kdialog nil nil 100 50 "Hi!" )) (addedit dlg 1 10 10 80 30 "well..." ) (display dlg)
(getvalue dlg 1) => "well..." |
Function Type | subr | |
Arguments | kdialog object, integer index, integer x, integer y, integer w, integer h, optional string text | |
Return Value | t or nil | |
Description | adds a groupbox to the kdialog object; the index identifies the widget and must be unique in the dialog; the index allows to set and retrieve the status of the widget; the groupbox is placed at the x,y pixels coordinates of the dialog window, and has w width and h height; the optional text given as last argument appears as groupbox title | |
Example | (setq dlg(make-instance kdialog nil nil 100 100 "Hi!" ) ) (addgroupbox dlg 1 10 10 80 80 "Title" ) (display dlg)
|
Function Type | subr | |
Arguments | kdialog object, integer index, integer x, integer y, integer w, integer h, integer low, integer high, integer step, integer page, integer val | |
Return Value | t or nil | |
Description | adds a horizontal scrollbar to the kdialog object; the index identifies the widget and must be unique in the dialog; the index allows to set and retrieve the status of the widget; the horizontal scrollbar is placed at the x,y pixels coordinates of the dialog window, and has w width and h height; arguments low, high, step, page and val indicate respectively the lowest value, the highest value, the stepping, the paging and the initial position; | |
Example | (setq dlg(make-instance kdialog nil nil 200 40 "Hi!" )) (addhscrollbar dlg 1 10 10 180 30 0 100 1 10 50) (display dlg)
(getvalue dlg 1) |
Function Type | subr | |
Arguments | kdialog object, integer index, integer x, integer y, integer w, integer h, integer low, integer high, integer step, integer val | |
Return Value | t or nil | |
Description | adds a horizontal slider to the kdialog object; the index identifies the widget and must be unique in the dialog; the index allows to set and retrieve the status of the widget; the horizontal slider is placed at the x,y pixels coordinates of the dialog window, and has w width and h height; arguments low, high, step and val indicate respectively the lowest value, the highest, the stepping and the initial position; | |
Example | (setq dlg(make-instance kdialog nil nil 200 50 "Hi!" )) (addhslider dlg 1 10 10 180 30 0 100 1 50) (display dlg)
(getvalue dlg 1) |
Function Type | subr | ||
Arguments | kdialog object, integer index, integer x, integer y, integer w, integer h, keyword, string or binary object | ||
Return Value | t or nil | ||
Description | adds a text label or an image to the kdialog object; the index identifies the widget and must be unique in the dialog; the index allows to set and retrieve the status of the widget; the text label or the image is placed at the x,y pixels coordinates of the dialog window, and has w width and h height; the keyword must be either 'text or 'pixmap ; the keyword 'text must be followed by a string containing the text to be displayed in the label rectangle; the keyword 'pixmap must be followed either by a string containing the filename of a valid image (jpeg, png, gif, ...) or by a binary block object containing the image in a valid format; | ||
Example | (setq dlg(make-instance kdialog nil nil 100 50 "Hi!" )) (addlabel dlg 1 10 10 80 30 'text "Text label" ) (display dlg)
(setq dlg(make-instance kdialog nil nil 100 100 "Hi!" )) (addlabel dlg 1 10 10 80 80 'pixmap "image.jpg" ) (display dlg)
|
Function Type | subr | |
Arguments | kdialog object, integer index, integer x, integer y, integer w, integer h, optional keywords | |
Return Value | t or nil | |
Description | adds the image of a LED (light emitting diode) to the kdialog object; the index identifies the widget and must be unique in the dialog; the index allows to set and retrieve the status of the widget; the LED image is placed at the x,y pixels coordinates of the dialog window, and has w width and h height; the state of the LED is defined by one of the keywords 'on or 'off the color of the LED is defined by one of the keywords 'red 'orange 'yellow 'green or 'blue the shape is defined by one of the keywords 'circular or 'rectangular the 3D aspect is defined by one of the keywords 'sunken 'raised or 'flat when no keyword is provided a LED is per default: off, red, circular and sunken; to change the status of a LED, use (setvalue dlg index 0) or (setvalue dlg index 1) | |
Example | (setq dlg(make-instance kdialog nil nil 100 50 "Hi!" )) (addled dlg 1 35 10 30 30 'on 'yellow 'circular 'sunken) (display dlg)
|
Function Type | subr | |
Arguments | kdialog object, integer index, integer x, integer y, integer w, integer h, list of strings | |
Return Value | t or nil | |
Description | adds a listbox to the kdialog object; the index identifies the widget and must be unique in the dialog; the index allows to set and retrieve the status of the widget; the listbox is placed at the x,y pixels coordinates of the dialog window, and has w width and h height; the next argument must be a list of string which will appear as the elements of the listbox; the initial state is such that no element is selected; | |
Example | (setq dlg(make-instance kdialog nil nil 100 100 "Hi!" )) (addlistbox dlg 1 10 10 80 80 '("line1" "line2" "line3" ) (display dlg)
(getvalue dlg 1) => "line1" |
Function Type | subr | |
Arguments | kdialog object, integer index, integer x, integer y, integer w, integer h, list of strings | |
Return Value | t or nil | |
Description | adds a multiple choice listbox to the kdialog object; the index identifies the widget and must be unique in the dialog; the index allows to set and retrieve the status of the widget; the listbox is placed at the x,y pixels coordinates of the dialog window, and has w width and h height; the next argument must be a list of string which will appear as the elements of the listbox; the initial state is such that no element is selected; multiple elements can be selected from this listbox | |
Example | (setq dlg(make-instance kdialog nil nil 100 100 "Hi!" )) (addlistboxmulti dlg 1 10 10 80 80 '("line1" "line2" "line3" )) (display dlg)
(getlist dlg 1) => ("line1" "line2") |
Function Type | subr | |
Arguments | kdialog object, integer index, integer x, integer y, integer w, integer h, list of strings, list of strings | |
Return Value | t or nil | |
Description | adds a listview to the kdialog object; the index identifies the widget and must be unique in the dialog; the index allows to set and retrieve the status of the widget; the listview is placed at the x,y pixels coordinates of the dialog window, and has w width and h height; the next argument must be a list of string which will appear as the title of the column of the listview; there are as many columns as titles; the last argument must be a list of strings which are dispatched in each column of each line of the list view, horizontally first; normally, the number of data strings must be a multiple of the number of columns, but if not there is no bad effect; | |
Example | (setq dlg(make-instance kdialog nil nil 200 100 "Hi!" )) (addlistview dlg 1 10 10 180 80 '("Header1" "Header2" ) '("text1-1" "text1-2" "text2-1" "text2-2" )) (display dlg)
|
Function Type | subr |
Arguments | kdialog object, integer, integer or file object, optional keyword |
Return Value | t or nil |
Description | adds a file or socket event notifier to the kdialog object; the index identifies the widget and must be unique in the dialog; the index allows to set and retrieve the status of the widget; at each event on the file or socket given by the third argument, the dialog will catch a read, write or exception event and eventually react to it if a callback has been defined for the subclass of the dialog; the fourth argument is a keyword indicating which type of event is to be notified: 'read 'except or 'write ; per default, if the keyword is ommitted, 'read is assumed |
Example | (setq dlg(make-instance kdialog nil nil 100 50 "Hi!" )) (addnotifier dlg 1 mysocket 'read) (display dlg) |
Function Type | subr | |
Arguments | kdialog object, integer index, integer x, integer y, integer w, integer h, list of strings | |
Return Value | t or nil | |
Description | adds a radiobuttongroup to the kdialog object; the index identifies the widget and must be unique in the dialog; the index allows to set and retrieve the status of the widget; the radiobuttongroup is placed at the x,y pixels coordinates of the dialog window, and has w width and h height; the list of strings define how many buttons and the labels of the buttons; the initial state is with no button pushed; | |
Example | (setq dlg(make-instance kdialog nil nil 100 70 "Hi!" )) (addradiobuttongroup dlg 1 10 10 80 60 '("red" "blue" )) (display dlg)
(getvalue dlg 1) => 0 |
Function Type | subr | |
Arguments | kdialog object, integer index, integer x, integer y, integer w, integer h, integer low, integer high, integer step, integer val | |
Return Value | t or nil | |
Description | adds a spinedit control to the kdialog object; the index identifies the widget and must be unique in the dialog; the index allows to set and retrieve the status of the widget; the spinedit is placed at the x,y pixels coordinates of the dialog window, and has w width and h height; arguments low, high, step and val indicate respectively the lowest value, the highest, the stepping and the initial position; | |
Example | (setq dlg(make-instance kdialog nil nil 100 50 "Hi!" )) (addspinedit dlg 1 10 10 80 30 0 100 1 50) (display dlg)
(getvalue dlg 1) => 50 |
Function Type | subr |
Arguments | kdialog object, integer index, integer x, integer y, integer w, integer h, optional string text |
Return Value | t or nil |
Description | adds a textedit field to the kdialog object; the index identifies the widget and must be unique in the dialog; the index allows to set and retrieve the status of the widget; the textedit field is placed at the x,y pixels coordinates of the dialog window, and has w width and h height; the optional text given as last argument appears as initial text; the widget is used to display non modifiable text, for example the output of a command line program |
Example | (setq dlg(make-instance kdialog nil nil 100 50 "Hi!" )) (addtextedit dlg 1 10 10 80 30 "well..." ) (display dlg) |
Function Type | subr |
Arguments | kdialog object, integer index, integer interval |
Return Value | t or nil |
Description | adds a timer to the kdialog object; the index identifies the widget and must be unique in the dialog; the index allows to set and retrieve the status of the widget; at each interval in milliseconds given by the third argument, the dialog will catch an event and eventually react to it if a callback has been defined for the subclass of the dialog; when added, the timer is started immediately, even if the dialog is not yet displayed; |
Example | (setq dlg(make-instance kdialog nil nil 100 50 "Hi!" )) (addtimer dlg 1 1000) (display dlg) |
Function Type | subr | |
Arguments | kdialog object, integer index, integer x, integer y, integer w, integer h, integer low, integer high, integer step, integer page, integer val | |
Return Value | t or nil | |
Description | adds a vertical scrollbar to the kdialog object; the index identifies the widget and must be unique in the dialog; the index allows to set and retrieve the status of the widget; the vertical scrollbar is placed at the x,y pixels coordinates of the dialog window, and has w width and h height; arguments low, high, step, page and val indicate respectively the lowest value, the highest, the stepping, the paging and the initial position; | |
Example | (setq dlg(make-instance kdialog nil nil 100 100 "Hi!" )) (addvscrollbar dlg 1 10 10 10 80 0 100 1 10 50) (display dlg)
(getvalue dlg 1) => 50 |
Function Type | subr | |
Arguments | kdialog object, integer index, integer x, integer y, integer w, integer h, integer low, integer high, integer step, integer val | |
Return Value | t or nil | |
Description | adds a vertical slider to the kdialog object; the index identifies the widget and must be unique in the dialog; the index allows to set and retrieve the status of the widget; the vertical slider is placed at the x,y pixels coordinates of the dialog window, and has w width and h height; arguments low, high, step and val indicate respectively the lowest value, the highest, the stepping and the initial position; | |
Example | (setq dlg(make-instance kdialog nil nil 100 200 "Hi!" )) (addvslider dlg 1 10 10 20 180 0 100 1 50) (display dlg)
(getvalue dlg 1) => 50 |
Function Type | subr | |
Arguments | kdialog object, integer, symbol, anything | |
Return Value | a symbol | |
Description | the method is the default callback of the kdialog class; it does nothing and always returns the symbol 'default; when a dialog returns from a callback and the return value is 'default and the widget which caused the event is a button, then the execution of the dialog is terminated and the dialog returns; thanks to this mechanism, a simple dialog can be constructed, displayed, filled, terminated by a button ok, cancel, done or any other text, then the values of the widgets can be read back, and finally the dialog can be destroyed, all in a linear fashion without using the concepts of callbacks, events or connexions; this way dialog scripting can be made simple and easy to use, like in the following example; more complicated dialogs, where widget status must change to inform the user before the final choice, will necessitate the definition of a subclass of the kdialog class and the definition of a callback method specific to that new subclass | |
Example | (setq dlg(make-instance kdialog nil nil 150 100 "Hi!")) (addradiobuttongroup dlg 1 10 10 60 80 '("apple" "cherry" "pear")) (addbutton dlg 2 90 10 50 25 "ok") (display dlg) (setq result(getvalue dlg 1)) (destroy-instance dlg) the following dialog box shows, where the user selects a radio button and presses the OK button...
|
Function Type | subr |
Arguments | the symbol kdialog, integer x, integer y, integer w, integer h, optional string text |
Return Value | a kdialog object |
Description | never call kdialog-constructor directly but always through (make-instance) ; a dialog box is created and a kdialog object is returned; the dialog box is placed at the x,y pixels coordinates of the current desktop, and has w width and h height; the optional text given as last argument appears as button name; if x and y are nil, the coordinates will be such that the dialog appears at the center of the screen; the dialog is always modal; when controls have been added to the dialogbox, this one can be displayed by calling kdialog-display |
Example | (make-instance kdialog nil nil 100 50 "Hi!" ) |
Function Type | subr |
Arguments | kdialog object, integer index |
Return Value | t or nil |
Description | removes a control from the kdialog object; the index identifies the widget which must be removed; the same index can eventually be reused in order to define another widget in the same dialog; as the effect is immediately visible, and when used from a callback function, kdialog-delcontrol allows to dynamically remove widgets on a dialog while this one is being displayed; |
Example | (setq dlg(make-instance kdialog nil nil 100 50 "Hi!" ) (addbutton dlg 1 10 10 80 30 "OK" ) (display dlg) (delcontrol dlg 1) |
Function Type | subr |
Arguments | an object of class kdialog |
Return Value | the result of the destructor |
Description | never call kdialog-destructor directly but always through destroy-instance ; also, do not destroy the dialog from a callback called by the dialog.... |
Example | (destroy-instance dlg) |
Function Type | subr |
Arguments | kdialog object, integer index |
Return Value | t |
Description | disables (greys) a specific widget in a kdialog object; the index identifies the widget; |
Example | (setq dlg(make-instance kdialog nil nil 100 50 "Hi!" ) (addbutton dlg 1 10 10 80 30 "OK" ) (disable dlg 1) (display dlg) |
Function Type | subr |
Arguments | a kdialog object |
Return Value | t |
Description | called from a callback, tells the dialog that it has finished and must disappear from the screen; the kdialog object is not destroyed and can be modified (add and delete controls, change values) and displayed again; in programs, kdialog-dismiss is mostly called when OK or Cancel buttons have been hit |
Example | (dismiss dlg) |
Function Type | subr |
Arguments | a kdialog object |
Return Value | t |
Description | displays the dialog on the screen; when no callback is defined for the class, the dialog will capture all events, and get dismissed automatically at the first button being pressed; when a callback is defined this callback function is called for each and every event concerning every widget; the callback invocation form is: (callback kdialogobject widget-index msg msgvalue) the widget corresponds to the index given in the kdialog-add* functions the msg argument is a symbolic atom among 'ok, 'dismiss, 'selected, 'timer; the msgvalue is the current value of the widget and can be nil, t, a string, or an integer depending on the type of the widget; note that as the callback function is a method of the kdialog class or of a subclass, the symbol this is bound to the current kdialog object instance, and henceforth that symbol can be used for calling the kdialog methods instead of another more global symbol bound to the object |
Example | (defclass dialog1(kdialog)) (defun dialog1-constructor nil (prog nil (kdialog-constructor nil nil 310 110 "New Function") (addlabel this 1 10 7 200 17 'text "Function Name:") (addedit this 2 10 25 210 22 "") (addbutton this 3 230 10 70 25 "OK" ) (addbutton this 4 230 40 70 25 "Cancel") (return t) ) ) (defun dialog1-callback(widget msg msgvalue) (prog nil (cond((= widget 0)(cond((= msg 'dismiss)(return)))) ((= widget 3)(setq result(getvalue this 2))(dismiss this)) ((= widget 4)(dismiss this)) ) ) ) (display(make-instance dialog1)) (if result(apply 'edit(list(symbol result)))) |
Function Type | subr |
Arguments | kdialog object, integer index |
Return Value | t |
Description | enables a specific widget in a kdialog object; the index identifies the widget |
Example | (setq dlg(make-instance kdialog nil nil 100 50 "Hi!" ) (addbutton dlg 1 10 10 80 30 "OK" ) (disable dlg 1) (display dlg) ; close it with the [X] on the window header (enable dlg 1) (display dlg) |
Function Type | subr |
Arguments | a kdialog object, integer index |
Return Value | an integer or nil |
Description | when called on a radiobuttongroup, listbox, listboxmulti and combobox widget, returns the position, starting at zero, of the item currently in focus (ie. with a dotted line frame surrounding it); always return nil for the other widget types; |
Example | (getcurrent dlg index) |
Function Type | subr |
Arguments | a kdialog object, integer index |
Return Value | a list of strings, or nil |
Description | when called on a listboxmulti widget, returns the list of the selected strings; always return nil for the other widget types; |
Example | (getcurrent dlg index) |
Function Type | subr |
Arguments | a kdialog object, integer index, optional symbol |
Return Value | anything |
Description | returns the current value of the widget indicated by the index argument; when called on a listboxmulti, returns just the string which is current, not the list of the selected strings as does kdialog-getlist ; on a label needs a keyword 'text or 'pixmap as third argument and returns the corresponding object from the label; on a groupbox, returns nil; |
Example | (getvalue dlg index) |
Function Type | subr |
Arguments | kdialog object, integer index |
Return Value | t or nil |
Description | checks whether a specific widget in a kdialog object is enabled or not; the index identifies the widget |
Example | (setq dlg(make-instance kdialog nil nil 100 50 "Hi!" ) (addbutton dlg 1 10 10 80 30 "OK" ) (disable dlg 1) (isenabled dlg 1) => nil |
Function Type | subr |
Arguments | kdialog object, integer index, integer item |
Return Value | t or nil |
Description | checks whether a specific entry in a widget in a kdialog object is selected or not; the index identifies the widget, the item number identifies the button in a radiobuttongroup, or the line in a list or combo box |
Example | (isselected dlg 1 3) => nil |
Function Type | subr |
Arguments | a kdialog object, integer index, integer item |
Return Value | t or nil |
Description | when called on a radiobuttongroup, listbox, listboxmulti and combobox widget, sets the position, starting at zero, of the item currently in focus (ie. with a dotted line frame surrounding it); always return nil for the other widget types; |
Example | (setcurrent dlg index item) |
Function Type | subr |
Arguments | a kdialog object, integer index, list of strings |
Return Value | t or nil |
Description | when called on a listbox, listboxmulti, combobox, listview widget, sets the lines of the widget strings; on a listview widget, the items are set column by column first and then line by line; always return nil for the other widget types; |
Example | (setcurrent dlg index list) |
Function Type | subr |
Arguments | a kdialog object, integer index, either a string or a binary |
Return Value | t or nil |
Description | replaces an image in the kdialog object; the index identifies the widget and must correspond to a label widget already initialized with an pixmap; when called on a label with a pixmap, the function replaces the pixmap by the new one given as third argument; the pixmap must be represented either by a string containing the filename of a valid image (jpeg, png, gif, ...) or by a binary block object containing the image in a valid format; does nothing for the other widget types; |
Example | (setpixmap dlg index "newimage.jpg") |
Function Type | subr |
Arguments | kdialog object, integer index, integer item |
Return Value | t or nil |
Description | sets as selected a specific entry in a widget in a kdialog object; the index identifies the widget, the item number identifies the button in a radiobuttongroup, or the line in a listbox, listboxmulti or combo box |
Example | (setselected dlg 1 3) |
Function Type | subr |
Arguments | a kdialog object, integer index, integer or string or symbol, integer or string or pixmap |
Return Value | t or nil |
Description | sets the current value of the widget indicated by the index argument; the value is an integer for the scalar widgets and a string for the edit and list widgets; when called on a listbox, listboxmulti or combobox, changes the value of the current line; on a label, the third argument must be the keyword 'text followed by a string or the keyword 'pixmap followed by either a pixmap stored in a binary object or a file name; on a groupbox, does nothing |
Example | (setvalue dlg index val) |