Jump to content

Simple windowed application: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
(added Vala)
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(7 intermediate revisions by 6 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,781 ⟶ 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,888 ⟶ 3,968:
=={{header|Wren}}==
{{libheader|DOME}}
<syntaxhighlight lang="ecmascriptwren">import "graphics" for Canvas, Color
import "input" for Mouse
import "dome" for Window
9,485

edits

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