Announcement

Collapse
No announcement yet.

Help wanted to understand kdialog output

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Help wanted to understand kdialog output

    System: Kubuntu 16.04 with kubuntu-backports enabled.

    I made eight files: abc.txt, def.txt, ghi.txt, jkl.txt, mno.txt, pqr.txt, stu.txt, and vwx.txt. Then, I ran kdialog with --menu, --checklist, and --combobox. The terminal output is shown below.

    What I see in the kdialog window that appears (not shown) is as follows.
    • with --menu, I get the terminal message shown below and I only see four files: def.txt, jkl.txt, pqr.txt, and vwx.txt
    • with --checklist, I get the terminal message shown below and I only see two files: def.txt and mno.txt
    • with --combox, there's no terminal message and I can see all files by scrolling with the down arrow.


    Is there something I need to fix? I would prefer to use either --menu or --checklist, if that's possible.

    Code:
    $ touch abc.txt def.txt ghi.txt jkl.txt mno.txt pqr.txt stu.txt vwx.txt
    $ ls
    abc.txt  def.txt  ghi.txt  jkl.txt  mno.txt  pqr.txt  stu.txt vwx.txt
    $ kdialog --menu "Select a file:" $(ls)
    QInotifyFileSystemWatcherEngine::addPaths: inotify_add_watch failed: No such file or directory
    QFileSystemWatcher: failed to add paths: /home/chimak/.config/ibus/bus
    Bus::open: Can not get ibus-daemon's address.
    IBusInputContext::createInputContext: no connection to ibus-daemon
    $ kdialog --checklist "Select a file:" $(ls)
    QInotifyFileSystemWatcherEngine::addPaths: inotify_add_watch failed: No such file or directory
    QFileSystemWatcher: failed to add paths: /home/chimak/.config/ibus/bus
    Bus::open: Can not get ibus-daemon's address.
    IBusInputContext::createInputContext: no connection to ibus-daemon
    $ kdialog --combobox "Select a file:" $(ls)
    $
    Edit: zenity works fine: all eight files are listed but zenity isn't default in Kubuntu.
    Code:
    $ zenity --list="Select a file:" --column="File" $(ls)
    Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
    $
    Last edited by chimak111; Nov 22, 2017, 12:41 AM. Reason: added stuff about zenity
    Kubuntu 20.04

    #2
    Documentation with examples

    Development/Tutorials/Shell Scripting with KDE Dialogs: https://techbase.kde.org/Development...th_KDE_Dialogs
    Before you edit, BACKUP !

    Why there are dead links ?
    1. Thread: Please explain how to access old kubuntu forum posts
    2. Thread: Lost Information

    Comment


      #3
      I read that but still can't understand why all items aren't being listed with --menu or --checklist. I'm not experienced in coding.
      Kubuntu 20.04

      Comment


        #4
        Originally posted by chimak111 View Post
        I read that but still can't understand why all items aren't being listed with --menu or --checklist. I'm not experienced in coding.
        No one is expecting that you are experienced but you could read and execute the examples. With the menu dialog: https://techbase.kde.org/Development...enu_dialog_box

        Code:
        kdialog --menu "Select a language:" a "American English" b French d "Oz' English"
        If you select the first option (in this case American English and press OK, then kdialog will send the associated key (in this case the letter a) to standard output. Note that the keys do not need to be lower case letters - you can equally use numbers, upper case letters, strings or the contents of shell variables.
        The 'kdialog --menu' is expecting a paired list of output and options.

        When you throw the command:
        Code:
        kdialog --menu "Select a file:" $(ls)
        to the terminal there is a list of:

        Code:
        output    option
        ---------------------
        abc.txt    def.txt
        ghi.txt     jkl.txt
        mno.txt   pqr.txt
        stu.txt     vwx.txt
        When you click the option 'def.txt' the output will be 'abc.txt' and so on...
        Last edited by Rog131; Nov 22, 2017, 03:34 AM.
        Before you edit, BACKUP !

        Why there are dead links ?
        1. Thread: Please explain how to access old kubuntu forum posts
        2. Thread: Lost Information

        Comment


          #5
          Sorry to have troubled you! I was trying to convert the code in https://github.com/leehblue/texpander to use kdialog instead of zenity. While what I managed doesn't work properly in konsole, it works in browser text boxes and in GUI-based text editors and in LibreOffice Writer.

          Code:
          #!/bin/bash
          
          # Version: 1.2.1
          # Release: September 12, 2017
          
          pid=$(xdotool getwindowfocus getwindowpid)
          proc_name=$(cat /proc/$pid/comm)
          
          base_dir="${HOME}/.texpander/"
          abbrvs=$(ls $base_dir)
          
          #name=$(zenity --list --title=Texpander --width=275 --height=400 --column=Abbreviations $abbrvs)
          name=$(kdialog --combobox "Choose from the dropdown" $abbrvs)
          
          path=$base_dir$name
          
          if [[ $name ]]
          then
           if [ -e "$path" ]
           then
             clipboard=$(xclip -selection clipboard -o)
             xclip -selection c -i "$path"
          
             if [[ $proc_name =~ (termin|nano|konsole) ]]
             then
               xdotool key ctrl+shift+v
             else
               xdotool key ctrl+v
             fi
             
             sleep 1s
          
             echo $clipboard | xclip -selection c
           else
          #    zenity --error --text="Abbreviation not found:\n$name"
             kdialog --title "Something went wrong" --passivepopup \ "What happened?" 2
             
           fi
          fi
          Kubuntu 20.04

          Comment


            #6
            Both those kdialog lines work fine here in konsole. The error must be elsewhere, or explain what you mean by "trouble"

            Please Read Me

            Comment


              #7
              Originally posted by oshunluvr View Post
              Both those kdialog lines work fine here in konsole. The error must be elsewhere, or explain what you mean by "trouble"
              I have a few simple scripts that use zenity and was trying to see if I could get them to work with kdialog instead.

              In this case, it's the texpander script which I linked to above. I was/am searching for the kdialog functional equivalent to zenity's "--list" option. As rog131 pointed out, neither --checklist nor --menu are equivalent. The closest I can find is --combobox.

              So I'm not saying that any kdialog options aren't working the way they are intended to. I misread their purpose
              Kubuntu 20.04

              Comment

              Working...
              X