[英]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.