我的目标是制作一个小巧的PC / Windows程序,使我可以从字面上画在屏幕顶部,并将结果另存为具有透明背景的png。像Epic Pen或gInk之类的软件一样,但是我的方式。全部使用Python 3.7和PyQt5。
到目前为止,由于我同时在学习PyQt,因此我设法获得了一个功能绘图应用程序(基本上遵循本教程)。我设法将草稿另存为具有透明背景的png。我可以使绘图板全屏且无边框。
现在的问题是,我找不到使整个背景透明的方法。尽管我找到了使用这些方法使窗口透明和无边界的方法:
Window = Window()
Window.setStyleSheet("background:transparent;")
Window.setAttribute(Qt.WA_TranslucentBackground)
Window.setWindowFlags(Qt.FramelessWindowHint)
Window.show()
Run Code Online (Sandbox Code Playgroud)
而且有效...直到我有了绘图区域。我可以在其上绘制,它将以透明背景保存,但显示为黑色。
因此,我正在寻找该解决方案。即使没有PyQt,只要我可以使程序正常运行,我也不在乎。
因此,这就是我所拥有的(我为您展示了带有框架的窗口,以便于解释):
这是我的代码:
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QMenuBar, QMenu, QAction, QShortcut, QFileDialog
from PyQt5.QtGui import QIcon, QImage, QPainter, QPen
from PyQt5.QtCore import Qt, QPoint
class Window(QMainWindow):
def __init__(self):
super().__init__()
top = 400
left = 400
width = 800
height = 600
icon = "icons/icon.png"
self.setWindowTitle("ScreenPen drawing board")
self.setGeometry(top, left, width, height)
self.setWindowIcon(QIcon(icon))
# ---------- sets …
Run Code Online (Sandbox Code Playgroud) 全部,
在实施身份验证保护之前,我能够在登录和注册屏幕中隐藏我的导航栏。通过读取 component.ts 中的路由事件并通过 ngIf 隐藏导航栏。在我实现了 auth guard 后,auth guard 到登录页面的路由没有隐藏下面的导航栏是我的代码..
在这里,我的 auth 守卫服务将检查用户是否通过 auth 服务(将从 cognito 获取数据)进行身份验证。现在,我怎样才能从 auth 守卫发生的路线中隐藏导航栏。请帮忙
应用程序组件.html
<app-toolbar *ngIf="isShowNavbar" ></app-toolbar>
<router-outlet></router-outlet>
Run Code Online (Sandbox Code Playgroud)
app.component.ts
import { Component,OnInit } from '@angular/core';
import {AuthorizationService} from "./authorization.service";
import { Router, ActivatedRoute, UrlSegment, NavigationEnd } from '@angular/router';
import { Observable } from 'rxjs';
import { first, distinctUntilChanged, throttleTime } from '../../node_modules/rxjs/operators';
@Component({
// tslint:disable-next-line: component-selector
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent implements OnInit {
isLoggedIn$: Observable<boolean>; …
Run Code Online (Sandbox Code Playgroud) 我想获得以下值data-url
:
{#each profiles as p}
<div data-url={p.url} class="item" on:click={goToPage}>
<div class="row">
<div class="col s12 l4">
<div class="a">
<br />
</div>
</div>
<div class="col s12 l8">
<p>
<strong>{p.fn} {p.ln}</strong><br />
{p.ttl}
</p>
</div>
</div>
{p.dsc}
<hr />
</div>
{/each}
Run Code Online (Sandbox Code Playgroud)
其功能是:
const goToPage = (e) => {
var slug = e.target.querySelector("item").getAttribute("url");
console.log("slug is:", slug);
window.location.href = slug;
};
Run Code Online (Sandbox Code Playgroud)
然而它不起作用,我得到
Uncaught TypeError: Cannot read properties of null (reading 'getAttribute')
Run Code Online (Sandbox Code Playgroud)
我尝试过其他事情,比如
e.target.querySelector("item").getAttribute("data-url");
Run Code Online (Sandbox Code Playgroud)
和
e.target.getAttribute("data-url");
Run Code Online (Sandbox Code Playgroud)
但它们都不起作用。
我想检测服务器端呈现的页面的当前请求 -ssr
来自网络爬虫或普通用户。
我想在网络爬虫中做一些事情,而不是当它是用户时做。
我想ng-in-viewport
在网络爬虫访问页面时运行以获取完整数据。
但不要在用户使用我的页面时运行。
如何检测这个东西?
angular ×2
angular8 ×1
auth-guard ×1
javascript ×1
pyqt5 ×1
python ×1
python-3.x ×1
screenshot ×1
svelte ×1
transparency ×1
universal ×1
web-crawler ×1