Home Home > 2009 > 02 > 13 > Writing first YCP program
Sign up | Login

Deprecation notice: openSUSE Lizards user blog platform is deprecated, and will remain read only for the time being. Learn more...

Writing first YCP program

February 13th, 2009 by

Hi folks!

It was a long time since my last blog. 😉

Today, i will show you my first program, it`s a simple test program which shows basic functions of YCP

Let`s start!!

first of all, you need all core development YaST and QT packages

(All mentioned bottom steps, can be made with normal user )

second , you must create a  symlink to /usr/lib/YaST2/bin/y2base

$ ln -s <destination> <linkname>

(In my case name of symlink is y2base.)

third , you need two console`s , one for program writing and one for monitoring .y2log (where you can see all debug messages)

if you wish more detailed debug output during root session, than type in console following :

$ su

$ export Y2DEBUG=1

$ exit

(switching back to normal user)

Ok, lets see the code of PushButton.ycp !

{
// Build a dialog with one button and two labels.
// Wait until that button is clicked,
// then close the dialog and terminate.

UI::OpenDialog( `VBox(
`Label(`opt(`boldFont),”PushButton TEST!!!!!!!!”),
`PushButton( “&OK” ),
`Label(`opt(`boldFont),”JUST SIMPLE TEST”)
)
);

UI::UserInput();
UI::CloseDialog();
}

Than:

$ chmod 765 PushButton.ycp

After you have written the program  , type in the console:

$ ./y2base ./PushButton.ycp qt

You will get following window:

PushButton

What is amazing at YCP, that this code can be interpreted into ncurses

Try following command:

$ ./y2base ./PushButton.ycp ncurses

Result:

You have written only one code , which can be used in two different gui environments graphical and  text mode!

In my next blog i will write about creating own SCR Agent.

Both comments and pings are currently closed.

7 Responses to “Writing first YCP program”

  1. Robin

    > $ su
    > $ export Y2DEBUG=1
    > $ exit

    That does exactly… nothing.

    Exporting variables only affects child processes

  2. Alexander Orlovskyy

    Hi Robin, please refer to YaST manual
    “The y2logs don’t seem to show my problem. Can that logging be made any more verbose?”

    http://en.opensuse.org/Bugs/YaST

  3. Robin

    sure, but exporting a variable and exiting immediately afterwards does nothing.

    from the wiki:

    export Y2DEBUG=1
    yast2

    That would start yast2 with the Y2DEBUG variable set to 1.
    export Y2DEBUG=1
    exit
    will set the variable and exit the shell which just discards the variable.

    You might want this:
    export Y2DEBUG=1 # once in your shell session

    ./y2base ./PushButton.ycp qt

  4. Alexander Orlovskyy

    Robin,i understand , i edited my blog ,so now it makes sense. 😉
    Don`t forget,i still learning .

  5. Robin

    well, you never stop learning when using linux, that’s why I love it

  6. You can also do it without the symlink: yast2 --qt ./PushButton.ycp, yast2 --gtk ./PushButton.ycp, yast2 --ncurses ./PushButton.ycp

    And if people got interested, here’s a page with useful links about YaST development