Revision history for gtkdialogDocTips7


Revision [33326]

Last edited on 2023-02-24 06:49:31 by zigbert
Additions:
[[HomePage]] > [[SoftwareIndex|Software Index]] > [[SoftwareDevelopment|Development]] > [[gtkdialog|gtkdialog]] > [[gtkdialogDocTips|Tips and Tricks]]
===@@**#%[[gtkdialogDocTips6.2|❰❰❰ Previous]]#% #%[[gtkdialogDocTips|Index]]#% #%[[gtkdialogDocTips8|Next ❱❱❱]]#%**@@===
Deletions:
[[HomePage]] > [[SoftwareIndex Software Index]] > [[SoftwareDevelopment Development]] > [[gtkdialog gtkdialog]] > [[gtkdialogDocTips Tips and Tricks]]
@@**#%[[gtkdialogDocTips6.2|❰❰❰ Previous]]#% #%[[gtkdialogDocTips|Index]]#% #%[[gtkdialogDocTips8|Next ❱❱❱]]#%**@@


Revision [32905]

Edited on 2020-07-28 05:39:36 by zigbert
Additions:
@@**#%[[gtkdialogDocTips6.2|❰❰❰ Previous]]#% #%[[gtkdialogDocTips|Index]]#% #%[[gtkdialogDocTips8|Next ❱❱❱]]#%**@@


Revision [32866]

Edited on 2020-07-24 19:47:27 by zigbert
Additions:
----
==Categories==
CategoryGtkdialog


Revision [32848]

Edited on 2020-07-24 03:09:41 by zigbert
Additions:
====7. Advanced Syntax - make your code readable====
**Comments in your code**
Gtkdialog doesn't support comments in its xml code. But if we convert all comments before execution, it works. The reason why I use double hash (""##"") for my comments, is because colors in a ##<span>## tag might be defined as ##red## or ###FF0000##. The latter would be removed by using a single hash.
%%(language-ref)
XML='
<vbox> ##this is how to comment your xml code.
<text height-request="50"> ##force the text to take more space.
<label>Hello</label>
</text>
<hbox> ##hbox to align button to the right.
<button ok></button> ##button ok is fetched from the gtk stock.
</hbox>
</vbox>'
export GUI="`echo "$XML" | sed -e 's/##.*//'`"
gtkdialog -p GUI
%%
**Include code if...**
It is possible to build the gtkdialog out of many small pieces. Every piece is a variable and are put together when exporting the gtkdialog code. It is easy to think that a button should have different label depending on "//this or that//". Or like in the following example, - include a button if file/app/... exists. Instead of defining all these pieces before the actual gtkdialog code, it is much more human readable if you define all 'inside' the gtkdialog code.
%%(language-ref)
script='
<vbox>
<hbox>
<text>
<label>Yes button added if file /root/testfile exists</label>
</text>'
[ -f /root/testfile ;then script=${script}'<button yes></button>'
script=${script}'
<button no>
</button>
</hbox>
</vbox>'
export SCRIPT="$script"
gtkdialog --program=SCRIPT
%%
Deletions:
====6. Extended use of widgets====
[[http://01micko.com/reference/ The reference guide]] contains most info about the widgets. This chapter is heading for the undocumented features.
**Generals**
Add tooltips.
~##<hbox tooltip-text=" This is the text ">...</hbox>##
Add tooltips with advanced text layout.
~##<button tooltip-markup="<span background='yellow'><b><i> press alt m </i></b></span>">......</button>##
Widgets might be invisible.
~##<progressbar visible="false">...</progressbar>##
Define how much space the widget should take.
~##<text height-request="50" width-request="200">...</text>##
Avoid tab-key to give focus
~##<edit can-focus="no">...</edit>##
Align widget.
~xalign/yalign may hold 0 (left), 1 (right) and 2 (center).
~xalign/yalign works for most widgets.
~For button/progressbar they describe placement of label rather than widget itself.
~##<text xalign="0">...</text>##
**[[http://01micko.com/reference/window.html <window>]]**
prevent user from resizing the gui.
~##<window allow-grow="false">##
Shrink window smaller than the widgets requires to show up.
~##<window allow-shrink="true">##
**[[http://01micko.com/reference/text.html <text>]]**
Text knowledge has been moved to its own chapter - [[gtkdialogDocTips8 Text managing]]
Justify aligment to right (1), center (2), left (3).
~##<text justify="2">##
Angle the text
~##<text angle="45">##
Force one-line text
~##<text wrap="false">##
~##<text single-line-mode="true">##
Set underline pattern
~##<text label="Underline me with an useless pattern" pattern="__ __ __ __ __ __ _"></text>##
**[[http://01micko.com/reference/button.html <button>]]**
You can skip the button decoration.
~##<button relief="2">...</button>##
The image doesn't need to be left of label.
~It can be left/right/above/below. Values 0-3.
~Be aware that this seems to work only for icons in the gtk-stock.
~##<button use-stock="true" image-position="3">...</button>##
Use gtk-stock values
~##<button use-stock="true" label="gtk-quit"></button>##
Hotkey is set in 2 ways
~##<button use-stock="true" label="gtk-cancel">...</button>##
~##<button use-underline="true"><label>_Cancel</label>...</button>##
Scale icon
~##<button height-request="50" width-request="80">
~~<input file>file.jpg</input>
~~<height>40</height>
~~<width>70</width>
~</button>##
**[[http://01micko.com/reference/entry.html <entry>]]**
Give entry focus
~##<entry text="Focus is here" is-focus="true"></entry>##
Not editable
~##<entry editable="false"></entry>##
Password - show input text as ""******"", and a note if capslock is turned on
~##<entry visibility="false" caps-lock-warning="true"></entry>##
Alternative way to define default text
~##<entry text="default string">##
Show progress in entry - or simply change the color of the entry background
~##<entry progress-fraction="0.5">##
Icons in <entry>
~##<entry primary-icon-activatable="true" primary-icon-stock="gtk-refresh" secondary-icon-activatable="true" secondary-icon-stock="gtk-clear"##
**[[http://01micko.com/reference/notebook.html <notebook>]]**
You can define which tab should be active by default. "0" represent tab1, "1" represent tab2 ...
~##<notebook page="1">...</notebook>##
Tabs can be shown at Top/Bottom/Left/Right. Values from 0-3
~##<notebook tab-pos="3">...</notebook>##
Tabs can chosen in right-click menu
~##<notebook enable-popup="true">...</notebook>##
**[[http://01micko.com/reference/edit.html <edit>]]**
insert margins
~##<edit left-margin="20">...</edit>##
avoid user input
~##<edit editable="no">...</edit>##
**[[http://01micko.com/reference/pixmap.html <pixmap>]]**
Scale image
~##<pixmap><input file>file.jpg</input><height>40</height><width>70</width></pixmap>##
**[[http://01micko.com/reference/progressbar.html <progressbar>]]**
Avoid window to autoscale because of too much text in progressbar.
~You can truncate text at left (1), at right (3) or in the middle (2) by the ellipsize tag.
~##<progressbar text="Truncated the text in the middle" ellipsize="2"></progressbar>##
Define the text alignment by text-xalign and text-yalign tag.
~Try out values from 0-3 for left, right and center.
~##<progressbar text-xalign="1" text-yalign="1">##
Do not show text
~##<progressbar show-text="false">##
Alternative bar outfit. - view blocks
~##<progressbar bar-style="1">##
Do not truncate result to block-size.
~##<progressbar discrete-blocks="25">##
Set orientation
~0 - Horizontal - left to right.
~1 - Horizontal - right to left.
~2 - Vertical - bottom to top.
~3 - Vertical - top to bottom.
~##<progressbar orientation="3">##
**[[http://01micko.com/reference/chooser.html <chooser>]]**
Type of chooser-widget
~0 - Open file
~1 - Save file
~2 - Select folder
~3 - Create folder
~##<chooser action="1">##
Hide/Show 'create folders' button
~##<chooser create-folders="false">##
App with extended use of <chooser>
~[[MMview]]
**[[http://01micko.com/reference/tree.html <tree>]]**
manual sort the list
~##<tree reorderable="true">...</tree>## - See the Drag'n drop workaround to succeed
App with extended use of <tree>
~[[pMusic]]


Revision [32847]

The oldest known version of this page was created on 2020-07-24 03:00:05 by zigbert
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki