Gtkdialog update script window, not open a new one?

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
thanius
Posts: 10
Joined: Tue 04 Feb 2014, 17:19

Gtkdialog update script window, not open a new one?

#1 Post by thanius »

Is it possible for gtkdialog to update the window using new content instead of having to close and open a new window?
I need a script where I press a button (options) to open up a new dialog -WITHIN- the existing one, exchanging the current dialog.

OPTION_DIALOG='
<window>
<vbox>
<button><label>Back to Main</label><action>CHANGE_SCRIPT: MAIN</action></button>
</vbox>
</window>
'

MAIN_DIALOG='
<window>
<vbox>
<button><label>Options</label><action>CHANGE_SCRIPT: OPTION_DIALOG</action></button>
</vbox>
</window>
'

Possible or not?
Cheers.

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

#2 Post by SFR »

From what I know it's not possible to replace widgets in already opened window, but you can always prepare various GUIs on subsequent tabs of <notebook> widget and switch between them, e.g.:

Code: Select all

#!/bin/bash

export PAGE=/tmp/notebook_page_${$}
echo 0 > $PAGE
trap 'rm $PAGE' EXIT

export MAIN='
<window>
  <notebook show-tabs="false">
    
    <vbox>
      <text><label>This is first page</label></text>
      <checkbox><label>some checkbox</label></checkbox>
      <entry><default>some entry</default></entry>
      <edit><default>edit field</default></edit>   
      <button>
        <label>Show Options</label>
        <action>echo 1 >${PAGE}</action>
        <action>refresh:NOTEBOOK</action>
      </button>
    </vbox>
    
    <vbox>
      <text><label>This is second page</label></text>
      <radiobutton></radiobutton>
      <tree><item>some</item><item>tree</item></tree>
      <button>
        <label>Back to main</label>
        <action>echo 0 > ${PAGE}</action>
        <action>refresh:NOTEBOOK</action>
      </button>
    </vbox>
  
    <variable>NOTEBOOK</variable>
    <input file>'${PAGE}'</input>
  </notebook>
</window>'

gtkdialog -p MAIN
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
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#3 Post by don570 »

I did an example with a togglebutton widget

Clicking on the toggle button changed the window and changed the
label of the button that did the toggling.


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

_____________________________________________________

thanius
Posts: 10
Joined: Tue 04 Feb 2014, 17:19

#4 Post by thanius »

Exactly was I was looking for! Thanks!

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#5 Post by zigbert »

Using a <notebook> is ok, but more flexible is the solution to hide/show any widget - also <h/vbox> that hides everything inside the box.

example for togglebutton:
<action>if true show:MY_VBOX</aciton>

thanius
Posts: 10
Joined: Tue 04 Feb 2014, 17:19

#6 Post by thanius »

The vbox hiding works, but I cannot make the other "dialog" appear with same method, so I guess I'm sticking with the notebook-widget.

I need some help with some problems I'm having trying to style a checkbox. I want to have a flat checkbox without focus colors, which I've managed through widget_class Checkbutton, but I want to have different colors on certain checkbutton labels.

For example, I want one checkbutton with gtklabel normal grey and highlight black. On the other dialog I want a checkbutton with normal black and no hightlight.

As a workaround I've made a checkbox widget with a blank label, then put a text widget on front of that, but I want the text to act as a toggle so hopefully I can get this sorted out.
Cheers.

Post Reply