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 Sun 26 Oct 2014, 04:02
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 54 of 64 Posts_count   Goto page: Previous 1, 2, 3, ..., 52, 53, 54, 55, 56, ..., 62, 63, 64 Next
Author Message
koulaxizis


Joined: 17 Jul 2011
Posts: 428
Location: Greece

PostPosted: Fri 16 Aug 2013, 13:07    Post_subject:  

Nathan F wrote:
@koulaxizis - check out the comboboxtext and comboboxentry widgets, which are more powerful than the stock combobox.

For comboboxtext, the default signal is "changed", which is emitted when you choose another selection in the combobox. So you can easily do some useful things with it. The following example lists the contents of all the hidden directories in your home folder in the tree widget.
Code:
<vbox>
<comboboxtext tooltip-text="List contents of your dotdirs">
<variable>COMB1</variable>
<input>find $HOME -maxdepth 1 -mindepth 1 -type d -name '.*'</input>
<default>$HOME/.config</default>
<action>refresh:TREE1</action>
</comboboxtext>
<tree>
<label>Contents</label>
<variable>TREE1</variable>
<input>ls \$COMB1</input>
</tree>
<button ok></button>
</vbox>

Hope that's helpful in the future even though you settled on a different approach.


Thank you very much! I'll try this too to see how it goes!

_________________
Christos Koulaxizis
Woof woof from Greece...

[ Puppy packages | Puppy search ]
Back to top
View user's profile Send_private_message Visit_website 
Nathan F


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

PostPosted: Sun 18 Aug 2013, 01:54    Post_subject:  

Quick question. Is it still possible to do right click actions on the tree widget? Adding 'signal="button-press-event"' seems to execute the actions on both right and left click, which is not what I remember the case being before.
_________________
Bring on the locusts ...
Back to top
View user's profile Send_private_message AIM YIM MSNM 
Nathan F


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

PostPosted: Sun 18 Aug 2013, 02:55    Post_subject:  

And another one. Trying to set accel-keys for an app. So far as I can tell, the menu and menuitem widgets are the only ones that accept accel keys.

What I would like to do is set an accel key for an action without actually showing the menuitem. However, so far my experimentation has not worked. It seems if the widget set 'visible="false"' then the accel-key no longer works. I also tried putting a menubar inside a notebook tab with the 'show-tabs="false"' setting, and once again no luck.

At the moment what does work is a menu with a blank label. It doesn't show on the menubar, but it can still be opened by clicking it's location, and the accel-key works. But this is not exactly what I want.

_________________
Bring on the locusts ...
Back to top
View user's profile Send_private_message AIM YIM MSNM 
zigbert


Joined: 29 Mar 2006
Posts: 5754
Location: Valåmoen, Norway

PostPosted: Sun 18 Aug 2013, 02:57    Post_subject:  

Nathan
gtkdialog sends the status of $PTR_BTN. - 1=left, 2=middle, 3=right
Code:
[ $PTR_BTN != 3 ] && exit

_________________
Stardust resources
Back to top
View user's profile Send_private_message Visit_website 
Nathan F


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

PostPosted: Sun 18 Aug 2013, 03:15    Post_subject:  

Thanks. Works like a champ.
_________________
Bring on the locusts ...
Back to top
View user's profile Send_private_message AIM YIM MSNM 
smokey01


Joined: 30 Dec 2006
Posts: 1829
Location: South Australia

PostPosted: Mon 19 Aug 2013, 10:21    Post_subject:  

Does anyone know how to automatically shrink a gtkdialog window?

By unhiding frames the window will automatically expand to show the new frames but unfortunately it won't shrink back when the frames are hidden again.

_________________
Puppy Software <-> Distros <-> Puppy Linux Tips
Back to top
View user's profile Send_private_message Visit_website 
Nathan F


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

PostPosted: Mon 19 Aug 2013, 11:01    Post_subject:  

From my experiments if you set 'resizable="false"' then it will resize back.
_________________
Bring on the locusts ...
Back to top
View user's profile Send_private_message AIM YIM MSNM 
don570


Joined: 10 Mar 2010
Posts: 3347
Location: Ontario

PostPosted: Mon 19 Aug 2013, 16:07    Post_subject:  

Here's a tip for the entry widget...

