GtkDialog - tips

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
PastorEdBTwo
Posts: 3
Joined: Thu 01 Oct 2015, 18:50

#1036 Post by PastorEdBTwo »

Geoffrey -

Thank you for responding. However adding the ampersand (&) after the program name in the action does NOT make the original gtkdialog menu go away.

It just lets me run the command, with the menu still active in the background.

For example:

Code: Select all

<menuitem icon="accessories-calculator"><label>Calculator</label><action>galculator &</action></menuitem>
DOES run the program "galculator" - but right over the top of the still-in-existence-not-dismissed menu.

What I'm wanting to happen is whenever I select a program, the menu is dismissed right after I've clicked it AS the program is launching.[/code]

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

#1037 Post by Geoffrey »

PastorEdBTwo wrote:It just lets me run the command, with the menu still active in the background.

For example:

Code: Select all

<menuitem icon="accessories-calculator"><label>Calculator</label><action>galculator &</action></menuitem>
DOES run the program "galculator" - but right over the top of the still-in-existence-not-dismissed menu.

What I'm wanting to happen is whenever I select a program, the menu is dismissed right after I've clicked it AS the program is launching.[/code]
This will fix it, you need to run exit also. :)

Code: Select all

<menuitem icon="accessories-calculator"><label>Calculator</label><action>galculator &</action><action>exit:Quit</action></menuitem>
[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]

PastorEdBTwo
Posts: 3
Joined: Thu 01 Oct 2015, 18:50

#1038 Post by PastorEdBTwo »

WHOO HOO!

The combination of the last two hints makes it work:

Both the ampersand (&) AND the <action>exit:Quit</action> command make it work the way I want.

Thanks, everyone! It works a treat. Here's the final result:

Image

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

comboboxentry widget

#1039 Post by Argolance »


User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#1040 Post by don570 »

to PastorEdBTwo...


You could make the cancel button small (homogeneous) and place it in the middle or to
to extreme side of a column ---> Thunor's tip

I show how in gtkdialog manual

http://murga-linux.com/puppy/viewtopic.php?t=89045

___________________________________________

Another tip - I found that <window> widget is needed when
using gtkdialog in Ubuntu

Scripts just wouldn't work without it.

_____________________________________

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#1041 Post by don570 »

To make two buttons appear in the middle of a column --->

Here's a simple example...

width-request="300" is needed to make the column wide so space
will show.
#!/bin/sh
export MAIN='
<window resizable="true">

<hbox width-request="300" homogeneous="true"> <hbox>

<button cancel></button>
<button>
<label>"Set"</label>
<input file stock="gtk-ok"></input>

<action>EXIT:exit</action>
</button>
</hbox> </hbox>
</window>

'

gtkdialog -c -p MAIN

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

export variable to dialog

#1042 Post by mavrothal »

In a script a have a function that exports a viariable, say test_func() that exports TEST_VAR. Then in then gtkdialog gui I have

Code: Select all

<action>test_func</action>
<action>echo $TEST_VAR</action>
and TEST_VAR is empty.
If I run test_func before I call gtkdialog then TEST_VAR is there.
I guess I need some way to tell to a running dialog to import this newly generated variable.
How could I do that?
Thanks.
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#1043 Post by SFR »

Hey Mavrothal

As far as I know everything enclosed by a single <action>...</action> tags is executed in a seaparate subshell, so any changes made to variables won't get back to a parent shell.
Well, taking your example, this would work:

Code: Select all

<action>test_func; echo $TEST_VAR</action>
since it's still in boundaries of the very same subshell, but not much beyond that; $TEST_VAR's value will be lost in next line...

The only way I know to freely share data between subshells is to use some kind of IPC, e.g. a temp file or named pipe.

Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#1044 Post by mavrothal »

SFR wrote:The only way I know to freely share data between subshells is to use some kind of IPC, e.g. a temp file or named pipe.
Thanks. I'll try this then.
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

tele1234567891
Posts: 13
Joined: Sat 15 Nov 2014, 20:53

#1045 Post by tele1234567891 »

https://code.google.com/p/gtkdialog/w/list

