Skip to content

Commit 7b7f7ae

Browse files
committed
First steps in Interface example
1 parent e82218c commit 7b7f7ae

File tree

4 files changed

+99
-1
lines changed

4 files changed

+99
-1
lines changed

NAMESPACE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ import(jaspBase)
22
export(addOne)
33
export(processData)
44
export(processTable)
5-
export(parabola)
5+
export(parabola)
6+
export(interfaceExample)

R/examples.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
interfaceExample <- function(jaspResults, dataset, options) {
2+
result <- as.character(options$my_tick_mark) # options$my_tick_mark was defined at inst/qml/Interface.qml
3+
4+
jaspResults[["result"]] <- createJaspHtml(text = result,
5+
title = "Your tick mark is set to:")
6+
7+
return()
8+
}
9+
110
addOne <- function(jaspResults, dataset, options) {
211
result <- as.character(options$my_number + 1) # options$my_number comes from the menu created by inst/qml/integer.qml
312

inst/Description.qml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ Description
1515
preloadData: true
1616
requiresData: true
1717

18+
GroupTitle
19+
{
20+
title: qsTr("Interfaces")
21+
}
22+
23+
Analysis
24+
{
25+
title: qsTr("Interface example") // Title for window
26+
menu: qsTr("Interface example") // Title for ribbon
27+
func: "interfaceExample" // Function to be called
28+
qml: "Interface.qml" // Design input window
29+
requiresData: false // Allow to run even without data
30+
}
1831

1932
GroupTitle
2033
{

inst/qml/Interface.qml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
//
2+
// Copyright (C) 2013-2018 University of Amsterdam
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as
6+
// published by the Free Software Foundation, either version 3 of the
7+
// License, or (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Affero General Public
15+
// License along with this program. If not, see
16+
// <http://www.gnu.org/licenses/>.
17+
//
18+
import QtQuick
19+
import QtQuick.Layouts
20+
import JASP.Controls
21+
import JASP.Widgets
22+
import JASP
23+
24+
Form
25+
{
26+
27+
info: qsTr("This analysis shows you different interface elements of JASP, such as tick marks, text boxes, ... \\
28+
Its purpose is pedagogical, and its target audience is that of JASP module developers. \\
29+
\\
30+
From the technical point of view, the most challenging part of JASP module development is the communication between the QML interface and the R backend. \\
31+
Playing with the current JASP analysis while simultaneously inspecting the R code in the files `./inst/qml/Interface.qml` and `./R/examples.R` is a good way to learn how this communication works. \\
32+
\\
33+
The source code is available at [github.com/jasp-stats/jaspModuleTemplate](https://github.com/jasp-stats/jaspModuleTemplate)")
34+
35+
Text
36+
{
37+
text: qsTr("This analysis shows you different interface elements of JASP")
38+
}
39+
40+
Group
41+
{
42+
title: qsTr("Logical controls")
43+
44+
CheckBox
45+
{
46+
info: qsTr("This is a tick mark that can be used to control the flow of the analysis")
47+
48+
name: "my_tick_mark"
49+
label: qsTr("Tick mark")
50+
51+
// We can add some extra control parameters
52+
checked: false
53+
}
54+
}
55+
56+
Group
57+
{
58+
title: qsTr("Keyboard inputs")
59+
60+
IntegerField
61+
{
62+
info: qsTr("This is the number that will be used in the operation")
63+
64+
name: "my_integer" // This will map to options$my_integer in R
65+
label: qsTr("Input an integer") // qsTr allows for future translations
66+
67+
// We can add some extra control parameters
68+
min: 1
69+
defaultValue: 10
70+
fieldWidth: 50
71+
max: 1000
72+
}
73+
}
74+
75+
}

0 commit comments

Comments
 (0)