Page 48 of 76

ROhms

Posted: Sat 12 Jul 2014, 21:24
by walter leonardo
Program to calculate resistors by color codes. 8)

Posted: Thu 17 Jul 2014, 19:37
by Scooby
thanks for very useful gtkdialog tips :!:

Gif inside Pixmap

Posted: Sat 02 Aug 2014, 16:00
by mister_electronico
Hello I was looking for ways to introduce a gif into a pixmap and set the following.

I am not a good programmer so surely anyone can improve.

However this opens possibilities for other things I want to do.

To run the pixmap_gif decompress directory and execute within:

. / pixmap_gif




______________________________________________________________________
My blog

https://misterelectronicoes.wordpress.com/

No forget

Posted: Sat 02 Aug 2014, 16:07
by mister_electronico
Do not forget that if not executed give execute permissions to pixmap_gif and script_01.

Greetings.




______________________________________________________________________
My blog

https://misterelectronicoes.wordpress.com/

Another one

Posted: Sat 02 Aug 2014, 19:07
by mister_electronico
Another one, this time a Counter.

See you.




______________________________________________________________________
My blog

https://misterelectronicoes.wordpress.com/

Posted: Sat 02 Aug 2014, 20:22
by don570
Note to mister_electronico..

If you're learning gtkdialog then I recommend
reading my togglebutton example page. Very neat 8)

http://208.109.22.214/puppy/viewtopic.p ... f714757e5a
_____________________________________________

Hi don570

Posted: Sat 02 Aug 2014, 23:59
by mister_electronico
Hi don570, I like you post like other you did, but I ddn't find the relationship with my two last post.

See you.



______________________________________________________________________
My blog

https://misterelectronicoes.wordpress.com/

Display meter-panel.

Posted: Sun 31 Aug 2014, 20:32
by mister_electronico
I always look for a display to display data from my electronic circuits, so that I did this program gtkdialog, I think I can be useful and other people.... I hope so

The program would look like.



______________________________________________________________________
My blog

https://misterelectronicoes.wordpress.com/

The program

Posted: Sun 31 Aug 2014, 20:38
by mister_electronico
This program can accommodate the needs that we have.

Greetings




______________________________________________________________________
My blog

https://misterelectronicoes.wordpress.com/

Mobile sign

Posted: Sun 07 Sep 2014, 23:18
by mister_electronico
One mobile sign:

Code: Select all

#!/bin/bash
[ -z $GTKDIALOG ] && GTKDIALOG=gtkdialog

export DAT=/dev/shm/var1
echo "800" > $DAT


# Letro movil
funcion1 () {
VAR=( `cat $DAT` )
echo '<svg width="800" height="150" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<text x="'$VAR'" y="46" xml:space="preserve" style="font-family:monospace;font-size:64px;" font-weight="bold" fill="#7F0D0D" opacity="0.8">MOBILE SIGN WORKING</text>
</svg>' > /dev/shm/var2.svg

  VAR=`echo "$VAR - 10" | bc -l`
  echo ${VAR} > $DAT
  NUM=${VAR%%} 
  if [ $NUM -lt -720 ]; then  echo "800" > $DAT; else deci=0; fi      
}  
export -f funcion1

export MAIN='
<window title="Mobile sign" resizable="false">
  <vbox>
    <pixmap>
      <variable>IMG</variable>
      <input file>/dev/shm/var2.svg</input>
    </pixmap>
    <button ok></button>
    <timer visible="false" milliseconds="true" interval="100">
      <action>funcion1</action>
      <action type="refresh">IMG</action>
    </timer>
  </vbox>
</window>
'

case $1 in
	-d | --dump) echo "$MAIN" ;;
	*) $GTKDIALOG -cp MAIN ;;
esac
unset mobile_sign
unset funcion1
killall -9 mobile_sign.sh
Greetings


______________________________________________________________________
My blog

https://misterelectronicoes.wordpress.com/

<notebook> tabs height?

