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 30 Oct 2014, 08:31
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 5 of 64 [956 Posts]   Goto page: Previous 1, 2, 3, 4, 5, 6, 7, ..., 62, 63, 64 Next
Author Message
01micko


Joined: 11 Oct 2008
Posts: 7840
Location: qld

PostPosted: Mon 05 Oct 2009, 08:53    Post subject:  

zigbert wrote:
Hello Mick
Nice tutorial!
I will include this in the main post, but thought it might fit better as a new chapter - The benefits of a config file.
- Both <entry> and <edit> widgets uses the <default> tag.
- How to activate a given item in a combobox.


Sigmund


Hi Sigmund,

Glad I could add something useful to this thread. It has some nice info. Very Happy

Mick

_________________
Woof Mailing List | keep the faith Cool |
Back to top
View user's profile Send private message Visit poster's website 
technosaurus


Joined: 18 May 2008
Posts: 4353

PostPosted: Mon 05 Oct 2009, 13:52    Post subject:  

I was trying to get some more documentation on GTK Dialog and figured out a reason why there may not be much documentation thus far. It seems that it was an intermediated step / building block for these:

CUI http://linux.pte.hu/~pipas/CUI/index.html
GUI Completion http://linux.pte.hu/~pipas/GUIcompletion/index.html

So goes the development cycle on a project with a small or one man team. They do look pretty promising for a couple of my projects (Pcompile in particular) Has anyone here done anything with them yet?

_________________
Web Programming - Pet Packaging 100 & 101

Last edited by technosaurus on Mon 05 Oct 2009, 18:15; edited 1 time in total
Back to top
View user's profile Send private message 
disciple

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

PostPosted: Mon 05 Oct 2009, 16:50    Post subject:  

I looked at them the other day, but I can't remember why I gave up on them. I think one had some unreasonable (gnome?) dependencies.
_________________
DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
Back to top
View user's profile Send private message 
zigbert


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

PostPosted: Sun 11 Oct 2009, 04:06    Post subject:  

Make the gui scalable
>> Did you know that it is possible to make gtkdialog windows fully scalable? That means to be able to drag the window corner, and make the gui bigger.

As long as a <tree>, <table>, <list> or <edit> widget is enclosed ONLY by a <hbox> OR <vbox>, the widget will remain scalable both horizontally and vertically. Pfind, Pmusic and Pprocess uses various solutions of this.

>> Note about frames
If you enclose a <frame> with <hbox> or <vbox>, you set a fixed size of the frame. If you instead put the <hbox>/<vbox> definitions inside the <frame>, the frame will dynamically scale to fit gui.

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


Joined: 08 Jun 2005
Posts: 5039
Location: Arizona, U.S.A.

PostPosted: Tue 13 Oct 2009, 02:46    Post subject:  

Hi zigbert; I need help with the "tree", I don`t see how the sub levels are controlled.
Code:
#! /bin/bash
export MAIN_DIALOG='
<vbox>
  <tree>
    <input file>tmp.text</input>
    <label>Device</label>
    <item stock="gtk-harddisk">Hard Disk</item>
    <item stock="gtk-floppy">Floppy Disk</item>
    <item stock="gtk-floppy">Floppy Disk</item>
    <item stock="gtk-floppy">Floppy Disk</item>
    <item stock="gtk-cdrom">CD_ROM Drive</item>
    <height>200</height>
    <width>300</width>
    <variable>TREE</variable>
  </tree>
</vbox>
'
gtkdialog2 --program=MAIN_DIALOG

This should give multi. levels but only gives a few, but what designates the sub levels?
The code above is gtk-2, so gtk-3 may be a better choice...

I`m trying to make a "WinExplorer" type file browser, left pane = dir. tree, right pane = file list.
Back to top
View user's profile Send private message 
zigbert


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

PostPosted: Tue 13 Oct 2009, 12:21    Post subject:  

sunburnt
I had no idea that sub-levels was supported. Shocked
I really hope you see the light and tell us how it all works. I also want this. Very Happy
Have you seen any documentation at all about sub-levels?


