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 Thu 23 Nov 2017, 22:17
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 77 of 82 [1226 Posts]   Goto page: Previous 1, 2, 3, ..., 75, 76, 77, 78, 79, 80, 81, 82 Next
Author Message
Geoffrey


Joined: 30 May 2010
Posts: 2308
Location: Queensland

PostPosted: Wed 28 Sep 2016, 09:08    Post subject:  

zigbert wrote:
Geoffrey
Thanks for this one - interesting!

I have put your code in the new post about Text managing


Yes it is interesting, I was looking for another means to make strikethrough text other than doing it online,
this isn't perfect as there can be some small spaces in the line if you look carefully and when paste in to a text file the line shifts to the right by one character, but it's good enough.
I found the simplest code solution here
Code:
echo text | sed $"s/./&\xCC\xB6/g"
I noted that the "$" in the code made no difference, so I removed it.

List of character codes here

edit:
I compared both ways of doing it, their identical.

I see a space in the line on the "m"
Quote:
w̶r̶i̶t̶e̶ ̶s̶o̶m̶e̶ ̶t̶e̶x̶t̶ ̶h̶e̶r̶e̶ online strikethrough
w̶r̶i̶t̶e̶ ̶s̶o̶m̶e̶ ̶t̶e̶x̶t̶ ̶h̶e̶r̶e̶ gtkdialog strikethrough

_________________
Carolina: Recent Repository Additions

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


Joined: 26 Jan 2011
Posts: 1392
Location: Japan

PostPosted: Wed 28 Sep 2016, 23:48    Post subject:  

Geoffrey wrote:
this isn't perfect as there can be some small spaces in the line if you look carefully
As you already said: Good enough. Spaces occur when you put the line character, which as any other character has its own width, on top of another character with a different width. If this character (e.g. the relatively wide letter 'm') is wider than the line you will see gaps. These gaps disappear when you use a fixed width font. You may see line gaps here: m̶m̶m̶m̶m̶m̶m̶m̶m̶m̶m̶
Now copy the string into Geany, which can handle UTF-8 and by default uses a fixed width font. See the difference?

Quote:
I found the simplest code solution here
I use almost the same simple code, but made me a GUI. I didn't even bother to put it into a script and entered it directly into a desktop icon, but for "normal" users here is the code:
Code:
xclip -o | sed "s/./&\xCC\xB6/g" | gxmessage -c -file -
Usage: Select some text in any application, then run the script (e.g. via desktop icon or keyboard shortcut)

Since we are here in the gtkdialog thread it should be noted that gtkdialog can produce beautiful strkethrough text, even with colored strike. The only problem is that the text loses its formats when the text is copied to another application. UTF-8 makes the text usable in all aplications that understand Unicode. To see the difference between strikethrough formatting via Pango mark-up in gtkdialog and via UTF-8 you can try this demo:
Code:
#!/bin/sh
function  mark_me_up { echo -n "<span strikethrough='true'  strikethrough_color='red' font='bold 14'>$@</span>" ;}
export -f mark_me_up

echo '
<window>
<vbox>
    <frame>
        <edit>
            <default>"Sample text"</default>
            <variable>vEDIT</variable>
        </edit>
    </frame>

    <frame Pango Markup>
        <text use-markup="true" xalign="left" selectable="true">
            <variable>vTEXT1</variable>
            <input>mark_me_up "$vEDIT"</input>
        </text>
    </frame>

    <frame UTF-8 U+0336>
        <text xalign="left" selectable="true">
            <variable>vTEXT2</variable>
            <input>echo "$vEDIT" | sed "s/./&\xCC\xB6/g"</input>
        </text>
    </frame>


    <button label="Create S̶T̶R̶I̶K̶E̶̶̶">
        <action>refresh:vTEXT1</action>
        <action>refresh:vTEXT2</action>
    </button>
</vbox>
</window>' | gtkdialog -s
strikethrough.png
 Description   
 Filesize   7.45 KB
 Viewed   700 Time(s)

strikethrough.png

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


Joined: 30 May 2010
Posts: 2308
Location: Queensland

PostPosted: Fri 30 Sep 2016, 18:45    Post subject:  

MochiMoppel wrote:
I use almost the same simple code, but made me a GUI. I didn't even bother to put it into a script and entered it directly into a desktop icon, but for "normal" users here is the code:
Code:
xclip -o | sed "s/./&\xCC\xB6/g" | gxmessage -c -file -
Usage: Select some text in any application, then run the script (e.g. via desktop icon or keyboard shortcut)


Nice, I had a play and opted for this with a hotkey
Code:
#!/bin/sh
xclip -o | sed "s/./&\xCC\xB6/g" | xclip -selection "clipboard"


Select text - press hotkey - paste, result = S̶e̶l̶e̶c̶t̶ ̶t̶e̶x̶t̶

