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 Dec 2014, 16:46
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 55 of 65 [961 Posts]   Goto page: Previous 1, 2, 3, ..., 53, 54, 55, 56, 57, ..., 63, 64, 65 Next
Author Message
Karl Godt


Joined: 20 Jun 2010
Posts: 3982
Location: Kiel,Germany

PostPosted: Thu 22 Aug 2013, 13:40    Post subject:  

First you would need a wrapper script that calls the main script.
This wrapper script needs to be linked into the rox open with directory to be able to right-click it.
( /root/.config/rox.sourceforge.net/OpenWith/ )

Wrapper :
Code:
#!/bin/sh

exec myz-gui "$@"

Code:
#!/bin/sh
GTKDIALOG=gtkdialog

ent2=`basename "$@"`
[ "$ent2" ] && export ent2

export MAIN_DIALOG="
<window title=\"Find Subtitles\" window_position=\"1\">
<vbox>
<frame Choose preferred interface>
<hbox>
<combobox>
<variable>COMBOBOX1</variable>
<item>el</item>
<item>en</item>
<item>es/sp</item>
</combobox>
</hbox>
</frame>
<frame Choose preferred language>
<hbox>
<combobox>
<variable>COMBOBOX2</variable>
<item>ell</item>
<item>eng</item>
<item>spa</item>
</combobox>
</hbox>
</frame>
<frame Paste the exact movie name>
<hbox>
<entry>
<default>\"$ent2\"</default>
<variable>ent2</variable>
</entry>
</hbox>
</frame>
<hbox>
<button>
<label>Find subs!</label>
<action>defaultbrowser http://www.opensubtitles.org/\"$COMBOBOX1\"/search/sublanguageid-\"$COMBOBOX2\"/moviename-\"$ent2\" &</action>
<action>exit:EXIT</action>
</button>
<button cancel></button>
</hbox>
</vbox>
</window>
"

$GTKDIALOG --program=MAIN_DIALOG
Back to top
View user's profile Send private message Visit poster's website 
Nathan F


Joined: 08 Jun 2005
Posts: 1760
Location: Wadsworth, OH (occasionally home)

PostPosted: Thu 22 Aug 2013, 14:04    Post subject:  

Quote:
Question: Is there a way to automatically read the movie's name with "right-click" on the movie file and clicking the script instead of copy-paste it in the entry?

Assuming the title of the movie file is the exact title of the movie plus some extension then yes. Say for an avi:
Code:
TITLE="$(basename "$@" .avi)"

To handle multiple extensions it gets a little more involved.
Code:
TITLE="$(basename "$@" | \
sed -e 's/.avi//' | \
-e 's/.mpeg//' | \
-e 's/.wmv//' | \
-e 's/.m4v//')"

_________________
Bring on the locusts ...
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger 
recobayu


Joined: 15 Sep 2010
Posts: 114
Location: indonesia

PostPosted: Thu 22 Aug 2013, 14:41    Post subject: mukstart  

Hi All,
I just make a simple menu like start metro wdz8. I learn by looking another script, especially in programming thread and akita. But it just simple and so far to good. I have a problem in search and press enter. The screenshot is here:
http://dl.dropboxusercontent.com/s/g38l401kfu05ltp/mukstart.png
I originally wanted if search button pressed, the button (not tree) show. Another things are can gtkdesklet show blur transparent? So it will like unity effect. But it seems, that are not easy for me. Can anyone help me? Or developing this script? I really happy.
Thank you.
Very Happy
mukstart.gz
Description  remove .gz, then chmod +x mukstart
gz

 Download 
Filename  mukstart.gz 
Filesize  5.76 KB 
Downloaded  198 Time(s) 
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3437
Location: Ontario

PostPosted: Thu 22 Aug 2013, 19:38    Post subject:  

To recobayu:


If your problem is how to transfer data using the clipboard I suggest that you
read this script by forum member Seaside.

He uses an utility app (xclip) that is built into every puppy.

The app was written to compare md5sums to make sure that the
download was correct.
Clipboard_MD5sum-1.2.pet
Description 
pet

 Download 
Filename  Clipboard_MD5sum-1.2.pet 
Filesize  2.81 KB 
Downloaded  198 Time(s) 
Back to top
View user's profile Send private message 
recobayu


Joined: 15 Sep 2010
Posts: 114
Location: indonesia

PostPosted: Sat 24 Aug 2013, 09:44    Post subject:  