web page is in read only,
exist newer version with newer code and updated tutorial?

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#1046 Post by don570 »

If you're looking for source code....

http://ftp.nl.freebsd.org/pub/pub/ibibl ... 8.4.tar.xz

____________________________________

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#1047 Post by don570 »

Tip:

If you're using a button to close the window and then initiate some processing
of the data.....

your button should assign the exit variable to a word,
if you don't ----> the exit variable will be the label text. If you use
gettext it could be a foreign word.

EXAMPLE:

Code: Select all

<button>
<input file stock="gtk-ok"></input>
<label>"'"$(gettext 'Apply')"'"</label>
<action>exit:CLICKED</action>
</button>

Without the line <action>exit:CLICKED</action>
the exit variable would be assigned the foreign word for 'Apply'

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#1048 Post by don570 »

Tip :

In a situation where you have two text widgets that you want to be horizontal , I found a situation where 'echo -n' is important.

Here's an example. The second text widget is simply loading a number
from a text file, but I found that the number needs a line ending.

Code: Select all

echo -n  "5" >  /tmp/pcount 
provides that line ending

Code: Select all

 <hbox>
         <text>
            <variable>TEXTFLD</variable>
            <label>Times Button pressed: </label>
         </text>
         
         <text>
            <variable>TEXTWD</variable>
            <input>cat /tmp/pcount</input>
         </text>
      </hbox> 
Look at the difference between a line ending(the top image) and no line ending(the bottom image)

Image

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#1049 Post by zigbert »

This was a great tip. I used echo -n to fix 2 vertical alignment issues in pMusic.

Thank you

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#1050 Post by step »

The code below displays two side-by-side pictures with editable captions.
Image #1 in the attached screenshot shows the right side of the window.
I can't get it to look right. I want it to look like Image #2. Basically I want to eliminate the bleeding window color from inside the <frame> so that picture background and text background blend. I added some styles to ease the task, but still I can't get image #1 to look like image #2. Help me please.

You need to place a test image in /tmp/test.png, save this code as /tmp/test.xml, save the styles to /tmp/test.rc, write some caption text to /tmp/test.txt, and run with

Code: Select all

gtkdialog --space-expand=true --space-fill=true --styles /tmp/test.rc -s < /tmp/test.xml
Thanks in advance.

Code: Select all

<window name="filmstripWindow" resizable="false">
  <vbox>
    <hbox>
      <vbox>
        <frame>
          <eventbox name="filmstripPictureFrame">
            <pixmap yalign="0">
              <variable export="false">y0x0</variable>
              <width>180</width>
              <height>120</height>
              <input>/tmp/test.png</input>
            </pixmap>
	    <action signal="button-press-event">echo >&2 pressed y0x0</action>
          </eventbox>
          <edit name="filmstripCaption" cursor-visible="false" editable="false" accepts-tab="false" wrap-mode="2" hscrollbar-policy="2" vscrollbar-policy="2">
            <variable export="false">y0x0c</variable>
            <input file>/tmp/test.txt</input>
            <width>200</width>
            <height>60</height>
          </edit>
        </frame>
      </vbox>
      <vbox>
        <frame>
          <eventbox name="filmstripPictureFrame">
            <pixmap yalign="0">
              <variable export="false">y0x1</variable>
              <width>180</width>
              <height>120</height>
              <input file>/tmp/test.png</input>
            </pixmap>
	    <action signal="button-press-event">echo >&2 pressed y0x1</action>
          </eventbox>
          <edit name="filmstripCaption" cursor-visible="false" editable="false" accepts-tab="false" wrap-mode="2" hscrollbar-policy="2" vscrollbar-policy="2">
            <variable export="false">y0x1c</variable>
            <input file>/tmp/test.txt</input>
            <width>200</width>
            <height>60</height>
          </edit>
        </frame>
      </vbox>
    </hbox>
    <hbox space-fill="false" space-expand="false">
      <text space-fill="true" space-expand="true"><label>""</label></text>
      <button tooltip-text="Help" stock-icon-size="1">
        <input file stock="gtk-about"></input>
        <action>launch:GUI_ABOUT</action>
      </button>
      <button tooltip-text="Help" stock-icon-size="1">
        <input file stock="gtk-about"></input>
        <action>launch:GUI_ABOUT</action>
      </button>
      <button tooltip-text="Exit" stock-icon-size="1">
        <input file stock="gtk-quit"></input>
        <action>exit:EXIT</action>
      </button>
    </hbox>
  </vbox>
