This repository has been archived on 2023-09-06. You can view files and clone it, but cannot push or open issues/pull-requests.
yutent
/
py-gtk-notes
Archived
1
0
Fork 0
py-gtk-notes/app.js

58 lines
1.4 KiB
JavaScript

/**
* {}
* @author yutent<yutent.io@gmail.com>
* @date 2023/07/20 14:19:13
*/
import 'es.shim'
import { $, bind } from 'wkit'
async function test1() {
let txt = await native.clipboard.readText()
$('input').value = txt
}
async function test2() {
native.clipboard.writeText('这是一段写进剪切板的文本')
// native.handler('blabla', { foo: 'bar' }).then(r => {
// $('#output').innerHTML = JSON.stringify(r)
// })
}
bind($('.btn1'), 'click', test1)
bind($('.btn2'), 'click', test2)
bind($('.btn3'), 'click', async function () {
// window.open('about:blank')
// let img = await native.clipboard.writeImage('/code/gtk/webkit/debian.png')
let img = await native.image('/code/gtk/webkit/debian.png')
native.clipboard.writeImage(img)
// native.clipboard.writeImage('/code/gtk/webkit/debian.png')
try {
$('img').src = URL.createObjectURL(await img.export())
} catch (err) {
alert(err)
}
})
bind($('.btn4'), 'click', async function () {
native.quit()
// native.clipboard.clear()
})
bind($('.btn5'), 'click', async function () {
native.tray()
})
bind($('.btn6'), 'click', async function () {
console.log(await native.screen.getAllDisplays())
console.log(await native.screen.getPrimaryDisplay())
})
bind($('textarea'), 'paste', async function (ev) {
let items = ev.clipboardData.items
for (let it of items) {
let file = it.getAsFile()
$('img').src = URL.createObjectURL(file)
break
}
})
python + gtk3 + webkit2 学习笔记
Python 60.1%
JavaScript 37.6%
HTML 2.3%