Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 30 Sep 2014, 12:10
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
GtkDialog - tips
Post new topic   Reply to topic View previous topic :: View next topic
Page 58 of 64 [953 Posts]   Goto page: Previous 1, 2, 3, ..., 56, 57, 58, 59, 60, 61, 62, 63, 64 Next
Author Message
Moose On The Loose


Joined: 24 Feb 2011
Posts: 525

PostPosted: Tue 08 Oct 2013, 21:31    Post subject:  

SFR wrote:
Ahh, me too can't find a way to use markup within buttons' labels. Is it possible? I hope so...

Another way would be to use (dynamically generated) SVG images as button's body, instead of a plain text.


I think xpm works too. I did this to make a color changing curved line:
Code:

  echo "/* XPM */" >$DEMOXPM
  echo "static char * Untitled_xpm[] = {" >>$DEMOXPM
  echo '"64 64 2 1",' >>$DEMOXPM
  echo '"   c #000000",' >>$DEMOXPM
  echo "\".  c #$COLOR\"," >>$DEMOXPM
  for (( I=0; I<63; I=I+1 )) ; do
    THIS=$(( ( 64 * $I * $I  + ( 63 * 63 ) ) / ( 63 * 63 ) ))
    STR="............."
    STR="${STR:0:$(( 1 + $THIS - $PREV ))}"
    STR=$( printf "%${THIS}s" "$STR" )
    STR=$( printf "%-64s" "$STR" )
    echo "\"$STR\"," >>$DEMOXPM
    PREV="$THIS"
    done
  printf '"%64s"};' " " >>$DEMOXPM
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5032
Location: Arizona, U.S.A.

PostPosted: Wed 09 Oct 2013, 14:34    Post subject:  

Moose On The Loose; Interesting... Worked for me.

01micko; You code works good. Need to pad the text ( pic size )

It looks like vovchik`s text-size utility could be used to size the button.

Interesting idea, creating images with text in them.
Now to be able to merge images in code. Icons and the text.

The BaCon language can import GTK properties and methods.
So almost anything`s possible.

Something like this could be done for GtkDialog too.
Hopefully in a wrapper so as to mask the horrible GTK code.
.
Back to top
View user's profile Send private message 
disciple

Joined: 20 May 2006
Posts: 6438
Location: Auckland, New Zealand

PostPosted: Sat 19 Oct 2013, 00:30    Post subject:  

If you make a vbox or an hboxes scrollable then it becomes tiny by default.
Rather than specified a fixed size for it, does anyone have a solution to make it expand automatically to fit the contents, without displaying a scrollbar until it runs out of space on the screen?

_________________
DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3307
Location: Ontario

PostPosted: Mon 21 Oct 2013, 17:28    Post subject:
Subject description: SVG image buttons
 

I made some changes to 01micko's script (previous page)
to make it generate a more general button.





There are 8 options to give the script. (or just 7 if you want the
outline to be black)

If you don't want an outline then make the stroke width 0.

If you save the script as 'SVG-button.sh' then type in terminal...

./SVG-button.sh DejaVu 24 "My Message" 10 red 2 .1 black


EDIT: An attractive button can be made with white as the rectangle color
but set opacity to .1

./SVG-button.sh DejaVu 24 "My Message" 10 white 2 .1 black




Code:

#!/bin/sh
#  create a SVG color button  with text
# rewritten by don570  from 01micko script
# params: $1 = font ; $2 = size ; $3 = string (use quotes) ;
# $4 corner's parameter  (= 0 to 15 recommended) ; $5  color of rect background ; $6  stroke width ;
#  $7 rect opacity ; $8 (optional) stroke color  (quoted hex or otherwise)
#  example command:   ./SVG-button.sh  DejaVu 24  "My Message" 10  red 2 .1  black

Y=$((${2}/2))
H=$((${Y}+${2}))
X1=$(echo "$3"|wc -c)
X2=$((${Y}/2))
W=$((${X1}*${X2}*95/31))
let "DISPLACE=$W/7"
Z=$((${2}+2))