thanks don570, but I still don't understand with that. I had extract that pet and find any script I can study, but still not too much understand that. Ok, I make the simple problem. Now I have this script, there are an entrybox and a tree. When I change the entrybox, I want the tree selected on the top of tree, and when I press enter, it can execute the selection (top of tree). How to do that? Can anyone help me? Thank You.
Code:
#!/bin/sh
ls /usr/share/applications > aplikasiku
luru(){
   cat aplikasiku | grep $Entriku > ketemu
}
export -f luru
export auto='
<window height-request="400" width-request="200">
   <vbox>
      <entry>
         <variable>Entriku</variable>
         <label>search application here</label>
         <action>luru</action>
         <action>refresh:Wit</action>
      </entry>
      <tree rules-hint="true" headers-visible="false">
         <variable>Wit</variable>
         <input file>ketemu</input>
      </tree>
   </vbox>
</window>'
gtkdialog --program=auto --center
Back to top
View user's profile Send private message 
Nathan F


Joined: 08 Jun 2005
Posts: 1760
Location: Wadsworth, OH (occasionally home)

PostPosted: Sat 24 Aug 2013, 10:21    Post subject:  

If I'm understanding what you want to do correctly, you need to change the signal for the entrybox so that it performs the action you want when you press Enter.
Code:
<action signal="activate">actions...</action>

I'm having a hard time following exactly what you want to do. It seems to be a language barrier problem. Sorry if that's not helpful.

_________________
Bring on the locusts ...
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger 
don570


Joined: 10 Mar 2010
Posts: 3437
Location: Ontario

PostPosted: Sat 24 Aug 2013, 13:55    Post subject:  

The old fashioned way of getting something to the top of a list
was to have a default tag <default>....</default> then relaunch.

...But that wasn't very slick so there are better ways of doing it
as Nathan F points out.


If you install the gtkdialog examples by Thunor
http://murga-linux.com/puppy/viewtopic.php?t=82059
Look at comboboxtext and comboboxentry examples. They are difficult to
understand but maybe they will explain how signal activation works.
__________________________________________________

Last edited by don570 on Sat 24 Aug 2013, 14:12; edited 1 time in total
Back to top
View user's profile Send private message 
Nathan F


Joined: 08 Jun 2005
Posts: 1760
Location: Wadsworth, OH (occasionally home)

PostPosted: Sat 24 Aug 2013, 14:06    Post subject:  

+1 but to make them easier to follow run them with the --dump option, which will spit out the actual dialog passed to gtkdialog instead of all the functions he used to build the dialog. Even better save the dump to a file so you can look it over while you actually run the example.
_________________
Bring on the locusts ...
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger 
Nathan F


Joined: 08 Jun 2005
Posts: 1760
Location: Wadsworth, OH (occasionally home)

PostPosted: Sat 24 Aug 2013, 14:17    Post subject:  

The key here if I understand correctly what is wanted, is that the default signal passed by the entry widget is "changed", and it's emitted every time you type any character into the box. What is needed is to perform the action on the press of the "Enter" key, which is why you have to change the signal to "activate".
_________________
Bring on the locusts ...
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger 
don570


Joined: 10 Mar 2010
Posts: 3437
Location: Ontario

PostPosted: Sat 24 Aug 2013, 14:25    Post subject:  

To NathanF

Thanks for tip. The only way I could make any sense of
the combobox entry examples was to cut out as many buttons and
tags as possible to simplify the examples.

_________________________________________

The options in the entry tag are important to set
See my example
http://murga-linux.com/puppy/viewtopic.php?p=720397#720397


Here is the official list of options available
https://code.google.com/p/gtkdialog/wiki/entry

_________________________
Back to top
View user's profile Send private message 
recobayu


Joined: 15 Sep 2010
Posts: 114
Location: indonesia

PostPosted: Sun 25 Aug 2013, 11:55    Post subject:  

Very Happy
Thank you don570 and nathan. signal="activate" works great.
I do a little trick here. I make a function mlaku that run the application that writed in the first item of tree (by read a < ketemu). Ya, although the clicked effect doesn't appear in the tree. Smile Please correct me.

Code:
#!/bin/sh
ls /usr/share/applications > aplikasiku

