Author |
Message |
potong
Joined: 06 Mar 2009 Posts: 88
|
Posted: Wed 17 Mar 2010, 21:07 Post subject:
|
|
sunburnt: You forgot a closing <./window> directive in your gui.
Here are some tips I use when building a gui.
1) Every time you write an opening directive, copy and edit it into closing one. Then go back and continue Code: | <window title="GUI">
<vbox>
</window> |
Code: | <window title="GUI">
<vbox>
</vbox>
</window> | etc
2) Use indentation for clarity and self checking. This is your code formated with indentation. Code: | #!/bin/sh
export SETTINGS="
<window title=\". DM Settings\">
<hbox>
<vbox>
<frame Max. Drive List Height >
<vbox>
<text>
<label>Set Maximum Number of</label>
</text>
<text>
<label>Drives to Show in Drive List.</label>
</text>
<hbox>
<button>
<label>Increase</label>
<action>$1/driveman lstHEIGHT up</action>
<action type=\"clear\">HEIGHT</action>
<action type=\"refresh\">HEIGHT</action>
</button>
<button>
<label>Decrease</label>
<action>$1/driveman lstHEIGHT dn</action>
<action type=\"clear\">HEIGHT</action>
<action type=\"refresh\">HEIGHT</action>
</button>
<entry>
<variable>HEIGHT</variable>
<input>cat $1/lstHEIGHT.set</input>
<width>40</width>
<height>25</height>
</entry>
</hbox>
</vbox>
</frame>
<frame Bootup Control>
<vbox>
<checkbox>
<label>Run DriveMan at Bootup.</label>
<variable>DMBOOT</variable>
<action>$1/driveman dmBOOT</action>
</checkbox>
<checkbox>
<label>Run Auto-Drive at Bootup.</label>
<variable>AUTOBOOT</variable>
<action>$1/driveman autoBOOT</action>
</checkbox>
</vbox>
</frame>
</vbox>
<vbox>
<frame Auto-Drive Control >
<vbox>
<checkbox>
<label>Start or Stop Auto-Drive.</label>
<variable>AUTODRV</variable>
<action>$1/driveman autoDRV</action>
</checkbox>
<checkbox>
<label>Auto-Drive Pops up ROX.</label>
<variable>AUTOROX</variable>
<action>$1/driveman autoROX</action>
</checkbox>
</vbox>
</frame>
<button>
<label>Exit</label>
<action>exit</action>
</button>
</vbox>
</hbox>
</window>
"
gtkdialog3 -d -p SETTINGS |
it is long winded, I know but you can shorten it later after everything is working. Notice how every container is aligned, you can run a cursor up and down and check all are closed off. Also you know everyting is in its place when you finish the gui at the column you started.
3) Use the construct GUI=$(cat <<EOV|sed 's/#.*//'...EOV) This allows you to comment your gui and can greatly speed up those tweaks Code: | GUI=$(cat <<EOV|sed 's/#.*//'
<window title="gui">
<vbox>
<text label="Use This></text>
#<text label="Do Not Use This"></text>
</vbox>
</window>
EOV) |
another side effect of uing the here document (cat <<EOV...EOV) is you don't need to escape your double-quotes (") in the directive tags BUT remember interpolation is a double edged sword and code you intend gtkdialog to pass through to bash will need escaping. This leads on to the fourth tip..
4)KISS I try to divorce the gui from the actions of the gui. By this I mean when you have an action rather than writing the code into your gui, perform a subroutine instead e.g Code: | <action>display ENTRY</action> | and in the script Code: | display(){ echo "${!1}"; } |
instead of Code: | <action>echo \$ENTRY</action> |
This has several benefitsTesting: you can get the gui working without having to worry about your bash code working
Reuse: You can use a function anywhere, inside another script or even on the command line
Looks: Funnily enough using functions and variables indirectly as parameters ( ${!1} in a function means use the literal of the first parameter as a variable) fits right in in with the look and feel of the xml(ish) gui
5) Use the debug option in gtkdialog Code: | gtkdialog3 -d -p GUI |
HTH
Potong
|
Back to top
|
|
 |
sunburnt