_________________
Carolina: Recent Repository Additions

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


Joined: 26 Jan 2011
Posts: 1392
Location: Japan

PostPosted: Sat 01 Oct 2016, 02:43    Post subject:  

Yes, that's probably the fastest solution and similar to what was discussed in this recent thread.
You only need to be careful not to use xclip from within gtkdialog, otherwise gtkdialog will acquaint you with its very nasty variable bug.
Back to top
View user's profile Send private message 
torm


Joined: 07 Mar 2015
Posts: 129

PostPosted: Sat 08 Oct 2016, 10:18    Post subject:  

MochiMoppel wrote:
torm wrote:
<action signal="type">activity</action>
if "button-release-event" is the event
does GtkStatusbar widget support that?

Needs an eventbox to work:
Code:
#! /bin/sh
echo '
<window width-request="200">
    <eventbox>
        <statusbar>
            <input>echo "Click me!"</input>
        </statusbar>
        <action signal="button-press-event">beep</action>
        <action signal="button-release-event">beep -f100</action>
    </eventbox>
</window>'|gtkdialog -s



Thanks for reply
Smile
I think I've already tested it, at some point.
And it is emitting at least some signals that can be used.
(to store the new location, etc.)

Tricked it to move around with middle-mouse-button.
However, the result is not as reliable as expected.
Will look into RoxFM and JWM to see if there's some built-in way..

Or, maybe there is some gtk-module to drag around the (not decorated) window?
Something small and simple, that could be used with Gtkdialog?
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1392
Location: Japan

PostPosted: Mon 10 Oct 2016, 01:03    Post subject:  

torm wrote:
Or, maybe there is some gtk-module to drag around the (not decorated) window?
Something small and simple, that could be used with Gtkdialog?
What's wrong with the system wide default? You can move any window, decorated or not, by pressing Alt key + drag.
Back to top
View user's profile Send private message 
torm


Joined: 07 Mar 2015
Posts: 129

PostPosted: Mon 10 Oct 2016, 05:33    Post subject:  

Quote:
What's wrong with the system wide default? You can move any window, decorated or not, by pressing Alt key + drag.


Rolling Eyes
default user, maybe..
most people are not able to remember how to use kb+mb combinations.
So I'm trying to keep it simple.

Maybe I just bundle it with xdotool Confused
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1392
Location: Japan

PostPosted: Wed 02 Nov 2016, 00:51    Post subject:  

"Tips and Tricks" section of the first post, chapter
Let entry accept (some) numbers only:

Code:
<entry editable="true" allow-empty="false">
How does allow-empty work? Does it work at all for entry widgets?

BTW: Sorry to poke around in the code, but the main code doesn't seem right.
Code:
<input>case $ENTRY in [0-9]*) echo $ENTRY;; *) echo 0;; esac</input>
Text will not default to 0 if the text starts with a number.

It works better when the logic is "reversed":
Code:
<input>case $ENTRY in *[^0-9]*) echo 0;; *) echo $ENTRY ;; esac</input>
This will default to 0 if ENTRY contains any character other than characters 0 to 9.

If a completely empty field should also default to 0 then this should do it:
Code:
<input>case $ENTRY in ""|*[^0-9]*) echo 0;; *) echo $ENTRY ;; esac</input>
Back to top
View user's profile Send private message 
zigbert


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

PostPosted: Wed 02 Nov 2016, 17:12    Post subject:  

MochiMoppel wrote:
BTW: Sorry to poke around in the code, but the main code doesn't seem right
Laughing Laughing Laughing

The code in this thread is a collection of many inputs, and all improvements are welcome.

I'll update the main post
Thank you

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1392
Location: Japan

PostPosted: Thu 03 Nov 2016, 23:18    Post subject:  

"Tips and Tricks" section of the first post, chapter
Let entry accept (some) numbers only:

Actually it's an interesting example and shows the dilemma when dealing with incorrect input. If an entry widget is supposed to accept only numbers and the user inputs letters, what should the checking routine do?
- Erase everything and replace with zero? That's probably the worst reaction
- Erase everything? Very common and not bad.
- Keep wrong entry and alert user? That's what I would prefer and what most web forms are doing.

This dilemma could be avoided if the entry would do what the headline promises and would accept numbers only - nothing else. Any input of non-numbers should be blocked. No more rubbish input to clean up later. Can it be done?

Of course it can. Here is the code:
Code:
#!/bin/bash
TMP=/tmp/last_good  # file to hold last verified (=good) entry value
echo > $TMP         # create file
trap "rm $TMP" EXIT # delete tmp file before closing dialog