luru(){
   cat aplikasiku | grep -i $Entriku > ketemu
   cat ketemu | sed 's/.desktop//' > ditampilkan
}
export -f luru
mlaku(){
   read a < ketemu
   $(cat /usr/share/applications/$a | grep Exec | cut -d "=" -f2)&
}
export -f mlaku
export auto='
<window height-request="400" width-request="200">
   <vbox>
      <entry>
         <variable>Entriku</variable>
         <label>search application here</label>
         <action>luru</action>
         <action>refresh:Wit</action>
         <action signal="activate">mlaku</action>
      </entry>
      <tree rules-hint="true" headers-visible="false" activates-default="true" hover-selection="true">
         <variable>Wit</variable>
         <input file>ditampilkan</input>
         <action>exec $Wit</action>
      </tree>
   </vbox>
</window>'
gtkdialog --program=auto --center


Ok, now I want to hide the tree if the entrybox is empty and show that again if I write something in the entrybox. How to do that?
Back to top
View user's profile Send private message 
Nathan F


Joined: 08 Jun 2005
Posts: 1760
Location: Wadsworth, OH (occasionally home)

PostPosted: Sun 25 Aug 2013, 14:16    Post subject:  

Quote:
Ok, now I want to hide the tree if the entrybox is empty and show that again if I write something in the entrybox. How to do that?

Try something like this
Code:
<tree visible="false">
  <variable>TREE</variable>
</tree>
<entry>
 <action function="show">TREE</action>
</entry>

Quote:
I do a little trick here. I make a function mlaku that run the application that writed in the first item of tree (by read a < ketemu). Ya, although the clicked effect doesn't appear in the tree. Please correct me.

Not sure what the question is again, sorry.

_________________
Bring on the locusts ...
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger 
recobayu


Joined: 15 Sep 2010
Posts: 114
Location: indonesia

PostPosted: Sun 25 Aug 2013, 15:08    Post subject:  

Nathan F wrote:

Try something like this
Code:
<tree visible="false">
  <variable>TREE</variable>
</tree>
<entry>
 <action function="show">TREE</action>
</entry>


Smile yes, it happen just one time. But when i clear the text in entry, the tree still show, it doesn't hide anymore.
I try this code, but fail.
Code:
#!/bin/sh
a="false"
muncul(){
   if [[ $Entryku == "" ]]; then
      echo '<action function="hide">Wit</action>';
   else
      echo '<action function="show">Wit</action>';
   fi
   echo $Entryku
}
export -f muncul

export ketok='
<window>
   <vbox>
      <entry>
         <variable>Entryku</variable>
         <action>eval $Entryku</action>
         '"`muncul`"'
         <action>refresh:Entryku</action>
      </entry>
         <tree visible="'$a'">
            <variable>Wit</variable>
            <item>first line</item>
            <item>second</item>
            <item>third</item>
         </tree>
         <button>
            <label>ada</label>
            <action function="show">Wit</action>
         </button>
         <button>
            <label>sembunyi</label>
            <action function="hide">Wit</action>
         </button>
   </vbox>
</window>'

gtkdialog --program=ketok
Back to top
View user's profile Send private message 
Nathan F


Joined: 08 Jun 2005
Posts: 1760
Location: Wadsworth, OH (occasionally home)

PostPosted: Sun 25 Aug 2013, 15:18    Post subject:  

That's probably because your function is only being run the first time the dialog is created. In order to get it to run whenever the widget refreshes you have to put it inside a pair of input tags.
Code:
      <entry>
         <variable>Entryku</variable>
         <action>eval $Entryku</action>
         <input>muncul</input
         <action>refresh:Entryku</action>
      </entry>

EDIT: I'm still fuzzy on whether it will do what you want it to. I think you need to use a conditional on the action itself (as a tag attribute), which I've only tried once.

_________________
Bring on the locusts ...
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger 
recobayu


Joined: 15 Sep 2010
Posts: 114
Location: indonesia

PostPosted: Thu 29 Aug 2013, 06:15    Post subject:  

Thanks All, this is the new mukstart from me. I also use gtk2desklet by akash_rawal. here: http://murga-linux.com/puppy/viewtopic.php?t=74204
how about this? Smile
mukstart1.0.tar.gz
Description  now, i think it's better than before..
gz

 Download 
Filename  mukstart1.0.tar.gz 
Filesize  2.89 KB 
Downloaded  194 Time(s) 
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 55 of 65 [961 Posts]   Goto page: Previous 1, 2, 3, ..., 53, 54, 55, 56, 57, ..., 63, 64, 65 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.1324s ][ Queries: 13 (0.0233s) ][ GZIP on ]