Sigmund

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


Joined: 08 Jun 2005
Posts: 5039
Location: Arizona, U.S.A.

PostPosted: Tue 13 Oct 2009, 13:51    Post subject:  

The GTK widget your using is probably a different one.
Here`s the tree from GTK 0.59.8, the floppy has 2 tree levels of depth.
But I see no method by which it`s done or to control it.
The xDialog controls are completely different of course...
tree_multicolumn_gtk-0.59.8.gz
Description 
gz

 Download 
Filename  tree_multicolumn_gtk-0.59.8.gz 
Filesize  503 Bytes 
Downloaded  400 Time(s) 
Back to top
View user's profile Send private message 
zigbert


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

PostPosted: Wed 14 Oct 2009, 06:11    Post subject:  

Be careful with the use of subshells, and slow commands as sed, ps, expr, cat ... This is of course most important when building a loop.

This script takes 3.0 seconds on my system
Code:
echo 'hello' > /tmp/tmp
for I in $(seq 1 1000); do
   B="`cat /tmp/tmp`"
done
while the next takes 0.9 seconds
Code:
echo 'hello' > /tmp/tmp
IFS=$'\n'
for I in $(seq 1 1000); do
   B=($(<"/tmp/tmp"))
done

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


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

PostPosted: Wed 14 Oct 2009, 07:40    Post subject:  

Rewritten:

The pairs of code shows how to do the same operation in 2 different ways. The speed differs a lot. First an example why avoid 'cat', then why never use 'expr' if speed matters. My system needed 4 seconds to calculate 1+1 thousand times with 'expr'. Using the builtin bash command it took 'no time'.
Code:
# time for I in $(seq 1 1000); do B="`cat /tmp/tmp`"; done
real    0m3.095s
# time `IFS=$'\n'; for I in $(seq 1 1000); do B=($(<"/tmp/tmp")); done`
real    0m0.927s


# time for I in $(seq 1 1000); do expr 1 + 1 > /dev/null; done
real    0m4.286s
# time for I in $(seq 1 1000); do A=$((1+1)); done
real    0m0.032s

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


Joined: 08 Jun 2005
Posts: 5039
Location: Arizona, U.S.A.

PostPosted: Wed 14 Oct 2009, 13:01    Post subject:  

