我目前正在尝试在辅助屏幕上显示无边界图像,使用PyQT5修改Matplotlib的默认图形。在上下文中,这是在空间光调制器上显示图像,该调制器使用简单的HDMI输出,并由我的计算机作为辅助屏幕处理。其分辨率为1280x1024。我按照How to disable the maximize, minimize and close button of the matplotlib window?的答案进行了链接,但仍然在图形的底部添加了边框,并且在全屏显示图形时也添加了边框。这是我用来生成窗口的类:
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()
我用这个非常简单的片段测试了窗口的良好初始化:
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)
最后,窗口如下所示:
任何帮助都将不胜感激
我终于在这里找到了答案:https://discourse.matplotlib.org/t/image-full-screen/19797/2 通过添加
window.statusBar().setVisible(False)
,边界消失相关问题 更多 >
编程相关推荐