### Hello World in Ruby/Tk Source: https://tkdocs.com/tutorial/install A 'Hello World' example using Ruby/Tk, creating a button within a root window. This is saved to 'hello.rb' and executed within the IRB environment. ```ruby require 'tk' require 'tkextlib/tile' root = TkRoot.new() button = Tk::Tile::TButton.new(root) {text "Hello World"}.grid Tk.mainloop() ``` -------------------------------- ### Install Tcl/Tk from Source (Unix) Source: https://tkdocs.com/tutorial/install Build and install Tcl and Tk from their source code. This process involves configuring, making, and installing both Tcl and Tk, specifying a custom installation directory using the 'prefix' option. Adjust version numbers as necessary. ```shell % export TCLTKDIR=`pwd` % cd tcl8.6.17/unix % ./configure --prefix=$TCLTKDIR % make && make install % cd ../../tk8.6.17/unix % ./configure --with-tcl=$TCLTKDIR/lib % make && make install ``` -------------------------------- ### Verify Tk Installation in Ruby Source: https://tkdocs.com/tutorial/install Commands to verify the successful installation and version of Tk in Ruby. This ensures the environment is correctly set up for Tk-based applications. ```Ruby require 'tk' Tk::TK_PATCHLEVEL ``` -------------------------------- ### Install Ruby/Tk Gem Source: https://tkdocs.com/tutorial/install Command to install the Ruby/Tk binding gem. This allows Ruby programs to utilize Tk for graphical user interfaces. ```ruby % sudo gem install tk ``` -------------------------------- ### Install Ruby/Tk Gem Source: https://tkdocs.com/tutorial/install This command installs the Ruby Tk module, which provides bindings for Tcl/Tk. It uses the 'gem' command and specifies the full path to the installed Ruby binary. This gem requires a pre-existing Tcl/Tk installation. ```shell % /usr/local/opt/ruby/bin/gem install tk ``` -------------------------------- ### Hello World in Tcl/Tk Source: https://tkdocs.com/tutorial/install A basic 'Hello World' program in Tcl/Tk, creating a button. This is saved to a 'hello.tcl' file and executed using the 'wish' shell. ```tcl package require Tk grid [ttk::button .b -text "Hello World"] ``` -------------------------------- ### Build and Install Tcl/Tk from Source on macOS Source: https://tkdocs.com/tutorial/install These commands compile and install Tcl and Tk from their source code. The installation path can be customized using the --prefix option. Ensure to adjust version numbers according to the downloaded source files. ```shell % export TCLTKDIR=`pwd` % cd tcl8.6.17/unix % ./configure --with-system-libtommath --prefix=$TCLTKDIR % make && make install % cd ../../tk8.6.17/unix % ./configure --enable-aqua=yes --without-x --with-tcl=$TCLTKDIR/lib % make && make install ``` -------------------------------- ### Verify Ruby/Tk Installation Source: https://tkdocs.com/tutorial/install Ruby code to load the Tk library and check the Tk patch level. This confirms that Ruby/Tk is correctly installed and communicating with the Tk backend. ```ruby % require 'tk' % Tk::TK_PATCHLEVEL ``` -------------------------------- ### Verify Tcl/Tk Installation Source: https://tkdocs.com/tutorial/install This Tcl command checks the installed version of Tcl/Tk. Running the 'wish8.6' binary should also launch a graphical window, confirming a successful installation. ```tcl % info patchlevel ``` -------------------------------- ### Start Tk event loop in Tcl Source: https://tkdocs.com/tutorial/firstexample Tcl command to enter the event loop using vwait. This keeps the application running and responsive to user input. ```Tcl vwait forever ``` -------------------------------- ### Verify Ruby/Tk Installation Source: https://tkdocs.com/tutorial/install These commands are run within the Ruby interactive interpreter (irb) to verify the Ruby/Tk installation. The first command loads the Tk library, and the second retrieves the Tk patch level. ```ruby % require 'tk' % Tk::TK_PATCHLEVEL ``` -------------------------------- ### Install Tk Development Libraries on Ubuntu Source: https://tkdocs.com/tutorial/install Command to install Tcl/Tk development libraries and Ruby development packages on Ubuntu systems. This is a prerequisite for building Ruby/Tk. ```bash % sudo apt install tk8.6-dev ruby2.7 ruby2.7-dev ``` -------------------------------- ### Determine Windowing System (Ruby) Source: https://tkdocs.com/tutorial/menus Gets the windowing system (x11, win32, or aqua) using Tk. ```Ruby Tk.windowingsystem ``` -------------------------------- ### Install Developer Tools on macOS Source: https://tkdocs.com/tutorial/install This command installs Apple's developer tools, including the compiler, necessary for building software from source on macOS. It is a prerequisite for compiling Tcl/Tk and Python from source. ```bash % xcode-select --install ``` -------------------------------- ### Determine Windowing System (Perl) Source: https://tkdocs.com/tutorial/menus Gets the windowing system (x11, win32, or aqua) using Tkx. ```Perl Tkx::tk_windowingsystem() ``` -------------------------------- ### Start Tk event loop in Ruby Source: https://tkdocs.com/tutorial/firstexample Ruby command to initiate the Tk main event loop, which processes events and maintains the application's responsiveness. ```Ruby Tk.mainloop ``` -------------------------------- ### Create ttk__progressbar in Perl (Tkx) Source: https://tkdocs.com/tutorial/morewidgets Provides an example of creating a determinate ttk__progressbar using the Tkx Perl module. The new_ttk__progressbar method is used with named arguments for configuration. ```perl $parent->new_ttk__progressbar(-orient => 'horizontal', -length => 200, -mode => 'determinate'); ``` -------------------------------- ### Get Text Widget Contents Source: https://tkdocs.com/tutorial/morewidgets Demonstrates how to retrieve the entire text content from a Text widget. It uses the 'get' method with start and end indices. ```python contents = txt.get('1.0', 'end') ``` ```tcl set contents [.txt get 1.0 end] ``` ```python_string contents = txt.get("1.0", 'end') ``` ```perl $contents = $txt->get("1.0", "end"); ``` -------------------------------- ### Get and Set Tab Options (Perl) Source: https://tkdocs.com/tutorial/complex Shows how to get and set options for individual tabs within a Perl Tkinter notebook. This example focuses on retrieving and modifying the text option of a tab. ```perl print($n->tab($f1, -text)); # get the value of the tab's text option $n->tab($f2, -text => "New Title"); # change the tab's 'text' option ``` -------------------------------- ### Hello World in Tkx (Perl) Source: https://tkdocs.com/tutorial/install A 'Hello World' program using Perl's Tkx module, displaying a button. Note the double underscore in 'ttk__button'. This is saved to 'hello.pl' and run with the Perl interpreter. ```perl use Tkx; Tkx::grid( Tkx::ttk__button(".b", -text => "Hello, world" ) ); Tkx::MainLoop(); ``` -------------------------------- ### Hello World in Tkinter (Python) Source: https://tkdocs.com/tutorial/install A simple 'Hello World' program using Python's Tkinter library. It creates a basic window with a button. This is saved to a 'hello.py' file and run using the Python interpreter. ```python from tkinter import * from tkinter import ttk root = Tk() ttk.Button(root, text="Hello World").grid() root.mainloop() ``` -------------------------------- ### Retrieving and Modifying Entry Widget Values Source: https://tkdocs.com/tutorial/widgets This functionality retrieves the current text value using get(), deletes text between indices (0-based, with 'end' for last position), and inserts new text at a specified index. It relies on a linked variable via textvariable option for entries. Inputs are indices for delete/insert; outputs are strings for get(). Limitations: Indices start at 0; no validation shown. ```Python print(f'current value is {name.get()}') name.delete(0, 'end') # delete between two indices, 0-based name.insert(0, 'your name') # insert new text at a given index ``` ```Tcl puts "current value is [.name get]" .name delete 0 end ; # delete between two indices, 0-based .name insert 0 "your name" ; # insert new text at a given index ``` ```Ruby puts ("current value is #{name.get}") name.delete(0, end) ; # delete between two indices, 0-based name.insert(0, 'your name') ; # insert new text at a given index ``` ```Perl print "current value is " . $name->get; $name->delete(0, "end"); # delete between two indices, 0-based $name->insert(0, "your name"); # insert new text at a given index ``` -------------------------------- ### Get Tk Window Screen Information Source: https://tkdocs.com/tutorial/windows Retrieve information about the screen a Tk window is running on. This is useful for multi-monitor setups, especially on X11 systems. The methods return a display name string. ```python root.winfo_screen() ``` ```tcl winfo screen . ``` ```python_object root.winfo_screen ``` ```perl $mw->g_winfo_screen() ``` -------------------------------- ### Create and grid frame in Perl/Tkx Source: https://tkdocs.com/tutorial/morewidgets Creates the main content frame and configures grid weights for responsive layout. Demonstrates basic widget creation and grid configuration in Perl/Tkx. ```Perl # Create and grid the outer content frame $mw = Tkx::widget->new("."); $content = $mw->new_ttk__frame(-padding => "5 5 12 0"); $content->g_grid(-column => 0, -row => 0, -sticky => "nwes"); $mw->g_grid_columnconfigure(0, -weight => 1); $mw->g_grid_rowconfigure(0, -weight => 1); ``` -------------------------------- ### Delete Menu Items (Python, Tcl, Ruby, Perl) Source: https://tkdocs.com/tutorial/menus Demonstrates how to remove one or more menu items from a menu using the `delete` method. The example shows deleting all items from the 'recent' menu by specifying the start and end indices as 0 and 'end'. ```python menu_recent.delete(0, 'end') ``` ```tcl $m.file.recent delete 0 end ``` ```ruby recent.delete 0, 'end' ``` ```perl $recent->delete(0, 'end'); ``` -------------------------------- ### Retrieve Text from Tk Text Widget (Python, Tcl, Ruby, Perl) Source: https://tkdocs.com/tutorial/text Illustrates how to retrieve the entire content of a Tk Text widget using the `get` method. The method takes start and end positions, with 'end' signifying the widget's conclusion. ```Python thetext = text.get('1.0', 'end') ``` ```Tcl set thetext [.text get 1.0 end] ``` ```Ruby thetext = t.get("1.0", 'end') ``` ```Perl $thetext = $text->get("1.0", "end"); ``` -------------------------------- ### Initialize data in Perl/Tkx Source: https://tkdocs.com/tutorial/morewidgets Sets up country databases including codes, names, and populations. Also defines available gift options. Required before creating UI elements. ```Perl use Tkx; # Initialize our country "databases": # - the list of country codes (a subset anyway) # - parallel list of country names, same order as the country codes # - a hash table mapping country code to population @countrycodes = ("ar", "au", "be", "br", "ca", "cn", "dk", "fi", "fr", "gr", "in", "it", "jp", "mx", "nl", "no", "es", "se", "ch"); @countrynames = ("Argentina", "Australia", "Belgium", "Brazil", "Canada", "China", "Denmark", "Finland", "France", "Greece", "India", "Italy", "Japan", "Mexico", "Netherlands", "Norway", "Spain", "Sweden", "Switzerland"); %populations = ("ar" => 41000000, "au" => 21179211, "be" => 10584534, "br" => 185971537, "ca" => 33148682, "cn" => 1323128240, "dk" => 5457415, "fi" => 5302000, "fr" => 64102140, "gr" => 11147000, "in" => 1131043000, "it" => 59206382, "jp" => 127718000, "mx" => 106535000, "nl" => 16402414, "no" => 4738085, "es" => 45116894, "se" => 9174082, "ch" => 7508700); # Names of the gifts we can send %gifts =("card" => "Greeting card", "flowers" => "Flowers", "nastygram" => "Nastygram"); ``` -------------------------------- ### Verify Tcl/Tk Installation Source: https://tkdocs.com/tutorial/install Command to check the installed Tcl/Tk patch level. This is a fundamental verification step after installing Tk. ```tcl % info patchlevel ``` -------------------------------- ### Create Tk GUI Layout with Padding, Sticky, and Resizing Source: https://tkdocs.com/tutorial/grid Demonstrates a complete Tk GUI implementation showing padding configuration via widget options and grid geometry manager. Illustrates sticky behavior for widget alignment and column/row weighting for dynamic resizing. Creates a form layout with labels, entry field, checkbuttons, and action buttons requiring appropriate Tk toolkit bindings for each language. ```python from tkinter import * from tkinter import ttk root = Tk() content = ttk.Frame(root, padding=(3,3,12,12)) frame = ttk.Frame(content, borderwidth=5, relief="ridge", width=200, height=100) namelbl = ttk.Label(content, text="Name") name = ttk.Entry(content) onevar = BooleanVar() twovar = BooleanVar() threevar = BooleanVar() onevar.set(True) twovar.set(False) threevar.set(True) one = ttk.Checkbutton(content, text="One", variable=onevar, onvalue=True) two = ttk.Checkbutton(content, text="Two", variable=twovar, onvalue=True) three = ttk.Checkbutton(content, text="Three", variable=threevar, onvalue=True) ok = ttk.Button(content, text="Okay") cancel = ttk.Button(content, text="Cancel") content.grid(column=0, row=0, sticky=(N, S, E, W)) frame.grid(column=0, row=0, columnspan=3, rowspan=2, sticky=(N, S, E, W)) namelbl.grid(column=3, row=0, columnspan=2, sticky=(N, W), padx=5) name.grid(column=3, row=1, columnspan=2, sticky=(N,E,W), pady=5, padx=5) one.grid(column=0, row=5) two.grid(column=1, row=5) three.grid(column=2, row=5) ok.grid(column=3, row=5) cancel.grid(column=4, row=5) root.columnconfigure(0, weight=1) root.rowconfigure(0, weight=1) content.columnconfigure(0, weight=3) content.columnconfigure(1, weight=3) content.columnconfigure(2, weight=3) content.columnconfigure(3, weight=1) content.columnconfigure(4, weight=1) content.rowconfigure(1, weight=1) root.mainloop() ``` ```tcl ttk::frame .c -padding "3 3 12 12" ttk::frame .c.f -borderwidth 5 -relief ridge -width 200 -height 100 ttk::label .c.namelbl -text Name ttk::entry .c.name ttk::checkbutton .c.one -text One -variable one -onvalue 1; set one 1 ttk::checkbutton .c.two -text Two -variable two -onvalue 1; set two 0 ttk::checkbutton .c.three -text Three -variable three -onvalue 1; set three 1 ttk::button .c.ok -text Okay ttk::button .c.cancel -text Cancel grid .c -column 0 -row 0 -sticky nsew grid .c.f -column 0 -row 0 -columnspan 3 -rowspan 2 -sticky nsew grid .c.namelbl -column 3 -row 0 -columnspan 2 -sticky nw -padx 5 grid .c.name -column 3 -row ``` -------------------------------- ### Install Ruby using Homebrew Source: https://tkdocs.com/tutorial/install This command uses the Homebrew package manager to install the Ruby programming language. It assumes Homebrew is already installed at '/usr/local/bin/brew'. ```shell % brew install ruby ``` -------------------------------- ### Adding Grid Configuration, Padding, Focus, and Key Binding in Tk Applications Source: https://tkdocs.com/tutorial/firstexample This snippet configures root and mainframe grids for resizable expansion, adds padding to all child widgets, sets initial focus on the feet entry, and binds the Return key to the calculate function. Enhances UI responsiveness and usability. Depends on root, mainframe/content, feet_entry/f, and calculate function; no direct outputs but modifies layout and behavior. Limitations: Padding applied uniformly, focus only on entry. ```Python root.columnconfigure(0, weight=1) root.rowconfigure(0, weight=1) mainframe.columnconfigure(2, weight=1) for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=5) feet_entry.focus() root.bind("", calculate) ``` ```Tcl grid columnconfigure . 0 -weight 1; grid rowconfigure . 0 -weight 1 grid columnconfigure .c -weight 1 foreach w [winfo children .c] {grid configure $w -padx 5 -pady 5} focus .c.feet bind . {calculate} ``` ```Ruby TkGrid.columnconfigure root, 0, :weight => 1; TkGrid.rowconfigure root, 0, :weight => 1 TkGrid.columnconfigure content, 2, :weight => 1 TkWinfo.children(content).each {|w| TkGrid.configure w, :padx => 5, :pady => 5} f.focus root.bind("Return") {calculate} ``` ```Perl Tkx::grid_columnconfigure( ".", 0, -weight => 1); Tkx::grid_rowconfigure(".", 0, -weight => 1); Tkx::grid_columnconfigure(".c", 2, -weight => 1); foreach (Tkx::SplitList(Tkx::winfo_children(".c"))) { Tkx::grid_configure($_, -padx => 5, -pady => 5); } Tkx::focus(".c.feet"); Tkx::bind(".", "", sub {calculate();}); ``` -------------------------------- ### Initialize and Configure Tkx Font Chooser Source: https://tkdocs.com/tutorial/windows Sets up the Tk font chooser dialog using the Tkx library. It creates a label, defines a callback subroutine to update the label's font, and then configures the font chooser with an initial font and the callback. ```perl our $l = $mw->new_ttk__label(-text => "Hello World", -font => "helvetica 24"); $l->g_grid(-padx => 10, -pady => 10); sub font_changed { ($font) = @_; $l->configure(-font => $font); } Tkx::tk_fontchooser_configure( -font => "helvetica 24", -command => &font_changed); ``` -------------------------------- ### Verify Tkx installation in Perl Source: https://tkdocs.com/tutorial/install Checks if the Tkx module is installed and reports the Tcl/Tk patchlevel it found. This confirms that Perl can successfully interface with the installed Tcl/Tk libraries. ```perl % /usr/local/opt/perl/bin/perl -MTkx -e 'print Tkx::info("patchlevel");' ``` -------------------------------- ### Create Contextual Menu with Tcl/Tk Source: https://tkdocs.com/tutorial/menus Creates a contextual menu using standard Tcl/Tk commands. Adds Control-Button-1 event for Aqua platform support. Uses tk_popup command with global coordinates (%X %Y) to show menu at mouse position. No external dependencies required. ```Tcl menu .menu if {[tk windowingsystem]=="aqua"} { event add <> } foreach i [list One Two Three] {.menu add command -label $i} bind . <> "tk_popup .menu %X %Y" ``` -------------------------------- ### Install Tcl-Tk using Homebrew on macOS Source: https://tkdocs.com/tutorial/install This command uses the Homebrew package manager to install Tcl/Tk on macOS. This is the recommended 'easy way' for users who have Homebrew installed. It provides a pre-compiled version of Tcl/Tk. ```bash % brew install tcl-tk ``` -------------------------------- ### Install Tkx module for Perl, bypassing tests Source: https://tkdocs.com/tutorial/install Installs the Tkx module for Perl from CPAN, specifically bypassing the test suite to ensure installation even if tests fail. This is necessary for Perl's Tk bindings to function correctly. ```perl % /usr/local/opt/perl/bin/perl -MCPAN -e "CPAN::Shell->notest('install','Tkx')" ``` -------------------------------- ### Tk System Menu Creation (Perl/Tkx) Source: https://tkdocs.com/tutorial/menus Demonstrates system menu creation using Perl with the Tkx library. It highlights the need to explicitly set the menu's pathname to '.system'. ```perl $system = Tkx::widget->new(Tkx::menu($m->_mpath . ".system")); $m->add_cascade(-menu => $system); ``` -------------------------------- ### Provide Help Menu in Tkx Source: https://tkdocs.com/tutorial/menus Provides a Tkx implementation for adding a macOS Help menu. It creates the '.help' menu widget and defines the `::tk::mac::ShowHelp` procedure using Tkx. ```Perl $helpmenu = Tkx::widget->new(Tkx::menu($m->_mpath . ".help")); $m->add_cascade(-menu => $helpmenu); Tkx::proc('::tk::mac::ShowHelp', '{args}', sub {...}); ``` -------------------------------- ### Create and Configure Image in Ruby Tk (Procedural) Source: https://tkdocs.com/tutorial/widgets Procedural Ruby Tk example to create a photo image and configure a label to display it. Assumes a label object and an image object named 'imgobj'. ```Ruby Tkx::image_create_photo( "imgobj", -file => "myimage.png"); $label->configure(-image => "imgobj"); ``` -------------------------------- ### Create Ttk Button with Options Source: https://tkdocs.com/tutorial/concepts Create a button widget with text and command options. Demonstrates basic widget creation and placement using grid. The command option specifies a callback function to execute when the button is clicked. ```Tcl grid [ttk::button .b -text "Hello" -command {button_pressed}] ``` ```Ruby require 'tk' require 'tkextlib/tile' root = TkRoot.new button = Tk::Tile::Button.new(root) {text "Hello"; command "button_pressed"}.grid ``` ```Perl use Tkx $mw = Tkx::widget->new(".") ($b = $mw->new_ttk__button(-text => "Hello", -command => sub {button_pressed();}))->g_grid ``` -------------------------------- ### Create Tk Text Widget (Python, Tcl, Ruby, Perl) Source: https://tkdocs.com/tutorial/text Demonstrates the creation of a Tk Text widget with specified dimensions across different programming languages. It highlights the syntax for initializing the widget and setting its width and height. ```Python text = Text(parent, width=40, height=10) ``` ```Tcl tk::text .text -width 40 -height 10 ``` ```Ruby text = TkText.new(parent) { width 40 height 10 } ``` ```Perl $text = $parent->new_tk__text(-width => 40, -height => 10); ``` -------------------------------- ### Verify Tkinter Installation in Python Source: https://tkdocs.com/tutorial/install Python commands to test the installation of Tkinter, the Python interface to Tk. This opens a test window displaying the Tcl/Tk version. ```Python import tkinter tkinter._test() ``` -------------------------------- ### Create Toplevel Window in Python, Tcl, Ruby, and Perl Source: https://tkdocs.com/tutorial/windows Demonstrates creating new toplevel windows, which function similarly to the root window, in various programming languages. These are separate from the main application window and can contain their own widgets. ```Python t = Toplevel(parent) ``` ```Tcl tk::toplevel .t ``` ```Ruby t = TkToplevel.new(parent) ``` ```Perl my $win = $parent->new_toplevel; ``` -------------------------------- ### Provide Help Menu in Python Source: https://tkdocs.com/tutorial/menus Demonstrates adding a standard macOS Help menu to a Tkinter menubar. It includes creating a 'help' named menu and setting up the `tk::mac::ShowHelp` command. ```Python helpmenu = Menu(menubar, name='help') menubar.add_cascade(menu=helpmenu, label='Help') root.createcommand('tk::mac::ShowHelp', ...) ``` -------------------------------- ### Verify Tk Installation in Perl Source: https://tkdocs.com/tutorial/install Perl command to check the version of Tk installed via the Tkx module. This confirms that Perl can access the Tk libraries. ```Perl perl -MTkx -e "print Tkx::info(\"patchlevel\");" ``` -------------------------------- ### Build Tcl from Source on macOS Source: https://tkdocs.com/tutorial/install These commands compile Tcl from its source code on macOS. It involves setting an environment variable for the installation directory, navigating to the Tcl source directory, configuring the build with specific options, and then making and installing Tcl. This is part of the 'hard way' of installing Tcl/Tk. ```bash export TCLTKDIR=`pwd` cd tcl8.6.17/unix ./configure --with-system-libtommath --prefix=$TCLTKDIR make && make install ``` -------------------------------- ### Create and Attach Menubar to Toplevel Window (Tcl) Source: https://tkdocs.com/tutorial/menus This snippet shows how to create a toplevel window and attach a menubar using Tcl/Tk commands. It involves creating a menu widget and configuring the toplevel window to use it as its menubar. ```tcl toplevel .win menu .win.menubar .win configure -menu .win.menubar ``` -------------------------------- ### Install Ruby/Tk Gem on Windows Source: https://tkdocs.com/tutorial/install Installs the Tk module for Ruby using the gem package manager. This is necessary for Ruby applications that require Tk for GUI development. ```Ruby gem install tk ``` -------------------------------- ### Choose Color Dialog (Tcl/Tk) Source: https://tkdocs.com/tutorial/windows A command-line interface for the color chooser dialog in Tcl/Tk. Allows specifying an initial color using the '-initialcolor' option. ```tcl tk_chooseColor -initialcolor #ff0000 ``` -------------------------------- ### Verify Perl Tkx Installation Source: https://tkdocs.com/tutorial/install Perl command to verify the Tkx installation and check the Tk patch level. Tkx is a recommended module for modern Tk programming in Perl. ```perl % perl -MTkx -e 'print Tkx::info("patchlevel");' ``` -------------------------------- ### Example: Raising Overlapping Widgets in Tk Source: https://tkdocs.com/tutorial/windows Demonstrates stacking order with overlapping grid-placed labels, using after to raise one after delay. Depends on Tk, ttk for labels; inputs root and widgets; runs mainloop. Illustrates sibling widget overlap handling; timer via after. ```python from tkinter import * from tkinter import ttk root = Tk() little = ttk.Label(root, text="Little") bigger = ttk.Label(root, text='Much bigger label') little.grid(column=0,row=0) bigger.grid(column=0,row=0) root.after(2000, lambda: little.lift()) root.mainloop() ``` ```tcl grid [ttk::label .little -text "Little"] -column 0 -row 0 grid [ttk::label .bigger -text "Much Bigger Label"] -column 0 -row 0 after 2000 raise .little ``` ```ruby require 'tk' require 'tkextlib/tile' root = TkRoot.new little = Tk::Tile::Label.new(root) {text 'Little'}.grid( :column => 0, :row => 0) bigger = Tk::Tile::Label.new(root) {text 'Much Bigger Label'}.grid( :column => 0, :row => 0) Tk.after 2000, proc{little.raise} Tk.mainloop ``` ```perl use Tkx; $mw = Tkx::widget->new("."); $little = $mw->new_ttk__label(-text => "Little"); $little->g_grid(-column => 0, -row => 0); $bigger = $mw->new_ttk__label(-text => "Much Bigger Label"); $bigger->g_grid(-column => 0, -row => 0); Tkx::after(2000, sub {$little->g_raise();}); Tkx::MainLoop(); ``` -------------------------------- ### Install Perl using Homebrew Source: https://tkdocs.com/tutorial/install Installs the Perl programming language using the Homebrew package manager on macOS or Linux. This command ensures that the Perl binaries are available for use. ```bash % brew install perl ``` -------------------------------- ### Tkinter Initial State Setup Source: https://tkdocs.com/tutorial/morewidgets Initializes the Tkinter application's state. It sets the default gift to 'card', clears status and sent messages, selects the first item in the listbox, and explicitly calls 'showPopulation' to display initial data. ```perl # Set the starting state of the interface, including selecting the # default gift to send, and clearing the messages. Select the first # country in the list; because the <> event is only # fired when users makes a change, we explicitly call showPopulation. $gift = 'card'; $sentmsg = ""; $statusmsg = ""; $lbox->selection_set(0); showPopulation; Tkx::MainLoop(); ```