Simple windowed application: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
(Added Processing implementation)
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(14 intermediate revisions by 11 users not shown)
Line 11:
=={{header|AArch64 Assembly}}==
{{works with|as|Raspberry Pi 3B version Buster 64 bits}}
<syntaxhighlight lang="aarch64 assembly">
<lang AArch64 Assembly>
/* ARM assembly AARCH64 Raspberry PI 3B */
/* program simpleWin64.s link with X11 library */
Line 457:
/* for this file see task include a file in language AArch64 assembly */
.include "../includeARM64.inc"
</syntaxhighlight>
</lang>
 
=={{header|Ada}}==
Line 466:
Apart from GtkAda, there exist numerous other GUI bindings and libraries:
CLAW, AdaGLUT, GWindow, JEWL, win32ada, QtAda etc.
<langsyntaxhighlight lang="ada">with Gdk.Event; use Gdk.Event;
with Gtk.Button; use Gtk.Button;
with Gtk.Label; use Gtk.Label;
Line 532:
 
Gtk.Main.Main;
end Simple_Windowed_Application;</langsyntaxhighlight>
 
=={{header|APL}}==
{{works with|Dyalog APL}}
 
<langsyntaxhighlight APLlang="apl">∇ WindowedApplication
 
⍝ define a form with a label and a button
Line 553:
}
 
∇</langsyntaxhighlight>
 
{{works with|GNU APL}}
 
[my-application.apl]
<langsyntaxhighlight APLlang="apl">#!/usr/local/bin/apl --script --OFF
 
⍝ Some GTK API consts for readability
Line 582:
⍝ Launch GUI application
get_NAME_and_POSITION
</syntaxhighlight>
</lang>
 
[my-application.css]
<langsyntaxhighlight CSSlang="css">/* general button */
.BUTTON { color: #F00; background: #4F4; }
 
/* the OK button */
#OK-button { color: #A22; background: #FFF; }
</syntaxhighlight>
</lang>
 
[my-application.glade]
<langsyntaxhighlight XMLlang="xml"><?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
Line 680:
</object>
</interface>
</syntaxhighlight>
</lang>
 
=={{header|AppleScript}}==
<syntaxhighlight lang="applescript">
<lang Applescript>
set counter to 0
 
Line 699:
if theAnswer is "Quit" then exit repeat
end repeat
</syntaxhighlight>
</lang>
 
===Description===
Line 706:
 
=={{header|AutoHotkey}}==
<langsyntaxhighlight Autohotkeylang="autohotkey">; Create simple windowed application
Gui, Add, Text, vTextCtl, There have been no clicks yet ; add a Text-Control
Gui, Add, Button, gButtonClick xm, click me ; add a Button-Control
Line 719:
GuiClose: ; the subroutine executed when the Window is closed
ExitApp ; exit this process
Return</langsyntaxhighlight>
 
=={{header|AutoIt}}==
<syntaxhighlight lang="autoit">
<lang AutoIt>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
Line 747:
EndSwitch
WEnd
</syntaxhighlight>
</lang>
 
=={{header|B4J}}==
<langsyntaxhighlight lang="freebasic">
#Region Project Attributes
#MainFormWidth: 593
Line 783:
Return falseVal
End If
End Sub</langsyntaxhighlight>
 
Layout1.fxml (as B4J uses JavaFX's Scene Builder)
<langsyntaxhighlight lang="cfm">
<?xml version="1.0" encoding="UTF-8"?>
 
Line 814:
</children>
</AnchorPane>
</syntaxhighlight>
</lang>
 
=={{header|BaConBASIC}}==
==={{header|BaCon}}===
Requires BaCon version 4.0.1 or higher, using GTK3.
<langsyntaxhighlight lang="bacon">OPTION GUI TRUE
PRAGMA GUI gtk3
 
Line 835 ⟶ 836:
CALL GUISET(gui, "label", "label", "Button clicks: " & STR$(clicked))
ENDSELECT
WEND</langsyntaxhighlight>
 
==={{header|BBC BASIC}}===
{{works with|BBC BASIC for Windows}}
<langsyntaxhighlight lang="bbcbasic"> INSTALL @lib$+"WINLIB2"
INSTALL @lib$+"WINLIB5"
Line 856 ⟶ 857:
clicks% += 1
SYS "SetDlgItemText", !window%, 100, "Number of clicks = " + STR$(clicks%)
ENDPROC</langsyntaxhighlight>
 
=={{header|Beads}}==
<langsyntaxhighlight Beadslang="beads">beads 1 program simple title:'Simple windowed application' // written by CodingFiend
 
var g : record // global tracked mutable state
Line 901 ⟶ 902:
// update our click count
inc g.nclicks
g.label = to_str(g.nclicks)</langsyntaxhighlight>
 
=={{header|C}}==
{{libheader|GTK}}
<langsyntaxhighlight lang="c">#include <stdio.h>
#include <gtk/gtk.h>
 
Line 944 ⟶ 945:
gtk_main();
return 0;
}</langsyntaxhighlight>
 
=={{header|C sharp|C#}}==
 
<langsyntaxhighlight lang="csharp">using System.Windows.Forms;
 
class RosettaForm : Form
Line 977 ⟶ 978:
}
}
</syntaxhighlight>
</lang>
 
=={{header|C++}}==
Line 983 ⟶ 984:
{{libheader|Qt}} 4.4 with source files as shown , built from a Makefile generated by the Qt tool qmake
===clickcounter.h===
<langsyntaxhighlight lang="cpp">#ifndef CLICKCOUNTER_H
#define CLICKCOUNTER_H
 
Line 1,003 ⟶ 1,004:
void countClicks( ) ;
} ;
#endif</langsyntaxhighlight>
===clickcounter.cpp===
<langsyntaxhighlight lang="cpp">#include <QPushButton>
#include <QLabel>
#include <QVBoxLayout>
Line 1,024 ⟶ 1,025:
number++ ;
countLabel->setText( QString( "The button has been clicked %1 times!").arg( number ) ) ;
}</langsyntaxhighlight>
===main.cpp===
<langsyntaxhighlight Cpplang="cpp">#include <QApplication>
#include "clickcounter.h"
 
