Page 51 of 76

Close to slit my wrists

Posted: Sat 11 Apr 2015, 17:12
by mister_electronico
Sorry to present a code in C on a forum gtkdialog
But it's the only way I've found to increase slightly speed knob.
I think the refresh process images in gtkdialog is a slow process.

A slightly increased considering doing more things anyway as it
was not fast enough steps to increase knob 10 degrees.

Anyway not know how many more will these steps in commercial programs.

I copied the rotary knob Zigbert but only one because all code of him is crazy for me.

Just as I left the code SFR for the coordinates of the mouse.

The program still needs tweaking but it could be a start for me.

I hope the C program can run on other computers, but if not it is very easy to compile.

gcc -o knob knob.c -lm

To run the program first unzip the file and run within the directory KNOB:

# ./knob1

If someone prove it I very grateful to tell your impressions.

All codes are in the compressed archive.

Greating

Thinking of many things forgotten in the simplest

Posted: Sun 12 Apr 2015, 14:42
by mister_electronico
Thinking of many things forgotten in the simplest, thought the refresh time it marked the click of the mouse, but forget the most obvious.

Code: Select all

    <timer visible="false" milliseconds="true" interval="100" sensitive="false">
      <variable>varTIMER</variable>
      <action>get_xy</action>
      <action>refresh:PICTURE</action>
    </timer>
If we change the timer 100 ms to 50 ms is obviously faster.


However this can produce jumps in the knob I do not like it.
What imply that this timer setting depends of the speed of our CPU.


Greetings.

improving knob

Posted: Wed 15 Apr 2015, 09:38
by mister_electronico
This a new version knob, No rebounds in the pointer and softer in slip.

Checking the speed of the program in C from the terminal is found to have enough speed.

Code: Select all

# cd /mnt/home/KNOBC2
# ls
imgini.svg  img.svg  knob  knob1  knob.c
# mkdir /tmp/knob
# cp imgini.svg  /tmp/knob
# cp img.svg  /tmp/knob
# echo "0" > /tmp/knob/DEGR.dat
# 
# time ./knob 78 98

real	0m0.003s
user	0m0.000s
sys	0m0.000s

If it does not work or is jerky at best is convenient in some computers speed up timer in the "knob1" program at the line of code.

Code: Select all

<timer visible="false" milliseconds="true" interval="80" sensitive="false">
Doing more than 80

I hope to be useful and my thanks to all the great people of this forum Puppy.

Posted: Wed 15 Apr 2015, 17:21
by don570
I modified a Thunor example to show how to use SVG image buttons
in a toggle button example. A menu heading is disabled in this example.
I'm sure lots of other useful things could be done as well.

You can change the size of the button by fiddling with the height and width tags.

Explanation: I generate two SVG images, then change their names to
true.svg and false.svg .
Note the importance of the variable tgb1. I am using Thunor's notation.

Image

Code: Select all

#!/bin/sh
#example to toggle menu by don570

rm -rf /tmp/TOGGLE_EXAMPLE # start fresh
TMPDIR=/tmp/TOGGLE_EXAMPLE
mkdir -p $TMPDIR
cd $TMPDIR  # create and load images from this folder


for LABEL in 1 2 ;do
[  $LABEL -eq 1 ] && TEXT="Enable Menu"
[  $LABEL -eq 2 ] && TEXT="Disable Menu"



X1=$(echo "$TEXT"|wc -c)  # number of letters
W=$((${X1}*6*95/31))
DISPLACE=$(($W/7))
FILL=white


echo '<svg version="1.1"> 
      <rect
      style="fill:'$FILL';fill-opacity:.7;stroke-width:2;stroke:black;stroke-opacity:1;"
     width='\"$W\"' height="36" rx="10" ry="10" x="1" y="1"/>
           <text style="font-family:DejaVu;font-size:24;fill-opacity:1"
      x='\"$DISPLACE\"'  y="26" >
'$TEXT'
     </text>

</svg>
'> "$TEXT".svg

done

ln -sf "Disable Menu".svg tgb0.svg
ln -sf "Enable Menu".svg tgb1.svg
# create true and false images
cp "Disable Menu".svg true.svg 
cp  "Enable Menu".svg false.svg 

