3

How can I reorder widgets in the Glade widget tree?

For example, assume I have a Glade application that contains this partial tree:

box1 (GtkBox)
|--button1 (GtkButton)
|--button2 (GtkButton)
|--button3 (GtkButton)

How can I swap the position of e.g. button1 with e.g. button2, so that button2 will be above button1 in the UI?

strugee
  • 1,092
  • 1
  • 10
  • 25
  • You're looking for re-parenting. Post a more complete code sample and glade file for an answer instead of a comment. An example answer that provides the context the question should have: http://askubuntu.com/questions/155298/how-do-i-add-a-notebook-to-a-box-in-a-vbox/155345#155345 – RobotHumans Apr 07 '13 at 13:35
  • https://gist.github.com/strugee/5330567. i don't have any logic hooked up yet for buttons and stuff. – strugee Apr 07 '13 at 13:50
  • it has one additional .py file that shouldn't be getting imported from anything. other than that it's a generic quickly application. – strugee Apr 07 '13 at 13:51

2 Answers2

1

Stumbled across this, and found that the accepted answer is incorrect, or at least is no longer correct in current versions of Glade.

From within Glade, you can adjust the Position property under the Packing tab, whose value determines the index of the widget within its parent.

So in OP's example:

box1 (GtkBox)
|--button1 (GtkButton) (Position: 0)
|--button2 (GtkButton) (Position: 1)
|--button3 (GtkButton) (Position: 2)

Each button would have a Position value of 0, 1, and 2 respectfully. If you were to change the Position value of button2 to 0, it would move it up and button1 would then have a Position value of 1, which changes the order both in the tree and how it is displayed in the designer and final application.

box1 (GtkBox)
|--button2 (GtkButton) (Position: 0)
|--button1 (GtkButton) (Position: 1)
|--button3 (GtkButton) (Position: 2)
ForeverZer0
  • 131
  • 1
  • 6
  • This worked for me in Glade version 3.38.2. – rrirower Feb 21 '21 at 15:40
  • When was this feature added? It doesn't exist in v3.22.2-1 (using Linux Mint 20.1). – ajgringo619 Mar 28 '21 at 22:35
  • @ajgringo619 I am not sure at exactly which point it was added, I am using 3.38.2-1 on Arch, though I believe it has existed for at least a few minor versions before that. Would probably have to slog through the changelogs for an exact version. Does Mint offer any "bleeding edge" version that you could use instead of the stable one in the official repos? – ForeverZer0 Mar 31 '21 at 22:17
  • Since my comment I installed the flatpak version (v3.38) and none of my widgets have a Position property. – ajgringo619 Mar 31 '21 at 22:59
  • I should rephrase that - none of the widgets have a Position setting under Packing. – ajgringo619 Apr 01 '21 at 18:15
1

Upon further investigation, it appears that you cannot modify the order from the widget tree panel. However, you can still modify order in the visual editor.

In the toolbar, there are a couple of buttons for selecting cursor modes. Click the button right after the cursor. It should have four arrows. Then click on the widget that you want to move, and drag it where you want to move it to.

strugee
  • 1,092
  • 1
  • 10
  • 25