</window>

Code: Select all

style "styleWindow" {
	bg[NORMAL] = "#DCDAD5"
}
style "stylePictureFrame" {
	bg[NORMAL] = "#fff"
}
style "styleCaption" {
	bg[NORMAL] = "#fff"
}

widget "*filmstripWindow" style "styleWindow"
widget "*filmstripPictureFrame" style "stylePictureFrame"
widget "*filmstripCaption" style "styleCaption"
Attachments
2016-01-11_185341_J.png
(17.42 KiB) Downloaded 260 times
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#1051 Post by zigbert »

step
<vbox> and <hbox> has a default margin of 5 pixels. This can be overwritten by

<vbox margin="0">

If this didn't help you, give a note...

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#1052 Post by don570 »

a guess...
Do your testing with resizable="true"

Code: Select all

<window name="filmstripWindow" resizable="true"> 
_______________________________

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#1053 Post by step »

Hi, thanks for helping me.
I added margin="0" to all vbox and hbox tags: no visible change.
I changed resizable to false (but I need it true in the final code): no visible change.
Still unresolved.
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

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

#1054 Post by MochiMoppel »

For debugging I took the liberty to make the code simpler. Here is how far I got:
To eliminate the horizontal border between the eventbox and the edit widget you have set spacing="0" for the vbox (vboxes have a default spacing of 5px).
However this is not sufficient to remove the border. You also have to place the vbox inside the frame. Looks OK to me now.

Code: Select all

<window name="filmstripWindow" resizable="false"> 
<vbox> 
 <hbox> 
   <frame Frametitle> 
   <vbox spacing="0">
	   <eventbox name="filmstripPictureFrame"> 
			<pixmap yalign="0"> 
				<variable export="false">y0x1</variable> 
				<width>180</width> 
				<height>120</height> 
				<input file>/tmp/test.png</input> 
			</pixmap> 
			<action signal="button-press-event">echo >&2 pressed y0x1</action> 
	   </eventbox> 
	   <edit margin="0" name="filmstripCaption" cursor-visible="false" editable="false" accepts-tab="false" wrap-mode="2" hscrollbar-policy="2" vscrollbar-policy="2"> 
		 <variable export="false">y0x1c</variable> 
		 <input file>/tmp/test.txt</input> 
		 <width>200</width> 
		 <height>60</height> 
	   </edit>
   </vbox> 
	</frame> 
 </hbox> 
 <hbox space-fill="false" space-expand="false"> 
   <text space-fill="true" space-expand="true"><label>""</label></text> 
   <button tooltip-text="Help" stock-icon-size="1"> 
	 <input file stock="gtk-about"></input> 
	 <action>launch:GUI_ABOUT</action> 
   </button> 
   <button tooltip-text="Help" stock-icon-size="1"> 
	 <input file stock="gtk-about"></input> 
	 <action>launch:GUI_ABOUT</action> 
   </button> 
   <button tooltip-text="Exit" stock-icon-size="1"> 
	 <input file stock="gtk-quit"></input> 
	 <action>exit:EXIT</action> 
   </button> 
 </hbox> 
</vbox> 
</window>
Attachments
testoutput.png
(13.72 KiB) Downloaded 592 times

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#1055 Post by step »

Thanks MochiMoppel for helping me, this is good!
Left: no margin and frame inside vbox (adding spacing="0" makes no difference)
Center: spacing="0" and frame outside, as you pointed out
Right: spacing="0" and no frame.

edit 2015-1-13 margin->spacing
Attachments
xscreenshot00001.png
(4.89 KiB) Downloaded 517 times
Last edited by step on Wed 13 Jan 2016, 22:06, edited 1 time in total.
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

Post Reply