Skip to content

Commit

Permalink
#25 hooked up ng->Python api
Browse files Browse the repository at this point in the history
  • Loading branch information
InBrewJ committed Jul 1, 2019
1 parent 4cde680 commit 4c0a827
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions gui/lrpi/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ plugins/ios.json
$RECYCLE.BIN/

.DS_Store
UNKNOWN*
Thumbs.db
UserInterfaceState.xcuserstate
11 changes: 9 additions & 2 deletions gui/lrpi/lrpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@
import webview, threading

class Api():
pass
def event(self, param):
print('select audio file!')

if __name__ == '__main__':
# t = threading.Thread(target=load_html)
# t.start()

print('Begin...')

api = Api()
webview.config.gui = "qt"
webview.create_window('Lushroom Pi', 'www/index.html',
js_api=api, width=400, height =600, min_size=(400, 600), confirm_quit=True,
text_select=True, resizable=False, debug=False)
text_select=True, resizable=False, debug=True)

# Sending events from JS -> Python and back:
# https://askubuntu.com/questions/97430/connect-webkit-webview-form-to-a-python-callback
# See also: https://github.com/r0x0r/pywebview/blob/master/examples/todos/assets/script.js
Empty file modified gui/lrpi/setup.py
100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions gui/lrpi/www/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ angular.module('app', ['ionic', 'app.controllers', 'app.routes', 'app.directives
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)

if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
Expand Down
10 changes: 10 additions & 0 deletions gui/lrpi/www/js/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ angular.module('app.controllers', [])
// TIP: Access Route Parameters for your page via $stateParams.parameterName
function ($scope, $stateParams) {

console.log('Can you see me in the debugger?');


}])

Expand All @@ -13,6 +15,14 @@ function ($scope, $stateParams) {
// TIP: Access Route Parameters for your page via $stateParams.parameterName
function ($scope, $stateParams) {

var vm = this;
vm.selectAudioFile = selectAudioFile;

function selectAudioFile() {
console.log('click!');
window.pywebview.api.event()
}


}])

Expand Down
4 changes: 2 additions & 2 deletions gui/lrpi/www/templates/play.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<div>
<img src="img/CKywsQCfRlO4E7ZSqqQ1_lushroom_pi.svg" style="display: block; width: 150px; height: auto; margin-left: auto; margin-right: auto;">
</div>
<div id="play-container1">
<div ng-controller="playCtrl as vm" id="play-container1">
<form id="play-form4" class="list">
<button id="play-button9" style="border-radius:0px 0px 0px 0px;" class="button button-dark button-block icon-left ion-music-note">Select Audio File</button>
<input type="file" ng-click="vm.selectAudioFile();" id="play-button9" style="border-radius:0px 0px 0px 0px;" class="button button-dark button-block icon-left ion-music-note">Select Audio File</input>
<label class="item item-input" id="play-input7" name="play_audio_filename">
<span class="input-label">File name</span>
<input type="text" placeholder="Choose an audio file ">
Expand Down

0 comments on commit 4c0a827

Please sign in to comment.