Dec-12-2018, 04:23 PM
(This post was last modified: Dec-12-2018, 04:24 PM by WatcherMagic.)
I've got a widget I'm designing with code.
https://sta.sh/01fewfus0r9s
I want the buttons and text box to take up nearly the whole page, with the title labels being at the top. I don't have stretches anywhere, could someone help?
https://sta.sh/01fewfus0r9s
I want the buttons and text box to take up nearly the whole page, with the title labels being at the top. I don't have stretches anywhere, could someone help?
import os
import sys
import PyQt5
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
home = os.path.expanduser('~')
app = PyQt5.QtWidgets.QApplication(sys.argv)
screenres = app.desktop().screenGeometry()
scrW, scrH = screenres.width(), screenres.height()
width = 500
height = 500
class EditPage(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.setGeometry((scrW-width)/2, (scrH-height)/2, width, height)
self.setWindowTitle('IvyVine')
#__________Buttons
btnW = (width *.15)
btnH = (height *.25)
vbtns = QVBoxLayout()
buttons = ['A','B','C','D','E']
buttonSizePolicy = QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
for letter in buttons:
button = QPushButton(letter)
button.resize(btnW, btnH)
button.setSizePolicy(buttonSizePolicy)
vbtns.addWidget(button)
backbtn = QPushButton('<', self)
backbtn.setSizePolicy(buttonSizePolicy)
savebtn = QPushButton('Save', self)
savebtn.setSizePolicy(buttonSizePolicy)
homebtn = QPushButton('Home', self)
homebtn.setSizePolicy(buttonSizePolicy)
vbtns.addWidget(backbtn)
vbtns.addWidget(savebtn)
vbtns.addWidget(homebtn)
#________________
topbox = QVBoxLayout()
foldertitle = QLabel()
foldertitle.setText('Folder Title')
foldertitle.setAlignment(Qt.AlignCenter)
foldertitle.setMaximumHeight(25)
pagetitle = QLabel()
pagetitle.setText('Page Title')
pagetitle.setAlignment(Qt.AlignCenter)
pagetitle.setMaximumHeight(25)
topbox.addWidget(foldertitle)
topbox.addWidget(pagetitle)
#________________
midbox = QHBoxLayout()
textSizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
pagetext = QLineEdit()
pagetext.setSizePolicy(textSizePolicy)
midbox.addWidget(pagetext)
midbox.addLayout(vbtns)
#________________
bigbox = QVBoxLayout()
bigbox.addLayout(topbox)
#bigbox.addStretch(1)
bigbox.addLayout(midbox)
#bigbox.addStretch(1)
self.setLayout(bigbox)
self.show()
if __name__ == '__main__':
window = EditPage()
sys.exit(app.exec_())
