python - How to Resize and Position Buttons in PySide? -
i writing application using pyside , have added 2 buttons 2 it. however, when run program buttons scale length of window not want. want button of small size , positioned right. how do this? there method use?
i don't know layout you've used or want use, maybe help:
using box layout:
#!/usr/local/bin/python2.7 # -*- coding: utf-8 -*- import sys pyside import qtgui class sample(qtgui.qwidget): def __init__(self): super(sample, self).__init__() self.initui() def initui(self): self.setgeometry(300, 300, 800, 600) self.setwindowtitle('sample') btn1 = qtgui.qpushbutton("button 1") hbox = qtgui.qhboxlayout() hbox.addstretch(1) hbox.addwidget(btn1) self.setlayout(hbox) self.show() def main(): app = qtgui.qapplication(sys.argv) ex = sample() sys.exit(app.exec_()) if __name__ == '__main__': main()
Comments
Post a Comment