Separators in a Page Form

04 June 2018

Years ago, when I programmed in Visual Basic, I found that I occasionally needed some separators, just a series of 2 pixel lines, to break up the information on the form. I didn’t need a full frame to do this. I started off using a 2 pixel light line, but visually that wasn’t pleasing enough. Then one day I was fooling around and found that if I used a frame the width that I wanted, but only set the height at 2, that I had something that looked like it was done using a control (what we called widgets back in those days). When anyone saw my layouts, they would as me how I did it.

Now, I use Page to create my Python forms and found myself needing a horizontal separator again. I know that the Tkinter ttk toolbox provides a separator widget, but much to my dismay, Page didn’t support the separators. Then I remembered my trick from way back when. I tried using a frame widget, but it didn’t work. A flash of inspiration hit me and I tried a standard label with the relief set to ‘raised’ and a height of 2 pixels. It worked just the way I remembered.

Separators Demo

As you can see, not only can you do horizontal separators, you can also do vertical ones and as an added bonus, you can place the end of your horizontal separator on top of the vertical one.

So, the steps are simple.

  • Add a label widget to your layout in the Page designer.
  • Drag the label widget edge to the width (or height for vertical) you want it to be
  • Using the Attribute Editor, set the relief to ‘raised’
  • Set the alias to something like ‘lblSep1’ (optional)
  • Set the height (or width for vertical) to 2.

That’s it.

When you look at your file generated by Page, you can see:

    self.lblSep2 = Label(top), rely=0.3, height=2, width=506)

Now you have a visual separator, with NO code, just a couple of attribute changes.

Have a great day!