반응형
반응형

안드로이드폰에서 파이썬을 사용하려면 SL4A(Scripting Layer for Android),

 Python for Android를 설치해야 한다.

 

SL4A 설치 : http://code.google.com/p/android-scripting/


QR로 다운 받을 수 있다. : http://android-scripting.googlecode.com/files/sl4a_r6.apk

 

SL4A를 실행하고 Menu > View > Interpreters 를 선택하면 "SHELL"이라는 메뉴가 나타난다.

shell 을 통해서 안드로이드폰과 대화를 할 수 있다.

 

난 "SHELL"이 나오지 않아서 바로 Python for Android를 설치해버렸다.

 

Python for Android 설치 : http://code.google.com/p/android-scripting/downloads/detail?name=PythonForAndroid_r4.apk

File:
Description:
Latest Python release.

Note that Python for Android is now being hosted here:
http://code.google.com/p/python-for-android/

This is a copy of the lastest release, placed here for convenience.
SHA1 Checksum: ff4dfef760880fd1cdbc164045cc859947ecbe1d What's this?

 

설치하면 Install 메뉴가 나오는데, 바로 Install 터치.

몇 번의 다운로드와 설치가 끝나고, Install > UnInstall 로 변경된다.

 

그럼, 다시 SL4A를 실행하면  Script와 Shell이 대기중일 것이다.

스크립트 목록이 나오는데, shell화면으로 가고 싶으면 View > Interpreters 로 이동한다.

 

Interpreters에서 python을 선택하면 파이썬 shell로 들어간다. 안드로이드를 import해서 핸드폰 기능을 테스트 해 볼 수 있다.

 

안드로이드 모듈을 가져온다.

>>>import android

>>>droid = android.Android()

 

>>>droid.vibrate()

: 진동을 실행한다. 그런데, 한번밖에 되지 않는다.

 

>>>droid.ttsSpeak('anneung')

: '안녕'이라고 스피커에서 나온다.

 

>>>def ann(): droid.ttsSpeak('anneung')

>>>ann()

>>>ann()

 

 

 

 

 

 

 

 

 

 

스크립트 파일을 추가해서 파일을 실행 해 볼 수 있다.

파일을 생성하고, MENU > Save & Run을 선택하면 저장하면서 실행이 된다.

반응형
반응형

성공과 명예란 항상
곤궁에 처한 날을 거쳐 이루어지는 것이요,
일을 그르침은 거의가
득의했다고 자만할 때에 이루어지는 것이다.
-임동석 역주, ‘석시현문’에서

 

중국에서 명심보감 보다 인기 있는
현문에 나와 있는 유사 내용을 함께 보내드립니다.
‘영화와 총애의 곁에는 욕됨의 기다림이 있고,
빈천의 등 뒤에는 복이 이를 따르고 있다.’
‘고통 속에 더 큰 고통을 겪어보아야 비로소
사람 중의 윗사람이 될 수 있다.’

반응형
반응형

우리는 행복했다.
예술과 철학에 대해 토론이 시작되면
몇 시간이고 지칠 줄 모르고 이야기를 나눴다.
토론이 시들해지면 사랑을 나누곤 했다.
젊고 거칠 것 없이 자유분방한 우리였기에,
절제도 수줍음도 몰랐다. 그러다 때로
심각한 언쟁이 붙으면 남준은 웃으며
"말 되게 많네, 시끄러워"하고는
나에게 달려들어 덮치곤 했다.


- 구보타 시게코의《나의사랑, 백남준》중에서 -


* 누군가와 세상을 살아가면서
"우리는 행복했다"고 말할 수 있는 사람,
또 그런 순간이 과연 얼마나 많이 있을까요?
부부든 친구든 어느 시점에서 서로를 바라보며
"우리는 행복했다"고 말할 수 있다는 것은
참으로 감사하고 행복한 일입니다.
지칠 줄 모르고 하는 사랑이
그 징검다리입니다.

반응형

'아침편지' 카테고리의 다른 글

사랑할수록  (0) 2013.02.18
얼마만의 휴식이던가?  (0) 2013.02.15
단식과 건강  (0) 2013.02.13
아버지의 포옹  (0) 2013.02.12
엄마의 기도상자  (0) 2013.02.08
반응형

6시 10분 입수

자유형 8

오리발 착용

자유형 발차기 4

자유형 10

자유형 50m 인터벌 6

 

접영 킥 1

 

