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 Fri 16 Nov 2018, 10:16
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 96 of 96 [1439 Posts]   Goto page: Previous 1, 2, 3, ..., 94, 95, 96
Author Message
MochiMoppel


Joined: 26 Jan 2011
Posts: 1678
Location: Japan

PostPosted: Wed 03 Oct 2018, 04:59    Post subject:  

I made small changes to your example. Every time the button is pressed, the file /tmp/myfile is updated.
The timer widget monitors this file and, when the file changed, emits a "file-changed" signal. I have no idea why the signal is emitted twice.

IMO using the timer widget in this way makes little sense.
Interesting detail: The widget allows more than one input file. Add an <input file> tag for each file and the timer widget will emit a signal when any of these files change.

Code:
#!/bin/bash
touch /tmp/myfile
echo '
 <button>
    <variable>BUT</variable>
    <label>press me</label>
    <action>date > /tmp/myfile</action>
 </button>
     
 <timer visible="true" milliseconds="true" file-monitor="true">
    <input file>/tmp/myfile</input>
    <action signal="file-changed">echo "working signal"</action>
 </timer>
 '| gtkdialog -s
Back to top
View user's profile Send private message 
fabrice_035


Joined: 28 Apr 2014
Posts: 534
Location: Bretagne / France

PostPosted: Wed 03 Oct 2018, 11:59    Post subject:  

Again thank you MochiMoppel.

And I propose this to answer the question of Argolance.
what do you think about it?

Code:

#!/bin/bash
#

touch /tmp/enable_button
touch /tmp/disable_button

# rem

myscript () {

echo "script execute until end and disable button, user must wait"

echo 0 > /tmp/disable_button
#...
sleep 5
#...
echo 0 > /tmp/enable_button
echo "enable now!"

} ; export -f myscript

echo '
 <button>
    <variable>BUT</variable>
   <label> START </label>
    <action>myscript&</action>
 </button>
     
 <timer visible="true" milliseconds="true" file-monitor="true" >
   <input file>/tmp/disable_button</input>
   <action signal="file-changed">disable:BUT</action>
 </timer>
 
  <timer visible="true" milliseconds="true" file-monitor="true" >
   <input file>/tmp/enable_button</input>
   <action signal="file-changed">enable:BUT</action>
 </timer>

 '| gtkdialog -s
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1678
Location: Japan

PostPosted: Wed 03 Oct 2018, 14:47    Post subject:  

Methinks that it will not work.
And since Argolances's question was asked in a different thread you should link to his question or better post in his thread.
Back to top
View user's profile Send private message 
fabrice_035


Joined: 28 Apr 2014
Posts: 534
Location: Bretagne / France

PostPosted: Wed 03 Oct 2018, 15:42    Post subject:  

Perhaps. But i think it's the only way to activate and/or desactivate button while waiting for the end of a script. But i am not expert! Regard.
Back to top
View user's profile Send private message 
Argolance


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

PostPosted: Sat 10 Nov 2018, 13:04    Post subject:  

Bonsoir,
Is it possible to execute a command when a combobox widget is clicked to select an item in the list (for example to echo some message to any temporary file)? If yes, how?
Code:
<combobox>
 <variable>COMBOBOX</variable>
 <item>First item</item>
 <item>Second item</item>
 <item>Third item</item>
 <action>echo yes > /tmp/tmpfile</action>
</combobox>
Thank you.

Cordialement.

_________________

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


Joined: 28 Apr 2014
Posts: 534
Location: Bretagne / France

PostPosted: Sat 10 Nov 2018, 13:43    Post subject:  

@Argolance,

I search too, i think it's not possible.

I tried that with comboboxtext

https://github.com/oshazard/gtkdialog/blob/master/examples/miscellaneous/signals

key event work, not mouse activity.

Of course changed event work

Code:

<action signal="changed">echo changed item!</action>


while waiting for an expert Embarassed