Thanks zigbert; I need to brush up on true bash replacements for the "odd" commands.
I added your examples to my code snips collection.
It will help for my removable drive auto mounter app. as it has a daemon loop.
The mount and unmount functions don`t matter so much as they only run occasionally.

I`ve looked for Bash replacements for sed, but don`t see the same functionality.
Same goes for: grep, tr, cut, paste, awk, comm, and the "if" statement.

### In looking at the tree control it seems that the sub levels are made
if the node is labeled the same as the one that came before it. Weird !!!
I modified it and the sub levels didn`t work properly, I think it`s just a bad control.
I need to find docs. for gtkDialog3, there must be a newer tree control...
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5039
Location: Arizona, U.S.A.

PostPosted: Wed 14 Oct 2009, 16:04    Post subject:  

zigbert; A problem with usage of your substitue for the "cat" command:
Code:
# PP='/proc/partitions'
# ($(<"$PP")) | wc -c
bash: major: command not found
0

It appears to try to execute the "catted" file`s contense; "major".
And then gives a wrong value for the byte count; "0".
This is in a daemon loop, so it`d be nice to figure it out...! Terry
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5039
Location: Arizona, U.S.A.

PostPosted: Thu 15 Oct 2009, 01:07    Post subject:  

It appears the command only gives the first word in the file, as shown:
Code:
# PP=($(<"/proc/partitions"))
# echo "$PP"
major
Back to top
View user's profile Send private message 
amigo

Joined: 02 Apr 2007
Posts: 2263

PostPosted: Thu 15 Oct 2009, 04:46    Post subject:  

This works:
PP=$(<"/proc/partitions")

PP=$(<"/proc/partitions") ; echo $PP
major minor #blocks name 22 0 78125000 hdc 22 1 1954480 hdc1 22 2 1955520 hdc2 22 3 10000368 hdc3 22 4 1 hdc4 22 5 19999696 hdc5 22 6 44214376 hdc6 3 0 1255968 hda 3 1 251968 hda1 3 2 1003968 hda2 3 64 78150744 hdb 3 65 1036161 hdb1 3 66 2056320 hdb2 3 67 7181055 hdb3 3 68 1 hdb4 3 69 10273536 hdb5 3 70 20555136 hdb6 3 71 37045858 hdb7

I've created a few pure-bash replacements for some tools -there's even a pure-bash wget!

I'll attach the tarball containing them here, since my site seems to be down at the moment.
This is what's included:
basename
cat
cut
dirname
grep
head
rev
sort
tail
tr
uniq
wc
wget
which

If you work out any new ones, let me know so they can be added to the collection.

Edit: You mentioned sed, that would be very diifficult to implement. However, the included 'tr' can do some of the same stuff. You can use it to do simple replacements like sed does. 'normal' tr only lets you replace single characters, but my version lets you replace however many you want, so it will do what sed does in that respect.
BashTrix-0.2.tar.gz
Description  pure-bash utility replacements
gz

 Download 
Filename  BashTrix-0.2.tar.gz 
Filesize  13.19 KB 
Downloaded  454 Time(s) 
Back to top
View user's profile Send private message 
zigbert


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

PostPosted: Thu 15 Oct 2009, 10:41    Post subject:  

sunburnt
To keep format
Code:
# IFS='\n' PP=$(<"/proc/partitions") ; echo $PP
major mi or  #blocks   ame

   1     0      13824 ram0
   1     1      13824 ram1
   1     2      13824 ram2
   1     3      13824 ram3
   1     4      13824 ram4
   1     5      13824 ram5
   1     6      13824 ram6
   1     7      13824 ram7
   1     8      13824 ram8
   1     9      13824 ram9
   1    10      13824 ram10
   1    11      13824 ram11
   1    12      13824 ram12
   1    13      13824 ram13
   1    14      13824 ram14
   1    15      13824 ram15
   7     0      93400 loop0
   7     1    1572864 loop1
   7     4      15616 loop4
   7     5     101668 loop5
   8     0  156290904 sda
   8     1    9140953 sda1
   8     2          1 sda2
   8     3     104422 sda3
   8     4     514080 sda4
   8     5    4088511 sda5
   8     6  141950308 sda6


Just a note. It would be possible to manually build a <tree> with sublevels. If you can live with not having icons in the <tree>, you could add + and - in front of each directory.


Sigmund

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

Joined: 11 Apr 2007
Posts: 887

PostPosted: Thu 15 Oct 2009, 14:20    Post subject:  

zigbert wrote:
sunburnt

Just a note. It would be possible to manually build a <tree> with sublevels. If you can live with not having icons in the <tree>, you could add + and - in front of each directory.


Sigmund


Zigbert,

Lot's of goodies here. Strange thing this Gtkdialog Very Happy trade icons for + and - signs. Question

How would the extra levels work in this context -
Code:

<tree>
    <input file>tmp.text</input>
    <label>Device                        | Directory | File</label>
    <item stock="gtk-floppy">Floppy Disk | /floppy/  | ak.tex</item>
    <item stock="gtk-floppy">Floppy Disk | /floppy/  | ak.dvi</item>
    <item stock="gtk-floppy">Floppy Disk | /floppy/  | ak.ps</item>
    <item stock="gtk-floppy">Floppy Disk | /floppy/  | ak.pdf</item>
    <item stock="gtk-cdrom">CD_ROM Drive | /cdrom/   | </item>
    <height>200</height>
    <width>300</width>
    <variable>TREE</variable>
  </tree>


What will be discovered next Question
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 5 of 64 [956 Posts]   Goto page: Previous 1, 2, 3, 4, 5, 6, 7, ..., 62, 63, 64 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.1049s ][ Queries: 12 (0.0114s) ][ GZIP on ]