连接ElectronJS和Python

时间:2018-08-04 18:38:29

标签: python electron desktop-application

我用Electron JS在Python中开发了一个桌面GUI。

我尝试过的是。 显示浏览器窗口的Python代码。 我的问题是如何使用Angularjs从Python获取和发布数据到Python。 我需要示例代码。

`import os
import pyelectron as pt

# setting the title via predefined variable
pt.TITLE = 'App'

# htmlFile name can be saved via the variable htmlFile . os.path.join() is used for absolute file path
# dir = r'/home/ramesh/Downloads'
dir = r'/home/ramesh/project/Python/ReconGUI'
pt.htmlFile = pt.handler + dir+'//'+'index.html'

window = pt.BrowserWindow()
window.show() # show or execute the main Window


# Finally execute the file
if __name__ == '__main__':
  pt.app.exec_()`

我的HTML文件是

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Hello World!</title>
    <link rel="stylesheet"
          href="../static/content/bootstrap.min.css"/>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
    <script src="../static/script/jquery-1.12.4.min.js"></script>
    <script src="../static/script/bootstrap.min.js"></script>
</head>

<body>

<div ng-app="myapp" ng-controller="crtlapp">

<p>Input something in the input box:</p>
<p>Name : <input type="text" ng-model="name" placeholder="Enter name here"></p>
<h1>Hello {{name}}</h1>
<button ng-click="click();"></button>
</div>

</body>
<script>
    var app=angular.module("myapp",[]);
    app.controller("crtlapp",function($scope){
        $scope.click=function(){
            alert("click");
        }
    });
</script>

</html>

0 个答案:

没有答案