Skip to content

Latest commit

 

History

History
262 lines (179 loc) · 5.16 KB

jsapi_mainwin.md

File metadata and controls

262 lines (179 loc) · 5.16 KB
layout
doc

pyChariot.api.mainwin

小应用主窗口管理,主窗口状态管理与操作

show() {#show}

显示主窗口

await __A.mainwin.show();

hide() {#hide}

隐藏主窗口

返回值 说明
string 路径名称
await __A.mainwin.hide();

getTitle() {#getTitle}

获取当前小应用主窗口的窗口标题

返回值 说明
string
await __A.mainwin.getTitle();

setTitle(title) {#setTitle}

获取当前小应用主窗口的窗口标题

参数 类型 说明
title string 窗口标题
await __A.mainwin.setTitle('新的窗口标题');

getOnTop() {#getOnTop}

返回主窗口 on_top 状态(显示在最前面)

await __A.mainwin.getOnTop();

setOnTop(on_top) {#setOnTop}

设置主窗口 on_top 状态(显示在最前面)

参数 类型 说明
on_top bool 是否显示在最前面,默认为 true。
await __A.mainwin.setOnTop();
await __A.mainwin.setOnTop(false);

getX() {#getX}

获取主窗口坐标 x 值。

返回值 说明
number
await __A.mainwin.getX();

getY() {#getY}

获取主窗口坐标 x 值。

返回值 说明
number
await __A.mainwin.getY();

move(x, y) {#move}

移动小应用主窗口到指定坐标

参数 类型 说明
x number
y number
// 主窗口向右下移动
x = await __A.mainwin.getX();
y = await __A.mainwin.getY();
await __A.mainwin.move(x + 2, y + 2);
// 主窗口移动到屏幕左上角
await __A.mainwin.move(0, 0);

getWidth() {#getWidth}

获取主窗口宽度

返回值 说明
number
await __A.mainwin.getWidth();

getHeight() {#getHeight}

获取主窗口高度

返回值 说明
number
await __A.mainwin.getHeight();

resize(width, height) {#resize}

移动小应用主窗口到指定坐标

参数 类型 说明
width number
height number
// 主窗口变大一些
width = await __A.mainwin.getWidth();
height = await __A.mainwin.getHeight();
__A.mainwin.resize(width + 2, height + 2);

restore() {#restore}

还原主窗口

await __A.mainwin.restore();

toggleFullscreen() {#toggleFullscreen}

切换主窗口全屏显示状态

await __A.mainwin.toggleFullscreen();

maximize() {#maximize}

主窗口最大化

await __A.mainwin.maximize();

minimize() {#minimize}

主窗口最小化

await __A.mainwin.minimize();

loadUrl(url) {#loadUrl}

在主窗口中加载指定的 url

参数 类型 说明
url string
await __A.mainwin.loadUrl('https://chanix.github.io/pyChariot/');

loadHtml(htmlcode) {#loadHtml}

在主窗口中加载指定的 url

参数 类型 说明
htmlcode string
await __A.mainwin.loadHtml('<h1>This is dynamically loaded HTML</h1>');

loadCss(css) {#loadCss}

在主窗口中加载自定义 CSS

参数 类型 说明
css string
await __A.mainwin.loadCss('body { background: red !important; }');

getStatus() {#getStatus}

获得主窗口常用信息

返回值 说明
object

主窗口常用信息,包括以下字段:

  • x: 坐标 x;
  • y: 坐标 y;
  • width: 宽度;
  • height: 高度;
  • title: 窗口标题;
  • ontop: 是否总是显示在最前面;
  • state: 窗口状态:
    • 0 最小化
    • 1 正常
    • 2 最大化
    • 其他:未知状态
await __A.mainwin.getInfo();

reload() {#reload}

重新装载浏览器窗口当前网址

await __A.mainwin.reload();