[英]Remove borders on PyQt5 QWidget
我目前正在尝试使用 PyQT5 在修改 Matplotlib 的默认图形的辅助屏幕上显示无边框图像。 就上下文而言,这是在使用简单 HDMI output 并由我的计算机作为辅助屏幕处理的空间光调制器上显示图像。 其分辨率为 1280x1024。 我按照如何禁用 matplotlib window 的最大化、最小化和关闭按钮? , 链接,但仍然在图形底部有一个边框,并且在全屏显示图形时也会添加边框。 这是我用来生成 window 的 class:
class SLMscreen:
def __init__(self, resX, resY):
"""
Initializes the window to be displayed on the SLM
:param resX: Width in pixel
:param resY: Height in pixel
"""
#dirty way of finding the primary screen size, could be improved
app = QApplication([])
screen_resolution = app.desktop().screenGeometry()
width, height = screen_resolution.width(), screen_resolution.height()
mpl.rcParams['toolbar'] = 'None'
self.fig = plt.figure(figsize=(resX / 100, resY / 100), frameon=False)
self.ax = plt.axes([0,0,1,1], frameon=False)
self.ax.get_xaxis().set_visible(False)
self.ax.get_yaxis().set_visible(False)
self.fig.patch.set_visible(False)
self.ax.patch.set_visible(False)
window = self.fig.canvas.parent()
window.setWindowFlags(Qt.FramelessWindowHint | Qt.CustomizeWindowHint)
window.setGeometry(width,0,resX,resY)
window.layout().setContentsMargins(0, 0, 0, 0)
window.layout().setSpacing(0)
#self.fig.canvas.parent().showFullScreen()
#self.figManager.window.showMaximized()
def update(self, array):
"""
Displays the array on the SLM
:param array: np.ndarray
"""
self.ax.imshow(array, cmap='gray', aspect='equal')
self.figManager.window.showMaximized()
我用这个非常简单的代码片段测试了 window 的良好初始化:
import numpy as np
from SLM import SLMscreen
mask =255* np.zeros((1024,1280), dtype='uint8')
slm_screen = SLMscreen(1280,1024)
slm_screen.update(mask)
最后 window 看起来像这样:
任何帮助将不胜感激!
我终于在这里找到了答案: https://discourse.matplotlib.org/t/image-full-screen/19797/2通过添加window.statusBar().setVisible(False)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.