Author |
Message |
recobayu

Joined: 15 Sep 2010 Posts: 325 Location: indonesia
|
Posted: Tue 25 Jul 2017, 03:19 Post subject:
|
|
yes. how to do that, Mochi?
|
Back to top
|
|
 |
MochiMoppel

Joined: 26 Jan 2011 Posts: 1772 Location: Japan
|
Posted: Tue 25 Jul 2017, 03:52 Post subject:
|
|
Code: | #!/bin/bash
echo '
<hbox>
<button>
<label>left</label>
<variable>BTN1</variable>
</button>
<entry has-focus="true">
<action signal="key-press-event" condition="command_is_true([ $KEY_SYM = Left ] && echo true )">grabfocus:BTN1</action>
<action signal="key-press-event" condition="command_is_true([ $KEY_SYM = Right ] && echo true )">grabfocus:BTN2</action>
</entry>
<button>
<label>right</label>
<variable>BTN2</variable>
</button>
</hbox>'|gtkdialog -s |
|
Back to top
|
|
 |
recobayu

Joined: 15 Sep 2010 Posts: 325 Location: indonesia
|
Posted: Tue 25 Jul 2017, 04:21 Post subject:
|
|
wow. That's works.
Thank you very much.
|
Back to top
|
|
 |
smokey01

