Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion css/boardFrame.css
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@
flex-direction: column;
justify-content: center;
touch-action: none;
cursor: pointer;
color: var(--font-primary);
font-family: 'AppleSDGothicNeo';

Expand All @@ -180,6 +179,7 @@
overflow: hidden;
border: 2px solid transparent;
border-radius: 2px;
cursor: pointer;
}
.vp-block-left-holder {
display: none;
Expand All @@ -197,6 +197,7 @@
position: absolute;
left: 0px;
color: rgba(0,0,0,0.3);
cursor: default;
}
.vp-block-num-info {
color: #828282;
Expand Down
35 changes: 18 additions & 17 deletions css/popupComponent.css
Original file line number Diff line number Diff line change
Expand Up @@ -115,29 +115,29 @@
height: 50px;
}
.vp-popup-button[data-type="code"] {
position: absolute;
left: 15px;
top: 9px;
float: left;
margin-top: 9px;
margin-left: 10px;
}
.vp-popup-button[data-type="data"] {
position: absolute;
left: 102px;
top: 9px;
float: left;
margin-top: 9px;
margin-left: 10px;
}
.vp-popup-button[data-type="cancel"] {
position: absolute;
float: right;
background-color: #E4E4E4;
top: 9px;
right: 106px;
margin-top: 9px;
margin-right: 10px;
}
.vp-popup-runadd-box {
position: absolute;
top: 9px;
right: 15px;
float: right;
width: fit-content;
height: 30px;
background: #F38504;
border-radius: 2px;
margin-top: 9px;
margin-right: 10px;
}
.vp-popup-button[data-type="run"] {
display: inline-block;
Expand All @@ -157,8 +157,8 @@
background: white;
border: 0.25px solid var(--border-gray-color);
position: absolute;
bottom: 35px;
right: 0px;
bottom: 45px;
right: 10px;
width: 120px;
text-align: center;
line-height: 30px;
Expand All @@ -172,10 +172,11 @@
background: var(--light-gray-color);
}
.vp-popup-save-button {
position: absolute;
top: 9px;
right: 15px;
float: right;
height: 30px;
width: 100px;
margin-top: 9px;
margin-right: 10px;
}
/* writable codemirror style*/
/* Code Option Codemirror */
Expand Down
2 changes: 1 addition & 1 deletion data/libraries.json
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@
"type" : "function",
"level": 1,
"name" : "elif",
"tag" : "ELSE,LOGIC",
"tag" : "ELIF,LOGIC",
"path" : "visualpython - logic - control - elif",
"desc" : "elif",
"file" : "m_logic/Elif",
Expand Down
2 changes: 1 addition & 1 deletion data/m_library/pandasLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -5119,7 +5119,7 @@ define([
name: 'Plot',
library: 'pandas',
description: 'create chart',
code: '${o0} = ${i0}.plot(${v}${etc})',
code: '${o0} = ${i0}.plot(${v}${etc})\nplt.show()',
input: [
{
name: 'i0',
Expand Down
4 changes: 2 additions & 2 deletions html/popupComponent.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
<button type="button" class="vp-button vp-popup-button" data-type="code">Code view</button>
<button type="button" class="vp-button vp-popup-button" data-type="data">Data view</button>

<button type="button" class="vp-button vp-popup-button" data-type="cancel">Cancel</button>
<div class="vp-popup-runadd-box">
<button type="button" class="vp-button activated vp-popup-button" data-type="run" title="Save to block & Run cell">Run</button>
<button type="button" class="vp-button activated vp-popup-button" data-type="show-detail"><img src="/nbextensions/visualpython/img/arrow_short_up.svg"/></button>
Expand All @@ -60,7 +59,8 @@
<div class="vp-popup-detail-button" data-type="add" title="Save to block & Add cell">Code to cell</div>
</div>
</div>
<button type="button" class="vp-button activated vp-popup-button vp-popup-save-button" data-type="save" title="Save to block" style="display:none;">Save</button>
<button type="button" class="vp-button activated vp-popup-button vp-popup-save-button" data-type="save" title="Save to block" style="display:none;">Save to block</button>
<button type="button" class="vp-button vp-popup-button" data-type="cancel">Cancel</button>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion js/board/BlockMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ define([
// run button
sbBlockMenu.appendLine('<div id="vp_block_menu_run" class="vp-block-menu-item">Run</div>');
// add button
sbBlockMenu.appendLine('<div id="vp_block_menu_add" class="vp-block-menu-item">Add</div>');
sbBlockMenu.appendLine('<div id="vp_block_menu_add" class="vp-block-menu-item">Code to cell</div>');
// duplicate button
sbBlockMenu.appendLine('<div id="vp_block_menu_duplicate" class="vp-block-menu-item">Duplicate</div>');
// delete button
Expand Down
17 changes: 14 additions & 3 deletions js/com/com_Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,17 @@ define([], function() {
' except ValueError:',
' return 0.0'
]
}
},
'vpimport': [
{ library: 'numpy', alias:'np' },
{ library: 'pandas', alias:'pd' },
{ library: 'matplotlib.pyplot', alias:'plt',
include: [
'%matplotlib inline'
]
},
{ library: 'seaborn', alias:'sns' }
]
}

this.data = {
Expand Down Expand Up @@ -165,7 +175,8 @@ define([], function() {
Jupyter.notebook.config.loaded.then(function() {
var data = Jupyter.notebook.config.data[configKey];
if (data == undefined) {
data = {};
reject('No data available.');
return;
}
if (dataKey == '') {
resolve(data);
Expand All @@ -184,7 +195,7 @@ define([], function() {
Jupyter.notebook.config.load();
var data = Jupyter.notebook.config.data[configKey];
if (data == undefined) {
data = {};
return undefined;
}
if (dataKey == '') {
return data;
Expand Down
8 changes: 8 additions & 0 deletions js/com/component/InstanceEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,14 @@ define([
if (callback) {
callback(varObj);
}
}).catch(function(resultObj) {
let { result } = resultObj;
// show alert
com_util.renderAlertModal(result.ename + ': ' + result.evalue);
// callback
if (callback) {
callback('');
}
});


Expand Down
4 changes: 0 additions & 4 deletions js/com/component/PopupComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,6 @@ define([
}
if (!dataview) {
$(this.wrapSelector('.vp-popup-button[data-type="data"]')).hide();
} else {
if (!codeview) {
$(this.wrapSelector('.vp-popup-button[data-type="data"]')).css({left: '15px', top: '9px'});
}
}

// footer
Expand Down
7 changes: 7 additions & 0 deletions js/loadVisualpython.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,13 @@
if (cfg.vp_section_display && vpFrame) {
vpFrame.openVp();
}

// Operations on kernel restart
events.on('kernel_ready.Kernel', function (evt, info) {
vpLog.display(VP_LOG_TYPE.LOG, 'vp operations for kernel ready...');
// read vp functions
_readKernelFunction();
});
}

return { initVisualpython: initVisualpython, readConfig: readConfig };
Expand Down
2 changes: 1 addition & 1 deletion js/m_apps/Import.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ define([
page.appendLine('</tr></thead>');
page.appendLine('<tbody>');
let that = this;
this.state.importMeta.forEach((lib, idx) => {
this.state.importMeta && this.state.importMeta.forEach((lib, idx) => {
page.appendLine(that.templateForLibrary(idx, lib.library, lib.alias));
});
page.appendLine('</tbody>');
Expand Down
19 changes: 19 additions & 0 deletions js/m_apps/Instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ define([
let component = evt.component;
component.close();
});
$(this.wrapSelector('#vp_instanceVariable')).on('focus_option_page', function(evt) {
let component = evt.component;
component.focus();
});
$(this.wrapSelector('#vp_instanceVariable')).on('apply_option_page', function(evt) {
let component = evt.component;
// apply its value
Expand Down Expand Up @@ -219,6 +223,21 @@ define([
return sbCode.toString();
}

hide() {
super.hide();
this.state.subsetEditor && this.state.subsetEditor.hide();
}

close() {
super.close();
this.state.subsetEditor && this.state.subsetEditor.close();
}

remove() {
super.remove();
this.state.subsetEditor && this.state.subsetEditor.remove();
}

updateValue(value) {
let cmObj = this.getCodemirror('vp_instanceVariable');
if (cmObj && cmObj.cm) {
Expand Down
1 change: 1 addition & 0 deletions js/m_apps/Snippets.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ define([

com_util.renderSuccessMessage('Default snippets imported');
}
$(that.wrapSelector('.vp-sn-menu-box')).hide();
evt.stopPropagation();
});

Expand Down
59 changes: 47 additions & 12 deletions js/m_logic/Elif.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/*
* Project Name : Visual Python
* Description : GUI-based Python code generator
* File Name : If.js
* File Name : Elif.js
* Author : Black Logic
* Note : Logic > if
* Note : Logic > elif
* License : GNU GPLv3 with Visual Python special exception
* Date : 2021. 11. 18
* Change Date :
*/

//============================================================================
// [CLASS] If
// [CLASS] Elif
//============================================================================
define([
'vp_base/js/com/com_String',
Expand All @@ -20,9 +20,9 @@ define([
], function(com_String, com_util, PopupComponent, SuggestInput) {

/**
* If
* Elif
*/
class If extends PopupComponent {
class Elif extends PopupComponent {
_init() {
super._init();
/** Write codes executed before rendering */
Expand All @@ -31,7 +31,7 @@ define([
this.config.saveOnly = true;

this.state = {
v1: [],
v1: [{ type: 'condition', value: {} }],
...this.state
}
}
Expand All @@ -43,11 +43,23 @@ define([
// Add param
$(this.wrapSelector('#vp_addCondition')).on('click', function() {
that.state.v1.push({ type: 'condition', value: {} });
$(that.wrapSelector('.v1 tbody')).append(that.templateForList(that.state.v1.length, {}));
$(that.wrapSelector('.v1-table')).append(that.templateForList(that.state.v1.length, {}));

// enable and disable last one
// enable all operator
$(that.wrapSelector('.v1 .v1-i4')).prop('disabled', false);
// disable last operator
$(that.wrapSelector('.v1 tr:last .v1-i4')).prop('disabled', true);
});
$(this.wrapSelector('#vp_addUserInput')).on('click', function() {
that.state.v1.push({ type: 'input', value: {} });
$(that.wrapSelector('.v1 tbody')).append(that.templateForInput(that.state.v1.length, {}));
$(that.wrapSelector('.v1-table')).append(that.templateForInput(that.state.v1.length, {}));

// enable and disable last one
// enable all operator
$(that.wrapSelector('.v1 .v1-i4')).prop('disabled', false);
// disable last operator
$(that.wrapSelector('.v1 tr:last .v1-i4')).prop('disabled', true);
});

// Delete param
Expand All @@ -61,6 +73,9 @@ define([
$(that.wrapSelector('.v1-tr')).each((idx, tag) => {
$(tag).find('th').text(idx + 1);
});

// disable last operator
$(that.wrapSelector('.v1 tr:last .v1-i4')).prop('disabled', true);
});
}

Expand Down Expand Up @@ -94,7 +109,8 @@ define([
var page = new com_String();
page.appendLine('<table class="v1 wp100" style="margin: 10px 0">');
// page.appendLine('<thead><tr><td></td><td>Parameter</td><td></td><td>Default Value</td></tr></thead>');
page.appendLine('<tbody><colgroup><col width="20px"><col width="100px"><col width="100px"><col width="100px"><col width="100px"><col width="30px"></colgroup>');
page.appendLine('<colgroup><col width="20px"><col width="100px"><col width="100px"><col width="100px"><col width="100px"><col width="30px"></colgroup>');
page.appendLine('<tbody class="v1-table">');
this.state.v1.forEach((v, idx) => {
if (v.type == 'condition') {
page.appendLine(this.templateForList(idx + 1, v.value));
Expand All @@ -118,8 +134,20 @@ define([
page.appendFormatLine('<th>{0}</th>', idx);
page.appendFormatLine('<td><input type="text" class="vp-input w100 {0}" value="{1}" placeholder="{2}"/></td>'
, 'v1-i1', v.i1, 'Variable');
page.appendFormatLine('<td><input type="text" class="vp-input w100 {0}" value="{1}" placeholder="{2}"/></td>'
, 'v1-i2', v.i2, 'Operator');
// suggestInput for operator
let operList = ['', '==', '!=', 'in', 'not in', '<', '<=', '>', '>='];
var suggestInput = new SuggestInput();
suggestInput.addClass('vp-input w100 v1-i2');
suggestInput.setSuggestList(function() { return operList; });
suggestInput.setPlaceholder('Operator');
suggestInput.setNormalFilter(false);
suggestInput.setValue(v.i2);
suggestInput.setSelectEvent(function(selectedValue) {
// trigger change
$(this.wrapSelector()).val(selectedValue);
$(this.wrapSelector()).trigger('change');
});
page.appendFormatLine('<td>{0}</td>', suggestInput.toTagString());
page.appendFormatLine('<td><input type="text" class="vp-input w100 {0}" value="{1}" placeholder="{2}"/></td>'
, 'v1-i3', v.i3, 'Variable');
page.appendFormatLine('<td><select class="vp-select w100 {0}">', 'v1-i4');
Expand Down Expand Up @@ -153,6 +181,13 @@ define([
return page.toString();
}

render() {
super.render();

// disable last operator
$(this.wrapSelector('.v1 tr:last .v1-i4')).prop('disabled', true);
}

generateCode() {
this.saveState();

Expand All @@ -179,5 +214,5 @@ define([

}

return If;
return Elif;
});