Simple windowed application: Difference between revisions

Added GNU APL GTK3/glade example
(Added GNU APL GTK3/glade example)
Line 555:
∇</lang>
 
{{works with|GNU APL}}
 
[my-application.apl]
<lang APL>#!/usr/local/bin/apl --script --OFF
 
⍝ Some GTK API consts for readability
⍝ event poll type for X ← ⎕gtk
Blocking ← 1
Nonblocking ← 2
 
∇Z←get_NAME_and_POSITION;GUI_path;CSS_path;Handle
GUI_path ← '/home/me/GNUAPL/workspaces/my-application.glade'
CSS_path ← '/home/me/GNUAPL/workspaces/my-application.css'
Handle ← CSS_path ⎕GTK GUI_path
 
⍝H_ID ← Handle, 'entry1' ⍝ Position field
⍝'<enter name>' ⎕gtk[H_ID] "set_text" ⍝ pre-fill entry
 
⊣⎕gtk Blocking ⍝ Wait for click event
 
Z ← ⊂1↓⎕gtk[Handle, 'entry1'] "get_text"
Z ← Z,⊂1↓⎕gtk[Handle, 'entry2'] "get_text"
⊣Handle ⎕gtk 0
 
⍝ Launch GUI application
get_NAME_and_POSITION
</lang>
 
[my-application.css]
<lang CSS>/* general button */
.BUTTON { color: #F00; background: #4F4; }
 
/* the OK button */
#OK-button { color: #A22; background: #FFF; }
</lang>
 
[my-application.glade]
<lang XML><?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkGrid" id="grid1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="row_homogeneous">True</property>
<child>
<object class="GtkLabel" id="label1">
<property name="name">lblEmployee</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Employee</property>
<property name="wrap">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label2">
<property name="name">lblPosition</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Position</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry1">
<property name="name">entryEmployee</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="valign">center</property>
</object>
<packing>
<property name="left_attach">3</property>
<property name="top_attach">1</property>
<property name="width">6</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry2">
<property name="name">entryPosition</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="valign">center</property>
</object>
<packing>
<property name="left_attach">3</property>
<property name="top_attach">2</property>
<property name="width">6</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btnOK">
<property name="label" translatable="yes">button</property>
<property name="name">OK-button</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="clicked" swapped="no"/>
<style>
<class name="BUTTON"/>
</style>
</object>
<packing>
<property name="left_attach">4</property>
<property name="top_attach">4</property>
<property name="width">2</property>
</packing>
</child>
</object>
</child>
</object>
</interface>
</lang>
 
=={{header|AppleScript}}==
67

edits