MAIN_DIALOG='
<window title="ToggleButton Advanced" resizable="false" border-width="0">
	<vbox>
		<menubar>
			<menu use-underline="true">
				<menuitem stock-id="gtk-quit" accel-key="0x51" accel-mods="4">
					<action>exit:Quit</action>
				</menuitem>
				<label>"_File"</label>
				<variable>mnuFile</variable>
				<sensitive>false</sensitive>
			</menu>
		</menubar>
		<vbox border-width="20" spacing="20">
			<hbox homogeneous="true">
				<text><label>My Example</label></text>
				<entry>
					<default>true</default>
					<variable>entry</variable>
					<input>echo $tgb1</input>
				</entry>
				
			</hbox>
			<hseparator></hseparator>
			<hbox homogeneous="true">
				<togglebutton>
					<variable>tgb1</variable>					
					<input file>tgb1.svg</input>
					<action>ln -sf $tgb1.svg tgb1.svg</action>
					<action>refresh:tgb1</action>
					<action>refresh:entry</action>					
					<action>if true enable:mnuFile</action>
					<action>if false disable:mnuFile</action>
				</togglebutton>
			</hbox>
		</vbox>
	</vbox>
</window>
'
export MAIN_DIALOG
gtkdialog --program=MAIN_DIALOG



design gui

Posted: Mon 20 Apr 2015, 14:29
by recobayu
Hi All,
I want to make a gui about encryption and decription of image. I have wrote my code in python 2.7.6. In puppy linux, we just load our devx.sfs. We also must install Image library from PIL, and I had done. My code has so many def.
Is there possible to implement it into gtkdialog? Could someone give me an example gui of that please (button, image, frame, etc.)?
Thanks.
Recobayu

Edited:
Finally, i know something like gtkdialog. There is Tkinter. I'm sorry for my out of topic here. :oops:

Posted: Mon 20 Apr 2015, 19:10
by don570
I would read the code in pupmd5sum for a start

http://www.murga-linux.com/puppy/viewtopic.php?t=84019

______________________________________________________

Posted: Fri 24 Apr 2015, 12:40
by BarryK
I have been playing with these flags in QuickSetup, at first bootup, click on one of them and immediately the QuickSetup window redraws in that language.
It is a friendly start for non-English users.

The first image is how I want it to look. The images packed closely. I used the 'pixmap' tag.
The problem is, I don't know how to associate an action on a mouse-click over one of those images.

The second image shows it done with buttons. Yes, I can get actions, but the rendering is not as densely packed as I want.

Does anyone know how I can pack the icons closely, and associate an action with each one?

Note, I am not sure how well this idea scales. There can be a third column, beyond that it is not practical. But, the translations are only intended to be "gross", for example Spanish for everywhere in the world Spanish or derivative is used.

Posted: Fri 24 Apr 2015, 13:08
by SFR
BarryK wrote:The first image is how I want it to look. The images packed closely. I used the 'pixmap' tag.
The problem is, I don't know how to associate an action on a mouse-click over one of those images.
You need to wrap every pixmap with <eventbox> tags, see this example:
http://www.murga-linux.com/puppy/viewto ... 007#836007

And if you want to pack the images even more closely, you can use <hbox>/<vbox>'s spacing attribute, e.g.: <vbox spacing="0">.

Greetings!

Posted: Fri 24 Apr 2015, 22:55
by BarryK
SFR wrote:
BarryK wrote:The first image is how I want it to look. The images packed closely. I used the 'pixmap' tag.
The problem is, I don't know how to associate an action on a mouse-click over one of those images.
You need to wrap every pixmap with <eventbox> tags, see this example:
http://www.murga-linux.com/puppy/viewto ... 007#836007

And if you want to pack the images even more closely, you can use <hbox>/<vbox>'s spacing attribute, e.g.: <vbox spacing="0">.

Greetings!
SFR,
Thanks very much, yes that works! And thanks to MochiMoppel for figuring out some peculiarities.

Posted: Mon 03 Aug 2015, 16:23
by recobayu
Hi All,
Can we clear everything in vbox and then fill some button inside that (vbox)?
Thanks.
Recobayu

Posted: Mon 03 Aug 2015, 21:53
by Bert
Hi recobayu,

I hope I understood you correctly...is this what you're looking for:

Code: Select all

#!/bin/sh
 export MAIN_DIALOG=' 
<vbox  width-request="200"  height-request="100">
	<button  space-fill="true" space-expand="true">
		<input file stock="gtk-ok"></input>
		<label>LIMUKS</label>
	</button>
</vbox>
'
gtkdialog --program=MAIN_DIALOG

Posted: Tue 04 Aug 2015, 03:20
by recobayu
:D
Thank you Bert, but my question is something like this:

Code: Select all

#!/bin/sh
export MAIN_DIALOG='
<window>
<hbox>
   <button  space-fill="true" space-expand="true">
      <input file stock="gtk-ok"></input>
      <label>LIMUKS</label>
      <action>echo "delete all inside vbox\nthen change to new \<button\>\nso the label and action of new button change\nto be our new parameter"</action>
   </button>
