Label
Labels are used for displaying text in the GUI.
- They are great for titles, at the top of the GUI, usually spanning multiple columns.
- They are really useful before Entries and Drop-downs to explain their purpose.
- And, they're very helpful at the bottom of the GUI, to show the results of an action.
from appJar import gui
app = gui()
app.addLabel("l1", "Label 1")
app.addLabel("l2", "Label 2")
app.addLabel("l3", "Label 3")
app.addLabel("l4", "Label 4")
# common set functions
app.setLabelBg("l1", "red")
app.setLabelBg("l2", "yellow")
app.setLabelBg("l3", "purple")
app.setLabelBg("l4", "orange")
app.go()
Add Labels
-
.addLabel(title, text=None)
This will create a label widget to display text in the GUI.
Thetitle
is used to uniquely identify the label, in case you want to change it later, and thetext
is what gets displayed.
Iftext
is set to None, or notext
is provided, thetitle
will be displayed in the label. -
.addEmptyLabel(title)
Does the same as add a label, except there's no parameter to set any text. -
.addSelectableLabel(title, text=None)
This adds a label whose text can be selected with the mouse.
This is really just a read-only Entry, disguised to look like a label.
But it seems to do the trick... -
.addFlashLabel(title, text=None)
This adds a flashing label, that will alternate between the foreground and background colours.
from appJar import gui
app = gui()
app.addFlashLabel("f1", "This is flashing")
app.addLabel("f2", "This is not flashing")
app.addFlashLabel("f3", "This is also flashing")
app.go()
Set Labels
-
.setLabel(title, text)
Change the contents of the label. -
.clearLabel(title)
Clear the contents of the label.
Get Labels
.getLabel(title)
Get the contents of the label.
Auto-Labelled Widgets
It's possible to automatically include a label alongside a lot of the widgets.
Both the label and widget will be placed in the same grid space.
Simply add the word Label
to the command when adding the widget:
.addLabelEntry(title)
.addLabelNumericEntry(title)
.addLabelSecretEntry(title)
.addLabelAutoEntry(title, words)
.addLabelScale(title)
.addLabelOptionBox(title, values)
.addLabelTickOptionBox(title, values)
.addLabelSpinBox(title, values)
.addLabelSpinBoxRange(title, from, to)
See the relevant section for a description of what the widget does.