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?

3
  • 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: askubuntu.com/questions/155298/… Apr 7, 2013 at 13:35
  • gist.github.com/strugee/5330567. i don't have any logic hooked up yet for buttons and stuff.
    – strugee
    Apr 7, 2013 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 7, 2013 at 13:51

2 Answers 2

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.

1
  • 2
    Or you can change the position property in the packing tab of the buttons.
    – Timo
    Apr 7, 2013 at 19:54
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)
5
  • This worked for me in Glade version 3.38.2.
    – rrirower
    Feb 21, 2021 at 15:40
  • When was this feature added? It doesn't exist in v3.22.2-1 (using Linux Mint 20.1). Mar 28, 2021 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? Mar 31, 2021 at 22:17
  • Since my comment I installed the flatpak version (v3.38) and none of my widgets have a Position property. Mar 31, 2021 at 22:59
  • I should rephrase that - none of the widgets have a Position setting under Packing. Apr 1, 2021 at 18:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .