Revision history for gtkdialogDocTips


Revision [33329]

Last edited on 2023-02-24 06:53:04 by zigbert
Additions:
**8. [[gtkdialogDocTips8| Text managing]]**
Deletions:
**8. [[gtkdialogDocTips8 Text managing]]**


Revision [33317]

Edited on 2023-02-24 06:45:57 by zigbert
Additions:
6.2.1 [[http://web.archive.org/web/20160919214114/http://blog.puppylinux.com/?viewDetailed=00020 Knob]]
6.2.2 [[http://web.archive.org/web/20170815224527/http://blog.puppylinux.com/?viewDetailed=00030 Right-click menu]]
6.2.3 [[http://web.archive.org/web/20180223030345/http://blog.puppylinux.com/?viewDetailed=00040 Dynamic tabs]]
===@@**#%❰❰❰ {{color text="Previous" c="gray"}}#% #%{{color text="Index" c="gray"}}#% #%[[gtkdialogDocTips1|Next ❱❱❱]]#%**@@===
Deletions:
6.2.1 [[http://blog.puppylinux.com/archive/current.php?post=posts/20-gtkdialog-knob.html Knob]]
6.2.2 [[http://blog.puppylinux.com/archive/current.php?post=posts/30-Gtkdialog-right-click-menu.html Right-click menu]]
6.2.3 [[http://blog.puppylinux.com/archive/current.php?post=posts/40-Gtkdialog---Dynamic-tabs.html Dynamic tabs]]
@@**#%❰❰❰ {{color text="Previous" c="gray"}}#% #%{{color text="Index" c="gray"}}#% #%[[gtkdialogDocTips1|Next ❱❱❱]]#%**@@


Revision [33303]

Edited on 2023-02-24 03:01:41 by zigbert
Additions:
[[HomePage]] > [[SoftwareIndex|Software Index]] > [[SoftwareDevelopment|Development]] > [[gtkdialog|gtkdialog]]
This documentation is based on the forum-thread 'Tips and Tricks' by [[zigbert| Sigmund Berglund (zigbert)]].
**1. [[gtkdialogDocTips1| Syntax]]** - How to use variables in the code.
**2. [[gtkdialogDocTips2| Let the script return data]]** - Choose a proper coding structure.
**3. [[gtkdialogDocTips3| Let external code act on your gtkdialog gui]]**
**5. [[gtkdialogDocTips5| Speed issues]]** - Let your turtle run
**7. [[gtkdialogDocTips7| Advanced Syntax]]** - make your code readable
8.1 [[gtkdialogDocTips8/#hn_8.1| Some options for the <text> widget]]
8.2 [[gtkdialogDocTips8/#hn_8.2| Advanced text layout]]
8.3 [[gtkdialogDocTips8/#hn_8.3| Scroll text]]
8.4 [[gtkdialogDocTips8/#hn_8.4| Strikethrough text]]
8.5 [[gtkdialogDocTips8/#hn_8.5| Set font]]
8.6 [[gtkdialogDocTips8/#hn_8.6| Hyperlink]]
**10. [[gtkdialogDocTips10| The holy grail]]**
Deletions:
[[HomePage]] > [[SoftwareIndex Software Index]] > [[SoftwareDevelopment Development]] > [[gtkdialog gtkdialog]]
This documentation is based on the forum-thread 'Tips and Tricks' by [[zigbert Sigmund Berglund (zigbert)]].
**1. [[gtkdialogDocTips1 Syntax]]** - How to use variables in the code.
**2. [[gtkdialogDocTips2 Let the script return data]]** - Choose a proper coding structure.
**3. [[gtkdialogDocTips3 Let external code act on your gtkdialog gui]]**
**5. [[gtkdialogDocTips5 Speed issues]]** - Let your turtle run
**7. [[gtkdialogDocTips7 Advanced Syntax]]** - make your code readable
8.1 [[http://wikka.puppylinux.com/gtkdialogDocTips8/#hn_8.1 Some options for the <text> widget]]
8.2 [[http://wikka.puppylinux.com/gtkdialogDocTips8/#hn_8.2 Advanced text layout]]
8.3 [[http://wikka.puppylinux.com/gtkdialogDocTips8/#hn_8.3 Scroll text]]
8.4 [[http://wikka.puppylinux.com/gtkdialogDocTips8/#hn_8.4 Strikethrough text]]
8.5 [[http://wikka.puppylinux.com/gtkdialogDocTips8/#hn_8.5 Set font]]
8.6 [[http://wikka.puppylinux.com/gtkdialogDocTips8/#hn_8.6 Hyperlink]]
**10. [[gtkdialogDocTips10 The holy grail]]**


Revision [32982]

Edited on 2020-08-09 16:03:17 by zigbert
Additions:
9.xx [[http://murga-linux.com/puppy/viewtopic.php?p=588570#588570 Transparent background (gtkdialog desklets)]]
Deletions:
9.xx [[https://web.archive.org/web/20200524085209/http://murga-linux.com/puppy/viewtopic.php?p=588570#588570 Transparent background (gtkdialog desklets)]]


Revision [32977]

Edited on 2020-08-07 06:10:50 by zigbert
Additions:
**10. [[gtkdialogDocTips10 The holy grail]]**
Deletions:
**10. [[gtkdialogDocTips8 The holy grail]]**


Revision [32976]

Edited on 2020-08-07 06:10:36 by zigbert
Additions:
**10. [[gtkdialogDocTips8 The holy grail]]**
Deletions:
**10. The holy grail**


Revision [32968]

Edited on 2020-08-04 21:44:28 by zigbert
Additions:
~
9.xx [[https://web.archive.org/web/20200524085209/http://murga-linux.com/puppy/viewtopic.php?p=588570#588570 Transparent background (gtkdialog desklets)]]
9.xx [[http://murga-linux.com/puppy/viewtopic.php?t=107675 Chooser - navigate by pressing keys]]
Deletions:
9.17 [[https://web.archive.org/web/20200524085209/http://murga-linux.com/puppy/viewtopic.php?p=588570#588570 Transparent background (gtkdialog desklets)]]
9.18 [[http://murga-linux.com/puppy/viewtopic.php?t=107675 Chooser - navigate by pressing keys]]


Revision [32929]

Edited on 2020-07-31 03:15:18 by zigbert
Additions:
@@**#%❰❰❰ {{color text="Previous" c="gray"}}#% #%{{color text="Index" c="gray"}}#% #%[[gtkdialogDocTips1|Next ❱❱❱]]#%**@@
Deletions:
@@**#%❰❰❰ {{color text="Previous" c="gray"}}#% #%[[gtkdialogDocTips|Index]]#% #%[[gtkdialogDocTips1|Next ❱❱❱]]#%**@@


Revision [32928]

Edited on 2020-07-31 02:53:17 by zigbert
Additions:
9.1 [[gtkdialogDocTips9.1| How to change the gui without restarting the app]]
9.2 [[gtkdialogDocTips9.2| Control the icon/label of menuitems]]
9.3 [[gtkdialogDocTips9.3| Understand the alignment]]
9.4 [[gtkdialogDocTips9.4| Insert empty gap]]
9.5 [[gtkdialogDocTips9.5| Window header icon]]
9.6 [[gtkdialogDocTips9.6| Refresh image]]
9.7 [[gtkdialogDocTips9.7| Drag'n drop]]
9.8 [[gtkdialogDocTips9.8| Hotkeys]]
9.9 [[gtkdialogDocTips9.9| Set a fixed size of a progressbar]]
9.10 [[gtkdialogDocTips9.10| Define unique gtk-theme]]
9.11 [[gtkdialogDocTips9.11| Override window manager - skip taskbar, sticky, layer, border]]
9.12 [[gtkdialogDocTips9.12| Let entry accept (some) numbers only]]
9.13 [[gtkdialogDocTips9.13| MIME]]
9.14 [[gtkdialogDocTips9.14| Checkbox with image]]
9.15 [[gtkdialogDocTips9.15| Use a splash screen]]
9.16 [[gtkdialogDocTips9.16| Press 'Enter' instead of clicking the 'Ok' button]]
9.17 [[https://web.archive.org/web/20200524085209/http://murga-linux.com/puppy/viewtopic.php?p=588570#588570 Transparent background (gtkdialog desklets)]]
9.18 [[http://murga-linux.com/puppy/viewtopic.php?t=107675 Chooser - navigate by pressing keys]]
Deletions:
- How to change the gui without restarting the app
- Control the icon/label of menuitems.
- Understand the alignment.
- Window header icon.
- Refresh image
- Drag'n drop.
- Hotkeys.
- Set a fixed size of a progressbar
- Define unique gtk-theme.
- Override window manager - skip taskbar, sticky, layer, border
- Let entry accept (some) numbers only.
- MIME.
- Checkbox with image
- Use a splash screen.
- Press 'Enter' instead of clicking the 'Ok' button.
- [[https://web.archive.org/web/20200524085209/http://murga-linux.com/puppy/viewtopic.php?p=588570#588570 Transparent background (gtkdialog desklets)]]
- [[http://murga-linux.com/puppy/viewtopic.php?t=107675 Chooser - navigate by pressing keys]]


Revision [32916]

Edited on 2020-07-31 00:04:02 by zigbert
Additions:
6.2 [[gtkdialogDocTips6.2| New widgets]]
Deletions:
6.2 [[gtkdialogDocTips6.1| New widgets]]


Revision [32907]

Edited on 2020-07-28 05:42:11 by zigbert
Additions:
- Set a fixed size of a progressbar
Deletions:
- Set a fixed size of a progressbar.settings


Revision [32903]

Edited on 2020-07-28 05:38:24 by zigbert
Additions:
6.2 [[gtkdialogDocTips6.1| New widgets]]
Deletions:
6.2 New widgets


Revision [32897]

Edited on 2020-07-28 05:33:04 by zigbert
Additions:
**6. Extended your widgets**
Deletions:
**6. [[gtkdialogDocTips6 Extended your widgets]]**


Revision [32896]

Edited on 2020-07-28 05:31:43 by zigbert
Additions:
This documentation is based on the forum-thread 'Tips and Tricks' by [[zigbert Sigmund Berglund (zigbert)]].
6.1 [[gtkdialogDocTips6.1| Undocumented features of builtin widgets]]
6.2 New widgets
**10. The holy grail**
Deletions:
This documentation is based on the thread 'Tips and Tricks' by [[zigbert Sigmund Berglund (zigbert)]] at the old Puppylinux forum.
6.1 [[gtkdialogDocTips6.1| Undocumented features of existing widgets]]
6.2 gtkdialogDocTips6.2| New widgets
**Tips and tricks - Links**


Revision [32895]

Edited on 2020-07-28 05:28:09 by zigbert
Additions:
**6. [[gtkdialogDocTips6 Extended your widgets]]**
6.1 [[gtkdialogDocTips6.1| Undocumented features of existing widgets]]
6.2 gtkdialogDocTips6.2| New widgets
6.2.1 [[http://blog.puppylinux.com/archive/current.php?post=posts/20-gtkdialog-knob.html Knob]]
6.2.2 [[http://blog.puppylinux.com/archive/current.php?post=posts/30-Gtkdialog-right-click-menu.html Right-click menu]]
6.2.3 [[http://blog.puppylinux.com/archive/current.php?post=posts/40-Gtkdialog---Dynamic-tabs.html Dynamic tabs]]
6.2.4 [[http://murga-linux.com/puppy/viewtopic.php?t=115140 Calendar]]
Deletions:
**6. [[gtkdialogDocTips6 Extended use of widgets]]** - Undocumented features
- [[http://blog.puppylinux.com/archive/current.php?post=posts/30-Gtkdialog-right-click-menu.html Right-click menu]]
- [[http://blog.puppylinux.com/archive/current.php?post=posts/20-gtkdialog-knob.html Knob]]
- [[http://blog.puppylinux.com/archive/current.php?post=posts/40-Gtkdialog---Dynamic-tabs.html Dynamic tabs]]
- [[http://murga-linux.com/puppy/viewtopic.php?t=115140 Calendar]]


Revision [32893]

Edited on 2020-07-28 05:20:44 by zigbert
Additions:
8.1 [[http://wikka.puppylinux.com/gtkdialogDocTips8/#hn_8.1 Some options for the <text> widget]]
8.2 [[http://wikka.puppylinux.com/gtkdialogDocTips8/#hn_8.2 Advanced text layout]]
8.3 [[http://wikka.puppylinux.com/gtkdialogDocTips8/#hn_8.3 Scroll text]]
8.4 [[http://wikka.puppylinux.com/gtkdialogDocTips8/#hn_8.4 Strikethrough text]]
8.5 [[http://wikka.puppylinux.com/gtkdialogDocTips8/#hn_8.5 Set font]]
8.6 [[http://wikka.puppylinux.com/gtkdialogDocTips8/#hn_8.6 Hyperlink]]
Deletions:
8.1 [[http://wikka.puppylinux.com/gtkdialogDocTips8/#hn_1. Some options for the <text> widget]]
8.2 [[http://wikka.puppylinux.com/gtkdialogDocTips8/#hn_2. Advanced text layout]]
8.3 [[http://wikka.puppylinux.com/gtkdialogDocTips8/#hn_3. Scroll text]]
8.4 [[http://wikka.puppylinux.com/gtkdialogDocTips8/#hn_4. Strikethrough text]]
8.5 [[http://wikka.puppylinux.com/gtkdialogDocTips8/#hn_5. Set font]]
8.6 [[http://wikka.puppylinux.com/gtkdialogDocTips8/#hn_6. Hyperlink]]


Revision [32890]

Edited on 2020-07-28 05:15:27 by zigbert
Additions:
**4. The benefits of a config file**
4.1 [[gtkdialogDocTips4.1| Set default status of Radiobuttons, Comboboxes...]]
4.2 [[gtkdialogDocTips4.2| How to store window size/placement]]
Deletions:
**4. [[gtkdialogDocTips4 The benefits of a config file]]**
4.1 Set default status of Radiobuttons, Comboboxes...
4.2 How to store window size/placement


Revision [32880]

Edited on 2020-07-28 05:03:19 by zigbert

No Differences

Revision [32879]

Edited on 2020-07-28 05:02:35 by zigbert
Additions:
@@**#%❰❰❰ {{color text="Previous" c="gray"}}#% #%[[gtkdialogDocTips|Index]]#% #%[[gtkdialogDocTips1|Next ❱❱❱]]#%**@@


Revision [32859]

Edited on 2020-07-24 19:45:38 by zigbert
Additions:
----
==Categories==
CategoryGtkdialog


Revision [32854]

Edited on 2020-07-24 03:56:03 by zigbert
Additions:
- [[http://murga-linux.com/puppy/viewtopic.php?t=115140 Calendar]]
- [[http://murga-linux.com/puppy/viewtopic.php?t=107675 Chooser - navigate by pressing keys]]
Deletions:
- ++[[https://web.archive.org/web/20200524085209/http://murga-linux.com/puppy/viewtopic.php?t=115140 Calendar]]++
- ++[[https://web.archive.org/web/20200524085209/http://murga-linux.com/puppy/viewtopic.php?t=107675 Chooser - navigate by pressing keys]]++


Revision [32852]

Edited on 2020-07-24 03:50:59 by zigbert
Additions:
4.1 Set default status of Radiobuttons, Comboboxes...
4.2 How to store window size/placement
7.1 Comments in your code.
7.2 Include code if...
**8. [[gtkdialogDocTips8 Text managing]]**
8.1 [[http://wikka.puppylinux.com/gtkdialogDocTips8/#hn_1. Some options for the <text> widget]]
8.2 [[http://wikka.puppylinux.com/gtkdialogDocTips8/#hn_2. Advanced text layout]]
8.3 [[http://wikka.puppylinux.com/gtkdialogDocTips8/#hn_3. Scroll text]]
8.4 [[http://wikka.puppylinux.com/gtkdialogDocTips8/#hn_4. Strikethrough text]]
8.5 [[http://wikka.puppylinux.com/gtkdialogDocTips8/#hn_5. Set font]]
8.6 [[http://wikka.puppylinux.com/gtkdialogDocTips8/#hn_6. Hyperlink]]
Deletions:
- Set default status of Radiobuttons, Comboboxes...
- How to store window size/placement
- Comments in your code.
- Include code if.......
**8. Text managing**


Revision [32849]

Edited on 2020-07-24 03:10:17 by zigbert
Additions:
**7. [[gtkdialogDocTips7 Advanced Syntax]]** - make your code readable
Deletions:
**7. Advanced Syntax** - make your code readable


Revision [32836]

Edited on 2020-07-23 15:16:06 by zigbert
Additions:
**6. [[gtkdialogDocTips6 Extended use of widgets]]** - Undocumented features
Deletions:
**6. [[gtkdialogDocTips5 Extended use of widgets]]** - Undocumented features


Revision [32835]

Edited on 2020-07-23 15:15:07 by zigbert
Additions:
This documentation is based on the thread 'Tips and Tricks' by [[zigbert Sigmund Berglund (zigbert)]] at the old Puppylinux forum.
Deletions:
This documentation is based on 'Tips and Tricks' by [[zigbert Sigmund Berglund (zigbert)]] at the old Puppylinux forum.


Revision [32832]

Edited on 2020-07-22 22:54:01 by zigbert
Additions:
**5. [[gtkdialogDocTips5 Speed issues]]** - Let your turtle run
**6. [[gtkdialogDocTips5 Extended use of widgets]]** - Undocumented features
Deletions:
**5. Speed issues** - Let your turtle run
**6. Extended use of widgets** - Undocumented features


Revision [32822]

Edited on 2020-07-21 04:24:48 by zigbert

No Differences

Revision [32820]

Edited on 2020-07-21 04:08:19 by zigbert
Additions:
[[HomePage]] > [[SoftwareIndex Software Index]] > [[SoftwareDevelopment Development]] > [[gtkdialog gtkdialog]]
Deletions:
[[HomePage]] > [[SoftwareIndex Software Index]] > [[SoftwareDevelopment Development]] > [[gtkdialog gtkdialog]] > [[gtkdialogDoc documentation]]


Revision [32817]

Edited on 2020-07-21 03:40:27 by zigbert
Additions:
[[HomePage]] > [[SoftwareIndex Software Index]] > [[SoftwareDevelopment Development]] > [[gtkdialog gtkdialog]] > [[gtkdialogDoc documentation]]
Deletions:
[[HomePage]] > [[SoftwareIndex Software Index]] > [[SoftwareDevelopment Development]] > [[gtkdialog gtkdialog]]


Revision [32816]

Edited on 2020-07-21 03:39:50 by zigbert
Additions:
======GtkDialog - Tips and Tricks======
This documentation is based on 'Tips and Tricks' by [[zigbert Sigmund Berglund (zigbert)]] at the old Puppylinux forum.
Deletions:
======GtkDialog Tips and Tricks======
This documentation is based on 'Tips and Tricks' by Sigmund Berglund (zigbert) at the old Puppylinux forum.


Revision [32815]

Edited on 2020-07-21 03:38:09 by zigbert
Additions:
This documentation is based on 'Tips and Tricks' by Sigmund Berglund (zigbert) at the old Puppylinux forum.
The info is based on input from many people. Please continue to share your knowledge.
**1. [[gtkdialogDocTips1 Syntax]]** - How to use variables in the code.
**2. [[gtkdialogDocTips2 Let the script return data]]** - Choose a proper coding structure.
**3. [[gtkdialogDocTips3 Let external code act on your gtkdialog gui]]**
**4. [[gtkdialogDocTips4 The benefits of a config file]]**
**5. Speed issues** - Let your turtle run
**6. Extended use of widgets** - Undocumented features
**7. Advanced Syntax** - make your code readable
**8. Text managing**
**9. Tips and tricks**
Deletions:
GtkDialog lets your bash script run in gui.
Here's some tips for learning more about gtkdialog.
This info is based on input from many people. Please share your knowledge.
**1. [[http://wikka.puppylinux.com/gtkdialogDoc#hn_1. Where to start]]** - links to documentation and examples.
**2. [[http://wikka.puppylinux.com/gtkdialogDoc#hn_2. Syntax]]** - How to use variables in the code.
**3. [[http://wikka.puppylinux.com/gtkdialogDoc#hn_3. Let the script return data]]** - Choose a proper coding structure.
**4. [[http://wikka.puppylinux.com/gtkdialogDoc#hn_4. Let external code act on your gtkdialog gui]]**
**5. [[http://wikka.puppylinux.com/gtkdialogDoc#hn_5. The benefits of a config file]]**
**6. Speed issues** - Let your turtle run
**7. Extended use of widgets** - Undocumented features
**8. Advanced Syntax** - make your code readable
**9. Text managing**
**10. Tips and tricks**
====1.====
====Where to start====
Most importantly, Thunor has written a comprehensive [[http://01micko.com/reference/ reference guide]] for all the gtkdialog widgets. This is the place to go for knowledge about syntax and options.
In addition there are other resources which may give some more flesh to the bone.
⚫ Basic tutorials [[http://www.tecmint.com/gtkdialog-create-graphical-interfaces-and-dialog-boxes/ here]] and [[http://pclosmag.com/html/Issues/200910/page21.html here]]
⚫ [[https://code.google.com/archive/p/gtkdialog/ Examples]] are often easier to understand.
⚫ [[http://xpt.sourceforge.net/techdocs/language/gtkdialog/gtkde03-GtkdialogUserManual/ General documentation]] of gtkdialog is poor, but it's a start.
⚫ The command 'gtkdialog --help' shows available parameters.
⚫ Get the gtkdialog code
- [[https://github.com/01micko/gtkdialog Source code]]
- [[https://web.archive.org/web/20200524085209/http://murga-linux.com/puppy/viewtopic.php?p=538294#538294 Compile info]]
- [[https://web.archive.org/web/20200524085209/http://murga-linux.com/puppy/viewtopic.php?p=707526#707526 Pets]]
- Note! woodenshoe-wi has fixed the [[https://github.com/woodenshoe-wi/gtkdialog/releases sourcecode to work with GTK3]]
====2.====
====Syntax====https://web.archive.org/web/20200524085209/
The basics of building a simple gui is told by the links in chapter [[http://wikka.puppylinux.com/gtkdialogDoc#hn_1. 1.]] You should have played a little bit before you continue.
About QUOTES ( **{{color text=""" c="red"}}** and **{{color text="'" c="red"}}** )
To show content of a variable in the gtkdialog code, we need to quote the variable correctly inside the gtkdialog code.
%%(language-ref)
TEXT='Hello world'
export script='
<text>
<label>Content of variable is: '"$TEXT"'</label>
</text>'
gtkdialog --program=script
%%
Now in other words - Because this is important!!!
First realize that you put all the gtkdialog code into a variable - ie MAIN_WINDOW or Psync:
~##export Psync=**{{color text=""" c="red"}}**<window title=\"Psync\"...........</window>**{{color text=""" c="red"}}**##
if you now try to ##echo Psync## you'll get
~##<window title="Psync"...........</window>##
which is correct code. But if you used ' instead of ", like this:
~##export Psync=**{{color text="'" c="red"}}**<window title=\"Psync\"...........</window>**{{color text="'" c="red"}}**##
you'll get
~##<window title=\"Psync\"...........</window>##
This will give a syntax error, while
~##export Psync='<window title="Psync"...........</window>'##
will give correct syntax.
Now using a variable inside the gtkdialog code like this:
~##TITLE=Psync
~export Psync=**{{color text=""" c="red"}}**<window title=\"$TITLE\"...........</window>**{{color text=""" c="red"}}**##
returns
~##<window title="Psync"...........</window>##
while
~##export Psync=**{{color text="'" c="red"}}**<window title="$TITLE"...........</window>**{{color text="'" c="red"}}**##
returns
~##<window title="$TITLE"...........</window>##
and not the content of variable TITLE
Now return to the first example about quotes. This example combines the use of ' and ".
====3.====
====Let the script return data====
The first step is to show a dialog window on your screen, then the next step is the interaction of the user with the gui. I think the easiest way is to divide guis into different groups. - Simple, Complex and Projects.
**Simple**
A simple dialog allows the user to give a response to a question/query on the screen:
- Do you want to continue?
- Please choose item in list
- ...
When the user click on the yes/no/cancel/ok-button the dialog exits and the script continues to evaluate the user input.
Here is an example:
%%(language-ref)
export script='
<vbox>
<text><label>Are you sure?</label></text>
<hbox>
<button no></button>
<button yes><action>EXIT:sure</action></button>
</hbox>
</vbox>'
I=$IFS; IFS=""
for STATEMENTS in $(gtkdialog --program=script); do
eval $STATEMENTS
done
IFS=$I
[ $EXIT = sure ] && gxmessage 'You are sure'
%%
**Complex**
For more complex dialogs, we want to keep the gui alive even if the user clicks on something, so using an EXIT value is not the right choice. Calling pre-defined functions from inside the gtkdialog gui is a handy way to do this. We must remember to export all functions before executing our gui.
%%(language-ref)
now () {
date > /tmp/date
}
export -f now
export script='
<vbox>
<entry>
<variable>ENTRY_DATE</variable>
<input>cat /tmp/date</input>
</entry>
<button>
<label>Refresh</label>
<action>now</action>
<action>refresh:ENTRY_DATE</action>
</button>
</vbox>'
gtkdialog -p script
%%
**Project**
When your project grows and its complexity makes it hard to work with, it's time to consider another approach. Splitting code into several files might be much more usable when working with your code. Group familiar functions into one file... In this example, the function-file must be saved in /root/test to work. Instead of sending ##<action>## to an EXIT-variable, we send it to the file with the function 'now'.
NOTE, that I don't use an ordinary function (like the previous example), but a case command instead. The benefits are faster loading of your app since it does not read your functions into memory, **but the greatest advantage is that you can edit the function while the gui is running.** The downside are slower execution of the function.
Function file
%%(language-ref)
case $1 in
-now)
date > /tmp/date
exit;;
esac
%%
Main file
%%(language-ref)
export script='
<vbox>
<entry>
<variable>ENTRY_DATE</variable>
<input>cat /tmp/date</input>
</entry>
<button>
<label>Refresh</label>
<action>/root/test -now</action>
<action>refresh:ENTRY_DATE</action>
</button>
</vbox>'
I=$IFS; IFS=""
for STATEMENTS in $(gtkdialog -p script); do
eval $STATEMENTS
done
IFS=$I
%%
====4.====
====Let external code act on your gtkdialog gui====
If you want a second gtkdialog-gui to act on your main gui. You simply "launch" the second gui from the main gui. The negative aspect about this solution is that before showing the main gui, it has to load all the launchable scripts. This means slower startup.
%%(language-ref)
export launch_me='
<button>
<input file stock="gtk-refresh"></input>
<action>Refresh:DATE</action>
</button>'
export box='
<vbox>
<entry><input>date</input><variable>DATE</variable></entry>
<button><label>launch</label><action type="launch">launch_me</action></button>
</vbox>'
gtkdialog -p box
%%
Imagine that you start a background process to calculate the content of ##<list>##. It will take too long to wait for the result before showing the gui. Imagine that you want to update the content in a gui from a separate app. Okay, here's the trick.....
Gtkdialog updates a [[http://01micko.com/reference/progressbar.html progressbar]] with info from standard output. Most common are the ##cat## and ##echo## commands. First ##echo "text in bar"## (optional), then ##echo 50## or whatever % integer to define how long the process is come. When a progressbar achieves 100% done (##echo 100##), it activates its ##<actions>##. So, as long as % is below 100, the actions are not run, but as soon as you ##echo 100## it will execute your defined actions. What is very good, is that you now can ##echo 0##, and start all over again. Last stage is to define if you want the progressbar shown in your gui. add ##visible="false"## to make it invisible.
Here is a simple example of a clock
%%(language-ref)
export box='
<vbox>
<progressbar visible="false">
<input>while [ A != B ; do sleep 0.5; P=`cat /tmp/p`; echo $P; echo 100 > /tmp/p; done</input>
<action>refresh:ENTRY</action>
<action>echo 99 > /tmp/p</action>
</progressbar>
<entry>
<variable>ENTRY</variable>
<input>date +%H:%M:%S</input>
</entry>
</vbox>'
gtkdialog -p box
%%
If you want a frequent refreshing of a widget, the ##[[http://01micko.com/reference/timer.html <timer>]]## widget was introduced in gtkdialog 0.7.21.
~##<timer milliseconds="true" interval="500" visible="false">##
Gtkdialog misses a tailbox widget, but using this solution it is easy to build our own tailbox.
Both ##[[http://01micko.com/reference/timer.html <timer>]]## and ##[[http://01micko.com/reference/progressbar.html <progressbar>]]## widgets uses cpu-power, and in a complex gui this could be a real pitfall. Here follows an explanation of how it is solved in pMusic. It is a way to update a complex gui on non-user actions. User-actions is mouse-clicks and key-entries, and is the common way to interact between user and gui. An example of updating the gui on a non-user-action in pMusic is the loading of id3-tags for files shown in the file-browser....
When clicking on a directory, the browser field refreshes and shows the content of the new directory. Now, pMusic continues with a background process to read the id3 information of the files. When finished, the file-browser should be updated by the new info. - Without the user to click anywhere.
The solution is to either use a ##[[http://01micko.com/reference/progressbar.html <progressbar>]]## which runs its ##<action>## when reaches 100% or a ##[[http://01micko.com/reference/timer.html <timer>]]## which acts at a given interval. Older pMusic releases used the ##[[http://01micko.com/reference/progressbar.html <progressbar>]]## solution while recent code uses a ##[[http://01micko.com/reference/timer.html <timer>]]##. Both solutions has the downside that they use an amount of cpu power. In a complex gui with several non-user actions this could end up with several cpu-hungry <timers> updating their unique widget(s) of the gui.
pMusic has used 2 <timers> running constantly to update their defined gui-part. You might think that 1 ##[[http://01micko.com/reference/timer.html <timer>]]## would be enough, - it could refresh all wanted widgets - it wouldn't harm if the refreshing didn't change anything. BUT, refreshing has an effect on the focus handling. It simply resets the focus, which means that:
- scrolling in ##[[http://01micko.com/reference/table.html <table>]]## is moved to top.
- what you are about to write in an ##[[http://01micko.com/reference/entry.html <entry>]]## is cleared.
- Your selected item in the ##[[http://01micko.com/reference/tree.html <tree>]]## is not selected anymore
- ...
The idea of pMusic 2.4.0 was to update all kinds of trackinfo (meta-tags, lyrics, albumart, discography, ...) when a new track starts playing. This would not be possible with the underlaying event-handling in pMusic because it would either suck your cpu-power (with several <timers>), or a global refreshing would make it impossible to be a user (because of focus issues). Also, there is a fact that too many refreshing ##<action>## on a ##[[http://01micko.com/reference/timer.html <timer>]]## will increase cpu-usage as well.
So the solution has been to add ONE ##[[http://01micko.com/reference/timer.html <timer>]]##, which refreshes a small set of ##[[http://01micko.com/reference/checkbox.html <checkboxes>]]## that (##if true##) refreshes a single or group of widgets.
##[[http://01micko.com/reference/checkbox.html <checkboxes>]]## can be set ##true## or ##false## by their ##<input file>##, so we can simply ##echo true## to its ##<input file>##. The ##[[http://01micko.com/reference/timer.html <timer>]]## runs its ##<actions>## each second, and the ##[[http://01micko.com/reference/checkbox.html <checkbox>]]## will be refreshed by its ##<input file>##. The code could look like this:
%%(language-ref)
<checkbox visible="false">
<label>a</label>
<variable>UPDATE_GUI</variable>
<input>cat /path/UPDATE_GUI</input>
<action>if true refresh:PLAYLIST</action>
<action>if true refresh:ARTWORK</action>
<action>if true refresh:BUTTON_PLAY</action>
<action>if true echo false > /path/UPDATE_GUI</action>
</checkbox>
%%
All actions will run only if value is ##true##. To avoid more than one refreshing we reset ##<input file>## and the ##[[http://01micko.com/reference/checkbox.html <checkbox>]]## value to false. Now it will be silent until the next time we ##echo true > inputfile##.
Example script [[https://web.archive.org/web/20200524085209/http://murga-linux.com/puppy/viewtopic.php?p=646846#646846 here]]
====5.====
====The benefits of a config file====
A config file is a nice way to store the settings in your program. At next startup, it will show the settings like you left them last time.
**Set default status of radiobuttons, Comboboxes...**
By default, gtkdialog always activates the first ##[[http://01micko.com/reference/radiobutton.html <radiobutton>]]## and the first list-item for ##[[http://01micko.com/reference/combobox.html <combobox>]]##.
An easy way to use a config file is to run it like an ordinary bash-script, and include variable definitions in it. It is most common to keep config files in home directory as a hidden file ($HOME/.testrc). The file might look like this:
%%(language-ref)
COMBOBOX="item 3"
ENTRY="default text"
RADIOBUTTON1="false"
RADIOBUTTON2="true"
%%

Now let's go to the main script. For the ##[[http://01micko.com/reference/radiobutton.html <radiobutton>]]## and the ##[[http://01micko.com/reference/entry.html <entry>]]##, we set the ##<default>## tag to the corresponding variable in the config file. Since the ##[[http://01micko.com/reference/combobox.html <combobox>]]## doesn't support the ##<default>## tag, we need a workaround. We simply build the ##[[http://01micko.com/reference/combobox.html <combobox>]]## item-list so show our saved variable first.


Revision [32806]

The oldest known version of this page was created on 2020-07-21 03:15:22 by zigbert
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki