The time now is Tue 21 May 2013, 00:49
All times are UTC - 4 |
|
Page 26 of 52 [767 Posts] |
Goto page: Previous 1, 2, 3, ..., 24, 25, 26, 27, 28, ..., 50, 51, 52 Next |
| Author |
Message |
seaside
Joined: 11 Apr 2007 Posts: 833
|
Posted: Thu 29 Jul 2010, 11:45 Post subject:
Re: Dynamic pixmaps |
|
| afishe2000 wrote: |
Here is the test code I modified from the pixmap example and an screenshot of the results:
| Code: | #!/bin/bash
get_Pic() {
echo foldger.jpg
}
export -f get_Pic
export MAIN_DIALOG="
<vbox>
<frame Static File Name>
<text>
<label>foldger.jpg</label>
</text>
</frame>
<frame Static Picture>
<pixmap>
<input file>\"folgers.jpg\"</input>
</pixmap>
</frame>
<frame Dynamic File Name>
<text>
<input>get_Pic</input>
</text>
</frame>
<frame Dynamic Picture>
<pixmap>
<input file>get_Pic</input>
</pixmap>
</frame>
<hbox>
<button cancel></button>
<button ok></button>
</hbox>
</vbox>
"
gtkdialog3 --program=MAIN_DIALOG
|
|
afishe2000,
If your question is "why doesn't the Dynamic Picture work?"
Two reasons-
| Code: |
get_Pic() {
echo foldger.jpg
} |
1. Should be "folgers.jpg"
2. This code -
| Code: | <frame Dynamic Picture>
<pixmap>
<input file>get_Pic</input>
</pixmap>
</frame> |
Command "get_pic" needs to be resolved to the actual filename in place like this -
| Code: | | <input file>$(get_Pic)</input> |
Great work - keep going
Regards,
s
|
|
Back to top
|
|
 |
afishe2000
Joined: 29 Jan 2010 Posts: 34
|
Posted: Thu 29 Jul 2010, 15:21 Post subject:
|
|
Thanks so much,
I'm surprised that <text> works with get_Pic ($(get_Pic) doesn't though) but <pixmap> needs $(get_Pic).
I thought the function was returning a string and both widgets just required a sting input.
| Code: | <text>
<input>get_Pic</input>
</text>
<pixmap>
<input file>$(get_Pic)</input>
</pixmap> |
|
|
Back to top
|
|
 |
seaside
Joined: 11 Apr 2007 Posts: 833
|
Posted: Thu 29 Jul 2010, 17:51 Post subject:
|
|
| afishe2000 wrote: | Thanks so much,
I'm surprised that <text> works with get_Pic ($(get_Pic) doesn't though) but <pixmap> needs $(get_Pic).
|
afishe2000,
The pixmap <input file> does not accept a variable for a filename, so $(get_Pic) is used as a subshell command.
$(get_Pic) doesn't work in text and other inputs because it IS a subshell (Subshell process variables are not visible to parents)
This may be useful-
http://tldp.org/LDP/abs/html/subshells.html#SUBSHELLSREF
Cheers,
s
|
|
Back to top
|
|
 |
neurino

Joined: 15 Oct 2009 Posts: 360
|
Posted: Wed 04 Aug 2010, 11:24 Post subject:
|
|
I'm using Glade Interface Designer to build up a little gui using libglade.
My problem is using signal to open an internet page: it escapes "&" char in urls to &#.38 (remove the ".", otherwise the forum re-escapes "&#.38" to "&" ) breaking the url, for example the link
http://www.google.com/search?hl=en&q=glade
| Code: | ...
<signal name=\"clicked\" handler=\"defaultbrowser "http://www.google.com/search?hl=en&q=glade"\"/>
... |
executes on click:
| Code: | | defaultbrowser "http://www.google.com/search?hl=en&#.38;q=glade" |
which is incorrect, so we have
& => & => & tha is "&" escaped!!!
Any tips?
|
|
Back to top
|
|
 |
Aitch

Joined: 04 Apr 2007 Posts: 6825 Location: Chatham, Kent, UK
|
Posted: Wed 04 Aug 2010, 13:05 Post subject:
|
|
Try
http://htmlhelp.com/tools/validator/problems.html
| Quote: | To avoid problems with both validators and browsers, always use & in place of & when writing URLs in HTML:
<a href="foo.cgi?chapter=1&section=2&copy=3&lang=en">...</a>
Note that replacing & with & is only done when writing the URL in HTML, where "&" is a special character (along with "<" and ">"). When writing the same URL in a plain text email message or in the location bar of your browser, you would use "&" and not "&". With HTML, the browser translates "&" to "&" so the Web server would only see "&" and not "&" in the query string of the request.
Incorrect Nesting of Elements |
HTH
Aitch
|
|
Back to top
|
|
 |
neurino

Joined: 15 Oct 2009 Posts: 360
|
Posted: Wed 04 Aug 2010, 14:48 Post subject:
|
|
Ehm...
ampersands are already escaped (instead of "&" I put & in links) but when & entity is restored it is re-escaped, by some process, which one I'd like to know, to &#.38 The last one is the same as &
I'm a webmaster and I'm used to special chars in XML, the problem comes when gtkdialog calls the command in XML <signal>
|
|
Back to top
|
|
 |