Line 1,034 ⟶ 1,035:
counter.show( ) ;
return app.exec( ) ;
}</langsyntaxhighlight>
 
=={{header|Clojure}}==
<langsyntaxhighlight lang="clojure">(ns counter-window
(:import (javax.swing JFrame JLabel JButton)))
 
Line 1,061 ⟶ 1,062:
(.setDefaultCloseOperation JFrame/EXIT_ON_CLOSE)
(.setVisible true))))
</syntaxhighlight>
</lang>
 
=={{header|Common Lisp}}==
Line 1,069 ⟶ 1,070:
{{works with|McCLIM}}
 
<langsyntaxhighlight lang="lisp">(defpackage #:rcswa
(:use #:clim #:clim-lisp))
(in-package #:rcswa)</langsyntaxhighlight>
 
This version uses CLIM's command system:
 
<langsyntaxhighlight lang="lisp">(define-application-frame simple-windowed-application ()
((clicks :initform 0
:accessor clicks-of))
Line 1,093 ⟶ 1,094:
(define-simple-windowed-application-command (com-click-me :menu t)
()
(incf (clicks-of *application-frame*)))</langsyntaxhighlight>
 
This version uses an explicit pushbutton gadget, and may be used if more direct control over the UI layout and behavior is needed:
 
<langsyntaxhighlight lang="lisp">(define-application-frame simple-windowed-application ()
((clicks :initform 0
:accessor clicks-of))
Line 1,123 ⟶ 1,124:
(vertically (:equalize-width nil :align-x :center)
the-label
(spacing (:thickness 10) the-button)))))</langsyntaxhighlight>
 
In either case, the window is opened with:
 
<langsyntaxhighlight lang="lisp">(run-frame-top-level (make-application-frame 'simple-windowed-application))</langsyntaxhighlight>
 
=={{header|D}}==
Line 1,133 ⟶ 1,134:
{{works with|D|1}}
{{libheader|DFL}}
<langsyntaxhighlight lang="d">module winapp ;
import dfl.all ;
import std.string ;
Line 1,163 ⟶ 1,164:
void main() {
Application.run(new MainForm);
}</langsyntaxhighlight>
 
===Hybrid===
Line 1,185 ⟶ 1,186:
}
SimpleWindow.d:
<langsyntaxhighlight lang="d">module SimpleWindow;
import tango.text.convert.Integer;
import tango.core.Thread; // For Thread.yield
Line 1,220 ⟶ 1,221:
Thread.yield();
}
}</langsyntaxhighlight>
 
=={{header|Delphi}}==
Line 1,230 ⟶ 1,231:
'''NOTE:''' The project name here must match the name of the file.
 
<langsyntaxhighlight lang="delphi">-- begin file --
 
Program SingleWinApp ;
Line 1,316 ⟶ 1,317:
Application.Run ;
 
end. // Program</langsyntaxhighlight>
 
=={{header|E}}==
{{libheader|Swing}}
{{works with|E-on-Java}}
<langsyntaxhighlight lang="e">when (currentVat.morphInto("awt")) -> {
var clicks := 0
def w := <swing:makeJFrame>("Rosetta Code 'Simple Windowed Application'")
Line 1,336 ⟶ 1,337:
w.pack()
w.show()
}</langsyntaxhighlight>
 
=={{header|EchoLisp}}==
UI elements are HTML DOM Nodes. '''ui-add''' adds an element to the UI. '''ui-on-event''' adds a (Lisp) event handler to an element.
<langsyntaxhighlight lang="scheme">
(define (ui-add-button text) ;; helper
(define b (ui-create-element "button" '((type "button"))))
Line 1,363 ⟶ 1,364:
 
(panel)
</syntaxhighlight>
</lang>
 
=={{header|Elena}}==
ELENA 56.0x:
<langsyntaxhighlight lang="elena">import forms;
import extensions;
 
Line 1,379 ⟶ 1,380:
constructor new()
<= super new()
{
lblClicks := Label.new();
Line 1,407 ⟶ 1,408:
lblClicks.Caption := "Clicks: " + clicksCount.toString();
}
}</langsyntaxhighlight>
 
=={{header|Euphoria}}==
===EuWinGUI===
{{libheader|EuWinGUI}}
<langsyntaxhighlight lang="euphoria">include EuWinGUI.ew
 
Window("EuWinGUI - Simple windowed application",100,100,360,100)
Line 1,430 ⟶ 1,431:
end while
 
CloseApp(0)</langsyntaxhighlight>
 
=={{header|F_Sharp|F#}}==
{{trans|C#}}
<langsyntaxhighlight lang="fsharp">open System.Windows.Forms
 
let mutable clickCount = 0
Line 1,449 ⟶ 1,450:
form.Controls.Add(button)
 
Application.Run(form)</langsyntaxhighlight>
 
=={{header|Factor}}==
<langsyntaxhighlight lang="factor">USING: accessors arrays kernel math math.parser namespaces
sequences ui ui.gadgets ui.gadgets.borders ui.gadgets.buttons
ui.gadgets.grids ui.gadgets.labels ui.gadgets.worlds ;
Line 1,478 ⟶ 1,479:
: main ( -- ) 1 n set build-ui ;
 
MAIN: main</langsyntaxhighlight>
 
=={{header|Fantom}}==
 
<langsyntaxhighlight lang="fantom">
using fwt
using gfx
Line 1,512 ⟶ 1,513:
}
}
</syntaxhighlight>
</lang>
 
=={{header|Forth}}==
Line 1,518 ⟶ 1,519:
{{works with|bigFORTH}}
{{libheader|MINOS}}
<langsyntaxhighlight lang="forth">also minos
text-label ptr click-label
Variable click# click# off
Line 1,528 ⟶ 1,529:
click-label assign ]S X" Click me" button new
&2 vabox new panel s" Clicks" assign show endwith ;
click-win</langsyntaxhighlight>
 
===The same with Theseus===
{{works with|bigFORTH}}
{{libheader|Theseus}}
<langsyntaxhighlight lang="forth">#! xbigforth
\ automatic generated code
\ do not edit
Line 1,568 ⟶ 1,569:
$1 0 ?DO stop LOOP bye ;
script? [IF] main [THEN]
previous previous previous</langsyntaxhighlight>
 
 
Line 1,576 ⟶ 1,577:
Creates a GUI with 'wish' from tk library. Uses pipes on standard input and output (created throw linux system calls).
 
<langsyntaxhighlight lang="forth">0 value tk-in
0 value tk-out
variable #clicks
Line 1,610 ⟶ 1,611:
s" rm tk-in tk-out" system ;
 
initiating counting cleaning</langsyntaxhighlight>
 
===with iMops===
{{works with|iMops|2.23}}
Macintosh only - Uses native MacOS GUI calls to Cocoa.
<langsyntaxhighlight lang="forth">
:class TextView' super{ TextView }
:m put: ( addr len -- )
Line 1,629 ⟶ 1,630:
200 30 200 15 setFrame: t
 
\ the running count is always on the stack
0 value cnt
\ so a variable for that is not needed
:noname
1+ \ increment the count
1 ++> cnt
" Number of clicks: " put: t
cntdup deciNumstr insert: t ; setAction: b \ update the text representation of count
 
: go
Line 1,642 ⟶ 1,644:
wview new: w show: w
" click me" setTitle: b
" There have been no clicks yet" put: t ;
0 ; \ the number of clicks start at zero
go</lang>
 
go</syntaxhighlight>
 
=={{header|FreeBASIC}}==
<syntaxhighlight lang="freebasic">
<lang FreeBasic>
#Include "windows.bi"
 
Line 1,681 ⟶ 1,685:
 
End
</syntaxhighlight>
</lang>
 
=={{header|FutureBasic}}==
<langsyntaxhighlight lang="futurebasic">_window = 1
 
begin enum 1
Line 1,719 ⟶ 1,723:
on dialog fn DoDialog
 
HandleEvents</langsyntaxhighlight>
 
=={{header|Gambas}}==
<langsyntaxhighlight lang="gambas">iCount As Integer 'Counter of clicks!
hLabel As Label 'We need a Label
 
Line 1,758 ⟶ 1,762:
hLabel.text = "The button has been clicked " & iCount & " times" 'Display the amount of clicks"
 
End</langsyntaxhighlight>
 
=={{header|Gastona}}==
<langsyntaxhighlight lang="gastona">#javaj#
 
<frames> main, Simple click counter
Line 1,780 ⟶ 1,784:
-->, lClicks data!,, //@<NN> clicks so far
 
</syntaxhighlight>
</lang>
 
=={{header|Go}}==
{{libheader|go-gtk}}
<langsyntaxhighlight lang="go">package main
 
import (
Line 1,816 ⟶ 1,820:
window.ShowAll()
gtk.Main()
}</langsyntaxhighlight>
 
=={{header|Groovy}}==
<langsyntaxhighlight lang="groovy">import groovy.swing.SwingBuilder
 
count = 0
Line 1,829 ⟶ 1,833:
}
}
}</langsyntaxhighlight>
 
'''with binding:'''
<langsyntaxhighlight lang="groovy">import groovy.swing.SwingBuilder
import groovy.beans.Bindable
 
Line 1,847 ⟶ 1,851:
}
}
}</langsyntaxhighlight>
 