Bonne soirée.

_________________
Linux Tahrpup 6.0.6 / 3.14.79
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 5171
Location: Ontario

PostPosted: Sat 10 Nov 2018, 13:57    Post subject:  

Looking at docs
http://01micko.com/reference/combobox.html

Various action signals are mentioned.
__________________________________________
Back to top
View user's profile Send private message 
fabrice_035


Joined: 28 Apr 2014
Posts: 534
Location: Bretagne / France

PostPosted: Sat 10 Nov 2018, 14:20    Post subject:  

don570 wrote:
Looking at docs
http://01micko.com/reference/combobox.html

Various action signals are mentioned.
__________________________________________


http://01micko.com/reference/combobox.html

Code:

The following signals are connected-up for all widgets:
button-press-event, button-release-event, configure-event, enter-notify-event, leave-notify-event, focus-in-event, focus-out-event, hide, show, realize, key-press-event, key-release-event, map-event, unmap-event


I think is wrong, u can try.

I hope I'm wrong.

Shocked

_________________
Linux Tahrpup 6.0.6 / 3.14.79
Back to top
View user's profile Send private message 
Argolance


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

PostPosted: Sat 10 Nov 2018, 14:55    Post subject:  

don570 wrote:
Looking at docs
http://01micko.com/reference/combobox.html

Various action signals are mentioned.
__________________________________________

I had a look to this page which is in my favorites... but I make the same observation as fabrice_035 (que je salue au passage! Wink): I didn't get any results!
On the other hand, this works as expected for me with the comboboxtext:
Code:
<action signal="changed">echo changed item!</action>

... that I discover and is much better in my case, because this kind of combobox prevents user to alter or type some wrong item in the entry. The option value-in-list seems to be instable and to make the script freezing in some cases.
Thanks!

_________________


Last edited by Argolance on Sun 11 Nov 2018, 05:24; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1678
Location: Japan

PostPosted: Sat 10 Nov 2018, 23:16    Post subject:  

fabrice_035 wrote:
I think is wrong, u can try.
I hope I'm wrong.
I'm afraid you are right.
May depend on what "connected-up" is supposed to mean. Things can be connected but not working (my laptop battery Crying or Very sad ). There is hardly any widget for which all signals in the list work, but combobox, comboboxtext and comboboxentry are an extreme. Only key-press-event and key-release-event seem to work.
Back to top
View user's profile Send private message 
Argolance


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

PostPosted: Sun 11 Nov 2018, 05:27    Post subject:  

Duplicate
_________________


Last edited by Argolance on Mon 12 Nov 2018, 06:20; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
fabrice_035


Joined: 28 Apr 2014
Posts: 534
Location: Bretagne / France

PostPosted: Sun 11 Nov 2018, 05:43    Post subject:  

Hi,

The source code can teach us a few things

Example about combobox, open widget_combobox.c, and go to line 223

Code:

      /* Connect signals */

It's empty!

Compare with widget_comboboxtext.c (line 487)

Code:

/* Connect signals */
      g_signal_connect(G_OBJECT(var->Widget), "changed",
         G_CALLBACK(on_any_widget_changed_event),
         (gpointer)var->Attributes);
(...)


I wanted to copy the behavior of wigget_button.c to -> widget_comboboxtext.c but


Code:
(gtkdialog:30539): GLib-GObject-WARNING **: /build/buildd/glib2.0-2.40.2/./gobject/gsignal.c:2462: signal 'toggled' is invalid for instance '0x916d918' of type 'GtkComboBox'


Which is curious https://github.com/oshazard/gtkdialog/blob/master/ChangeLog read changelog:

Code:
* Thu Nov 1 2012 Thunor <thunorsif@hotmail.com>
- Connected-up the button-press/release-event signals to the
comboboxentry widget's child entry widget.


It's important -> *widget's child entry widget* <-

