Simple GUI making under Linux - Suse

This is a discussion on Simple GUI making under Linux - Suse ; Is there an easy way to make a GUI program with Linux? All I need is an application with several buttons. Each button must do something like ivtv-tune --device=/dev/video0 -teurope-west -f $SOMETHING So basicaly it will be a TV station ...

+ Reply to Thread
Results 1 to 10 of 10

Thread: Simple GUI making under Linux

  1. Simple GUI making under Linux

    Is there an easy way to make a GUI program with Linux? All I need is an
    application with several buttons. Each button must do something like
    ivtv-tune --device=/dev/video0 -teurope-west -f $SOMETHING

    So basicaly it will be a TV station changer. I already have done it with
    zenity (and kdialog) but there I need to confirm my choice as it is
    radio buttons.

    And please very simple. I can do some bash, but have 0 exprience with
    anything else (Yeah, some html and php)

    It doesn't have to be cross-platform or anything. Probably something
    that other people can do in 15 minutes or so.

    I have glade and I am able to make something, but I am not able to let
    the bittons do anything or make the buttons the size I want them to be
    or even close the program by clicking on the X.

    houghi
    --
    Dr. Walter Gibbs: Won't that be grand? Computers and the programs
    will start thinking and the people will stop.
    -- Tron (1982)

  2. Re: Simple GUI making under Linux

    houghi wrote:

    > Is there an easy way to make a GUI program with Linux? All I need is an
    > application with several buttons. Each button must do something like
    > ivtv-tune --device=/dev/video0 -teurope-west -f $SOMETHING
    >
    > So basicaly it will be a TV station changer. I already have done it with
    > zenity (and kdialog) but there I need to confirm my choice as it is
    > radio buttons.
    >
    > And please very simple. I can do some bash, but have 0 exprience with
    > anything else (Yeah, some html and php)


    Tcl/tk is probably the easiest way to hack up some simple GUI:

    #!/usr/bin/wish

    button .btn1 -text "foo" -command {exec echo foo > /dev/tty}
    button .btn2 -text "bar" -command {exec echo bar > /dev/tty}

    grid .btn1 .btn2

    --
    Huibert
    "Okay... really not something I needed to see." --Raven

  3. Re: Simple GUI making under Linux

    Huibert Bol wrote:
    >> And please very simple. I can do some bash, but have 0 exprience with
    >> anything else (Yeah, some html and php)

    >
    > Tcl/tk is probably the easiest way to hack up some simple GUI:
    >
    > #!/usr/bin/wish
    >
    > button .btn1 -text "foo" -command {exec echo foo > /dev/tty}
    > button .btn2 -text "bar" -command {exec echo bar > /dev/tty}
    >
    > grid .btn1 .btn2


    (Posting took a bit longer. Actualy it took longer then making the
    script I will be describing)

    OK, looks easy enough. There is just one disadvantage that I see. The
    buttons are humongous. With that I mean there is too much white space
    around text. Even no text and a width and height of 0 gives me a HUGE
    whitespace, so we do some (soul)searching and come up with some more
    interesting things. From http://www.tcl.tk/man/tcl8.4/TkCmd/options.htm

    I would most likely select highlightThickness if it were not for the
    fact that I want more same sized buttons.

    At the bottom what I got after the better half of an hour. Most of the time
    looking how things worked. In Windowmaker I disabled the title and
    resize bar.

    So now I need to work out some smaller things.
    * How to set defaults
    * What font to use (or better an icon?)
    * How to do something like

    CHANNEL="ivtv-tune --device=/dev/video0 -teurope-west -f"
    VT4=245.25
    exec $CHANNEL $VT4

    * How to check if mplayer is running
    * How to run something like

    RUN ()
    {
    echo "Run"
    }

    * How to use an extrenal file for data. Ideal would be something where I
    can use:
    [Channels]
    1 245.25 VT4 images/vt4.png
    2 487.25 2BE images/2be.png
    3 259.25 BBCONE images/bbc1.png
    4 711.25 BBCTWO images/bbc2.png
    5 551.25 NG images/NationalGeographic.png
    6 719.25 Vitaya images/vitaya.png

    * How to become a billionaire with the program

    So here what I have now. It is intended to be running without taskbar
    and resize. There is not yet done any other decoration, so it looks a
    bit ugly right now.
    Also somewhere `mplayer /dev/video0` must be running or anything else
    that is getting the tv from /dev/video0

    #!/usr/bin/wish
    # ALPHA. This will kill babies if you use it. You have been warned
    # Place it where I like
    wm geometry . 64x128-0+128
    # Tell what the buttons do
    button .btn1 -bd 0 -text "VT4" -command {exec ivtv-tune --device=/dev/video0 -teurope-west -f 245.25}
    button .btn2 -bd 0 -text "2be" -command {exec ivtv-tune --device=/dev/video0 -teurope-west -f 487.25}
    button .btn3 -bd 0 -text "BB1" -command {exec ivtv-tune --device=/dev/video0 -teurope-west -f 259.25}
    button .btn4 -bd 0 -text "BB2" -command {exec ivtv-tune --device=/dev/video0 -teurope-west -f 711.25}
    button .btn5 -bd 0 -text "5TV" -command {exec ivtv-tune --device=/dev/video0 -teurope-west -f 182.25}
    # Tell where the buttons go
    place .btn1 -x 1 -y 0 -width 20 -height 20
    place .btn2 -x 22 -y 0 -width 20 -height 20
    place .btn3 -x 43 -y 0 -width 20 -height 20
    place .btn4 -x 1 -y 22 -width 20 -height 20
    place .btn5 -x 22 -y 22 -width 20 -height 20

    For completion, here is what I use now:
    #!/bin/bash
    # TV Player
    #set -x
    CHANNEL="ivtv-tune --device=/dev/video0 -teurope-west -f"
    LIST=`cat ~/list.csv`

    FREQ=`zenity --list \
    --height=255 \
    --text="Select Channel" \
    --column="" \
    --column="Frequency" \
    --column="Channel" \
    --radiolist \
    --hide-column=2 \
    $LIST `
    if [ "$FREQ" = "" ]
    then
    exit 1
    fi

    $CHANNEL $FREQ >> /dev/null 2>&1 &

    RUNNING=`ps aux|grep mplayer|grep -vE 'grep|mplayer'`
    if [ "$RUNNING" == "" ]
    then
    DISPLAY=:0.2 nice -4 mplayer /dev/video0 >> /dev/null 2>&1 &
    fi

    The file ~/list.csv contains the follwoing: (The first is needed,
    because with radio buttons, it will show the second row. Perhaps there
    is a way around it, but I don't care to look for it)

    1 245.25 VT4
    1 487.25 2BE
    1 259.25 BBCONE
    1 711.25 BBCTWO
    1 551.25 NationalGeographic
    1 719.25 Vitaya
    1 182.25 vijfTV
    1 655.25 TMF
    1 168.25 MTV
    1 273.25 JIM
    1 495.25 een
    1 479.25 vtm
    1 615.25 Canvas
    1 203.25 Nederland1
    1 217.25 Nederland2
    1 695.25 Nederland3
    1 189.25 ARD
    1 133.25 ZDF
    1 147.25 WDR
    1 140.25 ArteDeutch
    1 663.25 Infokanaal
    1 767.25 KanaalZ
    1 679.25 ROB
    1 535.25 ActuaTV
    1 161.25 CNN
    1 559.25 CNBC
    1 231.25 BBCNews
    1 238.25 EuroNewsE
    1 280.25 EuroNewsF
    1 527.25 LifeTV
    1 735.25 LibertyTV
    1 575.25 LaUne
    1 647.25 LaDeux
    1 727.25 RTL-TVi
    1 175.25 TF1
    1 583.25 France2
    1 759.25 France3
    1 639.25 ArteFrance
    1 775.25 RaiUno
    1 567.25 TVE
    1 791.25 RTP
    1 807.25 Mozaik
    1 815.25 S.televisie
    1 799.25 TCM
    1 252.25 MCM

    houghi
    --
    Dr. Walter Gibbs: Won't that be grand? Computers and the programs
    will start thinking and the people will stop.
    -- Tron (1982)

  4. Re: Simple GUI making under Linux

    houghi wrote:

    > * How to use an extrenal file for data. Ideal would be something where I
    > can use:
    > [Channels]
    > 1 245.25 VT4 images/vt4.png
    > 2 487.25 2BE images/2be.png
    > 3 259.25 BBCONE images/bbc1.png
    > 4 711.25 BBCTWO images/bbc2.png
    > 5 551.25 NG images/NationalGeographic.png
    > 6 719.25 Vitaya images/vitaya.png


    OK. This one read a file (channel.list) and creates a button for each
    line, three buttons per row. The image files will have to be in PNM or
    GIF format, as those are the only ones supported by TK.

    #!/usr/bin/wish

    proc addbutton {cnt no freq name img} {

    set columns 3

    set command [
    concat {exec ivtv-tune --device=/dev/video0 -teurope-west -f } $freq]
    set image [image create photo -file $img]
    set btn [button .btn$cnt -image $image -command $command]
    grid $btn -column [expr $cnt % $columns] -row [expr $cnt / $columns]
    }

    set fid [open "channel.list"]
    set channels 0
    while {[gets $fid line] >= 0} {
    eval addbutton $channels [split $line]
    incr channels
    }
    close $fid


    > * How to become a billionaire with the program
    >


    Still waiting for the lotery jackpot.

    --
    Huibert
    "Okay... really not something I needed to see." --Raven

  5. Re: Simple GUI making under Linux

    Huibert Bol wrote:
    > houghi wrote:
    >
    >> * How to use an extrenal file for data. Ideal would be something where I
    >> can use:
    >> [Channels]
    >> 1 245.25 VT4 images/vt4.png
    >> 2 487.25 2BE images/2be.png
    >> 3 259.25 BBCONE images/bbc1.png
    >> 4 711.25 BBCTWO images/bbc2.png
    >> 5 551.25 NG images/NationalGeographic.png
    >> 6 719.25 Vitaya images/vitaya.png

    >
    > OK. This one read a file (channel.list) and creates a button for each
    > line, three buttons per row. The image files will have to be in PNM or
    > GIF format, as those are the only ones supported by TK.


    OK.

    > #!/usr/bin/wish
    >
    > proc addbutton {cnt no freq name img} {


    OK, seems clear, although I would not realy need a "cnt" and a "no" as
    they would basically are the same.

    > set columns 3
    > set command [ concat {exec ivtv-tune --device=/dev/video0 -teurope-west -f } $freq]
    > set image [image create photo -file $img]
    > set btn [button .btn$cnt -image $image -command $command]
    > grid $btn -column [expr $cnt % $columns] -row [expr $cnt / $columns]


    OK. set is the thing to watch out for.

    > }
    >
    > set fid [open "channel.list"]
    > set channels 0
    > while {[gets $fid line] >= 0} {
    > eval addbutton $channels [split $line]
    > incr channels
    > }
    > close $fid


    Thanks. I am doing a re-write from what I have, so I will learn more.

    >
    >> * How to become a billionaire with the program
    >>

    >
    > Still waiting for the lotery jackpot.


    I heard that your chances increase if you actually play and the best you
    can become is a millionaire.


    houghi
    --
    Dr. Walter Gibbs: Won't that be grand? Computers and the programs
    will start thinking and the people will stop.
    -- Tron (1982)

  6. Re: Simple GUI making under Linux

    houghi wrote:
    >> OK. This one read a file (channel.list) and creates a button for each
    >> line, three buttons per row. The image files will have to be in PNM or
    >> GIF format, as those are the only ones supported by TK.

    >
    > OK.


    Well, I have done it not in a real scripting way. I basicaly have done
    the following:

    #!/usr/bin/wish
    wm geometry . 64x146-0+128
    set chan vt4
    set image [image create photo -file /home/houghi/bin/tv/$chan.pnm]
    button .$chan -bd 0 -image $image -command {exec ivtv-tune --device=/dev/video0 -teurope-west -f 245.25}
    place .$chan -x 1 -y 1 -width 20 -height 20
    set chan 2be
    set image [image create photo -file /home/houghi/bin/tv/$chan.pnm]
    button .$chan -bd 0 -image $image -command {exec ivtv-tune --device=/dev/video0 -teurope-west -f 487.25}
    place .$chan -x 22 -y 1 -width 20 -height 20


    And the repeated that for each channel I wanted.

    All the files I gave the name `station_name.pnm`, which means that even
    if I would re-write the script, all I need is just the station and the
    frequency. You then just see that you have the pnm files with the
    correct name

    Most of the time I needed to get the logo's. So what I di was the
    following. First find a logo with the image searcher of google. Only
    smal images. Then find a sqare one.

    I download an convert that with e.g. `convert
    http://vmmtv.be/afb/navigatie_vtm.jpg vtm.pnm`. As you can see no need
    to first download it.
    Then with gimp, I first did a autocrop and see if it is still a bit
    sqare and then convert it to 20x20. So here is how it looks:
    http://houghi.org/Fun/MyTV.jpg

    The channels are from top left to bottom righ:
    vt4, 2be, vijfTV
    BBC One, BBC Two, National Geographic
    Vitaya, Een, Canvas
    TMF, MTV, Jim Music
    Nederland 1, Nederland 2, Nederland 3
    ARD, ZDF, WDR
    VTM, CNBC, MCM



    houghi
    --
    Dr. Walter Gibbs: Won't that be grand? Computers and the programs
    will start thinking and the people will stop.
    -- Tron (1982)

  7. Re: Simple GUI making under Linux

    houghi turned on the Etch-A-Sketch and wrote:


    > I have glade and I am able to make something, but I am not able to let
    > the bittons do anything or make the buttons the size I want them to be
    > or even close the program by clicking on the X.
    >
    > houghi


    Hey, I think today is a good day for you to begin learning Assembly!

    http://www.cin.ufpe.br/~if817/arquiv...tut/index.html

    :P


    --
    www.perfectreign.com || www.filesite.org

    powered by the lizard: www.opensuse.org

  8. Re: Simple GUI making under Linux

    houghi schrieb:
    >>
    >>> * How to become a billionaire with the program
    >>>

    >>
    >> Still waiting for the lotery jackpot.

    >
    > I heard that your chances increase if you actually play and the best you
    > can become is a millionaire.
    >

    Nope. All you can achieve is becoming a grumpy, old-school Tcl hacker:

    http://wiki.tcl.tk/14103

    Kind regards

    Jan

  9. Re: Simple GUI making under Linux

    PerfectReign wrote:
    > Hey, I think today is a good day for you to begin learning Assembly!


    The last attempt to that was with my C64 and I never got any further
    then re-typing what others did. I was a bit better with basic and I even
    understood some of the peek and poke.

    houghi
    --
    You are about to enter another dimension, a dimension not only of
    sight and sound but of mind. A journey into a wondrous land of
    imagination. Next stop, Usenet!

  10. Re: Simple GUI making under Linux

    houghi turned on the Etch-A-Sketch and wrote:

    > PerfectReign wrote:
    >> Hey, I think today is a good day for you to begin learning Assembly!

    >
    > The last attempt to that was with my C64 and I never got any further
    > then re-typing what others did. I was a bit better with basic and I even
    > understood some of the peek and poke.
    >
    > houghi


    LOL!

    I remember peek and poke on my Apple II...


    --
    www.perfectreign.com || www.filesite.org

    powered by the lizard: www.opensuse.org

+ Reply to Thread