출근때문에 오늘은 여기까지만.

 

반응형

'운동일지 > 수영' 카테고리의 다른 글

2013.02.16 수영일지  (0) 2013.02.16
2013.02.15 수영일지  (0) 2013.02.15
2013.02.07 수영일지  (0) 2013.02.07
2013.02.06 수영일지  (0) 2013.02.06
2013.02.05 수영일지  (0) 2013.02.05
반응형

많은 사람들이 인생에서 성공하지 못하는 이유는기회가 문을 두드릴 때 뒤뜰에 나가 네잎클로버를 찾기 때문이다. - 월터 크라이슬러 -

반응형
반응형

jquery와 angulars 같이 사용하기.

requireJS로 시작했다가 무거운거 같아서 그냥 같이 쓰는걸로 해봤다.

문법적인 문제는 발견되지 않았다. 너무 간단한 테스트라서 그럴지도.

 

AS-IS

 : index.html에 require.js와 main.js, angular.js, controllers.js 등을 녹여넣었다.

* index.html

<!doctype html>
<html lang="en" ng-app>
    <head>
        <title>jQuery+RequireJS Sample Page</title>
        <!-- This is a special version of jQuery with RequireJS built-in -->
        <script data-main="scripts/main" src="scripts/require-jquery.js"></script>
               </script>
    </head>
    <body ng-controller="PhoneListCtrl" >
        <h1>jQuery+RequireJS Sample Page</h1>
        <p>Look at source or inspect the DOM to see how it works.</p>
       
       
       
        <div id="mydiv">aaa</div>
        <p>Total number of phones: {{phones.length}} </p>
        <p>Angulars Templates - http://docs.angularjs.org/tutorial/step_02</p>

 <p>Nothing here {{'yet' + '!'}}</p>
 
 <p>1 + 2 = {{ 1 + 2 }}</p>
 
 <p class="hello">{{hello}}______</p>
    </body>
</html> 

* main.js - require.js에서 사용함. 

 require(["jquery"], function($) {
  $("#mydiv").html("Hello this is RequireJS talking");
});


require(["jquery", "jquery.alpha", "jquery.beta"], function($) {
    //the jquery.alpha.js and jquery.beta.js plugins have been loaded.
    $(function() {
        $('body').alpha().beta();
    });
});

// angular.JS, controllers.js 를 LOAD.
require(["angular"], function($) {

});
require(["controllers"], function($) {

});

* controllers.js - angular.js에서 사용 

 function PhoneListCtrl($scope) {
  $scope.phones = [
    {"name": "Nexus S",
     "snippet": "Fast just got faster with Nexus S.",
     "age": 0},
    {"name": "Motorola XOOM™ with Wi-Fi",
     "snippet": "The Next, Next Generation tablet.",
     "age": 1},
    {"name": "MOTOROLA XOOM™",
     "snippet": "The Next, Next Generation tablet.",
     "age": 2}
  ];
 
  $scope.orderProp = "age";  
  $scope.hello = "Hello, world!"; 
}

 

TO-BE

* index.html 에 다 순차적으로 호출하였다.(require.js 사용안함) 

 <!doctype html>
<html lang="en" ng-app>
    <head>
        <title>jQuery+RequireJS Sample Page</title>
        <!-- This is a special version of jQuery with RequireJS built-in -->
        <script src="scripts/angular.js" ></script>
      <script src="scripts/controllers.js"></script>
      <script src="scripts/jquery-1.5.2.min.js"></script>
      <script src="scripts/jquery.alpha.js" ></script>
      <script src="scripts/jquery.beta.js" ></script>
        <script>        
         $(document).ready(function(){
             $("#mydiv").html("Hello this is RequireJS talking");
             $('body').alpha().beta();
         });
   
        </script>
    </head>
    <body ng-controller="PhoneListCtrl" >
        <h1>jQuery+RequireJS Sample Page</h1>
        <p>Look at source or inspect the DOM to see how it works.</p>
       
       
       
        <div id="mydiv">aaa</div>
        <p>Total number of phones: {{phones.length}} </p>
        <p>Angulars Templates - http://docs.angularjs.org/tutorial/step_02</p>

 <p>Nothing here {{'yet' + '!'}}</p>
 
 <p>1 + 2 = {{ 1 + 2 }}</p>
 
 <p class="hello">{{hello}}______</p>
    </body>
</html>

 

 

 

 

 

 

반응형

+ Recent posts