<vbox  width-request="200"  height-request="100">
   <button  space-fill="true" space-expand="true">
      <input file stock="gtk-ok"></input>
      <label>LIMUKS1</label>
      <variable>l1</variable>
   </button>
   <button  space-fill="true" space-expand="true">
      <input file stock="gtk-ok"></input>
      <label>LIMUKS2</label>
      <variable>l2</variable>
   </button>
   <button  space-fill="true" space-expand="true">
      <input file stock="gtk-ok"></input>
      <label>LIMUKS3</label>
      <variable>l3</variable>
   </button>
</vbox>
</hbox>
</window>
'
gtkdialog --program=MAIN_DIALOG
can we do that?

Edit:
I try this code:

Code: Select all

#!/bin/sh
export main='
<window>
<hbox>
	<vbox>
		<button>
			<label>hide</label>
			<action>hide:vku</action>
		</button>
		<button>
			<label>show</label>
			<action>show:vku</action>
		</button>
		<button>
			<label>delete</label>
			<action function="clear">frameku</action>
		</button>
	</vbox>
	<frame>
	<vbox>
		<button relief="2">
			<label>jwm settings</label>
			<action>echo myscript</action>
		</button>
		<button relief="2">
			<label>gtk change theme</label>
			<action>echo myscript2</action>
		</button>
		<button relief="2">
			<label>font viewer</label>
			<action>echo myscript3</action>
		</button>
		<button relief="2">
			<label>pcur selector</label>
			<action>echo myscript4</action>
		</button>
		<button relief="2">
			<label>LIMUKSku</label>
			<action>show:fku</action>
		</button>
		<variable>vku</variable>
	</vbox>
	<variable>frameku</variable>
	</frame>
