Jump to content

Simple windowed application: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
m (BaCon and BBC BASIC moved to the BASIC section.)
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(4 intermediate revisions by 3 users not shown)
Line 1,367:
 
=={{header|Elena}}==
ELENA 56.0x:
<syntaxhighlight lang="elena">import forms;
import extensions;
Line 1,380:
constructor new()
<= super new()
{
lblClicks := Label.new();
Line 3,561:
 
=={{header|Sidef}}==
===Gtk2===
<syntaxhighlight lang="ruby">require('Gtk2') -> init
 
Line 3,588 ⟶ 3,589:
# Main loop.
%s<Gtk2>.main</syntaxhighlight>
 
===Gtk3===
<syntaxhighlight lang="ruby">use('Gtk3 -init')
 
# Window.
var window = %O'Gtk3::Window'.new
window.signal_connect('destroy' => { %O'Gtk3'.main_quit })
 
# VBox.
var vbox = %O'Gtk3::VBox'.new(0, 0)
window.add(vbox)
 
# Label.
var label = %O'Gtk3::Label'.new('There have been no clicks yet.')
vbox.add(label)
 
# Button.
var count = 0
var button = %O'Gtk3::Button'.new(' Click Me ');
vbox.add(button)
button.signal_connect('clicked' => {
label.set_text(++count)
})
 
# Show.
window.show_all
 
# Main loop.
%O'Gtk3'.main</syntaxhighlight>
 
=={{header|Smalltalk}}==
Line 3,782 ⟶ 3,812:
Me.Caption = clicked & " clicks."
End Sub
</syntaxhighlight>
 
=={{header|V (Vlang)}}==
<syntaxhighlight lang="Zig">
import ui
import gx
 
[heap]
struct App {
mut:
window &ui.Window = unsafe {nil}
counter string = "No clicks yet" // will contain number count
}
 
fn main() {
mut app := &App{}
app.window = ui.window(
width: 200
height: 40
title: "Counter"
mode: .resizable
layout: ui.row(
spacing: 5
margin_: 10
widths: ui.stretch
heights: ui.stretch
children: [
ui.label(
id: "num"
text: &app.counter //refer to struct App
),
ui.button(
text: "Click me"
bg_color: gx.light_gray
radius: 5
border_color: gx.gray
on_click: app.btn_click //refer to function below
),
]
)
)
ui.run(app.window)
}
 
fn (mut app App) btn_click(btn &ui.Button) {
mut lbl := app.window.get_or_panic[ui.Label]("num") //"num" is id of label
app.counter = (app.counter.int() + 1).str() //change to string for label display
lbl.set_text(app.counter)
}
</syntaxhighlight>
 
Line 3,889 ⟶ 3,968:
=={{header|Wren}}==
{{libheader|DOME}}
<syntaxhighlight lang="ecmascriptwren">import "graphics" for Canvas, Color
import "input" for Mouse
import "dome" for Window
9,483

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.