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 Wed 19 Dec 2018, 12:41
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 94 of 98 [1462 Posts]   Goto page: Previous 1, 2, 3, ..., 92, 93, 94, 95, 96, 97, 98 Next
Author Message
misko_2083


Joined: 08 Nov 2016
Posts: 56

PostPosted: Thu 19 Jul 2018, 11:52    Post subject:  

smokey01 wrote:
seaside wrote:
smokey01 ,

You might consider List -
Code:
   <list  vscrollbar-policy="0">


This would not be a dropdown, but would prevent the choice items from dropping below the window.

Cheers,
s


The combobox will keep the list contained within the height of screen where the comboboxtext over shoots the screen and looks quite untidy.

I am considering a tree widget as it is quite neat which I guess is similar to the list widget. The only problem with tree and list widgets they take up a lot of real estate. My issue with the combobox is people can edit the selected data which can break things.

See attached for a sneak preview of what I'm working on. It will be in the August newsletter.

Well, I would try with the button that launches the window.
That window would have a list widget (or any other widget, buttons, notebook...) and make it close when it loses the focus.

This is a quick hack with xdotool.
Code:
#!/bin/sh

eval $(xdotool getmouselocation --shell)

[ -z $GTKDIALOG ] && GTKDIALOG=gtkdialog

TMPDIR=/tmp/gtkdialog/examples/"`basename $0`"
mkdir -p "$TMPDIR"

printf "First item\nSecond item\nThird item\nSmokey item\nWiak's Vodka\nNice Weather\nPuppy Linux\nLast Item" > "$TMPDIR"/inputfile

MAIN_DIALOG='
<window window_position="2" skip_taskbar_hint="true" decorated="false">
   <vbox>
      <list vscrollbar-policy="0">
         <variable>LIST</variable>
         <width>350</width>
         <height>150</height>
         <input file>'"$TMPDIR"'/inputfile</input>
         <output file>'"$TMPDIR"'/outputfile</output>
         <action>echo "The chosen item is \"$LIST\""</action>
      </list>
   </vbox>
</window>
'
export MAIN_DIALOG

case $1 in
   -d | --dump) echo "$MAIN_DIALOG" ;;
   *) $GTKDIALOG --class smokey --space-expand=true --space-fill=true --program=MAIN_DIALOG 2>/dev/null & gtkdiag_pid=$! ;;
esac

until win_id=$(xdotool search --onlyvisible --class smokey 2>/dev/null); do
   sleep .1
done

xdotool windowmove $win_id $X $Y

xdotool search --onlyvisible --class smokey  behave %@ blur windowkill & xdo_pid=$!

wait $gtkdiag_pid

kill $xdo_pid
exit 0


Maybe instead of moving the window xdotool windowmove $win_id $X $Y , when it's maped, gtkdialog --geometry would be better.

The trick is to position the window as close to the button as possible.
Back to top
View user's profile Send private message 
misko_2083


Joined: 08 Nov 2016
Posts: 56

PostPosted: Fri 20 Jul 2018, 09:35    Post subject:  

^This window can be used as a stand-alone menu.

The window placement with window_position="2" is centered on the mouse position.
Code:
#!/bin/sh

[ -z $GTKDIALOG ] && GTKDIALOG=gtkdialog

TMPDIR=/tmp/gtkdialog/examples/"`basename $0`"
mkdir -p "$TMPDIR"

printf "First item\nSecond item\nThird item\nSmokey item\nWiak's Vodka\nNice Weather\nPuppy Linux\nLast Item" > "$TMPDIR"/inputfile

MAIN_DIALOG='
<window window_position="2" skip_taskbar_hint="true" decorated="false">
   <vbox>
      <list vscrollbar-policy="0">
         <variable>LIST</variable>
         <width>350</width>
         <height>150</height>
         <input file>'"$TMPDIR"'/inputfile</input>
         <output file>'"$TMPDIR"'/outputfile</output>
         <action>echo "The chosen item is \"$LIST\""</action>
         <action>EXIT:0</action>
      </list>
   </vbox>
</window>
'
export MAIN_DIALOG

