GtkDialog - tips

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#1001 Post by don570 »

I'll try to make it more attractive rotary knob by SVG like bottons of don570,
I made fancy candy colored text label buttons that were two different sizes
One for normal buttons 'OK' 'Cancel'
and another size for longer phrases.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#1002 Post by technosaurus »

You can do this in svg with paths and a transform="rotate(...)":
https://developer.mozilla.org/en-US/doc ... definition

I like to hand write my SVGs for better control, but existing editors either mangle the code or don't have good access to the source, so I wrote a simple editor here:
http://murga-linux.com/puppy/viewtopic. ... 250#836250
I've found it to be extremely useful to play with paths and transforms until I understand them

Here is a simplified knob using only paths and rotate() ... just change height and width to XXpx
<svg id="svg" width="100%" height="100%" viewBox="0 0 96 96"><path d="M47 1A47 47 0 1 0 49 1z"/>
<path fill="red" transform="rotate(270, 48, 48)" d="M48 1A4 4 0 1 0 50 1z"/>
</svg>
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#1003 Post by 01micko »

technosaurus wrote:You can do this in svg with paths and a transform="rotate(...)":
https://developer.mozilla.org/en-US/doc ... definition

I like to hand write my SVGs for better control, but existing editors either mangle the code or don't have good access to the source, so I wrote a simple editor here:
http://murga-linux.com/puppy/viewtopic. ... 250#836250
I've found it to be extremely useful to play with paths and transforms until I understand them

Here is a simplified knob using only paths and rotate() ... just change height and width to XXpx

Code: Select all

<svg id="svg" width="100%" height="100%" viewBox="0 0 96 96"><path d="M47 1A47 47 0 1 0 49 1z"/>
<path fill="red" transform="rotate(270, 48, 48)" d="M48 1A4 4 0 1 0 50 1z"/>
</svg>
That darn droid and that darn 8) :)
Puppy Linux Blog - contact me for access

User avatar
mister_electronico
Posts: 969
Joined: Sun 20 Jan 2008, 20:20
Location: Asturias_ España
Contact:

trying again.

#1004 Post by mister_electronico »

Just back from my little vacation, hi zigbert I was watching you watching your penultimate code:

http://murga-linux.com/puppy/viewtopic. ... 718#837718

It's fast but for me has a problem that does not obey either the mouse.

I think that in the code must be taken into account also the X axis to rotate knob in the appropriate direction depending on the position in which it find.

I was freaking out that even a slight modification I make of your code causes it to become very slow.

The buttons on your last code are very nice, but not if it will be only in my system but I have to hold down the mouse outside the window and turn it so that the knob can fully rotate.

In the code of SFR the mouse only works over knob window I like it but this it is that makes the program more slower.

I think that is right don570 perhaps be better to try piece of code in C.

I am currently developing this program ligth panel:

https://www.youtube.com/watch?v=-B6hQdiPCaM

As soon as I finish I'll put it here, I think part of the code is faster that is in C.

Very interesting Technosaurus the path and rotate () I'll try to have if the speed improves.

Thanks gentlemen for all the information I will continue studying and making progress here

Greetings

cusco-travel-services
Posts: 8
Joined: Mon 02 Mar 2015, 22:35

Re: GtkDialog - tips

#1005 Post by cusco-travel-services »

zigbert wrote:

Code: Select all

#!/bin/bash
echo 'style "specialmono"
{
  font_name="Mono 12"
}
widget "*mono" style "specialmono"
class "GtkText*" style "specialmono"' > /tmp/gtkrc_mono

export GTK2_RC_FILES=/tmp/gtkrc_mono:/root/.gtkrc-2.0

export test_app="
<vbox>
  <text name="mono"><label>This text-widget uses monospace font....</label></text>
  <text><label>...while this text-widget don't.</label></text>
  <edit><default>All edit-widgets gets monospace.</default></edit>
</vbox>"
gtkdialog --program=test_app
Hi zigbert et al,

What is the following line, in the code above, supposed to do exactly?

Code: Select all

export GTK2_RC_FILES=/tmp/gtkrc_mono:/root/.gtkrc-2.0
Is the colon (:) a Field separator in this context or is it serving some other purpose?

When I use the following, for example, ...

Code: Select all

export GTK2_RC_FILES=/tmp/gtkrc_title:~/.gtkrc-2.0
... echo "$GTK2_RC_FILES" gives /home/mtbvfr/.gtkrc-2.0 but no such directory nor file exists.

Thanks, Michael.

User avatar
mister_electronico
Posts: 969
Joined: Sun 20 Jan 2008, 20:20
Location: Asturias_ España
Contact:

Close to slit my wrists

#1006 Post 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
Attachments
knob.tar.gz
(17.17 KiB) Downloaded 263 times

User avatar
mister_electronico
Posts: 969
Joined: Sun 20 Jan 2008, 20:20
Location: Asturias_ España
Contact:

Thinking of many things forgotten in the simplest

#1007 Post 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.

User avatar
mister_electronico
Posts: 969
Joined: Sun 20 Jan 2008, 20:20
Location: Asturias_ España
Contact:

improving knob

#1008 Post 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.
Attachments
knob2.tar.gz
(6.94 KiB) Downloaded 340 times
Last edited by mister_electronico on Wed 15 Apr 2015, 19:23, edited 1 time in total.

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#1009 Post 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



User avatar
recobayu
Posts: 387
Joined: Wed 15 Sep 2010, 22:48
Location: indonesia

design gui

#1010 Post 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:
Last edited by recobayu on Fri 24 Apr 2015, 10:03, edited 1 time in total.

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#1011 Post by don570 »

I would read the code in pupmd5sum for a start

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

______________________________________________________

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#1012 Post 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.
Attachments
quicksetup-button.png
(85.94 KiB) Downloaded 441 times
quicksetup-pixmap.png
(75.13 KiB) Downloaded 459 times
[url]https://bkhome.org/news/[/url]

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#1013 Post 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!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#1014 Post 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.
[url]https://bkhome.org/news/[/url]

User avatar
recobayu
Posts: 387
Joined: Wed 15 Sep 2010, 22:48
Location: indonesia

#1015 Post by recobayu »

Hi All,
Can we clear everything in vbox and then fill some button inside that (vbox)?
Thanks.
Recobayu

User avatar
Bert
Posts: 1103
Joined: Fri 30 Jun 2006, 20:09

#1016 Post 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
Attachments
vbox-button.png
(4.93 KiB) Downloaded 394 times
[url=http://pupsearch.weebly.com/][img]http://pupsearch.weebly.com/uploads/7/4/6/4/7464374/125791.gif[/img][/url]
[url=https://startpage.com/do/search?q=host%3Awww.murga-linux.com%2F][img]http://i.imgur.com/XJ9Tqc7.png[/img][/url]

User avatar
recobayu
Posts: 387
Joined: Wed 15 Sep 2010, 22:48
Location: indonesia

#1017 Post 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. :(

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#1018 Post 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

User avatar
recobayu
Posts: 387
Joined: Wed 15 Sep 2010, 22:48
Location: indonesia

#1019 Post 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.

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#1020 Post by MochiMoppel »

Using tree looks like a perfect solution. What would you gain from buttons?

Post Reply