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 Mon 22 Sep 2014, 14:21
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 61 of 64 [952 Posts]   Goto page: Previous 1, 2, 3, ..., 59, 60, 61, 62, 63, 64 Next
Author Message
Moose On The Loose


Joined: 24 Feb 2011
Posts: 525

PostPosted: Tue 10 Dec 2013, 11:14    Post subject:  

sunburnt wrote:
Thanks Moose; Looking at it...
Puppy has no: /tmp/gtkrc_fft


Look more closely. My script wrote that file.
/tmp/gtkrc_fft is what I added to make red and mono type

Quote:

And: /root/.gtkrc-2.0 is an empty file.


It must be you didn't set a theme or something mine looks like this.

Code:

# -- THEME AUTO-WRITTEN DO NOT EDIT
include "/usr/share/themes/Stardust/gtk-2.0/gtkrc"

style "user-font" {
   font_name = "Sans 12"
}

include "/root/.gtkrc.mine"

# -- THEME AUTO-WRITTEN DO NOT EDIT


You may have to use find to find the one that is used on your version of puppy. I am on puppy 5.2.8.006 right now.
Back to top
View user's profile Send private message 
Moose On The Loose


Joined: 24 Feb 2011
Posts: 525

PostPosted: Tue 10 Dec 2013, 11:25    Post subject:  

koulaxizis wrote:
Is it possible in a combobox when selecting an <item> to have a different action than reading the exact word written inside? For example: when selecting <item>hello</item>, the script will actually read/use <item>hello</item>. But i want to select <item>Greek</item> and use on the final output "el", not "Greek". I want to do that so i can change the ugly language shortcut code (eg "el) with the whole word (Greek) but on the final output it must be used the shortcut (el) for the command to work properly... I hope you understood what i mean, my English are not too good... :/


A method I've used is to use string operations in bash to change the string from what is returned into what I want it to be.
Code:

STRING="${STRING/Greek/el}"


It means you need to do one line per country but that is not too bad because you sort of need to do that anyway when you make the list of countries and codes.
Back to top
View user's profile Send private message 
sunburnt


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

PostPosted: Tue 10 Dec 2013, 21:20    Post subject:  

Yeah, Ive never set a theme on this Puppy. Not too concerned with that usually.

Changing the objects is beyond themes, I need new widgets and window decorations.
Back to top
View user's profile Send private message 
koulaxizis


Joined: 17 Jul 2011
Posts: 428
Location: Greece

PostPosted: Wed 11 Dec 2013, 07:45    Post subject:  

Moose On The Loose wrote:
A method I've used is to use string operations in bash to change the string from what is returned into what I want it to be.
Code:

STRING="${STRING/Greek/el}"


It means you need to do one line per country but that is not too bad because you sort of need to do that anyway when you make the list of countries and codes.


Can you show me a piece of the updated code to understand it? How should it look with the "string" parameter?

_________________
Christos Koulaxizis
Woof woof from Greece...

[ Puppy packages | Puppy search ]
Back to top
View user's profile Send private message Visit poster's website 
sunburnt


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

PostPosted: Wed 11 Dec 2013, 18:49    Post subject:  

Hi koulaxizis; Bash does built-in string manipulation.

Code:
STRING=12345abcde

echo ${STRING/a*/6789} ### This outputs: 123456789

echo $STRING:0:4} ### This outputs: 12345

echo $STRING: -4} ### This outputs: bcde

echo $STRING##*3} ### This outputs: 45abcde

P=/1/2/3/F.ext

echo $P##*/} ### This outputs: F.ext

echo $P#*/} ### This outputs: 1/2/3/F.ext

echo $P##*.} ### This outputs: ext