potong
Joined: 06 Mar 2009 Posts: 88
|
Posted: Wed 04 Aug 2010, 18:14 Post subject:
|
|
neurino:
It's easy to fall foul of gtkdialog parsing code within it's xml and doubly so when using glade!
I have found it far easier to keep the code out of the gtkdialog/glade xml and just refer to an exported function.
This function can be in the main bash script i.e. the script calling gtkdialog or in an included function library file (see /usr/share/doc/gtkdialog3/examples/glade-01.00-entries_functions.sh)
If using the first method don't forget to export the function! | Code: | say(){ echo hello; }
export -f say |
Or you can play safe and export all functions and variables by codingas the first line of your script.
In the glade file the xml for the signal handler could look like this | Code: | | <signal name="clicked" handler="getpage &"/> | and the include file like this: | Code: | | getpage(){ defaultbrowser "http://www.google.com/search?hl=en&q=glade"; } |
HTH
potong
N.B. In glade you would type in the Signal Handler entry
Last edited by potong on Wed 04 Aug 2010, 18:19; edited 1 time in total
|
|
Back to top
|
|
 |
potong
Joined: 06 Mar 2009 Posts: 88
|
Posted: Wed 04 Aug 2010, 18:16 Post subject:
|
|
Double post
|
|
Back to top
|
|
 |
neurino

Joined: 15 Oct 2009 Posts: 360
|
Posted: Thu 05 Aug 2010, 18:35 Post subject:
|
|
| potong wrote: | neurino:
It's easy to fall foul of gtkdialog parsing code within it's xml and doubly so when using glade!
I have found it far easier to keep the code out of the gtkdialog/glade xml and just refer to an exported function.
|
Thanks potong, your advice is always helpful.
I'm building a little GUI for the gmail checker in the other post you answered me.
Inserting directly links in xml interface along with other data as subject, author and summary was the easiest logical way and, in fact, it all works except the link part with escaped ampersands.
Not a big trouble writing dynamically separate functions, one for each link and this is what I'm going to do.
Of course, if I'd ever distribute a little pet of this work (would be nice to stay as neat and light as possible) I'd put most of credits to you
|
|
Back to top
|
|
 |
zigbert

Joined: 29 Mar 2006 Posts: 5241 Location: Valåmoen, Norway
|
Posted: Fri 06 Aug 2010, 03:54 Post subject:
|
|
Could anyone give us newbies an easy guide: 'howto use gtkdialog with glade'?
Pleeeease
Sigmund
_________________ Stardust resources
|
|
Back to top
|
|
 |
neurino

Joined: 15 Oct 2009 Posts: 360
|
Posted: Fri 06 Aug 2010, 13:29 Post subject:
|
|
| zigbert wrote: | Could anyone give us newbies an easy guide: 'howto use gtkdialog with glade'?
Pleeeease
Sigmund |
You newbiee with gtkdialog? Is it a joke?
Anyway I made all by tentatives until it worked somehow.
In few steps:
open glade, in prefs choose to use libglade, build and save your gui to file, call | Code: | | gtkdialog3 -g your_glade_file.glade -p name_of_the_window_to_show -i your_shell_script_with_functions_called_by_signals_in_glade_file_no_need_to_export |
Easy, but poorly documented.
|
|
Back to top
|
|
 |
disciple
Joined: 20 May 2006 Posts: 6179 Location: Auckland, New Zealand
|
Posted: Fri 06 Aug 2010, 20:42 Post subject:
|
|
So what's the advantage of using glade, given that gtkdialog uses a similar xml syntax anyway? Is it just that you can create the gui in the glade interface designer?
Glade is an extra dependency which is going extinct as programs are rewritten to use gtkbuilder...
_________________ DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
|
|
Back to top
|
|
 |
neurino

Joined: 15 Oct 2009 Posts: 360
|
Posted: Sat 07 Aug 2010, 04:22 Post subject:
|
|
The full name of Glade in my menu is Glade Interface Designer so what to expect more?
I'm not taking care of depenecies as long I don't need extra libs that the ones already present in Puppy distributions I'm using (Wary 030 and Puppeee at the moment).
I find building with glade is extra fast then I can fine-tune xml in a text editor if I have the need.
For a simple settings dialog I think it's the fastest option (even if glade xml is more verbose than the one explained in this topic... but you don't have to handwrite it so...)
|
|
Back to top
|
|
 |
disciple
Joined: 20 May 2006 Posts: 6179 Location: Auckland, New Zealand
|
Posted: Sat 07 Aug 2010, 05:17 Post subject:
|
|
| Quote: | | so what to expect more? |
Maybe. For all I know gtkdialog might be able to do more things when used with libglade. BTW, did Glade even start off as a GUI tool, or did that come later?
Zigbert, there's a thread I think on the forum of another distro, where a couple of guys were posting quite a lot of gtkdialog+glade examples. I thought I posted a link to it here, but I can't see the link... maybe it was the thread where I first reported hacking glade support out out of gtkdialog.
_________________ DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
|
|
Back to top
|
|
 |
disciple
Joined: 20 May 2006 Posts: 6179 Location: Auckland, New Zealand
|
Posted: Sat 07 Aug 2010, 05:50 Post subject:
|
|
| Quote: | | maybe it was the thread where I first reported hacking glade support out out of gtkdialog |
No, it doesn't look like that was it. Surely I wasn't negligent enough not to post it at all...
_________________ DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
|
|
Back to top
|
|
 |
|
|
Page 26 of 52 [767 Posts] |
Goto page: Previous 1, 2, 3, ..., 24, 25, 26, 27, 28, ..., 50, 51, 52 Next |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|