=={{header|Guish}}==
<syntaxhighlight>
c=0
p=|p|;v
l=|l|;<"There have been no clicks yet"o
b=|b|;=>c{
c = add(1, @c)
@l<@c
}<"click me"
@p<<<@b<<<@l
@l w
@p,o+
</syntaxhighlight>
 
=={{header|Haskell}}==
{{libheader|Gtk}} from [http://hackage.haskell.org/packages/hackage.html HackageDB]
<langsyntaxhighlight lang="haskell">import Graphics.UI.Gtk
import Data.IORef
 
Line 1,880 ⟶ 1,898:
widgetShowAll window
 
mainGUI</langsyntaxhighlight>
 
=={{header|HicEst}}==
<langsyntaxhighlight lang="hicest"> CHARACTER label="There have been no clicks yet"
 
DO count = 1, 1E100 ! "forever"
Line 1,890 ⟶ 1,908:
ENDDO
 
END</langsyntaxhighlight>
 
==Icon and {{header|Unicon}}==
 
This version is Unicon-specific:
<langsyntaxhighlight lang="unicon">import gui
$include "guih.icn"
 
Line 1,925 ⟶ 1,943:
initially
self.Dialog.initially()
end</langsyntaxhighlight>
 
=={{header|IDL}}==
<langsyntaxhighlight lang="idl">pro counter, ev
widget_control, ev.top, get_uvalue=tst
tst[1] = tst[1]+1
Line 1,941 ⟶ 1,959:
xmanager, "Simple", Id
end</langsyntaxhighlight>
 
=={{header|J}}==
'''J 9.x''' (note: the J 8.x version works fine under J 9.x)<syntaxhighlight lang="j">simple_run=: {{
simple_clicks=: 0 NB. initialize accumulator
wd {{)n
pc simple closeok escclose;
cc click button;cn "Click me";
cc message static;cn "There have been no clicks yet.";
pshow;
}}}}
simple_run''
simple_click_button=: {{wd 'set message text Button-use count: ',": simple_clicks=: 1+simple_clicks}}</syntaxhighlight>
'''J 8.x'''
<langsyntaxhighlight lang="j">SIMPLEAPP=: noun define
pc simpleApp;
cc inc button;cn "Click me";
Line 1,964 ⟶ 1,993:
simpleApp_cancel=: simpleApp_close
 
simpleApp_run''</langsyntaxhighlight>
 
'''J 6.x'''
<langsyntaxhighlight lang="j">SIMPLEAPP=: noun define
pc simpleApp;
xywh 131 11 44 12;cc inc button;cn "Click me";
Line 1,988 ⟶ 2,017:
simpleApp_cancel=: simpleApp_close
 
simpleApp_run''</langsyntaxhighlight>
 
=={{header|Java}}==
{{libheader|AWT}}
{{libheader|Swing}}
<langsyntaxhighlight lang="java">import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
Line 2,030 ⟶ 2,059:
);
}
}</langsyntaxhighlight>
 
=={{header|JavaFX Script}}==
{{libheader|JavaFX 1.2}}
<langsyntaxhighlight lang="javafx">import javafx.stage.*;
import javafx.scene.*;
import javafx.scene.layout.*;
Line 2,058 ⟶ 2,087:
}
}
}</langsyntaxhighlight>
 
=={{header|JavaScript}}==
<syntaxhighlight lang="javascript">
<lang JavaScript>
<html>
<head>
Line 2,091 ⟶ 2,120:
 
</html>
</syntaxhighlight>
</lang>
 
[http://melellington.com/simplewindow/javascript-simple-window.html Javascript Output]
Line 2,099 ⟶ 2,128:
=={{header|Julia}}==
Uses the Gtk library.
<langsyntaxhighlight lang="julia">using Gtk.ShortNames
 
function clickwindow()
Line 2,120 ⟶ 2,149:
 
clickwindow()
</syntaxhighlight>
</lang>
 
=={{header|Kotlin}}==
{{trans|Java}}
<langsyntaxhighlight lang="scala">// version 1.0.6
 
import java.awt.BorderLayout
Line 2,161 ⟶ 2,190:
fun main(args: Array<String>) {
Clicks() // call the constructor where all the magic happens
}</langsyntaxhighlight>
 
{{libheader|TornadoFX}}
<langsyntaxhighlight lang="scala">
import tornadofx.*
 
Line 2,178 ⟶ 2,207:
 
fun main(args: Array<String>) = launch<ClicksApp>(args)
</syntaxhighlight>
</lang>
 
=={{header|Lambdatalk}}==
Line 2,184 ⟶ 2,213:
 
The code is tested in this page: http://epsilonwiki.free.fr/lambdaway/?view=popup
<syntaxhighlight lang="scheme">
<lang Scheme>
1) the label: {div {@ id="label"} There have been no clicks yet }
2) the button: {input {@ type="button" value="click me" onclick="CLICKAPP.inc()" }}
Line 2,198 ⟶ 2,227:
return {inc:inc}
})();
</syntaxhighlight>
</lang>
 
=={{header|Liberty BASIC}}==
<langsyntaxhighlight lang="lb">nomainwin
button #demo.btn, "Click Me", [btnClick], UL, 20, 50
statictext #demo.num, "There have been no clicks yet.", 20, 100, 240, 30
Line 2,216 ⟶ 2,245:
nClicks = nClicks + 1
#demo.num "The button has been clicked ";nClicks;" times."
wait</langsyntaxhighlight>
 
=={{header|Lingo}}==
The standard approach in Lingo for creating GUIs and assigning scripts for handling user interaction is to use the graphical IDE/GUI-Builder "Director". But windows and sprites (visual elements) can also be created and scripted programmatically only:
<langsyntaxhighlight lang="lingo">on startMovie
 
-- window settings
Line 2,266 ⟶ 2,295:
_movie.stage.visible = 1
 
end</langsyntaxhighlight>
 
 
Line 2,277 ⟶ 2,306:
is in the object's message path so the button works well.
 
<langsyntaxhighlight LiveCodelang="livecode">global count
on openCard
put empty into count
Line 2,285 ⟶ 2,314:
add 1 to count
put count into field "clicks"
end mouseUp</langsyntaxhighlight>
 
[http://melellington.com/simplewindow/livecode-simple-window.jpg LiveCode Output]
Line 2,297 ⟶ 2,326:
{{works with|MSWlogo}}
 
<langsyntaxhighlight lang="logo">to clickwindow
windowCreate "root "clickWin [Click that button!!!] 0 0 100 100 []
Make "i 0
Line 2,305 ⟶ 2,334:
ifelse :i=1 [staticUpdate "clickSt (list "clicked :i "time)] ~
[staticUpdate "clickSt (list "clicked :i "times)]]
end</langsyntaxhighlight>
 
The window is opened with:
<syntaxhighlight lang ="logo">clickwindow</langsyntaxhighlight>
 
=={{header|Lua}}==
<langsyntaxhighlight lang="lua">require"iuplua"
l = iup.label{title="There have been no clicks yet."}
b = iup.button{title="Click me!"}
Line 2,324 ⟶ 2,353:
if (not iup.MainLoopLevel or iup.MainLoopLevel()==0) then
iup.MainLoop()
end</langsyntaxhighlight>
 
=={{header|M2000 Interpreter}}==
Line 2,334 ⟶ 2,363:
 
 
<syntaxhighlight lang="m2000 interpreter">
<lang M2000 Interpreter>
Module CheckIt {
Declare Form1 Form
Line 2,353 ⟶ 2,382:
}
Checkit
</syntaxhighlight>
</lang>
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<langsyntaxhighlight Mathematicalang="mathematica">DynamicModule[{n = 0},
CreateDialog[{Dynamic@
TextCell@If[n == 0, "There have been no clicks yet", n],
Button["click me", n++]}]]</langsyntaxhighlight>
 
=={{header|MAXScript}}==
<langsyntaxhighlight lang="maxscript">rollout buttonClick "Button Click"
(
label l "There have been no clicks yet"
Line 2,374 ⟶ 2,403:
)
)
createDialog buttonClick</langsyntaxhighlight>
 
=={{header|Modula-3}}==
Line 2,380 ⟶ 2,409:
 
This code uses <tt>Trestle</tt>, a windowing toolkit developed for Modula-3.
<langsyntaxhighlight lang="modula3">MODULE Click EXPORTS Main;
 
IMPORT Fmt, TextVBT, ButtonVBT, VBT, Axis, HVSplit, TrestleComm, Trestle;
Line 2,399 ⟶ 2,428:
Trestle.Install(main);
Trestle.AwaitDelete(main);
END Click.</langsyntaxhighlight>
 
To compile the above code, you need to create a file called <tt>m3makefile</tt> which contains:
Line 2,410 ⟶ 2,439:
 
=={{header|Nanoquery}}==
<langsyntaxhighlight lang="nanoquery">import Nanoquery.Util.Windows
 
// define the necessary objects
Line 2,444 ⟶ 2,473:
 
// show the window
$w.show()</langsyntaxhighlight>
 
=={{header|Nim}}==
{{libheader|GTK2}}
<langsyntaxhighlight lang="nim">import gtk2
 
nim_init()
Line 2,470 ⟶ 2,499:
discard button.signal_connect("clicked", SignalFunc clickedMe, label)
win.showAll()
main()</langsyntaxhighlight>
 
=={{header|Objective-C}}==
{{works with|GNUstep}}
<langsyntaxhighlight lang="objc">#include <Foundation/Foundation.h>
#include <AppKit/AppKit.h>
 
Line 2,486 ⟶ 2,515:
- (BOOL)applicationShouldTerminateAfterLastWindowClosed: (NSNotification *)notification;
- (void)advanceCounter: (id)sender;
@end</langsyntaxhighlight>
 
<langsyntaxhighlight lang="objc">@implementation ClickMe : NSWindow
-(instancetype) init
{
Line 2,558 ⟶ 2,587:
}
return 0;
}</langsyntaxhighlight>
 
=={{header|OCaml}}==
* with '''Labltk''', the '''Tk''' OCaml binding:
<langsyntaxhighlight lang="ocaml">#directory "+labltk"
#load "labltk.cma"
 
Line 2,577 ⟶ 2,606:
Tk.pack [Tk.coe label; Tk.coe b];
Tk.mainLoop ();
;;</langsyntaxhighlight>
 
* with '''LablGTK2''', the '''GTK2''' OCaml binding:
<langsyntaxhighlight lang="ocaml">open GMain
 
let window = GWindow.window ~border_width:2 ()
Line 2,592 ⟶ 2,621:
button#connect#clicked ~callback:window#destroy;
window#show ();
Main.main ()</langsyntaxhighlight>
 
=={{header|ooRexx}}==
<langsyntaxhighlight lang="oorexx">/* REXX ***************************************************************************************
* 18.06.2014 Walter Pachl shortened from Rony Flatscher's bsf4oorexx (see sourceforge) samples
* Look there for ShowCount.rxj
Line 2,679 ⟶ 2,708:
Otherwise how_often=userData~i 'times'
End
userData~label~setText("Button was pressed" how_often) -- display text</langsyntaxhighlight>
 
=={{header|Oz}}==
<langsyntaxhighlight lang="oz">functor
import
Application
Line 2,700 ⟶ 2,729:
{Window show}
end
</syntaxhighlight>
</lang>
 
=={{header|Pascal}}==
Line 2,708 ⟶ 2,737:
{{libheader|Gtk2}}
Ported from the C example.
<langsyntaxhighlight lang="pascal">Program SimpleWindowApplication;
 
uses
Line 2,754 ⟶ 2,783:
Gtk_widget_show_all(Gtk_WIDGET(win));
Gtk_main();
end.</langsyntaxhighlight>
 
=={{header|Perl}}==
==={{libheader|Perl/Tk}}===
<langsyntaxhighlight lang="perl">use Tk;
 
$main = MainWindow->new;
Line 2,767 ⟶ 2,796:
-command => sub { $l->configure(-text => 'Number of clicks: '.(++$count).'.'); },
)->pack;
MainLoop();</langsyntaxhighlight>
 
==={{libheader|GTK}} {{works with|Perl/Gtk}}===
<langsyntaxhighlight lang="perl">use Gtk '-init';
 
# Window.
Line 2,796 ⟶ 2,825:
 
# Main loop.
Gtk->main;</langsyntaxhighlight>
 
=={{header|Phix}}==
Line 2,803 ⟶ 2,832:
{{libheader|Phix/online}}
You can run this online [http://phix.x10.mx/p2js/simplewindow.htm here].
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<span style="color: #000080;font-style:italic;">-- demo\rosetta\Simple_window.exw</span>
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
Line 2,828 ⟶ 2,857:
<span style="color: #7060A8;">IupClose</span><span style="color: #0000FF;">()</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<!--</langsyntaxhighlight>-->
The above is cross platform, win/lnx, 32/64 bit, and runs in a browser.
An older win32-only version can be found [[Simple_windowed_application/Arwen|here]].
Line 2,835 ⟶ 2,864:
The standard PicoLisp GUI is HTTP based. Connect your browser to
http://localhost:8080 after starting the following script.
<langsyntaxhighlight PicoLisplang="picolisp">#!/usr/bin/picolisp /usr/lib/picolisp/lib.l
 
(load "@ext.l" "@lib/http.l" "@lib/xhtml.l" "@lib/form.l")
Line 2,853 ⟶ 2,882:
 
(server 8080 "!start")
(wait)</langsyntaxhighlight>
 
=={{header|Pike}}==
{{libheader|Gtk2}}
<langsyntaxhighlight Pikelang="pike">GTK2.Widget mainwindow,clickcnt,clicker;
int clicks;
 
Line 2,878 ⟶ 2,907:
return -1;
}
</syntaxhighlight>
</lang>
 
=={{header|PowerShell}}==
===Windows Forms===
{{works with|PowerShell|3}}
<syntaxhighlight lang="powershell">
<lang PowerShell>
$Label1 = [System.Windows.Forms.Label]@{
Text = 'There have been no clicks yet'
Line 2,904 ⟶ 2,933:
$Result = $Form1.ShowDialog()
</syntaxhighlight>
</lang>
{{works with|PowerShell|2}}
<syntaxhighlight lang="powershell">
<lang PowerShell>
Add-Type -AssemblyName System.Windows.Forms
Line 2,930 ⟶ 2,959:
$Result = $Form1.ShowDialog()
</syntaxhighlight>
</lang>
===WPF===
<syntaxhighlight lang="powershell">
<lang PowerShell>
[xml]$Xaml = @"
<Window
Line 2,971 ⟶ 3,000:
$Result = $Window1.ShowDialog()
</syntaxhighlight>
</lang>
 
=={{header|Processing}}==
<langsyntaxhighlight lang="java">
//Aamrun, 11th July 2022
 
Line 3,020 ⟶ 3,049:
 
 
</syntaxhighlight>
</lang>
 
=={{header|Prolog}}==
Works with SWI-Prolog and XPCE.
<langsyntaxhighlight Prologlang="prolog">:- dynamic click/1.
 
dialog('Simple windowed application',
Line 3,066 ⟶ 3,095:
send(D, open).
 
</syntaxhighlight>
</lang>
 
=={{header|PureBasic}}==
<langsyntaxhighlight PureBasiclang="purebasic">Define window_0
Define window_0_Text_0, window_0_Button_1
Define clicks, txt$, flags
Line 3,095 ⟶ 3,124:
EndSelect
ForEver
EndIf</langsyntaxhighlight>
 
=={{header|Python}}==
Line 3,101 ⟶ 3,130:
==={{libheader|Tkinter}}===
{{works with|Python|3.7}}
<langsyntaxhighlight lang="python">from functools import partial
import tkinter as tk
 
Line 3,127 ⟶ 3,156:
if __name__ == '__main__':
main()
</syntaxhighlight>
</lang>
 
The same in OO manner:
<langsyntaxhighlight lang="python">import tkinter as tk
 
class ClickCounter(tk.Frame):
Line 3,151 ⟶ 3,180:
if __name__ == "__main__":
ClickCounter().mainloop()
</syntaxhighlight>
</lang>
 
==={{libheader|PyQt}}===
<langsyntaxhighlight lang="python">from functools import partial
from itertools import count
 
Line 3,190 ⟶ 3,219:
if __name__ == '__main__':
main()
</syntaxhighlight>
</lang>
 
==={{libheader|wxPython}}===
<langsyntaxhighlight lang="python">import wx
 
 
Line 3,228 ⟶ 3,257:
frame.Show()
app.MainLoop()
</syntaxhighlight>
</lang>
 
=={{header|R}}==
Line 3,236 ⟶ 3,265:
 
gWidgetsRGtk2 or gWidgetsrJava can be used as an alternative to gWidgetstcltk.
<langsyntaxhighlight lang="r">library(gWidgets)
library(gWidgetstcltk)
win <- gwindow()
Line 3,245 ⟶ 3,274:
svalue(lab) <- ifelse(is.na(val) ,"1", as.character(val + 1))
}
)</langsyntaxhighlight>
 
=={{header|Racket}}==
 
<langsyntaxhighlight lang="racket">
#lang racket/gui
 
Line 3,261 ⟶ 3,290:
(new button% [parent frame] [label "Click me"] [callback cb])
(send frame show #t)
</syntaxhighlight>
</lang>
 
=={{header|Raku}}==
(formerly Perl 6)
{{libheader|GTK}}
<syntaxhighlight lang="raku" perl6line>use GTK::Simple;
use GTK::Simple::App;
 
Line 3,287 ⟶ 3,316:
}
 
$app.run;</langsyntaxhighlight>
 
=={{header|RapidQ}}==
RapidQ has form designer that produces RapidQ Basic source code. You can get the same result by writing the code yourself with a text editor. Then compile it either from within IDE or by using the command line compiler.
 
<langsyntaxhighlight lang="rapidq">DECLARE SUB buttonClick
 
CREATE form AS QForm
Line 3,317 ⟶ 3,346:
END SUB
 
form.ShowModal</langsyntaxhighlight>
 
=={{header|REBOL}}==
<langsyntaxhighlight REBOLlang="rebol">REBOL [
Title: "Simple Windowed Application"
URL: http://rosettacode.org/wiki/Simple_Windowed_Application
Line 3,346 ⟶ 3,375:
set-face label reform ["clicks:" clicks]
]
]</langsyntaxhighlight>
 
=={{header|Red}}==
<langsyntaxhighlight rebollang="red">Red []
 
clicks: 0
Line 3,359 ⟶ 3,388:
t/data: rejoin ["clicks: " clicks]
]
]</langsyntaxhighlight>
 
=={{header|Ring}}==
<langsyntaxhighlight lang="ring">
Load "guilib.ring"
 
Line 3,384 ⟶ 3,413:
num += 1
lineedit1.settext( "you clicked me " + num + " times")
</syntaxhighlight>
</lang>
Output:
 
Line 3,391 ⟶ 3,420:
=={{header|Ruby}}==
{{libheader|Ruby/Tk}}
<langsyntaxhighlight lang="ruby">require 'tk'
str = TkVariable.new("no clicks yet")
count = 0
Line 3,401 ⟶ 3,430:
pack
end
Tk.mainloop</langsyntaxhighlight>
 
{{libheader|Shoes}}
<langsyntaxhighlight lang="ruby">Shoes.app do
stack do
@count = 0
Line 3,413 ⟶ 3,442:
end
end
end</langsyntaxhighlight>
 
=={{header|Run BASIC}}==
<langsyntaxhighlight lang="runbasic">msg$ = "There have been no clicks yet"
[loop] cls ' clear screen
print msg$
Line 3,425 ⟶ 3,454:
clicks = clicks + 1
msg$ = "Button has been clicked ";clicks;" times"
goto [loop]</langsyntaxhighlight>
 
=={{header|Rust}}==
{{libheader|iced}}
<langsyntaxhighlight Rustlang="rust">use iced::{ // 0.2.0
button, Button, Column, Element, Length,
Text, Sandbox, Settings, Space,
Line 3,482 ⟶ 3,511:
settings.window.size = (600, 400);
Simple::run(settings).unwrap();
}</langsyntaxhighlight>
 
=={{header|Scala}}==
{{libheader|Scala}}
<langsyntaxhighlight Scalalang="scala">import scala.swing.{ BorderPanel, Button, Label, MainFrame, SimpleSwingApplication }
import scala.swing.event.ButtonClicked
 
Line 3,507 ⟶ 3,536:
}
}
}</langsyntaxhighlight>
 
 
=={{header|Scratch}}==
<syntaxhighlight lang="scratch">
<lang Scratch>
when flag clicked # when program is run
set counter to "0" # initialize counter object to zero
Line 3,520 ⟶ 3,549:
hide message # hide the initial message
change counter by 1 # increment the counter object
</syntaxhighlight>
</lang>
 
'''Comments and Description:'''<br>
Line 3,532 ⟶ 3,561:
 
=={{header|Sidef}}==
===Gtk2===
<lang ruby>require('Gtk2') -> init
<syntaxhighlight lang="ruby">require('Gtk2') -> init
 
# Window.
Line 3,558 ⟶ 3,588:
 
# Main loop.
%s<Gtk2>.main</langsyntaxhighlight>
 
===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}}==
{{works with|Smalltalk/X}}
<langsyntaxhighlight lang="smalltalk">|top clickCount lh button|
 
clickCount := 0.
Line 3,577 ⟶ 3,636:
].
 
top open</langsyntaxhighlight>
 
=={{header|Standard ML}}==
Works with PolyML
<langsyntaxhighlight Standardlang="standard MLml">open XWindows ;
open Motif ;
Line 3,608 ⟶ 3,667:
end;
</syntaxhighlight>
</lang>
call
countWindow () ;
Line 3,615 ⟶ 3,674:
=={{header|Tcl}}==
{{libheader|Tk}}
<langsyntaxhighlight lang="tcl">package require Tk
pack [label .l -text "There have been no clicks yet"]
set count 0
Line 3,621 ⟶ 3,680:
proc upd {} {
.l configure -text "Number of clicks: [incr ::count]"
}</langsyntaxhighlight>
 
=={{header|TI-89 BASIC}}==
Line 3,627 ⟶ 3,686:
The Ti-89 does not have general onscreen buttons; this program uses the OK/Cancel choice of a dialog box to implement the UI.
 
<langsyntaxhighlight lang="ti89b">Prgm
Local clicks
0 → clicks
Line 3,638 ⟶ 3,697:
clicks + 1 → clicks
EndWhile
EndPrgm</langsyntaxhighlight>
 
=={{header|Unicon}}==
 
<langsyntaxhighlight lang="unicon">
import gui
$include "guih.icn"
Line 3,674 ⟶ 3,733:
d.show_modal()
end
</syntaxhighlight>
</lang>
 
=={{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}}==
<langsyntaxhighlight lang="vedit">Reg_Set(10, "There have been no clicks yet")
#1 = 0
repeat (ALL) {
Line 3,689 ⟶ 3,775:
Reg_Set(10, "Clicked", INSERT)
Reg_Set(10, " times", APPEND)
}</langsyntaxhighlight>
 
=={{header|Visual Basic}}==
In VB, windows are usually created in the IDE. The generated code is hidden from the user unless viewed outside of VB. For the sake of this task, I have included that code, but normally it is hidden from the programmer.
 
<langsyntaxhighlight lang="vb">VERSION 5.00
Begin VB.Form Form2
Caption = "There have been no clicks yet"
Line 3,726 ⟶ 3,812:
Me.Caption = clicked & " clicks."
End Sub
</syntaxhighlight>
</lang>
 
=={{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>
 
=={{header|Web 68}}==
<langsyntaxhighlight lang="web68">@1Introduction.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public Licence as published by
Line 3,829 ⟶ 3,964:
The predefined form was created by the <b>fdesign</b> program for the Xforms library,
and the resulting form definition file was converted to Web 68 by the program
<b>fdtow68</b>.</langsyntaxhighlight>
 
=={{header|Wren}}==
{{libheader|DOME}}
<langsyntaxhighlight ecmascriptlang="wren">import "graphics" for Canvas, Color
import "input" for Mouse
import "dome" for Window
Line 3,876 ⟶ 4,011:
}
 
var Game = SimpleWindowedApplication.new(600, 600)</langsyntaxhighlight>
 
=={{header|XPL0}}==
<langsyntaxhighlight XPL0lang="xpl0">include c:\cxpl\stdlib; \standard library provides mouse routines, etc.
def Ww=40, Wh=12, Wx=(80-Ww)/2, Wy=(25-Wh)/2; \window width, etc.
def Bw=11, Bh=4, Bx=Wx+(Ww-Bw)/2, By=Wy+3*(Wh-Bh)/4; \button size & position
Line 3,908 ⟶ 4,043:
until ChkKey; \keystroke terminates program
SetVid(3); \turn off mouse and turn on flashing cursor
]</langsyntaxhighlight>
 
=={{header|Yorick}}==
Yorick does not include a GUI toolkit. However, it does provide a plotting system that can emulate some basic GUI features, such as buttons and labels. The above sample uses a built-in library "button.i", which is itself written in Yorick.
 
<langsyntaxhighlight lang="yorick">#include "button.i"
 
window, 0;
Line 3,934 ⟶ 4,069:
winkill, 0;
}
} while(!finished);</langsyntaxhighlight>
 
{{omit from|ACL2}}
{{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