echo $P%/*} ### This outputs: /1/2/3

echo $P%.*} ### This outputs: /1/2/3/F


# Is starting at the first character.
% Is starting at the last character.

### Ask if you have any more Qs... Always glad to help a friend.! Terry B.
.
Back to top
View user's profile Send private message 
koulaxizis


Joined: 17 Jul 2011
Posts: 428
Location: Greece

PostPosted: Thu 12 Dec 2013, 09:47    Post subject:  

sunburnt wrote:
Ask if you have any more Qs... Always glad to help a friend.! Terry B.
.


I'll try it and i'll return with questions if i don't manage to do it. Thanks brother! Smile

_________________
Christos Koulaxizis
Woof woof from Greece...

[ Puppy packages | Puppy search ]
Back to top
View user's profile Send private message Visit poster's website 
Moose On The Loose


Joined: 24 Feb 2011
Posts: 525

PostPosted: Thu 12 Dec 2013, 10:22    Post subject:  

sunburnt wrote:
Yeah, Ive never set a theme on this Puppy. Not too concerned with that usually.

Changing the objects is beyond themes, I need new widgets and window decorations.


My answer was narrow to the determination of what the fonts are.

A trick that I have used to make something beyond what gtkdialog did easily was to make an item that is a button and use that to pop up another dialog right on top of where the button is.

gtkdialog like many programs will take the geometry on the command line. The code that was the basis of doing it is below. It is not the best code in the world but it gets it done

Code:


#########################################################################
#  Use a slight bit of trickery to make the sub-dialogs come up on top
#  the main one in a relative position
#  Syntax:
#    RelToMain XOFFSET YOFFSET
#    RelToMain XOFFSET YOFFSET WIDTH HEIGHT
#
#  Output: "--geometry +123+456"  ready for command line
#  Output: "--geometry 543x654+123+456"  ready for command line
#########################################################################
DISPLAY_HEIGHT=`xdpyinfo | grep "dimensions:" | sed -r "s/ +/x/g"`
DISPLAY_WIDTH=`echo "$DISPLAY_HEIGHT" | cut -dx -f3`
DISPLAY_HEIGHT=`echo "$DISPLAY_HEIGHT" | cut -dx -f4`


function RelToMain () {
  local MAINWIN
  local MAINX
  local MAINY

  local HEIGHT
  local WIDTH
 
  # xdpyinfo contains the info about which window is in focus.  In our
  # case, that will be the window on which the user hit a button that
  # got us here
  # xwininfo tells us about the window in question once we know which one
  # to refer to
  MAINWIN=`xdpyinfo | grep "focus:" | sed "s/window/,/" | cut -d, -f2 `
  MAINWIN=`xwininfo -id $MAINWIN | grep "Absolute upper-left"`
  MAINX=`echo "$MAINWIN" | grep "X:" | cut -d: -f2`
  MAINY=`echo "$MAINWIN" | grep "Y:" | cut -d: -f2`
 
  # Add in the caller's offsets
  MAINX=$(( $MAINX + $1 ))
  MAINY=$(( $MAINY + $2 ))
 
  if [[ "$3" != "" ]] ; then
    WIDTH="$3"
  else
    WIDTH="200"
    fi
   
  if [[ "$4" != "" ]] ; then
    HEIGHT="$4"
  else
    HEIGHT="200"
    fi
   
  if (( $MAINX + $WIDTH + 30 > $DISPLAY_WIDTH )) ; then
    MAINX=$(( $DISPLAY_WIDTH - $WIDTH - 30 ))
    if (( $MAINX < 5 )) ; then
      MAINX=5
      fi 
    fi

  # echo "--- $MAINY   $HEIGHT  $DISPLAY_HEIGHT">&2
 
  if (( $MAINY + $HEIGHT + 60 > $DISPLAY_HEIGHT )) ; then
    MAINY=$(( $DISPLAY_HEIGHT - $HEIGHT - 60 ))
    if (( $MAINY < 5 )) ; then
      MAINY = 5
      fi
    fi
     
   
 
  if [[ "$4" != "" ]] ; then
    echo "--geometry ${3}x${4}+$MAINX+$MAINY"
  else
    echo "--geometry +$MAINX+$MAINY"
    fi
  }
Back to top
View user's profile Send private message 
sunburnt


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

PostPosted: Thu 12 Dec 2013, 16:11    Post subject:  

That`s very useful Moose, thank you, I keep code snip files for each type of "language".

Q: Have you ever tried my text-size utility? http://www.murga-linux.com/puppy/viewtopic.php?t=90592
Back to top
View user's profile Send private message 
Moose On The Loose


Joined: 24 Feb 2011
Posts: 525

PostPosted: Sat 14 Dec 2013, 12:04    Post subject:  

sunburnt wrote:
That`s very useful Moose, thank you, I keep code snip files for each type of "language".

Q: Have you ever tried my text-size utility? http://www.murga-linux.com/puppy/viewtopic.php?t=90592


As with many things, that is on the list of "not yet"
Back to top
View user's profile Send private message 
Argolance


Joined: 06 Jan 2008
Posts: 1826
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Sat 14 Dec 2013, 15:07    Post subject:  

Bonsoir,
This is what can be read on the first page of this topic:
Quote:
>> Show progress in entry - or simply change the color of the entry background
<entry progress-fraction="0.5">

"simply" Shocked change the color of the entry background?
Confused
... Could someone tell a bit more about the way to change the background color of an entry?
Thank you!

Cordialement.

_________________

Back to top
View user's profile Send private message Visit poster's website 
Bert


Joined: 30 Jun 2006
Posts: 928

PostPosted: Sat 14 Dec 2013, 18:42    Post subject:  

Hi Argolance,

Just change the progress-fraction="0.5" to "1" and the whole entry will be coloured:



And text will be white.
Hope I understood your question correctly.

Bye

_________________


Back to top
View user's profile Send private message 
Argolance


Joined: 06 Jan 2008
Posts: 1826
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Sat 14 Dec 2013, 19:41    Post subject:  

Hello Bert,
Thank you for replying.
This background color depends on the gtk theme configuration and is not necessarily "colored"... In my case, it is actually... white! Wink
Quote:
Hope I understood your question correctly.
I myself misunderstood the effect of this entry option, thinking it was really the entry background color that could be changed so.
As a matter of fact, my question has rather something to do with the "Define unique gtk-theme" section of this topic.

Cordialement.

Last edited by Argolance on Sun 15 Dec 2013, 09:30; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
Argolance


Joined: 06 Jan 2008
Posts: 1826
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Sun 15 Dec 2013, 09:28    Post subject: Change background and foreground entry colors  

Bonjour,
Thinking it could be useful, here is the way to customize background and foreground entry colors that I founded following the example given above, in the "Define unique gtk-theme" section of this topic. Very Happy
Code:
#!/bin/bash
echo 'style "entry_test"
{
  font_name="Sans 30"
  base[NORMAL]="#FF00E1"
  bg[SELECTED]="#FFCE00"
  text[SELECTED]="#62EEFF"
  text[NORMAL]="#04FD00"
  text[ACTIVE]="#FFCE00"
}
widget "*colored_entry" style "entry_test"
class "GtkText*" style "entry_test"' > /tmp/gtkrc_entry_test

export GTK2_RC_FILES=/tmp/gtkrc_entry_test:/root/.gtkrc-2.0

export test_app="
<vbox>
   <entry name=\"colored_entry\"><default>TEST</default></entry>
</vbox>"
gtkdialog4 --program=test_app


Cordialement.
colored_entry.jpg
 Description   selected text/active window - unselected text/active window - selected text/inactive window...
 Filesize   20.3 KB
 Viewed   262 Time(s)

colored_entry.jpg


_________________

Back to top
View user's profile Send private message Visit poster's website 
can8v

Joined: 15 Jul 2006
Posts: 584
Location: Yuba City, CA

PostPosted: Sun 26 Jan 2014, 23:47    Post subject: GtkDialog Select Option from List (combobox?)  

I have been searching for some examples on how to do this for over an hour and I think I must not be using relevant search queries or something, so I thought I would just ask here.
I am writing my first bash script of any significance and I need a gui dialog to ask the user to make a selection from a few different options and return the selected value back to the script in the form of a variable. Ideally I would feed an array with the possible options to the function that creates the dialog and after the user makes selection get the variable back.
I won't know how many options will be in the variable prior to running the script. The script will get the data for the array from a database and it will likely have from 1 to 7 elements. Even if it only has one element I still need to user to make the choice, as this will be a chance for the user to confirm that they want to proceed.
Sorry if this has been answered before, I just can't seem to find it.
This is what I have tried:
Code:

for i in ${LINES[@]}
do
   PRODUCTS=$PRODUCTS"<item>$i</item>"
done
export MAIN_DIALOG='
<combobox tag_attr="value">
        <variable>PRODUCT</variable>
        <sensitive>state</sensitive>
        <action signal="type">activity</action>
      $PRODUCTS
</combobox>'
gtkdialog --program MAIN_DIALOG
echo $PRODUCT

And this is the error I am getting:
Code:

** (gtkdialog:21366): ERROR **: gtkdialog: Error in line 7, near token 'string': syntax error

/root/my-applications/bin/unmountMTP.sh: line 25: 21366 Trace/breakpoint trap   gtkdialog --program MAIN_DIALOG

First of all am I even using the correct GtkDialog widget and second, if I am, what am I doing wrong?
Back to top
View user's profile Send private message Visit poster's website 
can8v

Joined: 15 Jul 2006
Posts: 584
Location: Yuba City, CA

PostPosted: Mon 27 Jan 2014, 17:22    Post subject:  

Ok I made some progress. I am using an appropriate GtkDialog widget.
If I use this
Code:
DEVICE_FILE="/root/my-applications/bin/activeMTPdevices.txt"
old_IFS=$IFS
IFS=$'\n'
LINES=($(cat $DEVICE_FILE)) # array
IFS=$old_IFS
for i in ${LINES[@]}
do
   PRODUCTS="$PRODUCTS""<item>""$i""</item>"$'\n'
done
DEVICE_DIALOG_LIST="'<combobox tag_attr=\"value\">
   <variable>PRODUCT</variable>
   <sensitive>state</sensitive>
   <action signal=\"type\">activity</action>
      $PRODUCTS</combobox>'"
#echo "$DEVICE_DIALOG_LIST"
export MAIN_DIALOG='<combobox tag_attr="value">
   <variable>PRODUCT</variable>
   <sensitive>state</sensitive>
   <action signal="type">activity</action>
      <item>Nexus_7</item>
<item>Galaxy_S4</item>
<item>Nexus_10</item>
<item>Nexus_4</item>
<item>Nexus_5</item>
<item>Galaxy_S2</item>
<item>Galaxy_S3</item>
</combobox>
gtkdialog --program MAIN_DIALOG'

I get a combo box widget with all of the various items. My problem is that I don't know the items at the time of writing the script, I need to have the script build that list of items. When I try the following I get and error, which I will copy below.
Code:

DEVICE_FILE="/root/my-applications/bin/activeMTPdevices.txt"
old_IFS=$IFS
IFS=$'\n'
LINES=($(cat $DEVICE_FILE)) # array
IFS=$old_IFS
for i in ${LINES[@]}
do
   PRODUCTS="$PRODUCTS""<item>""$i""</item>"$'\n'
done
DEVICE_DIALOG_LIST="'<combobox tag_attr=\"value\">
   <variable>PRODUCT</variable>
   <sensitive>state</sensitive>
   <action signal=\"type\">activity</action>
      $PRODUCTS</combobox>'"
export "$DEVICE_DIALOG_LIST"
gtkdialog --program DEVICE_DIALOG_LIST

Here is the error I am getting
Code:

# unmountMTP.sh
/root/my-applications/bin/unmountMTP.sh: line 24: export: `'<combobox tag_attr="value">
   <variable>PRODUCT</variable>
   <sensitive>state</sensitive>
   <action signal="type">activity</action>
      <item>Nexus_7</item>
<item>Galaxy_S4</item>
<item>Nexus_10</item>
<item>Nexus_4</item>
<item>Nexus_5</item>
<item>Galaxy_S2</item>
<item>Galaxy_S3</item>
</combobox>'': not a valid identifier

** (gtkdialog:2624): ERROR **: Gtkdialog: Could not find the dialog description in the environment variable 'DEVICE_DIALOG_LIST'.
/root/my-applications/bin/unmountMTP.sh: line 25:  2624 Trace/breakpoint trap   gtkdialog --program DEVICE_DIALOG_LIST
#
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 61 of 64 [952 Posts]   Goto page: Previous 1, 2, 3, ..., 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.1315s ][ Queries: 13 (0.0218s) ][ GZIP on ]