[ ! "$8" ] && STROKECOLOR='#000000' || STROKECOLOR=$8

  echo '<svg version="1.1"> 
      <rect
      style="fill:'$5';fill-opacity:'$7';stroke-width:'$6';stroke:'$STROKECOLOR';stroke-opacity:1;stroke-dasharray:none;"
     width='\"$W\"' height='\"$H\"' rx="'$4'" ry="'$4'" x="1" y="1"/>
           <text style="font-family:'$1';font-size:'$2';fill-opacity:1"
      x='\"$DISPLACE\"'  y='\"$Z\"' >
'$3'
     </text>

</svg>' > /tmp/img${$}.svg
echo "img${$}.svg is in /tmp"

echo '<button><input file>"'"/tmp/img${$}.svg"'"</input></button>'|gtkdialog -s
rm /tmp/img${$}.svg
 


________________________________________________

Last edited by don570 on Sat 26 Oct 2013, 14:53; edited 1 time in total
Back to top
View user's profile Send private message 
Moose On The Loose


Joined: 24 Feb 2011
Posts: 525

PostPosted: Mon 21 Oct 2013, 20:47    Post subject:  

sunburnt wrote:

Something like this could be done for GtkDialog too.
Hopefully in a wrapper so as to mask the horrible GTK code.


I end to do my gtkdialog stuff fragment by fragment with functions lost of like this:

Code:

function EnterSubGUI() {
  local DEF

  eval "DEF=\$$1"
  if [[ "$DEF" != "" ]] ; then
    DEF="<default>$DEF</default>"
    fi
  if [[ "$2" == "" ]] ; then
    echo "<entry>"
  else
    echo "<entry $2>"
    fi
   
  echo "<variable>$1</variable>$DEF $3"
  echo "<action>refresh:${1}_VALID</action>"
  echo "<action>refresh:OKOK</action>"
  echo "<action signal=\"show\">refresh:${1}_VALID</action>"
  echo "<action signal=\"show\">refresh:OKOK</action>"
  echo "</entry>"
  }


This then get used to build up the full dialog with functions calling functions that all echo out to stdout. The outer most level does:

Code:

DIA=$( MakeMyDialogFunction option option )
RESULT=$( RunGtkDialog )
eval $RESULT


I made a function to run gtkdialog so I could apply a grep that killed off certain results before they come out the RESULT.
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3307
Location: Ontario

PostPosted: Wed 23 Oct 2013, 15:07    Post subject: SVG image buttons  

SVG image buttons

A general method to generate attractive color buttons. The size is
(240x100 pts) however it is easy to modify a button size with width
and height directives

Provided the length of textstring isn't long --->
recommend max 12 characters or 10 if UPPERCASE.

The Text looks strange if you try to cram too much text into button.
I found that I could make the uppercase charcters look better in button
if an extra parameter was added --> called UPPERCASE.

This is because the uppercase (and probably the foreign characters)
take up more width than lowercase ones.

Parameters:

$1 = font
$2 = string (use quotes)
$3 background color (use quotes for hex)
$4 text color (usually black or white)
$5 (optional) =UPPERCASE if all characters are uppercase

Some command examples:

./SVG_button.sh Sans "My Message" "#00DB00" white
./SVG_button.sh DejaVu "MESSAGE" green white UPPERCASE

__________________________________________




Last edited by don570 on Sat 26 Oct 2013, 15:20; edited 1 time in total
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3307
Location: Ontario

PostPosted: Thu 24 Oct 2013, 19:46    Post subject:  

I noticed the following with my generation script above....

More than 8 characters results in the font size becoming noticeably smaller
than the other labels. This is noticeable in buttons that are in a column
such as this example. The label 'Top-panel' has 9 characters.





Here is a couple of scripts to show how to use code.
______________________________________________
scripts-don570.tar.gz
Description  demonstration scripts to show practical example
gz

 Download 
Filename  scripts-don570.tar.gz 
Filesize  1.67 KB 
Downloaded  166 Time(s) 
Back to top
View user's profile Send private message 
matiasbatero


Joined: 11 Oct 2012
Posts: 60
Location: Mar del Plata, Argentina

PostPosted: Thu 24 Oct 2013, 22:26    Post subject:  

don570 wrote:
I noticed the following with my generation script above....

More than 8 characters results in the font size becoming noticeably smaller
than the other labels. This is noticeable in buttons that are in a column
such as this example. The label 'Top-panel' has 9 characters.