echo '
<vbox>
  <text label="Strict number entry (non-numbers rejected)"></text>
  <entry>
    <variable>vENTRY</variable>
    <input file>'$TMP'</input>
    <action condition="command_is_true([[ $vENTRY =~ ^[0-9]*$ ]] && echo $vENTRY > '$TMP' || { beep & echo true;})">refresh:vENTRY</action>
  </entry>
  <button></button>
</vbox>' |gtkdialog -cs

The code checks every new input. If it's good, i.e if the entry field still contains only numbers, the content is saved to the tmp file. If the user has entered a non-number, he is alerted with a beep and the entry field is refreshed with the content of the tmp file (holding the field content displayed before the non-number was added). Simply speaking it's an automatic undo function.

Important: The tmp file must not be completely empty. Apparently gtkdialog <input file> ignores empty files. That's the reason for the echo > $TMP command, which creates the file by sending a newline character.

This real-time checking method can be useful for many things, i.e it can be used to change capitalization on-the-fly and it can be used to support the final checking. I'm still exploring the possibilities.
number_entry.png
 Description   
 Filesize   3.49 KB
 Viewed   407 Time(s)

number_entry.png

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


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

PostPosted: Fri 04 Nov 2016, 11:18    Post subject:  

Maybe the headline is wrong...

What about
Realtime check of <entry> input

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
mistfire

Joined: 04 Nov 2008
Posts: 643
Location: PH

PostPosted: Sun 06 Nov 2016, 02:41    Post subject:  

To all developers here. I have a question, How to create a treeview with nodes on gtkdialog?

I want to show all files and subdirectories recursively in path and show them in a treeview.

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


Joined: 15 Sep 2010
Posts: 278
Location: indonesia

PostPosted: Tue 15 Nov 2016, 00:55    Post subject:  

step wrote:
@recobayu , just a suggestion, why don't you move the text outside the button, so you can have all buttons left-aligned and same size, and text labels left-aligned and merged with background color?


Thank you Step.
Here is my code:
Code:

#!/bin/sh
buattombol(){
ls /root/puppy-reference/midi-icons > ikon
for i in `cat ikon`;do
   echo '
<hbox spacing="0">
<button relief="2">
   <input file>/root/puppy-reference/midi-icons/'$i'</input>
   <width>24</width>
</button>
<button xalign="0" width-request="200" relief="2">
   <label>'$i'</label>
</button>
</hbox>'
done
}
#~ export -f buattombol

export gui='
<window>
<vbox spacing="0" scrollable="true" width="260" height="600">
'"`buattombol`"'
<button>
   <label>okay</label>
</button>
</vbox>
</window>'
gtkdialog -p gui
button left align.png
 Description   this is really left aligned :)
 Filesize   26.76 KB
 Viewed   315 Time(s)

button left align.png

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


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

PostPosted: Fri 18 Nov 2016, 17:37    Post subject:  

Underline / strikethrough text
>> Underline and strikethrough text is supported by the use-markup="true" option for text widgets.
<text use-markup="true"><label>"<u>underline</u>"</label></text>
<text use-markup="true"><label>"<s>strikethrough</s>"</label></text>
>> This example shows underline and strikethrough on request
Code:
#!/bin/sh
> /tmp/text
export DIALOG='
<window title="unicode text formating" icon-name="gtk-strikethrough">
  <vbox>
    <edit wrap-mode="3">
      <variable>EDIT</variable>
      <default>write some text here</default>
      <height>50</height>
    </edit>
    <edit file-monitor="true" auto-refresh="true" wrap-mode="3" editable="false">
      <height>50</height>
      <input file>/tmp/text</input>
    </edit>
    <hbox homogeneous="true">
      <button>
        <label>Underline text</label>
        <input file stock="gtk-ok"></input>
        <action>`echo "$EDIT" | sed "s/./&\xCD\x9F/g" > /tmp/text`</action>
      </button>
      <button>
        <label>Strikethrough text</label>
        <input file stock="gtk-ok"></input>
        <action>`echo "$EDIT" | sed "s/./&\xCC\xB6/g" > /tmp/text`</action>
      </button>
    </hbox>
  </vbox>
</window>'
gtkdialog -p DIALOG

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
zigbert


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

PostPosted: Fri 25 Nov 2016, 03:25    Post subject:  

MochiMoppel has enlightened us with more <chooser> knowledge.
read this post: http://www.murga-linux.com/puppy/viewtopic.php?t=107675


<chooser>
>> Type of chooser-widget
0 - Open file
1 - Save file
2 - Select folder
3 - Create folder
<chooser action="1">
>> Hide/Show 'create folders' button
<chooser create-folders="false">

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 77 of 82 [1226 Posts]   Goto page: Previous 1, 2, 3, ..., 75, 76, 77, 78, 79, 80, 81, 82 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.0727s ][ Queries: 14 (0.0051s) ][ GZIP on ]