Pyloid 공식문서
GithubLanguage
  • 💎Pyloid란 무엇인가?
  • 시작하기
    • 사전 요구사항
    • 프로젝트 생성하기
  • API
    • Python (백엔드)
      • Pyloid
      • BrowserWindow
      • PyloidAPI
      • Monitor
      • TrayEvent
      • 유틸리티 함수
    • Javascript (프론트엔드)
      • WindowAPI
      • EventAPI
  • 가이드
    • 커스텀 보일러플레이트 만들기
    • 웹뷰 로드하기
    • JS에서 Python 호출하기
    • Python에서 JS 호출하기
    • 키보드 단축키
    • 알림
    • 트레이
    • 타이머
    • 파일 감시
    • 클립보드
    • 창 위치
    • 개발자 도구
    • 창 사용자 정의
    • 자동 시작
    • 프로덕션 유틸리티
    • 데스크탑 모니터
    • 파일 다이어로그
    • 스플래시 스크린
    • 스레드
    • ⚡pyside를 사용하여 API 커스터마이징
    • 테마
    • 빌드 가이드
      • Pyloid-React-Vite
      • Pyloid-HTML-Boilerplate
Powered by GitBook
On this page
  • Bridge와 함께 사용
  • Bridge 데코레이터
  • 사용 예시
  1. API
  2. Python (백엔드)

PyloidAPI

PyloidAPI 클래스는 QObject를 상속받아 구현됩니다.

Bridge와 함께 사용

PyloidAPI 클래스는 JavaScript와 Python 간의 상호 작용을 가능하게 하는 Bridge 데코레이터와 함께 사용됩니다. Bridge 데코레이터를 사용하면 JavaScript에서 Python 메서드를 호출할 수 있습니다.

Bridge 데코레이터

Bridge 데코레이터는 다음과 같은 매개변수를 사용할 수 있습니다:

  • result: 반환 타입을 지정합니다.

  • args: 인자 타입을 지정합니다.

사용 예시

from Pyloid import PyloidAPI, Bridge

class CustomAPI(PyloidAPI):
    @Bridge(str, int, result=str)
    def echo(self, message, number):
        print(f"메시지: {message}-{number}")
        return f"Python에서 받은 메시지: {message}-{number}"

    @Bridge(result=str)
    def getAppVersion(self):
        return "1.0.0"

    @Bridge(result=str)
    def create_window(self):
        window = app.create_window(
            title="Pyloid 브라우저2",
        )

        window.set_size(800, 600)
        window.set_position(0, 0)
        window.load_url("https://www.google.com")
        window.show()
        window.focus()

        return window.id

window = app.create_window(
    title="Pyloid 브라우저1",
    js_apis=[CustomAPI()],
    dev_tools=True
)

if (is_production()):
    window.load_file(os.path.join(get_production_path() + "/index.html"))
else:
    window.load_file("index.html")

window.show()
window.focus()

app.run()
PreviousBrowserWindowNextMonitor

Last updated 7 months ago