3

I am getting input with this here

areaInput = QtGui.QInputDialog.getText(self, "Copy Area", "New Area Name:", 0)

However I would like to make the dialog box larger, I've tried things such as

QtGui.QInputDialog.resize(400, 400)

However it says "the first argument must be a QWidget class" and I'm not quite sure what this means or how to fix it. Thanks.

siege
  • 61
  • 1
  • 1
  • 5

3 Answers3

16

it is possible by doing this:

dlg =  QtGui.QInputDialog(self)                 
dlg.setInputMode( QtGui.QInputDialog.TextInput) 
dlg.setLabelText("URL:")                        
dlg.resize(500,100)                             
ok = dlg.exec_()                                
url = dlg.textValue()
Jaroslav Safka
  • 169
  • 1
  • 2
4

That error implies that you're not calling an instance method with an instance.

QtGui.QInputDialog.getText() is a static method and doesn't return you a QWidget instance, so you can't call resize() on it.

If you want to call resize(), you need to create your own QWidget (or QDialog).

Kaleb Pederson
  • 45,767
  • 19
  • 102
  • 147
  • Ok thanks, so there is no way to resize the little pop up with just simple one line of code? – siege Mar 15 '10 at 23:23
  • No. But, it would be an interesting exercise to see if you could get a hold of the dialog through the parent's `findChildren()` method (I'm not sure what the PyQt equivalent might be) and on which you might be able to call resize. But since `getText()` is a blocking call and you would need to call `resize()` from the GUI thread, it certainly won't be trivial. – Kaleb Pederson Mar 15 '10 at 23:32
2

I had the same problem. Mainly that the window was too narrow horizontally, making the text edit input field small. I ended up putting lots of whitespace after the text in the label argument. Worked fine for me.

Henrik
  • 21
  • 1