case $1 in
   -d | --dump) echo "$MAIN_DIALOG" ;;
   *) $GTKDIALOG --class smokey --space-expand=true --space-fill=true --program=MAIN_DIALOG 2>/dev/null & gtkdiag_pid=$! ;;
esac

until win_id=$(xdotool search --onlyvisible --class smokey 2>/dev/null); do
   sleep .1
done

xdotool search --onlyvisible --class smokey  behave %@ blur windowkill 2>/dev/null & xdo_pid=$!

wait $gtkdiag_pid

kill $xdo_pid 2>/dev/null
exit 0

I could try to calculate the relative position of the mouse pointer and based on that try to find the best position. But not sure if it's, as Americans say, "worth the trouble". Smile

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

Joined: 18 Dec 2017
Posts: 5
Location: Fairmont, WV

PostPosted: Mon 23 Jul 2018, 15:51    Post subject: gtkdialog - tips
Subject description: How to set the same variable from multiple areas of a gtkdialog
 

I am trying to write a menu system that will execute various cli programs. Many of the programs need a variable like "output directory" or 'out_dir".

So in their frame I include a variable "out_dir". I would like to propagate the answer to any one of the "out_dir" entries to all of them.

I thought that if is use just 1 variable "out_dir". After the first entry, a refresh would fix all of the "out_dir" variables and the user would not have to entry the variable again. But that didn't work.

Can this be done? and how?

Thanks
Back to top
View user's profile Send private message 
smokey01