To make a button so that it will execute when the <ENTER>
key is pressed...


To get the default button to work properly with an
entry widget I found that I needed to put
activates_default="true" with the entry tag

Code:
<entry max_length="2"  activates_default="true">


and then make the button the default

Code:
<button can-default="true" has-default="true">


Taken from Bulldog Finder application

_______________________________________

Edited_time_total
Back to top
View user's profile Send_private_message 
smokey01


Joined: 30 Dec 2006
Posts: 1829
Location: South Australia

PostPosted: Mon 19 Aug 2013, 22:52    Post_subject:  

Nathan F wrote:
From my experiments if you set 'resizable="false"' then it will resize back.


Thanks Nathan, works great.

_________________
Puppy Software <-> Distros <-> Puppy Linux Tips
Back to top
View user's profile Send_private_message Visit_website 
disciple

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

PostPosted: Tue 20 Aug 2013, 07:30    Post_subject:  

thunor wrote:
Here's another top tip:

A text widget that has space-expand and space-fill set to true can be used as a spacer to push neighbouring widgets in certain directions.

Here the spacer text is "[]" so you can see it -- drag the window out and watch the button.
Code:
#!/bin/sh

GTKDIALOG=gtkdialog

Spacer="[]"

MAIN_DIALOG='
<window title="Spacer Test" window-position="1">
   <vbox>
      <hbox>
         <button space-expand="false" space-fill="false">
            <label>This button will stay put</label>
            <input file stock="gtk-about"></input>
         </button>
         <text space-expand="true" space-fill="true">
            <label>"'$Spacer'"</label>
         </text>
      </hbox>
   </vbox>
</window>
'
export MAIN_DIALOG

case $1 in
   -d | --dump) echo "$MAIN_DIALOG" ;;
   *) $GTKDIALOG --program=MAIN_DIALOG ;;
esac

Regards,
Thunor


Question: is the space-fill tag actually supposed to do anything? Changing it doesn't seem to have any effect here (0.8.3)...

_________________
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: 3347
Location: Ontario

PostPosted: Wed 21 Aug 2013, 16:22    Post_subject:  

to Disciple:

Just guessing... but maybe it's related to 'resizable="false/true"' option
in the window tag

____________________________
Back to top
View user's profile Send_private_message 
koulaxizis


Joined: 17 Jul 2011
Posts: 428
Location: Greece

PostPosted: Thu 22 Aug 2013, 10:56    Post_subject:  

Still playing with gtkdialog! Smile

If you have some spare time, try this one and suggest me ways to improve it, so i can further understand the possibilities of gtkdialog.

Thank you friends!!

Code:
#!/bin/sh

GTKDIALOG=gtkdialog

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>
<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


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?

_________________
Christos Koulaxizis
Woof woof from Greece...

[ Puppy packages | Puppy search ]
Back to top
View user's profile Send_private_message Visit_website 
Karl Godt


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

PostPosted: Thu 22 Aug 2013, 12:26    Post_subject:  

There are two options for a wrapper :

MOVIENAME="$MOVIENAME" /root/my-applications/bin/myz-gui

or

/root/my-applications/bin/myz-gui "$@"

.
The second is the common one .


Then myz-gui would look like

ent2="$MOVIENAME" for the first case

or

ent2="$@" for the second case

and

export ent2
ORIGINAL_CODE
here ..

IfIUnderstoodCorrectly
Back to top
View user's profile Send_private_message Visit_website 
koulaxizis


Joined: 17 Jul 2011
Posts: 428
Location: Greece

PostPosted: Thu 22 Aug 2013, 12:33    Post_subject:  

Karl Godt wrote:
There are two options for a wrapper :

MOVIENAME="$MOVIENAME" /root/my-applications/bin/myz-gui

or

/root/my-applications/bin/myz-gui "$@"

.
The second is the common one .


Then myz-gui would look like

ent2="$MOVIENAME" for the first case

or

ent2="$@" for the second case

and

export ent2
ORIGINAL_CODE
here ..

IfIUnderstoodCorrectly


I'm not sure if i understood... Sad

Can you please place it in the code to figure out how it works?

_________________
Christos Koulaxizis
Woof woof from Greece...

[ Puppy packages | Puppy search ]
Back to top
View user's profile Send_private_message Visit_website 
Nathan F


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