Joined: 08 Jun 2005 Posts: 5087 Location: Arizona, U.S.A.
|
Posted: Wed 17 Mar 2010, 22:30 Post subject:
|
|
Thanks again potong; Yep... You`re right, the main GUI had </window> but not the Settings.
Much of what you said is things I learned writing Visual Basic apps., Linux is a whole new bag.
# Writing the Tags in pairs: This is how I setup my GUI builder that makes gtkDialog GUIs.
# Indentation: Always good for readability, except in Python... Then it`s required.!
... How about a " gtkDialog code compressor and decompressor " ? And one for script code too.
# Using the gtkDialog code as a string input makes sense. Or just calling a file with the code (-f).
... So instead of running a script with gtkDialog code, you just run the gtkDialog command.
# And what you say about separating the GUI and the support code I`ve been saying for years.
... It`s sooo much easier to read and maintain it that way. Very long files should be broken up.
... Either the GUI file or the script code file can be replaced, even with another GUI or language!
|
Back to top
|
|
 |
8-bit

Joined: 03 Apr 2007 Posts: 3425 Location: Oregon
|
Posted: Wed 17 Mar 2010, 22:40 Post subject:
|
|
I just tried your settings file after adding the missing </window> and I found it would not exit.
If you are just wanting it to exit, delete the action line for the exit button.
The way I used it, I saw in another script.
But I am just a dumb farm boy trying to make sense of this gtkdialog3 scripting language.
Now an old retired one that has had various occupations.
Remember when programming was fun?
Just got back with an exit button code from my Floppy Formatter program.
Try this instead.
Code: |
<button>
<input file icon=\"gtk-quit\"></input>
<label>EXIT</label>
<action type=\"exit\">EXIT_NOW</action>
</button>
|
It includes an icon and icons can be added to any button.
|
Back to top
|
|
 |
sunburnt

Joined: 08 Jun 2005 Posts: 5087 Location: Arizona, U.S.A.
|
Posted: Wed 17 Mar 2010, 23:24 Post subject:
|
|
8-bit; Try this: <button><label>Exit</label><action>$appPATH/driveman saveGUI</action><action type=\"exit\">exit</action></button>
I`ve rewritten all of the driveman files and tested all but the Settings GUI.
All 5 separate settings files are now in one file, and the smaller Settings GUI has 4 CheckBoxes.
Description |
Both GUIs are smaller, I like that... |
Filesize |
28.24 KB |
Viewed |
525 Time(s) |

|
|
Back to top
|
|
 |
8-bit

Joined: 03 Apr 2007 Posts: 3425 Location: Oregon
|
Posted: Thu 18 Mar 2010, 00:11 Post subject:
|
|
It looks like it is coming along nicely!
I like the looks of it.
I do not know if the settings window comes up as you have it shown.
But you can have it do so by utilizing the position and size settings from the Driveman window.
|
Back to top
|
|
 |
sunburnt

Joined: 08 Jun 2005 Posts: 5087 Location: Arizona, U.S.A.
|
Posted: Thu 18 Mar 2010, 00:28 Post subject:
|
|
No, it pops up in an arbitrary position. Usually covers the main GUI which is ok anyway...
I might be getting the hang of gtkDialog3, I got the CheckBox to show it`s setting default.!!!
P.S. Did you try the revised gtkDialog tester I reposted above?
|
Back to top
|
|
 |
8-bit

Joined: 03 Apr 2007 Posts: 3425 Location: Oregon
|
Posted: Thu 18 Mar 2010, 00:43 Post subject:
|
|
I tried the gtkdialog script tester and I for one like it and think it would be a valuable inclusion in Zigbert's Gtk tips section!
Great work there!!!
One thing though. When I first ran it, I thought it was broke since when no tags are missing, it returns a window with just the headers for the tags found.
If no tags are found, no tmp file gets written and an alternate message could be displayed as to the file being checked as OK.
Just a thought for the dumb ones like me.
|
Back to top
|
|
 |
sunburnt

Joined: 08 Jun 2005 Posts: 5087 Location: Arizona, U.S.A.
|
Posted: Thu 18 Mar 2010, 00:57 Post subject:
|
|
LOL............ I had just realized that a little while ago... Not so think as I dumb I am...!!!
I guess I should post it in the Cutting Edge forum for appraisal. ( This forum`s for Q and A )
|
Back to top
|
|
 |
|