GtkDialog - tips

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
B.K. Johnson
Posts: 807
Joined: Mon 12 Oct 2009, 17:11

#1111 Post by B.K. Johnson »

@Geoffrey
Thanks for those 2 examples.

Bonus question:
What's the definitive link for yad commands. I did not see "timeout" and "no-buttons" anywhere I looked?
[color=blue]B.K. Johnson
tahrpup-6.0.5 PAE (upgraded from 6.0 =>6.0.2=>6.0.3=>6.0.5 via quickpet/PPM=Not installed); slacko-5.7 occasionally. Frugal install, pupsave file, multi OS flashdrive, FAT32 , SYSLINUX boot, CPU-Dual E2140, 4GB RAM[/color]

Wognath
Posts: 423
Joined: Sun 19 Apr 2009, 17:23

#1112 Post by Wognath »

What's the definitive link for yad commands.
http://smokey01.com/help/yad-tips-0.0.1.ncd.tar.xz

B.K. Johnson
Posts: 807
Joined: Mon 12 Oct 2009, 17:11

#1113 Post by B.K. Johnson »

@Wognath
Thanks for the link.
[color=blue]B.K. Johnson
tahrpup-6.0.5 PAE (upgraded from 6.0 =>6.0.2=>6.0.3=>6.0.5 via quickpet/PPM=Not installed); slacko-5.7 occasionally. Frugal install, pupsave file, multi OS flashdrive, FAT32 , SYSLINUX boot, CPU-Dual E2140, 4GB RAM[/color]

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

#1114 Post by Geoffrey »

B.K. Johnson wrote: I did not see "timeout" and "no-buttons" anywhere I looked?
In the terminal type either of these.

Code: Select all

Help Options:
  -h, --help                                     Show help options
  --help-all                                     Show all help options
  --help-general                                 Show general options
  --help-common                                  Show common options
  --help-calendar                                Show calendar options
  --help-color                                   Show color selection options
  --help-dnd                                     Show drag-n-drop options
  --help-entry                                   Show text entry options
  --help-file                                    Show file selection options
  --help-font                                    Show font selection options
  --help-form                                    Show form options
  --help-icons                                   Show icons box options
  --help-list                                    Show list options
  --help-multi-progress                          Show multi progress bars options
  --help-notebook                                Show notebook dialog options
  --help-notification                            Show notification icon options
  --help-paned                                   Show paned dialog options
  --help-picture                                 Show picture dialog options
  --help-print                                   Show print dialog options
  --help-progress                                Show progress options
  --help-scale                                   Show scale options
  --help-text                                    Show text information options
  --help-filter                                  Show file filter options
  --help-misc                                    Show miscellaneous options
  --help-gtk
The general help options show the commands you seek.

Code: Select all

# yad --help-general
Usage:
  yad [OPTION...] - Yet another dialoging program

General options
  --title=TITLE                                  Set the dialog title
  --window-icon=ICONPATH                         Set the window icon
  --width=WIDTH                                  Set the width
  --height=HEIGHT                                Set the height
  --geometry=WxH+X+Y                             Set the window geometry
  --timeout=TIMEOUT                              Set dialog timeout in seconds
  --timeout-indicator=POS                        Show remaining time indicator (top, bottom, left, right)
  --text=TEXT                                    Set the dialog text
  --text-align=TYPE                              Set the dialog text alignment (left, center, right, fill)
  --image=IMAGE                                  Set the dialog image
  --image-on-top                                 Show image above main widget
  --icon-theme=THEME                             Use specified icon theme instead of default
  --expander=TEXT                                Hide main widget with expander
  --button=NAME:ID                               Add dialog button (may be used multiple times)
  --no-buttons                                   Don't show buttons
  --buttons-layout=TYPE                          Set buttons layout type (spread, edge, start, end or center)
  --no-markup                                    Don't use pango markup language in dialog's text
  --no-escape                                    Don't close dialog if Escape was pressed
  --borders=NUMBER                               Set window borders
  --always-print-result                          Always print result
  --selectable-labels                            Dialog text can be selected
  --sticky                                       Set window sticky
  --fixed                                        Set window unresizable
  --on-top                                       Place window on top
  --center                                       Place window on center of screen
  --mouse                                        Place window at the mouse position
  --undecorated                                  Set window undecorated
  --skip-taskbar                                 Don't show window in taskbar
  --maximized                                    Set window maximized
  --fullscreen                                   Set window fulscreen
  --no-focus                                     Don't focus dialog window
  --splash                                       Open window as a splashscreen
  --plug=KEY                                     Special type of dialog for XEMBED
  --tabnum=NUMBER                                Tab nubmer of this dialog
  --parent-win=XID                               XID of parent window
  --kill-parent=SIGNAL                           Send SIGNAL to parent
  --print-xid                                    Print X Window Id to the stderr
  --image-path=PATH                              Add path for search icons by name
[b]Carolina:[/b] [url=http://smokey01.com/carolina/pages/recent-repo.html]Recent Repository Additions[/url]
[img]https://dl.dropboxusercontent.com/s/ahfade8q4def1lq/signbot.gif[/img]

B.K. Johnson
Posts: 807
Joined: Mon 12 Oct 2009, 17:11

#1115 Post by B.K. Johnson »

That is just wonderful Geoffrey.
Greatly appreciated.
[color=blue]B.K. Johnson
tahrpup-6.0.5 PAE (upgraded from 6.0 =>6.0.2=>6.0.3=>6.0.5 via quickpet/PPM=Not installed); slacko-5.7 occasionally. Frugal install, pupsave file, multi OS flashdrive, FAT32 , SYSLINUX boot, CPU-Dual E2140, 4GB RAM[/color]

User avatar
smokey01
Posts: 2813
Joined: Sat 30 Dec 2006, 23:15
Location: South Australia :-(
Contact:

#1116 Post by smokey01 »

I'm trying to find a way to make the GUI refresh depending if a file called checkfile exists in /root.

The create button creates the file and the delete buttons deletes it. I want the frame to hide if no checkfile exist and show if it does. It works fine if the GUI is restarted.

Code: Select all

#!/bin/bash

[ -z $GTKDIALOG ] && GTKDIALOG=gtkdialog

CHECK () {
if [ -f /root/checkfile ]; then
    eth0=true
else
    eth0=false
fi
}
export -f CHECK

CHECK

export MAIN_DIALOG='
<window window-position="3" icon-name="gtk-network" title="'"$eth0"'" resizable="true" border-width="0">
<vbox>
	<frame Create/Delete>
		<hbox>
			<button>
			<input file stock="gtk-add"></input>
				<label>Create</label>
				<action>echo checkfile > /root/checkfile &</action>
			</button>
			<button>
			<input file stock="gtk-delete"></input>
				<label>Delete</label>
				<action>rm /root/checkfile &</action>
			</button>	
</hbox>
	</frame>
<vbox visible="'"$eth0"'">
	<frame Boo>
		<hbox homogeneous="true" auto-refresh="true">
			<button>
				<input file>/usr/share/pixmaps/midi-icons/home48.png</input>
				<action>yad --text="Bingo" --center &</action>
				<action>CHECK</action>
				<action type="refresh">eth0</action>
				<variable>eth0</variable>
			</button>
		</hbox>
	</frame>
</vbox>
<vbox>	
		<hbox>
			<button ok>
			</button>
		</hbox>
</vbox>
</vbox>
</window>'

case $1 in
	-d | --dump) echo "$MAIN_DIALOG" ;;
	*) $GTKDIALOG --program=MAIN_DIALOG ;;
esac
Thanks

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#1117 Post by MochiMoppel »

smokey01 wrote:I'm trying to find a way to make the GUI refresh depending if a file called checkfile exists in /root.

The create button creates the file and the delete buttons deletes it.
This should do it:

Code: Select all

#! /bin/sh
export MAIN_DIALOG=' 
<window window-position="3" icon-name="gtk-network"  resizable="true" border-width="0"> 
<vbox> 
<frame Create/Delete> 
   <hbox> 
	  <button> 
	  <input file stock="gtk-add"></input> 
		 <label>Create</label> 
		 <action>echo checkfile > /root/checkfile &</action> 
         <action>show:vBOO</action>
        <action>refresh:vWIN</action>
	  </button> 
	  <button> 
	  <input file stock="gtk-delete"></input> 
		 <label>Delete</label> 
		 <action>rm /root/checkfile &</action> 
        <action>hide:vBOO</action>
        <action>refresh:vWIN</action>
	  </button>    
