How do I resize the combo box horizontally in python using pyqt4 -
this code i'm implementing right now, want resize combo box horizontally occupy maximum space possible. combo.resize
gives me option stretch vertically.
import sys pyqt4 import qtgui, qtcore class phaseone(qtgui.qwidget): def __init__(self): super(phaseone, self).__init__() self.initui() def initui(self): self.resize(350,150) self.center() self.setwindowtitle('programmer') self.setwindowflags(qtcore.qt.windowminimizebuttonhint) qtgui.qtooltip.setfont(qtgui.qfont('sansserif', 10)) btn = qtgui.qpushbutton('next', self) btn.settooltip('proceed next step') btn.resize(btn.sizehint()) btn.move(250, 110) btn = qtgui.qpushbutton('exit', self) btn.settooltip('exit application') btn.resize(btn.sizehint()) btn.move(175, 110) self.lbl = qtgui.qlabel("select programming language",self) combo = qtgui.qcombobox(self) combo.additem("c") combo.additem("c++") combo.additem("java") combo.additem("ruby") combo.additem("python") #adjusting combo box #combo.resize(50,20) combo.move(50,50) self.lbl.move(50,25) self.show() def center(self): qr = self.framegeometry() cp = qtgui.qdesktopwidget().availablegeometry().center() qr.movecenter(cp) self.move(qr.topleft()) def closeevent(self, event): reply = qtgui.qmessagebox.question(self, 'message', "are sure quit?", qtgui.qmessagebox.yes | qtgui.qmessagebox.no, qtgui.qmessagebox.no) if reply == qtgui.qmessagebox.yes: event.accept() else: event.ignore() def main(): app = qtgui.qapplication(sys.argv) ex = phaseone() sys.exit(app.exec_()) if __name__ == '__main__': main()
so, solved problem. combo.resize
option did provided didn't know how use it. positioning handled combo.move
, stretch horizontally first value changed in combo.resize
.
Comments
Post a Comment