当前位置:网站首页>Discard Tkinter! Simple configuration to quickly generate cool GUI!
Discard Tkinter! Simple configuration to quickly generate cool GUI!
2022-06-28 10:02:00 【AI technology base camp】

author | Parson sauce
source | Python technology
Python Session of the GUI There are lots of libraries , Like the famous Tkinter、PyGUI etc. , But the problem is that they generate GUI Not good-looking enough , There is a style of last century applications , It doesn't look like a product in the Internet age .
Today I recommend a super tool Electron, Just need to know some simple html、css and js Knowledge can write cross platform , Internet style applications .
big-name Visual Studio Code Is the use of Electron To write the .
install
Before the official start , Need to install Node Environmental Science , Download directly from the official website Node.js Can be installed .
After the installation, please use the following command to ensure your Node The environment is normal .
node -v
npm -vThen start initializing the project .
mkdir electron-app && cd electron-app
npm init thus , stay electron-app A... Will be generated in the folder package.json The file of , It should look like this , The meaning of each field does not matter for the time being , Keep going down .
{
"name": "my-electron-app",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
} Last , take electron Add to the development dependency of the application .
npm install --save-dev electron modify package.json file , Add the command to run the application .
{
"scripts": {
"start": "electron ."
}
}thus , The environment has been built .
GUI
It says ,Electron It's through html、css and js To build an application , Let's build one first html page .
Create in the root directory index.html page .
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>The page is finished , We also need a startup entry file to load our page .
New in the root directory index.js file .
const { app, BrowserWindow } = require('electron')
const path = require('path')
function createWindow () {
const win = new BrowserWindow({
width: 800,
height: 600,
})
win.loadFile('index.html')
}
app.whenReady().then(() => {
createWindow()
})stay js In the file, we create a BrowserWindow To load the page we specified index.html.
adopt npm To start our project .
npm startNo accident , You should see the following page .

summary
Electron It is a very mature and easy-to-use cross platform desktop application development artifact , Although we have only implemented a simple version of Hello World, but With the blessing of the front end , Write cool and follow the trend of the times GUI That's a matter of minutes .
So this one GUI How to communicate with our Python Programs interact with each other , First pass http Interface , Second, it can be executed directly Python Script for , If you are interested, you can follow the official documents to continue in-depth study .

Looking back
Matplotlib Two methods of drawing torus !
13 individual python Necessary knowledge , Recommended collection !
2D Transformation 3D, Look at NVIDIA's AI“ new ” magic !
Get it done Python Several common data structures !
Share
Point collection
A little bit of praise
Click to see 边栏推荐
- ==And eqauls()
- Stutter participle_ Principle of word breaker
- JSON数据与List集合之间的正确转换
- R language plot visualization: plot to visualize overlapping histograms, and use geom at the bottom edge of the histogram_ The rugfunction adds marginal rugplots
- Ideal interface automation project
- Dbeaver installation and use tutorial (super detailed installation and use tutorial)
- Summary of MySQL basic knowledge points
- An error is reported when uninstalling Oracle
- On the influence of small program on the digitalization of media industry
- 请教下, 我在本地idea运行flinkcdc的mysql到mysql全量同步,这个是在我本地ide
猜你喜欢

Function sub file writing

如何查看谷歌浏览器保存的网页密码

布隆过滤器 课程研究报告

TCP实战案例之即时通信、BS架构模拟

Missed the golden three silver four, found a job for 4 months, interviewed 15 companies, and finally got 3 offers, ranking P7+

PyGame game: "Changsha version" millionaire started, dare you ask? (multiple game source codes attached)

Proxy mode (proxy)

线程的生命周期

Thread lifecycle

Matplotlib属性及注解
随机推荐
2022-06-27:给出一个长度为n的01串,现在请你找到两个区间, 使得这两个区间中,1的个数相等,0的个数也相等, 这两个区间可以相交,但是不可以完全重叠
Data visualization makes correlation analysis easier to use
MySQL基础知识点总结
JSON数据与List集合之间的正确转换
Read PDF Text and write excel operation
Thread lifecycle
标识符的命名规则和规范
File operations in QT
Key summary VII of PMP examination - monitoring process group (1)
Global exception handlers and unified return results
我大抵是卷上瘾了,横竖睡不着!竟让一个Bug,搞我两次!
PMP examination key summary VIII - monitoring process group (2)
多线程-并发并行-线程进程
异常
Installing redis under Linux and windows (ultra detailed graphic tutorial)
Matplotlib attribute and annotation
引入 flink-sql-mysql-cdc-2.2.1 好多依赖冲突,有解决的吗?
Huawei OSPF single region
最小栈<难度系数>
如何查看谷歌浏览器保存的网页密码