1) Just set your label to have a fixed with (setFixedWidth), or make your other widgets size policies "expanding" so they take up any new space. Probably the first one though.
2) If you want an asynchronous result from your filedialog, then instead of using my static getExistingDirectory() suggestion, just stick with creating the instance like you were. If you stay with calling the exec_() on the dialog, you are waiting for a response anyways so you can just set the value on to the text box. But for the async approach, you would show() instead of exec_() and maybe connect the accept() signal to a slot that will check the value and enter it into the textedit. For more specific help, I would need to see an example of what you are trying. 3) Why would so many people recommend not using list comprehension? Just flat out not to use it? They are a great way to get more performance than a normal for loop. I can see there are misuses of them though. For your specific example, you would usually not want to use a list comprehension for side effects. That is, you shouldn't use them to append or call some method in a loop. They are used to produce results that you intend to keep. There really isn't much you can do to change your example. Qt would have needed to provide an layout.addWidgets(aList) to accept a list of widgets. So you just need to call them in order like you are doing. On Fri, Dec 7, 2012 at 1:10 PM, šãñ <[email protected]> wrote: > > thank you guys for pointing a solution but Now I really have a bunch of > more questions these are pretty basic that i know ... > > my first question is how do I keep the gridColumWidth fixed so that it > should not change if the label text changes(see attached image) > > my second question is how can i use a showFileDialog slot fill QLineEdit > for scne file for selecting directory and similarly in second tab ..(as you > can see in the attached screenshot I have so many browse buttons) > I remember seeing in the PyQt tutorial where you made use of partial but i > guess that was for removeCallable from OM, but now how should i find > QPushButton.objectName to be passed to slot so depending on what button is > pressed i can perform some operation... > > thirdly , so many people have recommended me not to use List comprehension > but i find it convenient(at least here) to use while addWidget or > addLayout... > like [p3_HBox2.addWidget(each) for each in > [self.pylbl,self.pyEdt,self.pybrwBtn]] > > but I have a situation when I am using a combination of addWidget > ,addStretch and addLayout > > like in this case > > p1_vertical.addLayout(gridLayout) > p1_vertical.addLayout(gridLayout2) > p1_vertical.addLayout(hbox) > p1_vertical.addWidget(hLine) > p1_vertical.addLayout(nxtbtnbox) > > in that case how should i after adding hbox in LC i can add > addWidget(hLine) then again nxtbtnbox, i feel like i can use it with > enumerate but is their any better option? > > > > > On Sat, Dec 8, 2012 at 12:30 AM, Justin Israel <[email protected]>wrote: > >> If you are using your own custom status bar in a widget, then you have to >> connect focus or hover events to something that sets the message on the >> status bar. You can set the setStatusTip("") on each widget and then just >> read that. >> >> When you use a QMainWindow, the status bar is already wired up for you so >> that any time you hover a widget, the statusBar will automatically read the >> widgets statusTip(): >> >> app = QtGui.QApplication([]) >> >> w = QtGui.QMainWindow() >> button = QtGui.QPushButton("clicky", w) >> button.setStatusTip("I am a clicky") >> w.setCentralWidget(button) >> >> status = w.statusBar() >> >> w.show() >> w.raise_() >> >> status.showMessage("Welcome to the app!", 5000) >> >> app.exec_() >> >> For the file dialog, the way you are using it, there is a convenience >> static method you can call: >> http://qt-project.org/doc/qt-4.8/qfiledialog.html#getExistingDirectory >> >> It will return an empty string if they cancel: >> >> directory=os.path.expanduser('~') >> selectedDir = QtGui.QFileDialog.getExistingDirectory(w, >> "Select Render Directory", directory) >> >> if selectedDir.isEmpty(): >> print "No directory selected" >> else: >> print selectedDir >> >> >> On Fri, Dec 7, 2012 at 9:56 AM, Kurian O.S <[email protected]> wrote: >> >>> For Directory you want to use exec so you need to change your code like >>> this >>> >>> def showDirDialog(self): >>> directory=os.path.expanduser('~') >>> dirPath=QtGui.QFileDialog(self,"Select Render Directory", >>> directory) >>> dirPath.setFileMode(QtGui.QFileDialog.DirectoryOnly) >>> if dirPath.exec_() == 1: >>> fname_list = str(dirPath.selectedFiles()[0]) >>> print fname_list >>> >>> For changing the statusBar text you need to implement focusIn and out >>> Event and Justin already mention about that in reimplement QPlainText’s >>> focusInEvent in another source file ,how to ? thread. >>> >>> >>> On Fri, Dec 7, 2012 at 6:25 AM, san <[email protected]> wrote: >>> >>>> as a part of my learning PyQt4 I started making a gui(see attachment) >>>> where I implement all the examples I learn from video tuts or book I am >>>> referring, >>>> >>>> however I count figure out how should I implement the method to show >>>> text message on the status bar when user hover mouse over a widget[link to >>>> pastebin >>>> <http://pastebin.com/9gfYaWRV>] >>>> >>>> and secondly I dont understand how come this method to select Directory >>>> is not working? >>>> >>>> def showDirDialog(self): >>>> directory=os.path.expanduser('~') >>>> dirPath=QtGui.QFileDialog(self,"Select Render Directory", >>>> directory) >>>> dirPath.setFileMode(QtGui.QFileDialog.DirectoryOnly) >>>> >>>> -- >>>> view archives: http://groups.google.com/group/python_inside_maya >>>> change your subscription settings: >>>> http://groups.google.com/group/python_inside_maya/subscribe >>>> >>> >>> >>> >>> -- >>> --:: Kurian ::-- >>> >>> -- >>> view archives: http://groups.google.com/group/python_inside_maya >>> change your subscription settings: >>> http://groups.google.com/group/python_inside_maya/subscribe >>> >> >> -- >> view archives: http://groups.google.com/group/python_inside_maya >> change your subscription settings: >> http://groups.google.com/group/python_inside_maya/subscribe >> > > > > -- > ** > > [image: San's personal blog] <http://feeds.feedburner.com/SanLuthraBlog> > > * > * > > -- > view archives: http://groups.google.com/group/python_inside_maya > change your subscription settings: > http://groups.google.com/group/python_inside_maya/subscribe > -- view archives: http://groups.google.com/group/python_inside_maya change your subscription settings: http://groups.google.com/group/python_inside_maya/subscribe