</hbox> 
</frame> 

<vbox> 
<frame Boo> 
   <hbox homogeneous="true" auto-refresh="true"> 
	  <button> 
		 <input file>/usr/share/pixmaps/midi-icons/home48.png</input> 
		 <action>yad --text="Bingo" --center &</action> 
	  </button> 
   </hbox> 
</frame>
<variable>vBOO</variable> 
</vbox> 
<vbox>    
   <hbox> 
	  <button ok> 
	  </button> 
   </hbox> 
</vbox> 
</vbox> 
<action signal="show" condition="command_is_true([[ -f /root/checkfile ]] || echo true )">hide:vBOO</action>
<variable>vWIN</variable>
<input>[[ -f /root/checkfile ]] && echo checkfile exists || echo no checkfile</input>
</window>' 

gtkdialog --program=MAIN_DIALOG
EDIT: My earlier version didn't update your window title. Now it does.
I noticed that you use window-position="3" resizeable="true". AFAIK you can't resize a centered gtkdialog.

User avatar
smokey01
Posts: 2813
Joined: Sat 30 Dec 2006, 23:15
Location: South Australia :-(
Contact:

#1118 Post by smokey01 »

That's great MochiMoppel but it's hiding the image and not the frame.

I want the GUI to shrink when there's no image.

Thanks

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

#1119 Post by Geoffrey »

smokey01 wrote:I want the GUI to shrink when there's no image.
make it resizable="false", that will do it.
[b]Carolina:[/b] [url=http://smokey01.com/carolina/pages/recent-repo.html]Recent Repository Additions[/url]
[img]https://dl.dropboxusercontent.com/s/ahfade8q4def1lq/signbot.gif[/img]

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#1120 Post by MochiMoppel »

smokey01 wrote:That's great MochiMoppel but it's hiding the image and not the frame.
It does exactly what you asked for ("I want the frame to hide if no checkfile exist and show if it does"). It is hiding the frame.
I want the GUI to shrink when there's no image
Geoffrey's trick does it and I have no idea why. I haven't found any explanation of a window tag attribute resizable , not in this tutorial and not in the gtkdialog reference though the GtkWindow Manual lists the “resizable

User avatar
smokey01
Posts: 2813
Joined: Sat 30 Dec 2006, 23:15
Location: South Australia :-(
Contact:

#1121 Post by smokey01 »

MochiMoppel wrote:
smokey01 wrote:That's great MochiMoppel but it's hiding the image and not the frame.
It does exactly what you asked for ("I want the frame to hide if no checkfile exist and show if it does"). It is hiding the frame.
I want the GUI to shrink when there's no image
Geoffrey's trick does it and I have no idea why. I haven't found any explanation of a window tag attribute resizable , not in this tutorial and not in the gtkdialog reference though the GtkWindow Manual lists the “resizable

B.K. Johnson
Posts: 807
Joined: Mon 12 Oct 2009, 17:11

#1122 Post by B.K. Johnson »

Hi guys
The timeout=TIMEOUT command seems to have the bizarre behaviour of wiping out the text in msgbox or text. Can someone confirm, please?
Thanks
[color=blue]B.K. Johnson
tahrpup-6.0.5 PAE (upgraded from 6.0 =>6.0.2=>6.0.3=>6.0.5 via quickpet/PPM=Not installed); slacko-5.7 occasionally. Frugal install, pupsave file, multi OS flashdrive, FAT32 , SYSLINUX boot, CPU-Dual E2140, 4GB RAM[/color]

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

#1123 Post by Geoffrey »

B.K. Johnson wrote:Hi guys
The timeout=TIMEOUT command seems to have the bizarre behaviour of wiping out the text in msgbox or text. Can someone confirm, please?
Thanks
This is yad?, could you give an example of how the text is read.

Maybe it would be better to move the discussion to the YAD - Tips
[b]Carolina:[/b] [url=http://smokey01.com/carolina/pages/recent-repo.html]Recent Repository Additions[/url]
[img]https://dl.dropboxusercontent.com/s/ahfade8q4def1lq/signbot.gif[/img]

B.K. Johnson
Posts: 807
Joined: Mon 12 Oct 2009, 17:11

#1124 Post by B.K. Johnson »

Sure Geoffery
This is a slight modification of your earlier post.

Code: Select all

#!/bin/bash
yad --title="Yad Message Box" --width=200 --height=150 --fixed --text-align="center" --skip-taskbar --window-icon="gtk-dialog-info" \
--text="<big><b>
This is a Yad message box
</b></big>" --no-buttons --timeout="3" 
The text is not displayed.
Remove the timeout and it is shown.
[color=blue]B.K. Johnson
tahrpup-6.0.5 PAE (upgraded from 6.0 =>6.0.2=>6.0.3=>6.0.5 via quickpet/PPM=Not installed); slacko-5.7 occasionally. Frugal install, pupsave file, multi OS flashdrive, FAT32 , SYSLINUX boot, CPU-Dual E2140, 4GB RAM[/color]

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

#1125 Post by Geoffrey »

[b]Carolina:[/b] [url=http://smokey01.com/carolina/pages/recent-repo.html]Recent Repository Additions[/url]
[img]https://dl.dropboxusercontent.com/s/ahfade8q4def1lq/signbot.gif[/img]

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#1126 Post by MochiMoppel »

Back to topic and to the confusing "resizable" attribute. It turns out that I used it before for the exact purpose it was invented. It removes the "Resize" item from the window menu and prevents user resizing.

With its surprising side effects I can now solve a problem that puzzled me for a long time.

I've created a tiny image viewer with the pixmap widget. Pretty much like Viewnior it uses one dialog window to read images one after another. The problem is that while the dialog window will automatically expand when reading an image bigger than the previous image (that's good!), it will not shrink when the following image is smaller. This puts ugly empty space around the image (see screenshot).

With resizable="false" the window will expand as well, but it will also shrink, adapting window size always to the size of the image. Very neat.
Attachments
window_resizable_true_false.png
(106.77 KiB) Downloaded 720 times

User avatar
peebee
Posts: 4370
Joined: Sun 21 Sep 2008, 12:31
Location: Worcestershire, UK
Contact:

[SOLVED]

#1127 Post by peebee »

Fixed by @MochiMoppel - thank you - http://www.murga-linux.com/puppy/viewto ... 479#922479
Last edited by peebee on Thu 08 Sep 2016, 15:45, edited 1 time in total.
ImageLxPup = Puppy + LXDE
Main version used daily: LxPupSc; Assembler of UPups, ScPup & ScPup64, LxPup, LxPupSc & LxPupSc64

User avatar
torm
Posts: 186
Joined: Sat 07 Mar 2015, 19:56

#1128 Post by torm »

<action signal="type">activity</action>
if "button-release-event" is the event
does GtkStatusbar widget support that?
Or there is no release event.. ?? it appears to accept button press event..
Maybe I'm barking at the wrong tree, dunno.. zzz :(
Or any good workaround :roll:

B.K. Johnson
Posts: 807
Joined: Mon 12 Oct 2009, 17:11

#1129 Post by B.K. Johnson »

Post made in wrong thread - DELETED
[color=blue]B.K. Johnson
tahrpup-6.0.5 PAE (upgraded from 6.0 =>6.0.2=>6.0.3=>6.0.5 via quickpet/PPM=Not installed); slacko-5.7 occasionally. Frugal install, pupsave file, multi OS flashdrive, FAT32 , SYSLINUX boot, CPU-Dual E2140, 4GB RAM[/color]

B.K. Johnson
Posts: 807
Joined: Mon 12 Oct 2009, 17:11

Request for gtkdialog lint(er), formatter/pretty printer

#1130 Post by B.K. Johnson »

I chose to place this request here rather than under REQUESTS. No ruffled feathers, I hope.

Is there a lint(er) a.k.a. code formatting tool; a.k.a. pretty-printer (to screen) for gtkdialog code?
I would not want one that automatically lints as I type. I think I would find that really distracting. I'd rather use a linter that processes my code after I’ve finished my work.
[color=blue]B.K. Johnson
tahrpup-6.0.5 PAE (upgraded from 6.0 =>6.0.2=>6.0.3=>6.0.5 via quickpet/PPM=Not installed); slacko-5.7 occasionally. Frugal install, pupsave file, multi OS flashdrive, FAT32 , SYSLINUX boot, CPU-Dual E2140, 4GB RAM[/color]

Post Reply