Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • CreatiCode
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

CreatiCode Scratch Forum

  1. CreatiCode Forum
  2. Knowledge Base
  3. 2D Blocks
  4. Introduction to Widgets with the Label Widget

Introduction to Widgets with the Label Widget

Scheduled Pinned Locked Moved 2D Blocks
1 Posts 1 Posters 1.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • CreatiCodeI Offline
    CreatiCodeI Offline
    CreatiCode
    wrote on last edited by admin
    #1

     

    Prerequisite

    • When Green Flag Clicked

     

    Description

    Widgets are GUI elements (e.g. labels or buttons) for displaying information and taking user inputs. They can be used in both 2D and 3D projects.

    Let’s look at labels as the first example widget. They are often used when we need to show some information to the user.

     

    Adding the Widget Extension

    Here is how to add the widget extension

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/a17835cb-17ea-4328-a4b6-eb15bdba1c5f.gif" width="900" style="border-radius: 5px; border: 1px solid #29622d;">

     

    Adding a Label Widget

    To add a new label, you can use the “add label” block:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/93f95fa0-35eb-4071-930c-19b9c0b4b42f.png" width="900" style="">

     

    Parameters

    • Text on Label: You can write some text on the label, or leave it blank.
    • Center Position: The x and y positions of the center point of the label.
    • Size: The width and height of the label. Note that the label is limited to the stage window, which has a width of 480 and a height of 360.
    • Widget Name: You need to assign a unique name to any widget you add, so that you can refer to it later using that name. If you use a name that is already used by another widget, that widget will be removed first.

     

    Removing a Widget

    You can remove any widget using the “remove widget” block:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/47024e29-2185-4721-b2fe-c429ce373a40.png" width="400" style="">

     

    Parameters

    • Widget Name: You have to select a valid name of an existing widget from the list. Note that to populate this list, you have to run the block that adds the widget first.

     

    Demo

    In this screencast, we first add 2 labels “start label” and “stop label”, then remove the “stop label”. Note that the dropdown for removal is empty before the labels are added.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/ff5d7662-ce1c-4154-ac40-29bed2b0fa3d.gif" width="1000" style="border-radius: 5px; border: 1px solid #29622d;">

     

    Removing All Widgets

    In case you need to remove all the widgets, you can use this block:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/be80091d-7cf9-4745-a618-fd06c77c2e19.png" width="200" style="">

    Note that when the user clicks the green flag button, all widgets will be removed, so it is not necessary to use “remove all widgets” at the very beginning of your project.

    1 Reply Last reply
    1
    • CreatiCodeI CreatiCode pinned this topic on

    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

    With your input, this post could be even better 💗

    Register Login
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode