Simple windowed application: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
No edit summary
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(9 intermediate revisions by 8 users not shown)
Line 816:
</syntaxhighlight>
 
=={{header|BaConBASIC}}==
==={{header|BaCon}}===
Requires BaCon version 4.0.1 or higher, using GTK3.
<syntaxhighlight lang="bacon">OPTION GUI TRUE
Line 837 ⟶ 838:
WEND</syntaxhighlight>
 
==={{header|BBC BASIC}}===
{{works with|BBC BASIC for Windows}}
<syntaxhighlight lang="bbcbasic"> INSTALL @lib$+"WINLIB2"
Line 1,366 ⟶ 1,367:
 
=={{header|Elena}}==
ELENA 56.0x:
<syntaxhighlight lang="elena">import forms;
import extensions;
Line 1,379 ⟶ 1,380:
constructor new()
<= super new()
{
lblClicks := Label.new();
Line 1,855 ⟶ 1,856:
<syntaxhighlight>
c=0
p=|p|;v
l=|l|;<"There have been no clicks yet"o
b=|b|;=>c{
c = add(1, @c)
@l<@c
Line 3,377 ⟶ 3,378:
 
=={{header|Red}}==
<syntaxhighlight lang="rebolred">Red []
 
clicks: 0
Line 3,560 ⟶ 3,561:
 
=={{header|Sidef}}==
===Gtk2===
<syntaxhighlight lang="ruby">require('Gtk2') -> init
 
Line 3,587 ⟶ 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,703 ⟶ 3,734:
end
</syntaxhighlight>
 
=={{header|Vala}}==
<syntaxhighlight lang="vala">// GTK 4
public class Example : Gtk.Application {
public Example() {
Object(application_id: "my.application",
flags: ApplicationFlags.FLAGS_NONE);
activate.connect(() => {
var window = new Gtk.ApplicationWindow(this);
var box = new Gtk.Box(Gtk.Orientation.VERTICAL, 20);
var label = new Gtk.Label("There have been no clicks yet");
var button = new Gtk.Button.with_label("click me");
var clicks = 0;
button.clicked.connect(() => {
clicks++;
label.label = "Button clicked " + clicks.to_string() + " times";
});
box.append(label);
box.append(button);
window.set_child(box);
window.present();
});
}
public static int main(string[] argv) {
return new Example().run(argv);
}
}</syntaxhighlight>
 
=={{header|Vedit macro language}}==
Line 3,754 ⟶ 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,861 ⟶ 3,968:
=={{header|Wren}}==
{{libheader|DOME}}
<syntaxhighlight lang="ecmascriptwren">import "graphics" for Canvas, Color
import "input" for Mouse
import "dome" for Window
Line 3,967 ⟶ 4,074:
{{omit from|AWK}}
{{omit from|Batch File|Does not have access to GUI functions.}}
{{omit from|EasyLang}}
{{omit from|GUISS}}
{{omit from|Logtalk}}
9,476

edits