Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

dialog box

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
johndoe777
Posts: 4
Joined: 2014-08-19 20:04

dialog box

#1 Post by johndoe777 »

I have been trying to write a simple script to use with kvm that uses the program dialog. For some reason it doesn't work for me. I am using debian wheezy but have installed kernel 3.14 amd64. I also altered my shell prompt to give me the exit status of my commands I write at the prompt and for some reason I get a return of 0 for exit status but can't see any dialog boxes. Here is the script I am using:

#!/bin/bash

#this will launch your virtual machines with a graphical menu
#in your terminal

cd /home/username/Qemu # my directory that stores virtual drives

dialogue --backtitle "KVM Virtualization Launcher" --title "Main\
Menu" --menu "Move using [UP] [DOWN], [ENTER] to Select" 15 50 10\
deb1_HDA.img "Launches deb1"\
deb2_HDA.img "Launches deb2"\
deb3_HDA.img "Launches deb3" 2>/tmp/menuitem.$$

menuitem=`cat /tmp/menuitem.$$`


case $menuitem in
deb1_HDA.img) kvm -hda deb1_HDA.img -m 256 -smp 2 -net nic -net tap,ifname=tap0,script=no,downscript=no;;
deb2_HDA.img) kvm -hda deb2_HDA.img -m 256 -smp 2 -net nic -net tap,ifname=tap0,script=no,downscript=no;;
deb3_HDA.img) kvm -hda deb3_HDA.img -m 256 -smp 2 -net nic -net tap,ifname=tap0,script=no,downscript=no;;
esac

I installed dialog with $ apt-get install dialog and I made this script executable with chmod +x virt-launcher.sh
this is what my prompt looks like:
0 11:46:45 <username>@:~$ the zero at the beginning tells me normally that the command I run is OK any other number and something is wrong :?: :?:

BowCatShot
Posts: 959
Joined: 2006-07-15 12:08

Re: dialog box

#2 Post by BowCatShot »

Try something really simple such as

/usr/bin/kdialog --msgbox "This dialog works"

If that doesn't work then dialog may not have been installed properly

User avatar
saulgoode
Posts: 1445
Joined: 2007-10-22 11:34
Been thanked: 4 times

Re: dialog box

#3 Post by saulgoode »

johndoe777 wrote:... and for some reason I get a return of 0 for exit status but can't see any dialog boxes.
The 'case' statement itself will return a status of zero if none of the patterns are matched. Since you are not seeing a dialog and the return is apparently zero, you should double check this.
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian Kernighan

User avatar
slackguy
Posts: 91
Joined: 2014-11-29 03:22

Re: dialog box

#4 Post by slackguy »

zenity works real easy. tk too (i think they are becoming tied to the mswin world?)

i'm sure kv is good but sometimes it's better not to beat yourself over the head on one free app that is temporarily not working and just use what is working

User avatar
slackguy
Posts: 91
Joined: 2014-11-29 03:22

Re: dialog box

#5 Post by slackguy »

debian installs perl early on in installation (always there, works well) and perl is quite a nifty language - and has modules to load for GUI user interface

User avatar
Issyer
Posts: 3032
Joined: 2007-05-23 02:59
Location: Khakassia

Re: dialog box

#6 Post by Issyer »

johndoe777 wrote: Menu" --menu "Move using [UP] [DOWN], [ENTER] to Select" 15 50 10\
If you know exact values why do you need any dialogs? You might want to try my LauncherBox.

Image

http://webguelph.blogspot.ca/p/qlauncherbox-10.html

As for the dialogs, PyQt is pretty simple.

Code: Select all

import sys
from PyQt4 import QtGui

def main():	
	app = QtGui.QApplication(sys.argv)
	w = QtGui.QWidget()
	
	s='Hello'

	QtGui.QMessageBox.about(w, "Alert", s)
	sys.exit(app.exec_())

if __name__ == '__main__':
	main()
apt-get install python-qt4

BowCatShot
Posts: 959
Joined: 2006-07-15 12:08

Re: dialog box

#7 Post by BowCatShot »

Here's one taken from my crontab. Without the env DISPLAY=:0.0, no dialog would be displayed.


env DISPLAY=:0.0 /usr/bin/kdialog --msgbox "Hello World"

Post Reply