diff --git a/css/boardFrame.css b/css/boardFrame.css index b975cf30..bbbdbd77 100644 --- a/css/boardFrame.css +++ b/css/boardFrame.css @@ -156,7 +156,6 @@ flex-direction: column; justify-content: center; touch-action: none; - cursor: pointer; color: var(--font-primary); font-family: 'AppleSDGothicNeo'; @@ -180,6 +179,7 @@ overflow: hidden; border: 2px solid transparent; border-radius: 2px; + cursor: pointer; } .vp-block-left-holder { display: none; @@ -197,6 +197,7 @@ position: absolute; left: 0px; color: rgba(0,0,0,0.3); + cursor: default; } .vp-block-num-info { color: #828282; diff --git a/css/popupComponent.css b/css/popupComponent.css index a1298f67..9bbbee31 100644 --- a/css/popupComponent.css +++ b/css/popupComponent.css @@ -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; @@ -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; @@ -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 */ diff --git a/data/libraries.json b/data/libraries.json index c4556704..812d75c7 100644 --- a/data/libraries.json +++ b/data/libraries.json @@ -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", diff --git a/data/m_library/pandasLibrary.js b/data/m_library/pandasLibrary.js index afce47f4..9d077cb1 100644 --- a/data/m_library/pandasLibrary.js +++ b/data/m_library/pandasLibrary.js @@ -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', diff --git a/html/popupComponent.html b/html/popupComponent.html index 503efe92..dbd04fbc 100644 --- a/html/popupComponent.html +++ b/html/popupComponent.html @@ -51,7 +51,6 @@ -
@@ -60,7 +59,8 @@
Code to cell
- + + diff --git a/js/board/BlockMenu.js b/js/board/BlockMenu.js index 3b414b07..f10623bb 100644 --- a/js/board/BlockMenu.js +++ b/js/board/BlockMenu.js @@ -74,7 +74,7 @@ define([ // run button sbBlockMenu.appendLine('
Run
'); // add button - sbBlockMenu.appendLine('
Add
'); + sbBlockMenu.appendLine('
Code to cell
'); // duplicate button sbBlockMenu.appendLine('
Duplicate
'); // delete button diff --git a/js/com/com_Config.js b/js/com/com_Config.js index 472227df..af94bf6f 100644 --- a/js/com/com_Config.js +++ b/js/com/com_Config.js @@ -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 = { @@ -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); @@ -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; diff --git a/js/com/com_Const.js b/js/com/com_Const.js index 3bd578ab..1adc6b4d 100644 --- a/js/com/com_Const.js +++ b/js/com/com_Const.js @@ -19,7 +19,7 @@ define ([ class Constants { } Constants.TOOLBAR_BTN_INFO = { - HELP: "Visual Python 2.0.0" + HELP: "Visual Python 2.0.1" , ICON: "vp-main-icon" , ID: "vpBtnToggle" , NAME: "toggle-vp" diff --git a/js/com/component/InstanceEditor.js b/js/com/component/InstanceEditor.js index 251b9eab..626ba0c4 100644 --- a/js/com/component/InstanceEditor.js +++ b/js/com/component/InstanceEditor.js @@ -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(''); + } }); diff --git a/js/com/component/PopupComponent.js b/js/com/component/PopupComponent.js index aa975997..8ccce0fd 100644 --- a/js/com/component/PopupComponent.js +++ b/js/com/component/PopupComponent.js @@ -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 diff --git a/js/loadVisualpython.js b/js/loadVisualpython.js index 7ecf9025..78cde851 100644 --- a/js/loadVisualpython.js +++ b/js/loadVisualpython.js @@ -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 }; diff --git a/js/m_apps/Import.js b/js/m_apps/Import.js index 866c1823..6f2161cc 100644 --- a/js/m_apps/Import.js +++ b/js/m_apps/Import.js @@ -81,7 +81,7 @@ define([ page.appendLine(''); page.appendLine(''); 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(''); diff --git a/js/m_apps/Instance.js b/js/m_apps/Instance.js index 4cbfb1d2..8e05de59 100644 --- a/js/m_apps/Instance.js +++ b/js/m_apps/Instance.js @@ -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 @@ -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) { diff --git a/js/m_apps/Snippets.js b/js/m_apps/Snippets.js index 11b0291c..713a52c4 100644 --- a/js/m_apps/Snippets.js +++ b/js/m_apps/Snippets.js @@ -194,6 +194,7 @@ define([ com_util.renderSuccessMessage('Default snippets imported'); } + $(that.wrapSelector('.vp-sn-menu-box')).hide(); evt.stopPropagation(); }); diff --git a/js/m_logic/Elif.js b/js/m_logic/Elif.js index 3081f57a..a520c9f2 100644 --- a/js/m_logic/Elif.js +++ b/js/m_logic/Elif.js @@ -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', @@ -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 */ @@ -31,7 +31,7 @@ define([ this.config.saveOnly = true; this.state = { - v1: [], + v1: [{ type: 'condition', value: {} }], ...this.state } } @@ -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 @@ -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); }); } @@ -94,7 +109,8 @@ define([ var page = new com_String(); page.appendLine(''); // page.appendLine(''); - page.appendLine(''); + page.appendLine(''); + page.appendLine(''); this.state.v1.forEach((v, idx) => { if (v.type == 'condition') { page.appendLine(this.templateForList(idx + 1, v.value)); @@ -118,8 +134,20 @@ define([ page.appendFormatLine('', idx); page.appendFormatLine('' , 'v1-i1', v.i1, 'Variable'); - page.appendFormatLine('' - , '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('', suggestInput.toTagString()); page.appendFormatLine('' , 'v1-i3', v.i3, 'Variable'); page.appendFormatLine('
ParameterDefault Value
{0}{0}