Comboboxtext and comboboxentry *are the same* widget (there is no source code for comboboxentry https://github.com/oshazard/gtkdialog/tree/master/src

widget_comboboxtext.c :
Code:

g_signal_connect(G_OBJECT(gtk_bin_get_child(
            GTK_BIN(var->Widget))), "button-press-event",
            G_CALLBACK(on_any_widget_button_pressed),
            (gpointer)var->Attributes);
         g_signal_connect(G_OBJECT(gtk_bin_get_child(
            GTK_BIN(var->Widget))), "button-release-event",
            G_CALLBACK(on_any_widget_button_released),
            (gpointer)var->Attributes);


I think the window decoration is not tested but just the inside text.

Bon dimanche, nice sunday

_________________
Linux Tahrpup 6.0.6 / 3.14.79
Back to top
View user's profile Send private message 
fabrice_035


Joined: 28 Apr 2014
Posts: 534
Location: Bretagne / France

PostPosted: Mon 12 Nov 2018, 17:07    Post subject:    

@Argolance
Code:
Bonsoir,
Is it possible to execute a command when a combobox widget is clicked to select an item in the list (for example to echo some message to any temporary file)? If yes, how?


Hey, finaly it's possible ! Laughing


Code:

#!/bin/sh
#
# find more here http://blogs.czapski.id.au/category/demo-building/gtkdialog
# fxc


export ytdlgui='
<window title="event box demonstration">
<hbox>
<eventbox above-child="false" visible-window="true" has-tooltip="true" tooltip-markup="This is tooltip for eventbox" height-request="30" sensitive="true" visible="true" width-request="140">


<hbox>
<frame All Events here>
<comboboxtext>

 <variable>COMBOBOXTEXT</variable>
 <item>First item</item>
 <item>Second item</item>
 <item>Third item</item>
 
   <action signal="changed">echo Combobox: changed</action>
</comboboxtext>
</frame>
</hbox>
            <variable>vEventBoxOuter</variable>
         
            <action signal="button-press-event">echo Event: button-press-event</action>
            <action signal="button-release-event">echo Event: button-release-event</action>
            <action signal="configure-event">echo Event: configure-event</action>
            <action signal="enter-notify-event">echo Event: enter-notify-event</action>
            <action signal="leave-notify-event">echo Event: leave-notify-event</action>
            <action signal="focus-in-event">echo Event: focus-in-event</action>
            <action signal="focus-out-event">echo Event: focus-out-event</action>
            <action signal="key-press-event">echo Event: key-press-event</action>
            <action signal="key-release-event">echo Event: key-release-event</action>
            <action signal="hide">echo Event: hide</action>
            <action signal="show">echo Event: show</action>
            <action signal="realize">echo Event: realize</action>
            <action signal="map-event">echo Event: map-event</action>
            <action signal="unmap-event">echo Event: unmap-event</action>
            
            
</eventbox>

<frame dedicate >
<comboboxtext>

 <variable>COMBOBOXTEXT2</variable>
 <item>First item</item>
 <item>Second item</item>
 <item>Third item</item>
   
   <action signal="changed">echo Combobox: changed</action>
</comboboxtext>
</frame>

</hbox>
</window>'

gtkdialog --program=ytdlgui


Cool OK it's not perfect Rolling Eyes

_________________
Linux Tahrpup 6.0.6 / 3.14.79
Back to top
View user's profile Send private message 
Argolance


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

PostPosted: Mon 12 Nov 2018, 19:54    Post subject:  

Bonsoir,
Bon, là, on joue plus dans la même cour! Embarassed
Effectivement ça marche mais j'avoue être perso "somewhat" largué, eh eh, sur la façon de parvenir à un tel résultat, ah ah...
Well done and thanks Smile.

Cheers!

_________________

Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 96 of 96 [1439 Posts]   Goto page: Previous 1, 2, 3, ..., 94, 95, 96
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.2056s ][ Queries: 13 (0.0389s) ][ GZIP on ]