Joined: 30 Dec 2006
Posts: 2801
Location: South Australia :-(

PostPosted: Mon 23 Jul 2018, 17:06    Post subject:  

Thanks misko_2083. I have settled with the tree widget.
_________________
Software <-> Distros <-> Tips <-> Newsletters
Back to top
View user's profile Send private message Visit poster's website 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1716
Location: Japan

PostPosted: Mon 23 Jul 2018, 22:43    Post subject: Re: gtkdialog - tips
Subject description: How to set the same variable from multiple areas of a gtkdialog
 

slippery60 wrote:
I thought that if is use just 1 variable "out_dir". After the first entry, a refresh would fix all of the "out_dir" variables and the user would not have to entry the variable again. But that didn't work.
Can this be done? and how?
Certainly possible but it depends on how you set and store your variable.
I find it hard to grasp your problem from your description. A simple example would help. Or post the code that "didn't work".
Back to top
View user's profile Send private message 
misko_2083


Joined: 08 Nov 2016
Posts: 56

PostPosted: Tue 24 Jul 2018, 05:46    Post subject: Re: gtkdialog - tips
Subject description: How to set the same variable from multiple areas of a gtkdialog
 

slippery60 wrote:
I am trying to write a menu system that will execute various cli programs. Many of the programs need a variable like "output directory" or 'out_dir".

So in their frame I include a variable "out_dir". I would like to propagate the answer to any one of the "out_dir" entries to all of them.

I thought that if is use just 1 variable "out_dir". After the first entry, a refresh would fix all of the "out_dir" variables and the user would not have to entry the variable again. But that didn't work.

Can this be done? and how?

Thanks

You have a menu with entries. Every entry uses the variable "out_dir" for something.

Code:
menu
├─cli_1 >/${out_dir}
├─cli_2 >/${out_dir}
└─cli_3 >/${out_dir}


With bash, exported variables get passed on to child processes, not-exported variables do not.

Code:
export out_dir="whatever"


If you export it in the parent shell, "out_dir" will be available in the children shells.
Code:
menu
└─bash
  export out_dir="whatever"
  ├─cli_1 >/${out_dir}
  ├─cli_2 >/${out_dir}
  └─cli_3 >/${out_dir}


Not sure how the menu system looks.

slippery60 wrote:

I would like to propagate the answer to any one of the "out_dir" entries to all of them.

Didn't understand that part.
Do you want to set the variable from the cli_1 and use it in cli_2?

Like Mochi-san said, code would tell much more.
Back to top
View user's profile Send private message 
slippery60

Joined: 18 Dec 2017
Posts: 5
Location: Fairmont, WV

PostPosted: Tue 24 Jul 2018, 08:34    Post subject:  How to set the same variable from multiple input
Subject description: How to set the same variable from multiple areas of a gtkdialog
 

Misko, and Moshi

Thanks for the information I'll try setting a variable.

as an example of what I am doing;

I am making a gui for a number of forensic programs that don't have them.
E.g. dc3dd,
or ewfacquire.

I provide the gui to the user to collect all of the arguments needed for the program then call the program with arguments in the back ground.

The issue I have is that many if not all of the programs need the out put from the process directed to a "output directory"

So for each program I am creating the GUI for, I have a variable like "output_dir"; many times the output directory is the same from program to program. So the variable would be nice to set once and be do with it.

I thought why not just set it once for all the programs to use. I tried that, but my tester, kept by-passing the common "output directory", and the programs put output all over the place.

So, I needed to put in a variable to set the "output_dir" into each programs gui.

So now, what I want to do is allow the user to set the "out_dir" in any program's gui and then update that for all of the other programs.

The variable will be the same for all of the programs but, "set"able by any program. or should I say re-"set"able.

My script is about 1000 lines at this point, you want me to post it?!
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1716
Location: Japan

PostPosted: Tue 24 Jul 2018, 10:01    Post subject: Re: How to set the same variable from multiple input
Subject description: How to set the same variable from multiple areas of a gtkdialog
 

slippery60 wrote:
My script is about 1000 lines at this point, you want me to post it?!
Heaven forbid, no Laughing
The idea was to have a simplified example code, functional but shortened to the absolute minimum, just to show and understand your problem.

I'm still not sure if I understand what you are trying to do and where the "menu system" comes into play.
I can only assume that each of your menu items opens a subwindow, containing several widgets to collect from the user all parameters necessary for a cli- program. One of the widgets, probably an entry widget, would hold the name of the output directory.

The easiest way would be to use a temporary file, containing the path of that directory, Your variable "output_dir" would point to this tmp file, would never change and would be available to all of your cli frontends.
Example: Assuming that you run a bash script from which you launch your gtkdialog application, your could set the default output directory at the beginning of the bash script:
export output_dir=/tmp/output_dir.txt
echo "/root/my-applications/out" > $output_dir

In this case "/root/my-applications/out" would be the default output directory for your programs (you may have to create it first if it doesn't exist)

Your cli frontends could read the common output path contained in file $output_dir. If a user changes the path the new path could be written to $output_dir , from which it is available again to all other frontends.
Back to top
View user's profile Send private message 
slippery60

Joined: 18 Dec 2017
Posts: 5
Location: Fairmont, WV

PostPosted: Tue 24 Jul 2018, 16:10    Post subject: How to set the same variable from multiple inpu
Subject description: How to set the same variable from multiple areas of a gtkdialog
 

Mochi;

Thanks for the response. I chopped the script from 1000 to about 125.
I would upload the small file but, I'm too new.

I think I am going to try exporting the updated "out_directory"

Thanks.
Back to top
View user's profile Send private message 
smokey01


Joined: 30 Dec 2006
Posts: 2801
Location: South Australia :-(

PostPosted: Thu 26 Jul 2018, 09:51    Post subject:  

Is it possible to display 01-100 in a <spinbutton>?

I can do 1-100 but I need leading zero's from 00 to 09. 10 and up is fine.

It's so I can define minutes from 00 to 59.

Thanks

_________________
Software <-> Distros <-> Tips <-> Newsletters
Back to top
View user's profile Send private message Visit poster's website 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1716
Location: Japan

PostPosted: Fri 27 Jul 2018, 01:56    Post subject:  

smokey01 wrote:
Is it possible to display 01-100 in a <spinbutton>?

I'm afraid not, but why would you "need" to display the figures with leading zeros?
You may have to format the output to fit your requirements, but the display? Also keep in mind that the user can override the displayed value with whatever he likes, so you will have to check the output anyway.

If you are really keen to display leading zeros you may have to resort to a workaround. The following code works for me and hides the entry part of the spinbutton widget and feeds the values to an added entry widget, which can be much better controlled and formatted. You could even set it to editable="false" and thus avoid invalid manual entries (though not a good idea!).
Code:
#!/bin/bash
export MAIN_DIALOG='
<hbox>
   <entry>
      <variable>MIN</variable>
      <input>printf "%02d" $SPIN</input>
   </entry>
   <spinbutton width-request="15" range-min="0" range-max="59">
      <variable>SPIN</variable>
      <action>refresh:MIN</action>
   </spinbutton>
   <button>
      <action condition="command_is_true([[ $MIN =~ ^[0-9]+$ && $MIN -ge 0 && $MIN -le 59 ]] && echo true )">exit:</action>
   </button>
</hbox>'
eval $(gtkdialog)
[[ $MIN ]] && MIN=$(printf "%02d" $((10#$MIN)) )
echo $MIN

The <action> code of the button checks if the entry consists of only numbers and if the numbers are between 0 and 59. If not the button would not close the window
$((10#$MIN)) makes sure that printf interprets $MIN as a base 10 integer. Without it a value of 020 would return octal 16
entry_spinbutton_combo.png
 Description   
 Filesize   1.78 KB
 Viewed   362 Time(s)

entry_spinbutton_combo.png

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


Joined: 08 Nov 2016
Posts: 56

PostPosted: Fri 27 Jul 2018, 09:11    Post subject:  

^^^^
There could be a timer to fix the invalid input.

Now, if it's not a number or less than 0 or greater than 59 it will revert to previous MIN value.
Code:
#!/bin/bash
export MAIN_DIALOG='
<hbox>
   <entry>
      <variable>MIN</variable>
      <input>printf "%02d" $SPIN</input>
   </entry>
   <spinbutton width-request="15" range-min="0" range-max="59">
      <variable>SPIN</variable>
      <action>refresh:MIN</action>
   </spinbutton>
   <button>
      <action condition="command_is_true([[ $MIN =~ ^[0-9]+$ && $MIN -ge 0 && $MIN -le 59 ]] && echo true )">exit:</action>
   </button>
   <timer milliseconds="true" interval="500" visible="false">
      <action condition="command_is_true([[ $MIN != +([0-9]) || $MIN -lt 0 || $MIN -gt 59 ]] && echo true )">refresh:MIN</action>
   </timer>
</hbox>'
eval $(gtkdialog)
[[ $MIN ]] && MIN=$(printf "%02d" $((10#$MIN)) )
echo $MIN


What can possibly be further improved is
- when more then 2 digits are entered to trim back to 2 [ ${#MIN} -gt 2 ]
now it's possible to enter 000000, 0000000057, 010,
- when the MIN is set manualy the spin button to continue increasing the number
if a number is entered manualy and the spin button is clicked it will continue from the previous SPIN value
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1716
Location: Japan

PostPosted: Sat 28 Jul 2018, 02:08    Post subject: Re: GtkDialog - tips  

zigbert wrote:

Tips and tricks - Links
--> Text managing
--> Transparent background (gtkdialog desklets)
--> Right-click menu
--> Knob
--> Dynamic tabs
--> Chooser - navigate by pressing keys


@zigbert: Links 3-5 lead to smokey01's Puppy Newsletter but not to the advertised topics.
Could they be fixed?
Thanks.
Back to top
View user's profile Send private message 
01micko


Joined: 11 Oct 2008
Posts: 8683
Location: qld

PostPosted: Sat 28 Jul 2018, 08:53    Post subject:  

@zigbert.. to make the request of MochiMoppel easier..

http://blog.puppylinux.com/archive/current.php?post=posts/30-Gtkdialog-right-click-menu.html
http://blog.puppylinux.com/archive/current.php?post=posts/20-gtkdialog-knob.html
http://blog.puppylinux.com/archive/current.php?post=posts/40-Gtkdialog---Dynamic-tabs.html

That was a result of migrating the blog to a new platform.

_________________
Puppy Linux Blog - contact me for access
Back to top
View user's profile Send private message Visit poster's website 
zigbert


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

PostPosted: Tue 31 Jul 2018, 00:24    Post subject:  

Fixed!
Thank you both for input Smile

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 94 of 98 [1462 Posts]   Goto page: Previous 1, 2, 3, ..., 92, 93, 94, 95, 96, 97, 98 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.2435s ][ Queries: 12 (0.1762s) ][ GZIP on ]