Joined: 30 Dec 2006 Posts: 2805 Location: South Australia :-(
|
Posted: Mon 31 Jul 2017, 07:53 Post subject:
|
|
Can anyone explain this weird behaviour in Fatdog64-710. Have a look at the code below. Turn it into a script and make it executable.
Code: | #!/bin/sh
##################################################
##################################################
##################################################
##################################################
##################
svg_buttons () {
echo '<svg width="100%" height="100%" viewBox="0 0 60 20">
<defs>
<linearGradient id="button_surface" gradientUnits="objectBoundingBox"
x1="1" x2="1" y1="0" y2="1">
<stop stop-color="#D26F6F" offset="0"/>
<stop stop-color="#FF0000" offset="0.67"/>
</linearGradient>
<linearGradient id="virtual_light" gradientUnits="objectBoundingBox"
x1="0" x2="0" y1="0" y2="1">
<stop stop-color="#EEEEEE" offset="0" stop-opacity="0.8"/>
<stop stop-color="#EEEEEE" offset="0.4" stop-opacity="0"/>
</linearGradient>
</defs>
<!-- button content -->
<rect x="0" y="0" width="60" height="20" fill="url(#button_surface)" stroke="#570B0B"/>
<text x="17" y="15" fill="white"
font-family="Tahoma" font-size="14" font-weight="bold">
Kill
</text>
<!-- vitual lighting effect -->
<rect x="2" y="2" width="56" height="16" fill="url(#virtual_light)" stroke="#FFFFFF" stroke-opacity="0.4"/>
</svg>
'>/tmp/killk.svg
}
export -f svg_buttons
defaultimageviewer /tmp/killk.svg |
When this script is run it creates an svg image and displays it in your default image viewer.
Notice all of the #### at the top. Try deleting one or two and the script is displayed as an image rather than a script.
If you rename your script from script to script.sh then it remains a script. It seems like it's a mime type problem. What the ????
_________________ Software <-> Distros <-> Tips <-> Newsletters
|
Back to top
|
|
 |
MochiMoppel

Joined: 26 Jan 2011 Posts: 1772 Location: Japan
|
Posted: Mon 31 Jul 2017, 08:27 Post subject:
|
|
@smokey01. Not really a Gtkdialog issue. See here.
The long # string is there to prevent the file to be mistakenly recognized as a svg image.
|
Back to top
|
|
 |
smokey01

Joined: 30 Dec 2006 Posts: 2805 Location: South Australia :-(
|
Posted: Mon 31 Jul 2017, 09:30 Post subject:
|
|
MochiMoppel wrote: | @smokey01. Not really a Gtkdialog issue. See here.
The long # string is there to prevent the file to be mistakenly recognized as a svg image. |
Probably not but I'm using it in a gtkdialog script. Thanks I will have a look.
_________________ Software <-> Distros <-> Tips <-> Newsletters
|
Back to top
|
|
 |
don570

Joined: 10 Mar 2010 Posts: 5260 Location: Ontario
|
Posted: Tue 01 Aug 2017, 12:20 Post subject:
|
|
Xdialog example are available thanks to wognath
http://puppylinux.org/wikka/Xdialog_examples
____________________________________________
|
Back to top
|
|
 |
smokey01

Joined: 30 Dec 2006 Posts: 2805 Location: South Australia :-(
|
Posted: Wed 02 Aug 2017, 20:32 Post subject:
|
|
Is it possible to convert a glade file to gtkdialog?
I would like to be able to create a GUI in glade then place it inside a bash script. Below is a simple example.
This is the gtkdialog code inside a bash script called (test):
Code: | #!/bin/sh
[ -z $GTKDIALOG ] && GTKDIALOG=gtkdialog
MAIN_DIALOG='
<window title="GtkDialog">
<vbox>
<hbox>
<button width-request="200">
<label>Viewnior</label>
<action>viewnior &</action>
</button>
</hbox>
</vbox>
</window>
'
export MAIN_DIALOG
case $1 in
-d | --dump) echo "$MAIN_DIALOG" ;;
*) $GTKDIALOG --program=MAIN_DIALOG ;;
esac |
This is the Glade/xml code called (test.glade)
Code: | <?xml version="1.0" encoding="UTF-8"?>
<glade-interface>
<!-- interface-requires gtk+ 2.24 -->
<!-- interface-naming-policy project-wide -->
<widget class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Glade</property>
<property name="default_width">200</property>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<widget class="GtkButton" id="button1">
<property name="label" translatable="yes">Viewnior</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="border_width">4</property>
<signal name="clicked" handler="viewnior &" swapped="no"/>
</widget>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>
|
The bash script will run by clicking on it.
To run the glade file it has to be saved as libglade format then called like:
Code: | gtkdialog --glade-xml=test.glade --program=window1 |
Your gtkdialog must be compiled to use glade as well.
In a terminal type:
Code: | gtkdialog --version |
you should see something like:
gtkdialog version 0.8.4 release (C) 2003-2007 Laszlo Pere, 2011-2012 Thunor
Built with support for: GTK+ 2, Glade, VTE.
It's easier to make complicated GUI in Glade but more difficult to make them run.
I have worked out how to compile the glade file in C++ but it requires a lot of code to run actions. I also like the idea of a single script that is not architecture dependant.
Any ideas?
_________________ Software <-> Distros <-> Tips <-> Newsletters
|
Back to top
|
|
 |
MochiMoppel

Joined: 26 Jan 2011 Posts: 1772 Location: Japan
|
Posted: Sat 05 Aug 2017, 23:57 Post subject:
|
|
smokey01 wrote: | I would like to be able to create a GUI in glade then place it inside a bash script. | And where exactly is the problem?
Code: | #!/bin/bash
echo '<?xml version="1.0" encoding="UTF-8"?>
<glade-interface>
<!-- interface-requires gtk+ 2.24 -->
<!-- interface-naming-policy project-wide -->
<widget class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Glade</property>
<property name="default_width">200</property>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<widget class="GtkButton" id="button1">
<property name="label" translatable="yes">Viewnior</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="border_width">4</property>
<signal name="clicked" handler="viewnior &" swapped="no"/>
</widget>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>' > /tmp/test.glade
gtkdialog -g /tmp/test.glade -p window1
rm /tmp/test.glade |
|
Back to top
|
|
 |
smokey01

Joined: 30 Dec 2006 Posts: 2805 Location: South Australia :-(
|
Posted: Sun 06 Aug 2017, 04:31 Post subject:
|
|
MochiMoppel wrote: | smokey01 wrote: | I would like to be able to create a GUI in glade then place it inside a bash script. | And where exactly is the problem? |
Ah, never thought to do it that way however, the file displays as a glade file in Rox instead of a script. If I click on it, it loads into glade.
Thanks
_________________ Software <-> Distros <-> Tips <-> Newsletters
|
Back to top
|
|
 |
MochiMoppel

Joined: 26 Jan 2011 Posts: 1772 Location: Japan
|
Posted: Sun 06 Aug 2017, 06:00 Post subject:
|
|
smokey01 wrote: | the file displays as a glade file in Rox instead of a script | Here it it recognized as a bash script and executed when clicked. Check your mime settings and your svg question 1 week ago.
|
Back to top
|
|
 |
smokey01

Joined: 30 Dec 2006 Posts: 2805 Location: South Australia :-(
|
Posted: Sun 06 Aug 2017, 18:02 Post subject:
|
|
MochiMoppel wrote: | smokey01 wrote: | the file displays as a glade file in Rox instead of a script | Here it it recognized as a bash script and executed when clicked. Check your mime settings and your svg question 1 week ago. |
I suspect you're right.
Thanks again
_________________ Software <-> Distros <-> Tips <-> Newsletters
|
Back to top
|
|
 |
smokey01

Joined: 30 Dec 2006 Posts: 2805 Location: South Australia :-(
|
Posted: Mon 14 Aug 2017, 06:44 Post subject:
|
|
Is there a script or program that will convert a glade file, saved as libglade or gtkbuilder, to regular gtkdialog code as discussed throughout this thread?
From something like this:
Code: | <?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="2.24"/>
<!-- interface-naming-policy project-wide -->
<object class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</object>
</interface> |
To something thik this:
Code: | #!/bin/sh
[ -z $GTKDIALOG ] && GTKDIALOG=gtkdialog
MAIN_DIALOG='
<window>
<vbox>
<frame Description>
<text>
<label>This is an example window.</label>
</text>
</frame>
<hbox>
<button ok></button>
<button cancel></button>
</hbox>
</vbox>
</window>
'
export MAIN_DIALOG
case $1 in
-d | --dump) echo "$MAIN_DIALOG" ;;
*) $GTKDIALOG --program=MAIN_DIALOG ;;
esac |
I would like to create GUI's in glade then run them inside normal bash scripts. It's possible using gtkdialog providing it's been built with glade support and glade is saved as libglade. Unfortunately libglade is deprecated.
The results are not identical but it provides an example of what I'm trying to achieve.
_________________ Software <-> Distros <-> Tips <-> Newsletters
|
Back to top
|
|
 |
Moose On The Loose

Joined: 24 Feb 2011 Posts: 778
|
Posted: Tue 15 Aug 2017, 10:24 Post subject:
|
|
MochiMoppel wrote: | @smokey01. Not really a Gtkdialog issue. See here.
The long # string is there to prevent the file to be mistakenly recognized as a svg image. |
Perhaps this is a better way:
Code: |
THING="SVG"
echo "<$THING" '.... more stuff ....
|
It is based on something commonly done for making html tags in javascript
|
Back to top
|
|
 |
MochiMoppel

Joined: 26 Jan 2011 Posts: 1772 Location: Japan
|
Posted: Tue 15 Aug 2017, 22:24 Post subject:
|
|
Moose On The Loose wrote: | Perhaps this is a better way:
Code: |
THING="SVG"
echo "<$THING" '.... more stuff ....
|
It is based on something commonly done for making html tags in javascript |
|
Back to top
|
|
 |
|