• Linux GUI脚本zenity


    zentiy可以帮助你使用脚本创建常用的gtk+对话框。
    1、使用日历控件:

    szDate=$(zenity --calendar --text "Pick a day" --title "Medical Leave" --day 13 --month 5
    --year 2010); echo $szDate


    2、创建一个Entry对话框:

    szAnswer=$(zenity --entry --text "where are you?" --entry-text "at home"); echo $szAnswer


    3、创建一个错误对话框:

    zenity --error --text "Installation failed! "


    4、创建一个Info对话框:

    zenity --info --text "Join us at irc.freenode.net #lbe."


    5、创建一个文件选择对话框:

    szSavePath=$(zenity --file-selection --save --confirm-overwrite);echo $szSavePath


    6、创建一个通知对话框:

    zenity  --notification  --window-icon=update.png  --text "Please update your system."


    7、创建一个进度对话框:

    gksudo lsof | tee >(zenity --progress --pulsate) >lsof.txt


    8、创建一个question对话框:

    zenity --question --text "Are you sure you want to shutdown?"; echo $?


    9、创建一个警告对话框:

    zenity --warning --text "This will kill, are you sure?";echo $?


    10、创建一个滑动scale对话框:

    ans=$(zenity --scale --text "pick a number" --min-value=2 --max-value=100 --value=2
    --step 2);echo $ans


    11、创建一个文本信息对话框:

    gksudo lsof | zenity --text-info --width 530


    12、创建一个列表对话框:
    radiolist:

    ans=$(zenity  --list  --text "Is linux.byexamples.com helpful?" --radiolist  --column "Pick"
    --column "Opinion" TRUE Amazing FALSE Average FALSE "Difficult to follow" FALSE "Not helpful");
    echo $ans


    checklist:

    ans=$(zenity  --list  --text "How linux.byexamples can be improved?" --checklist 
    --column "Pick" --column "options" TRUE "More pictures" TRUE "More complete post" FALSE "
    Includes Installation guidelines" FALSE "Create a forum for question queries"
    --separator=":"); echo $ans


    一个linux elementary主题的安装脚本的例子:

    Java代码  收藏代码
    1. #!/bin/bash  
    2.   
    3. zenity --info --text "This is an installation file for elementary theme.\nIt will download latest packages and install them\nand aswell apply the elementary theme.\n\nVisit us at: www.elementary-project.com\nIRC: #elementary on irc.freenode.org\n\nBest Regards\nElementary Team"  
    4.   
    5. OPTIONS=$(zenity --list --width=370 --height=350 --title="elementary installation" --text="Please select elementary components you\nwould like to have installed." --checklist  --column "Option" --column  "Description" TRUE "Elementary Theme" TRUE "Elementary Icons" TRUE "GTK Murrine Engine")  
    6.   
    7. (  
    8.   
    9. gksudo "add-apt-repository ppa:elementaryart/ppa"   
    10. gksudo "apt-get update"  
    11.   
    12. DOIT=$(echo $OPTIONS | grep "Engine")  
    13. if [ -n "$DOIT" ] ; then  
    14.     gksudo apt-get install gtk2-engines-murrine  
    15. fi  
    16.   
    17. DOIT=$(echo $OPTIONS | grep "Theme")  
    18. if [ -n "$DOIT" ] ; then  
    19.         gksudo apt-get install elementary-theme  
    20. fi  
    21.   
    22. DOIT=$(echo $OPTIONS | grep "Icons")  
    23. if [ -n "$DOIT" ] ; then  
    24.         gksudo apt-get install elementary-icon-theme  
    25. fi  
    26.   
    27. gconftool-2 --type string --set /desktop/gnome/interface/gtk_theme "elementary"  
    28. gconftool-2 --type string --set /apps/metacity/general/theme "elementary"  
    29. gconftool-2 --type string --set /desktop/gnome/interface/icon_theme "elementary"  
    30.   
    31. ) | zenity --progress --width 370 --height 180 --pulsate --title "Installing selected components" --text "Installing...\nBe patient please." --auto-close  
    32.   
    33. zenity --info --text "elementary theme successfully installed!\n\nScript made by: Nookie^\n\nVisit: elementary-project.com\nIRC: #elementary on irc.freenode.org" 


    转自:http://fuliang.iteye.com/blog/666057
  • 相关阅读:
    如何搭建企业级中台系统
    Linux上安装git
    Jenkins的CI持续集成
    docker安装jenkins
    在线思维导图网站
    K8s容器编排
    MySQL存储引擎
    tomcat8 进入不了Manager App 界面 403 Access Denied
    IdeaVim-常用操作
    Node.js 安装及环境配置之 Windows 篇
  • 原文地址:https://www.cnblogs.com/linuxer/p/2272514.html
Copyright © 2020-2023  润新知