Posted: Thu 18 Sep 2014, 14:21
by Argolance
Hello,
Is there a way to fix the notebook tabs height when they are right or left of a window to make them entirely fill it? Something like:

Code: Select all

<notebook tab-height=\"xx\"...</notebook>
??
Thank you!
Cordialement.

Posted: Sat 20 Sep 2014, 20:39
by don570
To Argolance..

The space-expand and space-fill set to true are the only way I know how to
change where widgets appear. I got the info from Thunor

Code: Select all

A text widget that has space-expand and space-fill set to true can be used as a spacer to push neighbouring widgets in certain directions.

Here the spacer text is "[]" so you can see it -- drag the window out and watch the button.
	
#!/bin/sh

GTKDIALOG=gtkdialog

Spacer="[]"

MAIN_DIALOG='
<window title="Spacer Test" window-position="1">
   <vbox>
      <hbox>
         <button space-expand="false" space-fill="false">
            <label>This button will stay put</label>
            <input file stock="gtk-about"></input>
         </button>
         <text space-expand="true" space-fill="true">
            <label>"'$Spacer'"</label>
         </text>
      </hbox>
   </vbox>
</window>
'
export MAIN_DIALOG

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

Regards,
Thunor
__________________________________________

Looking at the info on the notebook widget it says that it supports
space-expand and space-fill but I'm not sure what part of notebook
widget is affected.



gtkdialog wrote: #summary notebook widget reference

= notebook widget =

A [http://developer.gnome.org/gtk2/2.24/GtkNotebook.html GtkNotebook]

----

== Definition ==

{{{
<notebook tag_attr="value"...>
widget...
<variable>varname</variable>
<input>command</input>
<input file>filename</input>
<sensitive>state</sensitive>
<action signal="type">activity</action>...
<output file>filename</output>
</notebook>
}}}

"..." denotes acceptance of multiples of the same thing.

== Tag Attributes ==

See the [http://developer.gnome.org/gtk2/2.24/Gt ... -hierarchy GtkNotebook] widget and ancestor class properties.

The following custom tag attributes are available:

<wiki:comment>ExportTableStart</wiki:comment>
|| *Name* || *Description* || *Value* || *Since* ||
|| space-expand || Pack widget expanding into space || {{{true}}} or {{{false}}} || 0.7.21 ||
|| space-fill || Pack widget filling space || {{{true}}} or {{{false}}} || 0.7.21 ||
|| block-function-signals || Block signal emissions from functions || {{{true}}} or {{{false}}} || 0.7.21 ||
|| file-monitor || Emit signal when input file(s) change || {{{true}}} or {{{false}}} || 0.8.1 ||
|| auto-refresh || Auto refresh when input file(s) change || {{{true}}} or {{{false}}} || 0.8.1 ||
|| tab-base-index || Tab label start page number || Integer || 0.7.21 ||
|| tab-labels || Tab labels || _label0_ {{{|}}} _label1_ {{{|}}} ... || 0.7.21 ||
|| tab-prefix || Tab label prefix || || 0.7.21 ||
|| tab-suffix || Tab label suffix || || 0.7.21 ||
<wiki:comment>ExportTableEnd</wiki:comment>

== Directives ==

Some of these may have tag attribute equivalents.

<wiki:comment>ExportTableStart</wiki:comment>
|| *Name* || *Description* || *Contents* || *Since* ||
|| variable || Variable name || || 0.7.21 ||
|| variable export="false" || Variable name, not exported to shell || || 0.8.3 ||
|| input^[1]^ || Data input source || Shell command || 0.7.21 ||
|| input file^[1]^ || Data input source || Filename || 0.7.21 ||
|| sensitive || Sensitive state || {{{true}}} or {{{false}}} || 0.7.21 ||
|| action signal="_type_" || Execute command on signal || Shell command || ||
|| action signal="_type_" || Perform function on signal || _function_:_parameter_ || ||
|| action signal="_type_" condition="_type_" || Execute command on signal conditionally || Shell command || 0.8.3 ||
|| action signal="_type_" condition="_type_" || Perform function on signal conditionally || _function_:_parameter_ || 0.8.3 ||
|| output file || Data output target || Filename || 0.7.21 ||
<wiki:comment>ExportTableEnd</wiki:comment>

== Signals ==

There is no default signal for this widget.

The "file-changed" signal is emitted if file-monitor is true and the input file being monitored has changed.

The following signals are connected-up for all widgets:

[http://developer.gnome.org/gtk2/2.24/Gt ... ress-event button-press-event], [http://developer.gnome.org/gtk2/2.24/Gt ... ease-event button-release-event], [http://developer.gnome.org/gtk2/2.24/Gt ... gure-event configure-event], [http://developer.gnome.org/gtk2/2.24/Gt ... tify-event enter-notify-event], [http://developer.gnome.org/gtk2/2.24/Gt ... tify-event leave-notify-event], [http://developer.gnome.org/gtk2/2.24/Gt ... s-in-event focus-in-event], [http://developer.gnome.org/gtk2/2.24/Gt ... -out-event focus-out-event], [http://developer.gnome.org/gtk2/2.24/Gt ... idget-hide hide], [http://developer.gnome.org/gtk2/2.24/Gt ... idget-show show], [http://developer.gnome.org/gtk2/2.24/Gt ... et-realize realize], [http://developer.gnome.org/gtk2/2.24/Gt ... ress-event key-press-event], [http://developer.gnome.org/gtk2/2.24/Gt ... ease-event key-release-event], [http://developer.gnome.org/gtk2/2.24/Gt ... -map-event map-event], [http://developer.gnome.org/gtk2/2.24/Gt ... nmap-event unmap-event]

== Functions ==

The following functions can be performed upon this widget by any widget capable of emitting signals:

<wiki:comment>ExportTableStart</wiki:comment>
|| *Type* || *Description* || *Parameter* || *Since* ||
|| enable || Sensitise widget || Variable name || ||
|| disable || Desensitise widget || Variable name || ||
|| show || Show widget || Variable name || 0.8.1 ||
|| hide || Hide widget || Variable name || 0.8.1 ||
|| grabfocus || Grab input focus || Variable name || 0.8.1 ||
|| refresh || Reload input data || Variable name || 0.7.21 ||
|| save || Save widget data || Variable name || 0.7.21 ||
<wiki:comment>ExportTableEnd</wiki:comment>

The following general functions can be performed by any widget capable of emitting signals:

<wiki:comment>ExportTableStart</wiki:comment>
|| *Type* || *Description* || *Parameter* || *Since* ||
|| break || Break out of actions list || None || 0.8.3 ||
|| command || Execute command || Shell command || ||
|| exit || Exit dialog || A value for the {{{EXIT}}} variable || ||
|| closewindow || Close dialog || Variable name || ||
|| launch || Launch dialog || Variable name || ||
|| presentwindow || [http://developer.gnome.org/gtk2/2.24/Gt ... ow-present Present] dialog || Variable name || 0.8.1 ||
<wiki:comment>ExportTableEnd</wiki:comment>

== Conditions ==

The following conditions can be used within the condition attribute of action directives:

<wiki:comment>ExportTableStart</wiki:comment>
|| *Type* || *Description* || *Argument* || *Since* ||
|| active_is_true(_argument_) || Active state of toggle widget || Variable name || 0.8.3 ||
|| active_is_false(_argument_) || Active state of toggle widget || Variable name || 0.8.3 ||
|| command_is_true(_argument_) || Output of shell command || Shell command || 0.8.3 ||
|| command_is_false(_argument_) || Output of shell command || Shell command || 0.8.3 ||
|| file_is_true(_argument_) || Contents of a file || Filename || 0.8.3 ||
|| file_is_false(_argument_) || Contents of a file || Filename || 0.8.3 ||
|| sensitive_is_true(_argument_) || Sensitive state of widget || Variable name || 0.8.3 ||
|| sensitive_is_false(_argument_) || Sensitive state of widget || Variable name || 0.8.3 ||
|| visible_is_true(_argument_) || Visible state of widget || Variable name || 0.8.3 ||
|| visible_is_false(_argument_) || Visible state of widget || Variable name || 0.8.3 ||
<wiki:comment>ExportTableEnd</wiki:comment>

true means "true", "yes" or a non-zero value, false means "false", "no" or zero, therefore the shell command is expected to echo one of these values to stdout.

== Notes ==

1. This widget does not accept setting a default page before being shown (there's a note about it [http://developer.gnome.org/gtk2/2.24/Gt ... rrent-page here]) which will result in input data being discarded at start-up. This issue can be overcome by using the "[http://developer.gnome.org/gtk2/2.24/Gt ... book--page page]" tag attribute which will be applied after the widget is shown.


Posted: Wed 24 Sep 2014, 10:48
by Argolance
Hello don570,
Sorry, I didn't see your message before (though I asked to be notified when a reply is posted).
Thanks a lot (#summary notebook widget reference very interesting indeed!)
Looking at the info on the notebook widget it says that it supports
space-expand and space-fill but I'm not sure what part of notebook
widget is affected.
All the same... :(

Cordialement.

Posted: Sat 18 Oct 2014, 19:21
by don570
Can the frame heading be color?? I guess not, however here is a replacement technique.

Normally widgets flow from right side of a hbox to left side, but Thunor found
a method to modify this behaviour.
Just fill with empty text on right side with this widget....
<text space-expand="true" space-fill="true">

then use

<text space-expand="false">

for the left side of window.

Code: Select all

#!/bin/sh

export MAIN_DIALOG='<window title="Examples" icon-name="gtk-info" resizable="false">

<vbox width-request="200">
    <hbox>
        <text space-expand="false"  use-markup="true"><label>"<u><span size='"'large'"' color='"'red'"'>Heading</span></u>"</label></text>   
        <text space-expand="true" space-fill="true"><label>""</label> </text> 
    </hbox>
    <edit editable="false">
			<variable>EDITOR</variable>
			<height>150</height>
			<width>350</width>
			<default>
"This is the default 
text of the editor."
			</default>
		</edit>
</vbox> 

</window>
'

gtkdialog --program=MAIN_DIALOG


Image

Posted: Sat 18 Oct 2014, 19:49
by don570
This script will change the color of text according to gtk theme.
Certain theme names will trigger the change. Blue turns to orange.

Code: Select all

#!/bin/sh
export COLOUR=3272C0
[ "`egrep "Stardust_dark_mouse|Stardust_dark_touch|Azenis|TerraNova-Aquarius|terminus|Murrina-Black|DarkRoomCompact|PenOSmaster" /root/.gtkrc-2.0`"  ] && COLOUR=FFD900

 export MAIN_DIALOG='
<window title="Example"  window-position="1">
 <vbox>
<text use-markup="true"><label>"<b><span size='"'x-large'"'>p</span><span size='"'x-large'"' color='"'#$COLOUR'"'>Archive</span></b>"</label></text>
</vbox>
</window>' 
 
 gtkdialog -p MAIN_DIALOG 
 
Image

Posted: Tue 28 Oct 2014, 08:48
by trio
Sigmund,
Override JWM-settings - skip taskbar, sticky, layer, border
This is how to override default settings in your JWM configuration.

Your gtkdialog gui must be called with the --class parameter
Code:
gtkdialog --class=APPLET -f myfile
Then this code must be in your jwm configuration file - $HOME/.jwmrc (to be set permanently, it must be added to /etc/xdg/templates/_root_.jwmrc)
Code:
<Group>
<Class>APPLET</Class>
<Option>nolist</Option>
<Option>sticky</Option>
<Option>noborder</Option>
<Option>layer:12</Option>
</Group>
I tried <window skip-taskbar-hint="true"> and it works.

Regards,

Trio

Posted: Wed 17 Dec 2014, 01:28
by don570
Example: Make a destination folder choice so it shows next time the app is run

When the user clicks a button (Save in the example below)
the choice is saved in a secret place

Code: Select all

<action>echo  "$SAVEFOLDER" >  $WORKDIR/destination</action>
Image

Code: Select all

#!/bin/sh
# example to define a destination folder

mkdir -p /root/.config/example
export WORKDIR=/root/.config/example #  export is needed for input directive

[ ! -e  $WORKDIR/destination ]  && echo "/root" > $WORKDIR/destination # set initial

export EXAMPLE='<window>
<vbox width-request="390">
  <frame Destination Folder>
  
              <hbox>
                   <entry accept="directory"  tooltip-text="Choose Directory to save your data">
                   <input>cat $WORKDIR/destination</input>                    
                   <variable>SAVEFOLDER</variable>                   
                   </entry>
                                                      
                   <button tooltip-text="Choose Directory to save your data">
                   <input file stock="gtk-directory"></input>
                   <action type="fileselect">SAVEFOLDER</action>                                                        
                  </button>
              </hbox>
              <hbox>
                   <button use-stock="true" label="gtk-save"> 
                   <action>gxmessage My save folder is now  $SAVEFOLDER</action>                  
                   <action>echo  "$SAVEFOLDER" >  $WORKDIR/destination</action>                                                        
                  </button>
               </hbox>
                  
                     
    </frame>
</vbox>
</window>'
gtkdialog -c --program=EXAMPLE

Posted: Wed 17 Dec 2014, 04:42
by MochiMoppel
Variation of above example: When the user clicks the Save button, the choice is saved in the script itself. No need to write to /root/.config

Code: Select all

#!/bin/sh

DESTINATION=/root
export SCRIPTPATH="$0"

function  save_folder { sed -i "s|^DESTINATION=.*$|DESTINATION=\"$SAVEFOLDER\"|" "$SCRIPTPATH";} 
export -f save_folder

 export EXAMPLE='<window> 
 <vbox width-request="390"> 
   <frame Destination Folder> 
   
               <hbox> 
                    <entry accept="directory"  tooltip-text="Choose Directory to save your data"> 
                    <default>'$DESTINATION'</default>                    
                    <variable>SAVEFOLDER</variable>                    
                    </entry> 
                                                       
                    <button tooltip-text="Choose Directory to save your data"> 
                    <input file stock="gtk-directory"></input> 
                    <action type="fileselect">SAVEFOLDER</action>                                                        
                   </button> 
               </hbox> 
               <hbox> 
                    <button use-stock="true" label="gtk-save"> 
                    <action>gxmessage My save folder is now  $SAVEFOLDER</action>                  
                    <action>save_folder</action>                                                        
                   </button> 
                </hbox> 
     </frame> 
 </vbox> 
 </window>' 
 gtkdialog -c --program=EXAMPLE

Posted: Thu 18 Dec 2014, 00:51
by don570
I think there is a situation that I didn't perceive when writing my script.
i.e. if the file 'destination' exists but somehow the folder has disappeared
I should have a default folder to open when first launching.

Code: Select all

[ ! -d  $WORKDIR/destination ]  && echo "/root" > $WORKDIR/destination

Posted: Thu 18 Dec 2014, 01:44
by MochiMoppel
don570 wrote:I think there is a situation that I didn't perceive when writing my script.
i.e. if the file 'destination' exists but somehow the folder has disappeared
??? The way you wrote your script the folder and the file is created at each start of the script. How could the folder "disappear" and the file it contains still exist? And how does your new code fit into the original file? The test [ ! -d $WORKDIR/destination ] is always true since a folder $WORKDIR/destination is never created and therefore never exists.
I should have a default folder to open when first launching.
What was wrong with your script? You had that already. It would be even better if the script uses a default path hard coded in the script and creates $WORKDIR/destination only if this default path was actually changed by the user. This way the system keeps clean as long as possible. If the user shortly tests the script and decides not to keep it, no zombie config files are left.