Yast UI
YLabel Class Reference

Simple static text. More...

Detailed Description

Simple static text.

Following widget variants exist: Label Heading

Example:

# encoding: utf-8
module Yast
class Label1Client < Client
def main
Yast.import "UI"
UI.OpenDialog(VBox(Label("Hello, World!"), PushButton("&OK")))
UI.UserInput
UI.CloseDialog
nil
end
end
end
Yast::Label1Client.new.main

Example:

# encoding: utf-8
module Yast
class Label2Client < Client
def main
Yast.import "UI"
UI.OpenDialog(
VBox(Label("Labels can have\nmultiple lines."), PushButton("&OK"))
)
UI.UserInput
UI.CloseDialog
nil
end
end
end
Yast::Label2Client.new.main

Example:

# encoding: utf-8
module Yast
class Label3Client < Client
def main
Yast.import "UI"
# Build dialog with one label, 4 Beatles buttons and an OK button.
UI.OpenDialog(
VBox(
Label("Select your favourite Beatle:"),
Label(Id(:beatle), Opt(:outputField), " "),
HBox(
PushButton(Id(:john), "John"),
PushButton(Id(:paul), "Paul"),
PushButton(Id(:george), "George"),
PushButton(Id(:ringo), "Ringo")
),
PushButton(Id(:ok), "&OK")
)
)
# Wait for user input.
@button = nil
begin
@button = UI.UserInput
if @button == :john
UI.ChangeWidget(Id(:beatle), :Value, "John Lennon")
elsif @button == :paul
UI.ChangeWidget(Id(:beatle), :Value, "Paul McCartney")
elsif @button == :george
UI.ChangeWidget(Id(:beatle), :Value, "George Harrison")
elsif @button == :ringo
UI.ChangeWidget(Id(:beatle), :Value, "Ringo Starr")
end
# Recalculate the layout - this is necessary since the label widget
# doesn't recompute its size upon changing its value.
UI.RecalcLayout
end until @button == :ok
# Retrieve the label's value.
@name = Convert.to_string(UI.QueryWidget(Id(:beatle), :Value))
# Close the dialog.
# Remember to read values from the dialog's widgets BEFORE closing it!
UI.CloseDialog
# Pop up a new dialog to echo the input.
UI.OpenDialog(
VBox(
VSpacing(),
HBox(
Label("You selected:"),
Label(Opt(:outputField), @name),
HSpacing()
),
PushButton(Opt(:default), "&OK")
)
)
UI.UserInput
UI.CloseDialog
nil
end
end
end
Yast::Label3Client.new.main

Example:

# encoding: utf-8
# Label example using bold font
module Yast
class Label4Client < Client
def main
Yast.import "UI"
UI.OpenDialog(
VBox(
Label("Label using normal font"),
Label(Opt(:boldFont), "Label using bold font"),
Label("Label using normal font"),
PushButton(Opt(:default), "&OK")
)
)
UI.UserInput
UI.CloseDialog
nil
end
end
end
Yast::Label4Client.new.main

Example:

# encoding: utf-8
module Yast
class Heading1Client < Client
def main
Yast.import "UI"
UI.OpenDialog(VBox(Heading("This Is a Heading."), PushButton("&OK")))
UI.UserInput
UI.CloseDialog
nil
end
end
end
Yast::Heading1Client.new.main

Example:

# encoding: utf-8
module Yast
class Heading2Client < Client
def main
Yast.import "UI"
UI.OpenDialog(
VBox(
Heading("This Is a Heading."),
Label("This is a Label."),
PushButton("&OK")
)
)
UI.UserInput
UI.CloseDialog
nil
end
end
end
Yast::Heading2Client.new.main

Example:

# encoding: utf-8
module Yast
class Heading3Client < Client
def main
Yast.import "UI"
# Build dialog with one label, 4 Beatles buttons and an OK button.
UI.OpenDialog(
VBox(
Label("My favourite Beatle:"),
# `Heading(`id(`favourite), "Press one of the buttons below"),
Heading(Id(:favourite), "(please select one)"),
HBox(
PushButton(Id(:john), "John"),
PushButton(Id(:paul), "Paul"),
PushButton(Id(:george), "George"),
PushButton(Id(:ringo), "Ringo")
),
PushButton(Id(:ok), "&OK")
)
)
# Wait for user input.
@button = nil
begin
@button = UI.UserInput
if @button == :john
UI.ChangeWidget(Id(:favourite), :Value, "John Lennon")
elsif @button == :paul
UI.ChangeWidget(Id(:favourite), :Value, "Paul McCartney")
elsif @button == :george
UI.ChangeWidget(Id(:favourite), :Value, "George Harrison")
elsif @button == :ringo
UI.ChangeWidget(Id(:favourite), :Value, "Ringo Starr")
end
end until @button == :ok
nil
end
end
end
Yast::Heading3Client.new.main

A Label is static text displayed in the dialog. A Heading is static text with a bold and/or larger font. In both cases, the text may contain newlines.


The documentation for this class was generated from the following file: