GUI enabling/disabling of controls: Difference between revisions
Content added Content deleted
(Add Red) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 52: | Line 52: | ||
disabling.adb: |
disabling.adb: |
||
< |
<syntaxhighlight lang="ada">with Ada.Strings.Fixed; |
||
with Gtk.Main; |
with Gtk.Main; |
||
with Gtk.Handlers; |
with Gtk.Handlers; |
||
Line 220: | Line 220: | ||
Gtk.Main.Main; |
Gtk.Main.Main; |
||
end Disabling;</ |
end Disabling;</syntaxhighlight> |
||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |
||
< |
<syntaxhighlight lang="autohotkey">GUI, Add, Edit, w150 number vValue gEnableDisable, 0 ; Number specifies a numbers-only edit field. g<Subroutine> specifies a subroutine to run when the value of control changes. |
||
GUI, Add, button,, Increment |
GUI, Add, button,, Increment |
||
GUI, Add, button, xp+70 yp, Decrement ; xp+70 and yp are merely positioning options |
GUI, Add, button, xp+70 yp, Decrement ; xp+70 and yp are merely positioning options |
||
Line 267: | Line 267: | ||
GuiClose: |
GuiClose: |
||
ExitApp |
ExitApp |
||
; Ensures the script ends when the GUI is closed.</ |
; Ensures the script ends when the GUI is closed.</syntaxhighlight> |
||
=={{header|BaCon}}== |
=={{header|BaCon}}== |
||
This code requires BaCon 4.0.1 or higher. |
This code requires BaCon 4.0.1 or higher. |
||
< |
<syntaxhighlight lang="bacon">OPTION GUI TRUE |
||
PRAGMA GUI gtk3 |
PRAGMA GUI gtk3 |
||
Line 304: | Line 304: | ||
CALL GUISET(gui, "spin", "sensitive", IIF(input = 0, TRUE, FALSE)) |
CALL GUISET(gui, "spin", "sensitive", IIF(input = 0, TRUE, FALSE)) |
||
WEND</ |
WEND</syntaxhighlight> |
||
=={{header|BBC BASIC}}== |
=={{header|BBC BASIC}}== |
||
{{works with|BBC BASIC for Windows}} |
{{works with|BBC BASIC for Windows}} |
||
< |
<syntaxhighlight lang="bbcbasic"> INSTALL @lib$+"WINLIB2" |
||
INSTALL @lib$+"WINLIB5" |
INSTALL @lib$+"WINLIB5" |
||
ES_NUMBER = 8192 |
ES_NUMBER = 8192 |
||
Line 344: | Line 344: | ||
SYS "GetDlgItemInt", !form%, 101, 0, 1 TO number% |
SYS "GetDlgItemInt", !form%, 101, 0, 1 TO number% |
||
SYS "SetDlgItemInt", !form%, 101, number% - 1, 1 |
SYS "SetDlgItemInt", !form%, 101, number% - 1, 1 |
||
ENDPROC</ |
ENDPROC</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<p> |
<p> |
||
Line 354: | Line 354: | ||
<pre>file main.c</pre> |
<pre>file main.c</pre> |
||
< |
<syntaxhighlight lang="c">#include <windows.h> |
||
#include "resource.h" |
#include "resource.h" |
||
Line 433: | Line 433: | ||
EnableWindow( GetDlgItem(hwnd,IDC_INCREMENT), n<MAX_VALUE ); |
EnableWindow( GetDlgItem(hwnd,IDC_INCREMENT), n<MAX_VALUE ); |
||
EnableWindow( GetDlgItem(hwnd,IDC_DECREMENT), n>MIN_VALUE ); |
EnableWindow( GetDlgItem(hwnd,IDC_DECREMENT), n>MIN_VALUE ); |
||
}</ |
}</syntaxhighlight> |
||
<pre>file resource.h</pre> |
<pre>file resource.h</pre> |
||
< |
<syntaxhighlight lang="c">#define IDD_DLG 101 |
||
#define IDC_INPUT 1001 |
#define IDC_INPUT 1001 |
||
#define IDC_INCREMENT 1002 |
#define IDC_INCREMENT 1002 |
||
#define IDC_DECREMENT 1003 |
#define IDC_DECREMENT 1003 |
||
#define IDC_QUIT 1004</ |
#define IDC_QUIT 1004</syntaxhighlight> |
||
<pre>file resource.rc</pre> |
<pre>file resource.rc</pre> |
||
< |
<syntaxhighlight lang="c">#include <windows.h> |
||
#include "resource.h" |
#include "resource.h" |
||
Line 458: | Line 458: | ||
PUSHBUTTON "Quit", IDC_QUIT, 117, 25, 30, 14 |
PUSHBUTTON "Quit", IDC_QUIT, 117, 25, 30, 14 |
||
RTEXT "Value:", -1, 10, 8, 20, 8 |
RTEXT "Value:", -1, 10, 8, 20, 8 |
||
}</ |
}</syntaxhighlight> |
||
=={{header|C sharp}}== |
=={{header|C sharp}}== |
||
Using Windows Forms; compile with csc -t:winexe Program.cs (on MS.NET) or gmcs -t:winexe Program.cs (on Mono) |
Using Windows Forms; compile with csc -t:winexe Program.cs (on MS.NET) or gmcs -t:winexe Program.cs (on Mono) |
||
< |
<syntaxhighlight lang="csharp">using System; |
||
using System.ComponentModel; |
using System.ComponentModel; |
||
using System.Windows.Forms; |
using System.Windows.Forms; |
||
Line 543: | Line 543: | ||
Application.Run(new RosettaInteractionForm()); |
Application.Run(new RosettaInteractionForm()); |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
=={{header|C++}}== |
=={{header|C++}}== |
||
with Qt 4.4, creating project file with qmake -project, Makefile with qmake -o Makefile <projectfile> and finally make |
with Qt 4.4, creating project file with qmake -project, Makefile with qmake -o Makefile <projectfile> and finally make |
||
<pre>file task.h</pre> |
<pre>file task.h</pre> |
||
< |
<syntaxhighlight lang="cpp">#ifndef TASK_H |
||
#define TASK_H |
#define TASK_H |
||
Line 577: | Line 577: | ||
QHBoxLayout *lowerPart ; |
QHBoxLayout *lowerPart ; |
||
} ; |
} ; |
||
#endif</ |
#endif</syntaxhighlight> |
||
<pre>file task.cpp</pre> |
<pre>file task.cpp</pre> |
||
< |
<syntaxhighlight lang="cpp">#include <QtGui> |
||
#include <QString> |
#include <QString> |
||
#include "task.h" |
#include "task.h" |
||
Line 633: | Line 633: | ||
number-- ; |
number-- ; |
||
entryField->setText( QString("%1").arg( number )) ; |
entryField->setText( QString("%1").arg( number )) ; |
||
}</ |
}</syntaxhighlight> |
||
<pre>main.cpp</pre> |
<pre>main.cpp</pre> |
||
< |
<syntaxhighlight lang="cpp">#include <QApplication> |
||
#include "task.h" |
#include "task.h" |
||
Line 644: | Line 644: | ||
theWidget.show( ) ; |
theWidget.show( ) ; |
||
return app.exec( ) ; |
return app.exec( ) ; |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Delphi}}== |
=={{header|Delphi}}== |
||
< |
<syntaxhighlight lang="delphi">type |
||
TForm1 = class(TForm) |
TForm1 = class(TForm) |
||
MaskEditValue: TMaskEdit; // Set Editmask on: "99;0; " |
MaskEditValue: TMaskEdit; // Set Editmask on: "99;0; " |
||
Line 677: | Line 677: | ||
begin |
begin |
||
MaskEditValue.Text := IntToStr(Succ(StrToIntDef(Trim(MaskEditValue.Text), 0))); |
MaskEditValue.Text := IntToStr(Succ(StrToIntDef(Trim(MaskEditValue.Text), 0))); |
||
end;</ |
end;</syntaxhighlight> |
||
=={{header|Fantom}}== |
=={{header|Fantom}}== |
||
< |
<syntaxhighlight lang="fantom">using fwt |
||
using gfx |
using gfx |
||
Line 748: | Line 748: | ||
}.open |
}.open |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
=={{header|FreeBASIC}}== |
=={{header|FreeBASIC}}== |
||
<syntaxhighlight lang="freebasic"> |
|||
<lang FreeBASIC> |
|||
#Include "windows.bi" |
#Include "windows.bi" |
||
Line 789: | Line 789: | ||
End |
End |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Gambas}}== |
=={{header|Gambas}}== |
||
< |
<syntaxhighlight lang="gambas">hValueBox As ValueBox 'We need a ValueBox |
||
hButton0 As Button 'We need a button |
hButton0 As Button 'We need a button |
||
hButton1 As Button 'We need another button |
hButton1 As Button 'We need another button |
||
Line 870: | Line 870: | ||
Checks 'Rune the Checks routine |
Checks 'Rune the Checks routine |
||
End</ |
End</syntaxhighlight> |
||
=={{header|Go}}== |
=={{header|Go}}== |
||
{{libheader|Gotk3}} |
{{libheader|Gotk3}} |
||
Loosely based on the Vala entry. |
Loosely based on the Vala entry. |
||
< |
<syntaxhighlight lang="go">package main |
||
import ( |
import ( |
||
Line 996: | Line 996: | ||
window.ShowAll() |
window.ShowAll() |
||
gtk.Main() |
gtk.Main() |
||
}</ |
}</syntaxhighlight> |
||
==Icon and {{header|Unicon}}== |
==Icon and {{header|Unicon}}== |
||
Line 1,002: | Line 1,002: | ||
This uses the Unicon specific graphics library. |
This uses the Unicon specific graphics library. |
||
<syntaxhighlight lang="unicon"> |
|||
<lang Unicon> |
|||
import gui |
import gui |
||
$include "guih.icn" |
$include "guih.icn" |
||
Line 1,090: | Line 1,090: | ||
w.show_modal () |
w.show_modal () |
||
end |
end |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|J}}== |
=={{header|J}}== |
||
'''J 8.x''' |
'''J 8.x''' |
||
< |
<syntaxhighlight lang="j">task_run=: wd bind (noun define) |
||
pc task nosize; |
pc task nosize; |
||
cc decrement button;cn "Decrement"; |
cc decrement button;cn "Decrement"; |
||
Line 1,119: | Line 1,119: | ||
task_decrement_button=:verb define |
task_decrement_button=:verb define |
||
update Value=: ": _1 + 0 ". Value |
update Value=: ": _1 + 0 ". Value |
||
)</ |
)</syntaxhighlight> |
||
'''J 6.x''' |
'''J 6.x''' |
||
< |
<syntaxhighlight lang="j">task_run=: wd bind (noun define) |
||
pc task nosize; |
pc task nosize; |
||
xywh 6 30 48 12;cc decrement button;cn "-"; |
xywh 6 30 48 12;cc decrement button;cn "-"; |
||
Line 1,145: | Line 1,145: | ||
task_decrement_button=:verb define |
task_decrement_button=:verb define |
||
update Value=: ": _1 + 0 ". Value |
update Value=: ": _1 + 0 ". Value |
||
)</ |
)</syntaxhighlight> |
||
Example use: |
Example use: |
||
<lang> task_run''</ |
<syntaxhighlight lang="text"> task_run''</syntaxhighlight> |
||
=={{header|Java}}== |
=={{header|Java}}== |
||
{{works with|Swing}} |
{{works with|Swing}} |
||
{{works with|AWT}} |
{{works with|AWT}} |
||
< |
<syntaxhighlight lang="java">import java.awt.GridLayout; |
||
import java.awt.event.ActionEvent; |
import java.awt.event.ActionEvent; |
||
import java.awt.event.ActionListener; |
import java.awt.event.ActionListener; |
||
Line 1,306: | Line 1,306: | ||
new Interact().setVisible(true); |
new Interact().setVisible(true); |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
{{libheader|JavaFX}} |
{{libheader|JavaFX}} |
||
{{works with|Java|8}} |
{{works with|Java|8}} |
||
< |
<syntaxhighlight lang="java"> |
||
import javafx.application.Application; |
import javafx.application.Application; |
||
import javafx.beans.property.LongProperty; |
import javafx.beans.property.LongProperty; |
||
Line 1,390: | Line 1,390: | ||
} |
} |
||
} |
} |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
< |
<syntaxhighlight lang="julia"> |
||
using Tk |
using Tk |
||
w = Toplevel("GUI enabling/disabling") |
w = Toplevel("GUI enabling/disabling") |
||
Line 1,443: | Line 1,443: | ||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Kotlin}}== |
=={{header|Kotlin}}== |
||
{{libheader|JavaFX}} |
{{libheader|JavaFX}} |
||
{{trans|Java}} |
{{trans|Java}} |
||
< |
<syntaxhighlight lang="scala">// version 1.2.21 |
||
import javafx.application.Application |
import javafx.application.Application |
||
Line 1,517: | Line 1,517: | ||
fun main(args: Array<String>) { |
fun main(args: Array<String>) { |
||
Application.launch(InteractFX::class.java, *args) |
Application.launch(InteractFX::class.java, *args) |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Liberty BASIC}}== |
=={{header|Liberty BASIC}}== |
||
< |
<syntaxhighlight lang="lb">nomainwin |
||
textbox #demo.val, 20, 50, 90, 24 |
textbox #demo.val, 20, 50, 90, 24 |
||
button #demo.dec, "Decrement", [btnDecrement], UL, 20, 90, 90, 24 |
button #demo.dec, "Decrement", [btnDecrement], UL, 20, 90, 90, 24 |
||
Line 1,599: | Line 1,599: | ||
#demo.val "!disable" |
#demo.val "!disable" |
||
end if |
end if |
||
End Sub</ |
End Sub</syntaxhighlight> |
||
=={{header|LiveCode}}== |
=={{header|LiveCode}}== |
||
Line 1,615: | Line 1,615: | ||
4. Select Object->Card Script and enter the following to handle enabling the buttons. |
4. Select Object->Card Script and enter the following to handle enabling the buttons. |
||
< |
<syntaxhighlight lang="livecode">command enableButtons v |
||
switch |
switch |
||
case v <= 0 |
case v <= 0 |
||
Line 1,632: | Line 1,632: | ||
put v into fld "Field1" |
put v into fld "Field1" |
||
end switch |
end switch |
||
end enableButtons</ |
end enableButtons</syntaxhighlight> |
||
For the increment button, click on Button 1 (in edit mode) and the select "code" from the toolbar and enter the following to handle clicks< |
For the increment button, click on Button 1 (in edit mode) and the select "code" from the toolbar and enter the following to handle clicks<syntaxhighlight lang="livecode">on mouseUp |
||
put field "Field1" into x |
put field "Field1" into x |
||
add 1 to x |
add 1 to x |
||
enableButtons x |
enableButtons x |
||
end mouseUp</ |
end mouseUp</syntaxhighlight> |
||
Repeat for Button 2 (note we are subtracting here)< |
Repeat for Button 2 (note we are subtracting here)<syntaxhighlight lang="livecode">on mouseUp |
||
put field "Field1" into x |
put field "Field1" into x |
||
subtract 1 from x |
subtract 1 from x |
||
enableButtons x |
enableButtons x |
||
end mouseUp</ |
end mouseUp</syntaxhighlight> |
||
Finally add the code to handle keyboard entry in text field's code. Note this code prevents entering digits outside 0-9 and limits the value between 0 and 10.< |
Finally add the code to handle keyboard entry in text field's code. Note this code prevents entering digits outside 0-9 and limits the value between 0 and 10.<syntaxhighlight lang="livecode">on rawKeyDown k |
||
if numToChar(k) is among the items of "1,2,3,4,5,6,7,8,9,0" then |
if numToChar(k) is among the items of "1,2,3,4,5,6,7,8,9,0" then |
||
if (numToChar(k) + the text of me) <= 10 then |
if (numToChar(k) + the text of me) <= 10 then |
||
Line 1,654: | Line 1,654: | ||
pass rawKeyDown |
pass rawKeyDown |
||
end if |
end if |
||
end rawKeyDown</ |
end rawKeyDown</syntaxhighlight> |
||
Switch back to the form, and enter run mode to execute. |
Switch back to the form, and enter run mode to execute. |
||
Line 1,663: | Line 1,663: | ||
Normally a function can't call other except something global or something defined in function (local), or for member functions in Group object, they can call other members public or private at same level or deeper but then only the public members. Using Call Local we call functions like function's part. When an event service function called (by event), interpreter provide the same name as the module's name, where form declared, so this call is a "local call". So a second local call inside event service function,also provide same name. So global local1 called as local, so code executed as part of CheckIt (but without same "current" stack, and other specific to execution object properties). Modules, functions, threads, events are all executed on "execution objects" which carries the execution code. |
Normally a function can't call other except something global or something defined in function (local), or for member functions in Group object, they can call other members public or private at same level or deeper but then only the public members. Using Call Local we call functions like function's part. When an event service function called (by event), interpreter provide the same name as the module's name, where form declared, so this call is a "local call". So a second local call inside event service function,also provide same name. So global local1 called as local, so code executed as part of CheckIt (but without same "current" stack, and other specific to execution object properties). Modules, functions, threads, events are all executed on "execution objects" which carries the execution code. |
||
<syntaxhighlight lang="m2000 interpreter"> |
|||
<lang M2000 Interpreter> |
|||
\\ this is global, but call as local in events, which means with local visibility for identifiers |
\\ this is global, but call as local in events, which means with local visibility for identifiers |
||
\\ so thispos and this$ has to exist in caller 's context |
\\ so thispos and this$ has to exist in caller 's context |
||
Line 1,733: | Line 1,733: | ||
Checkit |
Checkit |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Maple}}== |
=={{header|Maple}}== |
||
For this problem, you will need to open up Maple, go to the Components tab on the left, and insert a Text Area, and 2 Buttons. By right clicking each button, and clicking Component Properties, change one to Increase, and the other to Decrease. Then, click on 'Edit Content Changed Action". In the one labeled increase, type: |
For this problem, you will need to open up Maple, go to the Components tab on the left, and insert a Text Area, and 2 Buttons. By right clicking each button, and clicking Component Properties, change one to Increase, and the other to Decrease. Then, click on 'Edit Content Changed Action". In the one labeled increase, type: |
||
<syntaxhighlight lang="maple"> |
|||
<lang Maple> |
|||
Increase(); |
Increase(); |
||
</syntaxhighlight> |
|||
</lang> |
|||
In the one labeled Decrease, type: |
In the one labeled Decrease, type: |
||
<syntaxhighlight lang="maple"> |
|||
<lang Maple> |
|||
Decrease(); |
Decrease(); |
||
</syntaxhighlight> |
|||
</lang> |
|||
Then, by clicking the 2 gears and opening up the start-up commands, enter this: |
Then, by clicking the 2 gears and opening up the start-up commands, enter this: |
||
<syntaxhighlight lang="maple"> |
|||
<lang Maple> |
|||
macro(SP=DocumentTools:-SetProperty, GP=DocumentTools:-GetProperty); |
macro(SP=DocumentTools:-SetProperty, GP=DocumentTools:-GetProperty); |
||
with(Maplets[Elements]): |
with(Maplets[Elements]): |
||
Line 1,779: | Line 1,779: | ||
end if; |
end if; |
||
end proc; |
end proc; |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Mathematica}}/{{header|Wolfram Language}}== |
=={{header|Mathematica}}/{{header|Wolfram Language}}== |
||
< |
<syntaxhighlight lang="mathematica">Manipulate[Null, {{value, 0}, |
||
InputField[Dynamic[value], Number, |
InputField[Dynamic[value], Number, |
||
Enabled -> Dynamic[value == 0]] &}, |
Enabled -> Dynamic[value == 0]] &}, |
||
Row@{Button["increment", value++, Enabled -> Dynamic[value < 10]], |
Row@{Button["increment", value++, Enabled -> Dynamic[value < 10]], |
||
Button["decrement", value--, Enabled -> Dynamic[value > 0]]}]</ |
Button["decrement", value--, Enabled -> Dynamic[value > 0]]}]</syntaxhighlight> |
||
=={{header|NewLISP}}== |
=={{header|NewLISP}}== |
||
< |
<syntaxhighlight lang="newlisp">; file: gui-enable.lsp |
||
; url: http://rosettacode.org/wiki/GUI_enabling/disabling_of_controls |
; url: http://rosettacode.org/wiki/GUI_enabling/disabling_of_controls |
||
; author: oofoe 2012-02-02 |
; author: oofoe 2012-02-02 |
||
Line 1,836: | Line 1,836: | ||
(gs:listen) |
(gs:listen) |
||
(exit)</ |
(exit)</syntaxhighlight> |
||
Screenshot: |
Screenshot: |
||
Line 1,845: | Line 1,845: | ||
===Using Gtk2=== |
===Using Gtk2=== |
||
{{libheader|Gtk2}} |
{{libheader|Gtk2}} |
||
< |
<syntaxhighlight lang="nim">import gtk2, strutils, glib2 |
||
var valu: int = 0 |
var valu: int = 0 |
||
Line 1,904: | Line 1,904: | ||
show_all(window) |
show_all(window) |
||
thisCheckBtns() |
thisCheckBtns() |
||
main()</ |
main()</syntaxhighlight> |
||
===Using Gtk3 (gintro)=== |
===Using Gtk3 (gintro)=== |
||
{{libheader|gintro}} |
{{libheader|gintro}} |
||
< |
<syntaxhighlight lang="nim">import strutils |
||
import gintro/[glib, gobject, gtk, gio] |
import gintro/[glib, gobject, gtk, gio] |
||
Line 1,999: | Line 1,999: | ||
let app = newApplication(Application, "Rosetta.GuiControls") |
let app = newApplication(Application, "Rosetta.GuiControls") |
||
discard app.connect("activate", activate) |
discard app.connect("activate", activate) |
||
discard app.run()</ |
discard app.run()</syntaxhighlight> |
||
===Using IUP=== |
===Using IUP=== |
||
{{libheader|IUP}} |
{{libheader|IUP}} |
||
< |
<syntaxhighlight lang="nim">import |
||
iup, strutils, math |
iup, strutils, math |
||
Line 2,095: | Line 2,095: | ||
discard dlg.show() |
discard dlg.show() |
||
discard mainloop() |
discard mainloop() |
||
iup.close()</ |
iup.close()</syntaxhighlight> |
||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
< |
<syntaxhighlight lang="perl">#!/usr/bin/perl |
||
use strict; |
use strict; |
||
Line 2,132: | Line 2,132: | ||
$dec and $dec->configure( -state => $_[0] > 0 ? 'normal' : 'disabled' ); |
$dec and $dec->configure( -state => $_[0] > 0 ? 'normal' : 'disabled' ); |
||
$entry and $entry->configure( -state => $_[0] == 0 ? 'normal' : 'disabled' ); |
$entry and $entry->configure( -state => $_[0] == 0 ? 'normal' : 'disabled' ); |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
Line 2,138: | Line 2,138: | ||
{{libheader|Phix/basics}} |
{{libheader|Phix/basics}} |
||
{{libheader|Phix/pGUI}} |
{{libheader|Phix/pGUI}} |
||
<!--< |
<!--<syntaxhighlight lang="phix">--> |
||
<span style="color: #008080;">include</span> <span style="color: #000000;">pGUI</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span> |
<span style="color: #008080;">include</span> <span style="color: #000000;">pGUI</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span> |
||
Line 2,180: | Line 2,180: | ||
<span style="color: #7060A8;">IupClose</span><span style="color: #0000FF;">()</span> |
<span style="color: #7060A8;">IupClose</span><span style="color: #0000FF;">()</span> |
||
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span> |
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span> |
||
<!--</ |
<!--</syntaxhighlight>--> |
||
=={{header|PicoLisp}}== |
=={{header|PicoLisp}}== |
||
The standard PicoLisp GUI is HTTP based. Connect your browser to |
The standard PicoLisp GUI is HTTP based. Connect your browser to |
||
http://localhost:8080 after starting the following script. |
http://localhost:8080 after starting the following script. |
||
< |
<syntaxhighlight lang="picolisp">#!/usr/bin/picolisp /usr/lib/picolisp/lib.l |
||
(load "@ext.l" "@lib/http.l" "@lib/xhtml.l" "@lib/form.l") |
(load "@ext.l" "@lib/http.l" "@lib/xhtml.l" "@lib/form.l") |
||
Line 2,201: | Line 2,201: | ||
(server 8080 "!start") |
(server 8080 "!start") |
||
(wait)</ |
(wait)</syntaxhighlight> |
||
=={{header|Prolog}}== |
=={{header|Prolog}}== |
||
Works with SWI-Prolog and XPCE. |
Works with SWI-Prolog and XPCE. |
||
< |
<syntaxhighlight lang="prolog">dialog('GUI_Interaction', |
||
[ object := |
[ object := |
||
GUI_Interaction, |
GUI_Interaction, |
||
Line 2,304: | Line 2,304: | ||
-> send(Incr, active, @off)). |
-> send(Incr, active, @off)). |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|PureBasic}}== |
=={{header|PureBasic}}== |
||
< |
<syntaxhighlight lang="purebasic">Enumeration |
||
#TextGadget |
#TextGadget |
||
#AddButton |
#AddButton |
||
Line 2,352: | Line 2,352: | ||
EndIf |
EndIf |
||
Until Event=#PB_Event_CloseWindow |
Until Event=#PB_Event_CloseWindow |
||
EndIf</ |
EndIf</syntaxhighlight> |
||
=={{header|Python}}== |
=={{header|Python}}== |
||
<syntaxhighlight lang="python"> |
|||
<lang Python> |
|||
#!/usr/bin/env python3 |
#!/usr/bin/env python3 |
||
Line 2,432: | Line 2,432: | ||
if __name__ == "__main__": |
if __name__ == "__main__": |
||
main() |
main() |
||
</syntaxhighlight> |
|||
</lang> |
|||
Result: [https://ibb.co/cEmqy5] |
Result: [https://ibb.co/cEmqy5] |
||
=={{header|R}}== |
=={{header|R}}== |
||
<syntaxhighlight lang="r"> |
|||
<lang R> |
|||
library(gWidgets) |
library(gWidgets) |
||
options(guiToolkit="RGtk2") ## using gWidgtsRGtk2 |
options(guiToolkit="RGtk2") ## using gWidgtsRGtk2 |
||
Line 2,464: | Line 2,464: | ||
addHandlerChanged(down_btn, handler=rement, action=-1) |
addHandlerChanged(down_btn, handler=rement, action=-1) |
||
addHandlerChanged(up_btn, handler=rement, action=1) |
addHandlerChanged(up_btn, handler=rement, action=1) |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Racket}}== |
=={{header|Racket}}== |
||
< |
<syntaxhighlight lang="racket"> |
||
#lang racket/gui |
#lang racket/gui |
||
Line 2,494: | Line 2,494: | ||
(send frame show #t) |
(send frame show #t) |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Raku}}== |
=={{header|Raku}}== |
||
(formerly Perl 6) |
(formerly Perl 6) |
||
Extremely basic implementation using the GTK library. |
Extremely basic implementation using the GTK library. |
||
<lang |
<syntaxhighlight lang="raku" line>use GTK::Simple; |
||
use GTK::Simple::App; |
use GTK::Simple::App; |
||
Line 2,526: | Line 2,526: | ||
$dec.clicked.tap: { my $val = $value.text; $val -= 1; $value.text = $val.Str } |
$dec.clicked.tap: { my $val = $value.text; $val -= 1; $value.text = $val.Str } |
||
$app.run;</ |
$app.run;</syntaxhighlight> |
||
=={{header|Red}}== |
=={{header|Red}}== |
||
< |
<syntaxhighlight lang="rebol">Red[] |
||
enable: does [ |
enable: does [ |
||
Line 2,541: | Line 2,541: | ||
i: button "increment" [f/text: mold n: add to-integer f/text 1 enable] |
i: button "increment" [f/text: mold n: add to-integer f/text 1 enable] |
||
d: button "decrement" disabled [f/text: mold n: subtract to-integer f/text 1 enable] |
d: button "decrement" disabled [f/text: mold n: subtract to-integer f/text 1 enable] |
||
]</ |
]</syntaxhighlight> |
||
=={{header|Ring}}== |
=={{header|Ring}}== |
||
< |
<syntaxhighlight lang="ring"> |
||
Load "guilib.ring" |
Load "guilib.ring" |
||
Line 2,580: | Line 2,580: | ||
lineedit1.settext(num) |
lineedit1.settext(num) |
||
if number(num)<0 btn2.setDisabled(True) ok |
if number(num)<0 btn2.setDisabled(True) ok |
||
</syntaxhighlight> |
|||
</lang> |
|||
Output: |
Output: |
||
[[File:CalmoSoftGui.jpg]] |
[[File:CalmoSoftGui.jpg]] |
||
Line 2,586: | Line 2,586: | ||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
{{libheader|Shoes}} |
{{libheader|Shoes}} |
||
< |
<syntaxhighlight lang="ruby">Shoes.app do |
||
@number = edit_line |
@number = edit_line |
||
@number.change {update_controls} |
@number.change {update_controls} |
||
Line 2,600: | Line 2,600: | ||
update_controls 0 |
update_controls 0 |
||
end</ |
end</syntaxhighlight> |
||
=={{header|Scala}}== |
=={{header|Scala}}== |
||
< |
<syntaxhighlight lang="scala">import swing.{ BoxPanel, Button, GridPanel, Orientation, Swing, TextField } |
||
import swing.event.{ ButtonClicked, Key, KeyPressed, KeyTyped } |
import swing.event.{ ButtonClicked, Key, KeyPressed, KeyTyped } |
||
Line 2,652: | Line 2,652: | ||
centerOnScreen() |
centerOnScreen() |
||
} // def top( |
} // def top( |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Smalltalk}}== |
=={{header|Smalltalk}}== |
||
{{works with|Smalltalk/X}} |
{{works with|Smalltalk/X}} |
||
< |
<syntaxhighlight lang="smalltalk">|top input vh incButton decButton| |
||
vh := ValueHolder with:0. |
vh := ValueHolder with:0. |
||
Line 2,675: | Line 2,675: | ||
decButton enableChannel:(BlockValue with:[:v | v > 0] argument:vh). |
decButton enableChannel:(BlockValue with:[:v | v > 0] argument:vh). |
||
top open</ |
top open</syntaxhighlight> |
||
=={{header|Tcl}}== |
=={{header|Tcl}}== |
||
{{libheader|Tk}} |
{{libheader|Tk}} |
||
< |
<syntaxhighlight lang="tcl">package require Tk |
||
# Model |
# Model |
||
Line 2,709: | Line 2,709: | ||
.dec state [expr {$field > 0 ? "!disabled" : "disabled"}] |
.dec state [expr {$field > 0 ? "!disabled" : "disabled"}] |
||
} |
} |
||
updateEnables; # Force initial state of buttons</ |
updateEnables; # Force initial state of buttons</syntaxhighlight> |
||
=={{header|Vala}}== |
=={{header|Vala}}== |
||
{{libheader|Gtk+-3.0}} |
{{libheader|Gtk+-3.0}} |
||
< |
<syntaxhighlight lang="vala">bool validate_input(Gtk.Window window, string str){ |
||
int64 val; |
int64 val; |
||
bool ret = int64.try_parse(str,out val);; |
bool ret = int64.try_parse(str,out val);; |
||
Line 2,825: | Line 2,825: | ||
return 0; |
return 0; |
||
} |
} |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Visual Basic}}== |
=={{header|Visual Basic}}== |
||
Line 2,835: | Line 2,835: | ||
by a "spinner" or "up-down" control, not by buttons.) |
by a "spinner" or "up-down" control, not by buttons.) |
||
< |
<syntaxhighlight lang="vb">VERSION 5.00 |
||
Begin VB.Form Form1 |
Begin VB.Form Form1 |
||
Caption = "Form1" |
Caption = "Form1" |
||
Line 2,905: | Line 2,905: | ||
cmdDec.Enabled = True |
cmdDec.Enabled = True |
||
End Select |
End Select |
||
End Sub</ |
End Sub</syntaxhighlight> |
||
=={{header|Wren}}== |
=={{header|Wren}}== |
||
{{libheader|DOME}} |
{{libheader|DOME}} |
||
{{libheader|Wren-polygon}} |
{{libheader|Wren-polygon}} |
||
< |
<syntaxhighlight lang="ecmascript">import "graphics" for Canvas, Color |
||
import "input" for Mouse, Keyboard |
import "input" for Mouse, Keyboard |
||
import "dome" for Window |
import "dome" for Window |
||
Line 3,034: | Line 3,034: | ||
} |
} |
||
var Game = GUIControlEnablement.new()</ |
var Game = GUIControlEnablement.new()</syntaxhighlight> |