Once you run this code, you can see that there is a horizontal slider at the bottom:
from PySide6.QtWidgets import QApplication, QWidget, QMainWindow, QScrollArea, QGridLayout, QLabel, QGroupBox
import pyqtgraph as pg
import sys
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
def Draw(self):
self.scroll = QScrollArea()
self.home_widget = QWidget()
self.home_layout = QGridLayout(self.home_widget)
self.home_layout.setContentsMargins(0,0,0,0)
self.home_layout.addWidget(self.Summary(), 0, 0)
self.home_layout.addWidget(self.Body(), 1, 0)
#self.home_widget.setFixedWidth(self.home_widget.sizeHint().width())
self.scroll.setWidget(self.home_widget)
return self.scroll
def Summary(self):
self.summary_groupbox = QGroupBox()
self.summary_layout = QGridLayout(self.summary_groupbox)
self.networth_label = QLabel("Networth :")
self.networth_value = QLabel("10,000,000.00")
self.networth_evolution_chart = pg.PlotWidget(name='networth', axisItems = {'bottom': pg.DateAxisItem()})
self.networth_evolution_chart.showGrid(x=True, y=True)
self.networth_evolution_chart.setLabel('left', 'Value', units='€')
self.total_assets = QLabel("Total Assets :")
self.total_assets_value = QLabel("11,000,000.00")
self.total_assets_evolution_chart = pg.PlotWidget(name='total_assets', axisItems = {'bottom': pg.DateAxisItem()})
self.total_assets_evolution_chart.showGrid(x=True, y=True)
self.total_assets_evolution_chart.setLabel('left', 'Value', units='€')
self.total_debt_label = QLabel("Total Debt :")
self.total_debt_value = QLabel("0")
self.total_debt_evolution_chart = pg.PlotWidget(name='total_debt', axisItems = {'bottom': pg.DateAxisItem()})
self.total_debt_evolution_chart.showGrid(x=True, y=True)
self.total_debt_evolution_chart.setLabel('left', 'Value', units='€')
self.total_liabilities = QLabel("Total Liabilities :")
self.total_liabilities_value = QLabel("1,000,000")
self.total_liabilities_evolution_chart = pg.PlotWidget(name='total_liabilities', axisItems = {'bottom': pg.DateAxisItem()})
self.total_liabilities_evolution_chart.showGrid(x=True, y=True)
self.total_liabilities_evolution_chart.setLabel('left', 'Value', units='€')
self.summary_layout.addWidget(self.networth_label, 0, 0)
self.summary_layout.addWidget(self.networth_value, 0, 1)
self.summary_layout.addWidget(self.networth_evolution_chart, 1, 0, 1, 2)
self.summary_layout.addWidget(self.total_assets, 0, 2)
self.summary_layout.addWidget(self.total_assets_value, 0, 3)
self.summary_layout.addWidget(self.total_assets_evolution_chart, 1, 2, 1, 2)
self.summary_layout.addWidget(self.total_debt_label, 0, 4)
self.summary_layout.addWidget(self.total_debt_value, 0, 5)
self.summary_layout.addWidget(self.total_debt_evolution_chart, 1, 4, 1, 2)
self.summary_layout.addWidget(self.total_liabilities, 0, 6)
self.summary_layout.addWidget(self.total_liabilities_value, 0, 7)
self.summary_layout.addWidget(self.total_liabilities_evolution_chart, 1, 6, 1, 2)
self.summary_groupbox.setFixedHeight(400)
return self.summary_groupbox
def Body(self):
self.body_groupbox = QGroupBox()
self.body_layout = QGridLayout(self.body_groupbox)
self.body_groupbox.setFixedHeight(3000)
return self.body_groupbox
if __name__ == '__main__':
app = QApplication(sys.argv)
mainWindow = MainWindow().Draw()
mainWindow.showMaximized()
sys.exit(app.exec())
What I want is for there not to be a horizontal slide bar at the bottom and the widgets fit nicely within the screen width wise, but you can still scroll down as there will be more widgets below. In this code right below, this width issue is not a problem, though I cannot scroll downwards to see the bottom of for example the second group box which is 3000 pixels high, which is what I want...
from PySide6.QtWidgets import QApplication, QWidget, QMainWindow, QScrollArea, QGridLayout, QLabel, QGroupBox
import pyqtgraph as pg
import sys
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
def Draw(self):
self.home_widget = QWidget()
self.home_layout = QGridLayout(self.home_widget)
self.home_layout.setContentsMargins(0,0,0,0)
self.home_layout.addWidget(self.Summary(), 0, 0)
self.home_layout.addWidget(self.Body(), 1, 0)
return self.home_widget
def Summary(self):
self.summary_groupbox = QGroupBox()
self.summary_layout = QGridLayout(self.summary_groupbox)
self.networth_label = QLabel("Networth :")
self.networth_value = QLabel("10,000,000.00")
self.networth_evolution_chart = pg.PlotWidget(name='networth', axisItems = {'bottom': pg.DateAxisItem()})
self.networth_evolution_chart.showGrid(x=True, y=True)
self.networth_evolution_chart.setLabel('left', 'Value', units='€')
self.total_assets = QLabel("Total Assets :")
self.total_assets_value = QLabel("11,000,000.00")
self.total_assets_evolution_chart = pg.PlotWidget(name='total_assets', axisItems = {'bottom': pg.DateAxisItem()})
self.total_assets_evolution_chart.showGrid(x=True, y=True)
self.total_assets_evolution_chart.setLabel('left', 'Value', units='€')
self.total_debt_label = QLabel("Total Debt :")
self.total_debt_value = QLabel("0")
self.total_debt_evolution_chart = pg.PlotWidget(name='total_debt', axisItems = {'bottom': pg.DateAxisItem()})
self.total_debt_evolution_chart.showGrid(x=True, y=True)
self.total_debt_evolution_chart.setLabel('left', 'Value', units='€')
self.total_liabilities = QLabel("Total Liabilities :")
self.total_liabilities_value = QLabel("1,000,000")
self.total_liabilities_evolution_chart = pg.PlotWidget(name='total_liabilities', axisItems = {'bottom': pg.DateAxisItem()})
self.total_liabilities_evolution_chart.showGrid(x=True, y=True)
self.total_liabilities_evolution_chart.setLabel('left', 'Value', units='€')
self.summary_layout.addWidget(self.networth_label, 0, 0)
self.summary_layout.addWidget(self.networth_value, 0, 1)
self.summary_layout.addWidget(self.networth_evolution_chart, 1, 0, 1, 2)
self.summary_layout.addWidget(self.total_assets, 0, 2)
self.summary_layout.addWidget(self.total_assets_value, 0, 3)
self.summary_layout.addWidget(self.total_assets_evolution_chart, 1, 2, 1, 2)
self.summary_layout.addWidget(self.total_debt_label, 0, 4)
self.summary_layout.addWidget(self.total_debt_value, 0, 5)
self.summary_layout.addWidget(self.total_debt_evolution_chart, 1, 4, 1, 2)
self.summary_layout.addWidget(self.total_liabilities, 0, 6)
self.summary_layout.addWidget(self.total_liabilities_value, 0, 7)
self.summary_layout.addWidget(self.total_liabilities_evolution_chart, 1, 6, 1, 2)
self.summary_groupbox.setFixedHeight(400)
return self.summary_groupbox
def Body(self):
self.body_groupbox = QGroupBox()
self.body_layout = QGridLayout(self.body_groupbox)
self.body_groupbox.setFixedHeight(3000)
return self.body_groupbox
if __name__ == '__main__':
app = QApplication(sys.argv)
mainWindow = MainWindow().Draw()
mainWindow.showMaximized()
sys.exit(app.exec())
this is the semi working version ^^