Pyside will also do that. Won't let the user enter anything but
numbers it you want. But it might be an overkill learning curve
if you only need it for this case.

On Tue, May 15, 2012, at 11:57, Nathan Rusch wrote:

You could do it with a PythonPanel containing an Int_Knob, but
that may be a little heavy for a simple case like this.

I would probably just wrap the nuke.getInput call to validate the
string as a number and cast it on return.

import re
def getNumericInput():
    while True:
        raw = nuke.getInput('Enter a number:')
        if raw is None:
            return
        if re.match('^\d+$', raw):
            return int(raw)
        nuke.message('Not a valid number')

Obviously this only handles ints, but if you need a float, you
can massage the regex a little.

Hope this helps.

-Nathan


From: [1]Ron Ganbar
Sent: Tuesday, May 15, 2012 11:48 AM
To: [2]Nuke Python discussion
Subject: Re: [Nuke-python] query a number from the user

Well, I wasn't in front of the computer before, and seems like
there isn't a number only knob to inherit for the panel object.
I tried this:

p = nuke.Panel( 'how many dudes?' )
p.addExpressionInput('dudes', '')
p.show()
result = p.value('dudes')
print p.value('dudes')

And it works, but you can type anything in there. Not just a
number.
Anybody knows a knob that only expects numbers?
Ron Ganbar
email: [3][email protected]
tel: +44 (0)7968 007 309 [UK]
     +972 (0)54 255 9765 [Israel]
url: [4]http://ronganbar.wordpress.com/
On 15 May 2012 20:27, Ron Ganbar <[5][email protected]> wrote:

  You can use a panel and create a knob that only permits
  numbers.

  R

On May 15, 2012 6:20 PM, <[6][email protected]>
wrote:

  Hiya.
  I Am looking for the way the get a pop up window asking me a
  value.
  I cheated by using
  val = int(nuke.getInput('enter the ref frame'))
  wich is normally a text box
  is there a better way for numbers ? I mean that will warn if
  something else than a number is entered
  cheers
  Olivier
  _______________________________________________
  Nuke-python mailing list
  [7][email protected],
  [8]http://forums.thefoundry.co.uk/
  [9]http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nu
  ke-python


  ____________________________________________________________

_______________________________________________
Nuke-python mailing list
[email protected],
http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-pyt
hon


_______________________________________________

Nuke-python mailing list

[10][email protected],
[11]http://forums.thefoundry.co.uk/

[12]http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke
-python

References

1. mailto:[email protected]
2. mailto:[email protected]
3. mailto:[email protected]
4. http://ronganbar.wordpress.com/
5. mailto:[email protected]
6. mailto:[email protected]
7. mailto:[email protected]
8. http://forums.thefoundry.co.uk/
9. http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
  10. mailto:[email protected]
  11. http://forums.thefoundry.co.uk/
  12. http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python


-- 
  Hugo Léveillé
  TD Compositing, Vision Globale
  [email protected]

_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to