PostPosted: Thu 22 Aug 2013, 13:31    Post_subject:  

Mainly stylistic changes, use what you like and discard the rest.
Code:
#!/bin/sh

: ${GTKDIALOG:=gtkdialog}

export MAIN_DIALOG="
<window title=\"Find Subtitles\" window_position=\"2\">
<vbox>
<hbox>
<text space-expand=\"false\" space-fill=\"false\">
 <label>$(gettext 'Preferred interface')</label>
</text>
<hbox space-expand=\"true\" space-fill=\"true\"><text><label>\"\"</label></text></hbox>
<comboboxtext space-expand=\"false\" space-fill=\"false\" tooltip-text=\"$(gettext 'The language used to display search results and information')\">
<variable>COMBOBOX1</variable>
<item>el</item>
<item>en</item>
<item>es/sp</item>
</comboboxtext>
</hbox>
<hbox>
<text space-expand=\"false\" space-fill=\"false\">
 <label>$(gettext 'Preferred language')</label>
</text>
<hbox space-expand=\"true\" space-fill=\"true\"><text><label>\"\"</label></text></hbox>
<comboboxtext space-expand=\"false\" space-fill=\"false\" tooltip-text=\"$(gettext 'The language the subtitles should be in')\">
<variable>COMBOBOX2</variable>
<item>ell</item>
<item>eng</item>
<item>spa</item>
</comboboxtext>
</hbox>
<hbox>
<entry tooltip-text=\"$(gettext 'Paste the exact movie title in this box')\" activates-default=\"true\">
<variable>ent2</variable>
</entry>
</hbox>
<hbox>
<button tooltip-text=\"$(gettext 'Get subtitles with an internet browser')\" can-default=\"true\" has-default=\"true\">
<input file icon=\"gtk-ok\"></input>
<label>$(gettext 'Go')</label>
<action>defaultbrowser \"http://www.opensubtitles.org/\$COMBOBOX1/search/sublanguageid-\$COMBOBOX2/moviename-\$ent2\" &</action>
<action>exit:EXIT</action>
</button>
<button tooltip-text=\"$(gettext 'Exit program')\">
<label>$(gettext 'Cancel')</label>
<input file stock=\"gtk-cancel\"></input>
<action>exit:ABORT</action>
</button>
</hbox>
</vbox>
</window>
"

$GTKDIALOG -p MAIN_DIALOG

The construct at the top only assigns the variable GTKDIALOG if it isn't already set. Useful for portability.

My feelings are that sometimes a more concise gui is desirable. I don't really care for the use of frames to display information or to label content, although I've done it before to mock something up quick. Here there is a concise label and a more meaningful tooltip. The entry should be obvious so it's unlabeled, but if unsure the tooltip should clue the user in.

The code to activate the "Go" button is very useful in a case like this and makes it quicker since the user can just press Enter and be taken to the site. Less mouse interaction is desired by a lot of users, especially power users.

I thought it appropriate that an app designed to get subtitles should be localized, so all text strings are displayed via gettext. You would need a line saying 'export TEXTDOMAIN=" near the top, and then it would be localization ready.

It seems more concise to me to quote the entire url.

I wrapped the entire dialog description in double quotes rather than single. This means all double quotes have to be ascaped, but it allows command substitution within the dialog description. Also escaped are the variables set by the comboboxes, so that if you follow my advice below about a state file they will use the current value rather than the saved one.

I also switched it from centered display to display near mouse. Centered display is somehow arrogant to me (look at my app now user!) and not as useful anyway. Place it near the pointer and it's quicker for the user to access. IMO dialogs should only be centered if they are displaying important system information and need to grab the user's attention.

One further suggestion would be to save the output to a state file inside ~/.config, which can then be sourced to set defaults for the two comboboxes on future runs of the program. Users appreciate little touches like that.

Cheers!

_________________
Bring on the locusts ...
Back to top
View user's profile Send_private_message AIM YIM MSNM 
Display_posts:   Sort by:   
Page 54 of 64 Posts_count   Goto page: Previous 1, 2, 3, ..., 52, 53, 54, 55, 56, ..., 62, 63, 64 Next
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1215s ][ Queries: 12 (0.0176s) ][ GZIP on ]