Here is a couple of scripts to show how to use code.
______________________________________________


You can use <button relief="2"> to get more realism for your button made with SVG. relief="2" removes the "button box" when is not selected.
Back to top
View user's profile Send private message 
recobayu


Joined: 15 Sep 2010
Posts: 112
Location: indonesia

PostPosted: Fri 25 Oct 2013, 06:14    Post subject:  

matiasbatero wrote:

You can use <button relief="2"> to get more realism for your button made with SVG. relief="2" removes the "button box" when is not selected.

we can use gtkdesklet by akash:
http://murga-linux.com/puppy/viewtopic.php?t=74204
this is very interesting, don570. Very Happy
Back to top
View user's profile Send private message 
matiasbatero


Joined: 11 Oct 2012
Posts: 60
Location: Mar del Plata, Argentina

PostPosted: Fri 25 Oct 2013, 12:15    Post subject:  

recobayu wrote:
matiasbatero wrote:

You can use <button relief="2"> to get more realism for your button made with SVG. relief="2" removes the "button box" when is not selected.

we can use gtkdesklet by akash:
http://murga-linux.com/puppy/viewtopic.php?t=74204
this is very interesting, don570. Very Happy


yes, but it works with gtkdialog (GTK2) not GTK3.
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3307
Location: Ontario

PostPosted: Sat 26 Oct 2013, 15:03    Post subject:  

I've worked on improvements to my candy color SVG image buttons.

For the wide version of the button I doubled the width to 480 pts.
I have also put limits on size of fonts which makes them more attractive
over a bigger range of characters.

Recommendation:

SVG_button.sh ----> 12 characters (max) 10 if UPPERCASE

SVG_widebutton.sh --> 19 characters (max) 16 if UPPERCASE

example commands:
Code:
# ./SVG_widebutton.sh   Sans  "My Message" "#00DB00" white
# ./SVG_widebutton.sh   DejaVu  "MESSAGE" blue white UPPERCASE





______
SVG_button.sh.gz
Description  remove fake .gz extension
gz

 Download 
Filename  SVG_button.sh.gz 
Filesize  3.82 KB 
Downloaded  150 Time(s) 
SVG_widebutton.sh.gz
Description  remove fake .gz extension
gz

 Download 
Filename  SVG_widebutton.sh.gz 
Filesize  3.37 KB 
Downloaded  147 Time(s) 
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5032
Location: Arizona, U.S.A.

PostPosted: Sun 27 Oct 2013, 00:52    Post subject:  

moose on the loose; Yes, building the dialog from parts ( modules ) is a good method.

Now to wrap the whole thing in a rational command set syntax. A GtkDialog fork ?
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5032
Location: Arizona, U.S.A.

PostPosted: Tue 29 Oct 2013, 14:08    Post subject:  

I`m looking at GtkDialog docs., and I don`t see much at all on the Tree.
To run the examples it has no tree structure at all, it looks like the Table.
I know GTK changed the way most of the higher level widgets work.
I`ve worked with the tree before, but it must have been GTK-2.

# Need to make dir./folder tree panel and control the icons for each node.

# Also need file panels and to control the icons individually for them also.
Probably 2 file panels, one a detailed list, and one a file only ( like Rox ).
.
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5032
Location: Arizona, U.S.A.

PostPosted: Thu 31 Oct 2013, 16:03    Post subject:  

Any way to detect which mouse buttons/wheel are active?

Using a list box at the moment...
Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1072

PostPosted: Thu 31 Oct 2013, 16:31    Post subject:  

Hey Sunburnt

sunburnt wrote:
Any way to detect which mouse buttons/wheel are active?

Using a list box at the moment...

Doesn't seem to work with a wheel, but detects left/middle/right buttons:
Code:
echo '<list><item>Click me</item><action signal="button-press-event">echo $BUTTON</action></list>' | gtkdialog -cs

BTW, as far as I'm aware, there's no such thing as real tree widget in Gtkdialog, unfortunately...

Greetings!

_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 58 of 64 [953 Posts]   Goto page: Previous 1, 2, 3, ..., 56, 57, 58, 59, 60, 61, 62, 63, 64 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

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
[ Time: 0.1216s ][ Queries: 13 (0.0197s) ][ GZIP on ]