</hbox>
</window>
'
gtkdialog -p main
It still just hide and show, but "clear" action still dont want run. :(

Posted: Tue 04 Aug 2015, 04:18
by MochiMoppel
I'm also not quite sure what your question is. You can't "clear" a vbox and change the contents on-the-fly, but you can prepare 2 vboxes ant show them alternatively:

Code: Select all

#!/bin/bash
export MAIN_DIALOG=' 
<window> 
<hbox> 
<togglebutton  space-fill="true" space-expand="true"> 
   <input file stock="gtk-ok"></input> 
   <label>LIMUKS</label> 
   <action>echo -e "delete all inside vbox\nthen change to new \<button\>"</action> 
   <action>if true show:vBOX2</action>
   <action>if true hide:vBOX1</action>
   <action>if false hide:vBOX2</action>
   <action>if false show:vBOX1</action>
</togglebutton> 
<vbox  width-request="200"  height-request="100"> 
	<button  space-fill="true" space-expand="true"> 
	   <input file stock="gtk-ok"></input> 
	   <label>LIMUKS1</label> 
	</button> 
	<button  space-fill="true" space-expand="true"> 
	   <input file stock="gtk-ok"></input> 
	   <label>LIMUKS2</label> 
	</button> 
	<button  space-fill="true" space-expand="true"> 
	   <input file stock="gtk-ok"></input> 
	   <label>LIMUKS3</label> 
	</button> 
	<variable>vBOX1</variable>
</vbox>
<vbox  visible="false" width-request="200"  height-request="100"> 
	<button  space-fill="true" space-expand="true"> 
	   <input file stock="gtk-save"></input> 
	   <label>LIMUKS100</label> 
	</button> 
	<button  space-fill="true" space-expand="true"> 
	   <input file stock="gtk-save"></input> 
	   <label>LIMUKS200</label> 
	</button> 
	<variable>vBOX2</variable>
</vbox> 
</hbox> 
</window> 
' 
 gtkdialog --program=MAIN_DIALOG

Posted: Tue 04 Aug 2015, 04:47
by recobayu
Thank you Mochi, it's work. But that is just 2 kind of change.
*I'm sorry of my bad english :oops:

My final purpose is I have an Entry, then I change the contain of vbox or frame based on string value of my entry. Like from my post (mukstart) here: http://www.murga-linux.com/puppy/viewtopic.php?p=859024. That use <tree>. I want to change that tobe button.

Posted: Tue 04 Aug 2015, 05:27
by MochiMoppel
Using tree looks like a perfect solution. What would you gain from buttons?

Posted: Tue 04 Aug 2015, 06:39
by recobayu
With <button relief="2">, the startmenu is like cinnamon's start menu.
This is the screenshoot:
Image

Posted: Tue 04 Aug 2015, 08:12
by MochiMoppel
Tree items are "unreliefed" by design and with <tree hover-selection="true"> you get a button-like hover effect.

Posted: Tue 04 Aug 2015, 10:10
by recobayu
Yap. It's very great :D
39 mochi.

Posted: Sat 08 Aug 2015, 02:37
by recobayu
Alhamdulillah.. Finally, I did it. :D
Here is my code:

Code: Select all

#!/bin/sh
#rm nbMain

cek(){
	if [[ $E == "" ]];then
		echo 0 > nbsubMain
	else
		echo 1 > nbsubMain
	fi
}
export -f cek



export main='
<window>
  <vbox>
	<entry>
		<action>cek</action>
		<action>refresh:nbCari</action>
		<variable>E</variable>
	</entry>
	<notebook show-tabs="false" show-border="false" tab-pos="1">
	<hbox>
	  <vbox>
		<button relief="2">
			<label>All</label>
			<action signal="enter-notify-event">echo "0" >nbMain</action>
			<action signal="focus-in-event">echo "0" >nbMain</action>
			<action signal="focus-in-event">refresh:nbGanti</action>
			<action signal="enter-notify-event">refresh:nbGanti</action>
		</button>
		<button relief="2">
			<label>Destop</label>
			<action signal="enter-notify-event">echo "1" >nbMain</action>
			<action signal="focus-in-event">echo "1" >nbMain</action>
			<action signal="focus-in-event">refresh:nbGanti</action>
			<action signal="enter-notify-event">refresh:nbGanti</action>
		</button>
		<button relief="2">
			<label>System</label>
			<action signal="enter-notify-event">echo "2" >nbMain</action>
			<action signal="focus-in-event">echo "2" >nbMain</action>
			<action signal="focus-in-event">refresh:nbGanti</action>
			<action signal="enter-notify-event">refresh:nbGanti</action>
		</button>
		<button relief="2">
			<label>Setup</label>
			<action signal="enter-notify-event">echo "3" >nbMain</action>
			<action signal="focus-in-event">echo "3" >nbMain</action>
			<action signal="focus-in-event">refresh:nbGanti</action>
			<action signal="enter-notify-event">refresh:nbGanti</action>
		</button>
	  </vbox>
	<notebook show-tabs="false" show-border="false">
		<vbox>
			<button relief="2">
				<label>bersama</label>
			</button>
			<button relief="2">
				<label>ke sini</label>
			</button>
			<button relief="2">
				<label>dan juga</label>
			</button>
			<button relief="2">
				<label>sekarang</label>
			</button>
			<button relief="2">
				<label>lanjut</label>
			</button>
		</vbox>
		<vbox>
			<button relief="2">
				<label>next</label>
			</button>
			<button relief="2">
				<label>okay</label>
			</button>
			<button relief="2">
				<label>ini</label>
			</button>
			<button relief="2">
				<label>juga</label>
			</button>
			<button relief="2">
				<label>next</label>
			</button>
		</vbox>
		<vbox>
			<button relief="2">
				<label>ini</label>
			</button>
			<button relief="2">
				<label>ada satu</label>
			</button>
			<button relief="2">
				<label>lagi</label>
			</button>
			<button relief="2">
				<label>yang nambah</label>
			</button>
			<button relief="2">
				<label>di framenya</label>
			</button>
		</vbox>
		<vbox>
			<button relief="2">
				<label>dan</label>
			</button>
			<button relief="2">
				<label>lagi</label>
			</button>
			<button relief="2">
				<label>orang</label>
			</button>
			<button relief="2">
				<label>beriman</label>
			</button>
			<button relief="2">
				<label>amal salih</label>
			</button>
		</vbox>
		<variable>nbGanti</variable> 
        <input file>nbMain</input> 
	</notebook>
	</hbox>
	<hbox>
		<tree rules-hint="true" headers-visible="false">
			<item>first</item>
			<item>second</item>
			<item>third</item>
			<item>fourth</item>
		</tree>
	</hbox>
	<variable>nbCari</variable> 
	<input file>nbsubMain</input> 
	</notebook>
  </vbox>
</window>'
gtkdialog -p main
We can change on right side by hover button or by keyboard arrow, also we can find something by search on entry. All of that done by "notebook"

Now, how to write a function that can automatically write code <vbox> or <Button> so we are not write every button. But we just call that function. I still learn that. 8)

Posted: Mon 07 Sep 2015, 05:04
by recobayu
Hi guys,
I want to ask a question.
If I have a file text.txt that contain a text,
and I have a file icon.txt that contain a path/to/icon.

How to make a tree that column one based on icon.txt and column two based on text.txt?