get updated value of a UI qt widget?

53 views
Skip to first unread message

Rudi Hammad

unread,
Mar 14, 2016, 12:17:28 PM3/14/16
to Python Programming for Autodesk Maya
hello everyone,
so I have built this ui using qtDesigner and pyside . I launch the main window and I am trying to retrieve the values of my widgets, but it seems that they are not updated.
They remain with the values the have when the window open.
After a google search i saw in forum people saying to use .repaint() or .update() but it is not working for me.
For example I have  a widget named fingerLinks_spinBox, and I am trying the following:

controlMainWindow.ui.fingerLinks_spinBox.update()
controlMainWindow.ui.fingerLinks_spinBox.value()

(it is only 2 lines, so I didn´t use pasteBin, i hope it is ok)

the value is not updated. what I am doing wrong?

thanks




Marcus Ottosson

unread,
Mar 14, 2016, 12:51:10 PM3/14/16
to python_in...@googlegroups.com
Could you post a small example of the problem?

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/02463c0d-1761-463e-8212-d5ab72531334%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Rudi Hammad

unread,
Mar 14, 2016, 1:36:08 PM3/14/16
to Python Programming for Autodesk Maya
sure. I have this code that create my UI

ui code

I want to query the value of the spine box jntNumber = self.ui.joints_spnBox.value()
so, having my environment setup okey, I try the following in the maya python interpreter :

import setupTools_UIs.createRibbon_UI as crUI; reload(crUI)
controlMainWindow = crUI.ControlMainWindow()
controlMainWindow.ui.joints_spnBox.update()
controlMainWindow.ui.joints_spnBox.value()

but the value that I get is now the one that I put in the ui spinebox. it is always the same.
I was trying to update the
joints_spnBox, thinking that i would get the new value, but it doesn´t

Rudi Hammad

unread,
Mar 14, 2016, 1:39:43 PM3/14/16
to Python Programming for Autodesk Maya
sorry,I meant he value that I get is NOT the one that I put in the ui spinebox

Justin Israel

unread,
Mar 14, 2016, 2:20:40 PM3/14/16
to Python Programming for Autodesk Maya

So you are saying that when you click the link button, the value from the spinbox is never the one shown in the actual UI? I can understand how that could happen other than you querying a different object that the one you are editing.
You should not need to call update or repaint. Simply changing the value visually should allow you to pull the new value, programmatically.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

Rudi Hammad

unread,
Mar 14, 2016, 3:18:22 PM3/14/16
to Python Programming for Autodesk Maya
no,I mean that, I launch my UI. And then, what I want is to query the value of the spinbox of thatsame  UI I just opened. So I execute the following line in the script editor:
controlMainWindow.ui.joints_spnBox.value()


El lunes, 14 de marzo de 2016, 19:20:40 (UTC+1), Justin Israel escribió:

So you are saying that when you click the link button, the value from the spinbox is never the one shown in the actual UI? I can understand how that could happen other than you querying a different object that the one you are editing.
You should not need to call update or repaint. Simply changing the value visually should allow you to pull the new value, programmatically.


On Tue, 15 Mar 2016 6:39 AM Rudi Hammad <rudih...@gmail.com> wrote:
sorry,I meant he value that I get is NOT the one that I put in the ui spinebox


El lunes, 14 de marzo de 2016, 18:36:08 (UTC+1), Rudi Hammad escribió:
sure. I have this code that create my UI

ui code

I want to query the value of the spine box jntNumber = self.ui.joints_spnBox.value()
so, having my environment setup okey, I try the following in the maya python interpreter :

import setupTools_UIs.createRibbon_UI as crUI; reload(crUI)
controlMainWindow = crUI.ControlMainWindow()
controlMainWindow.ui.joints_spnBox.update()
controlMainWindow.ui.joints_spnBox.value()

but the value that I get is now the one that I put in the ui spinebox. it is always the same.
I was trying to update the
joints_spnBox, thinking that i would get the new value, but it doesn´t

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

Justin Israel

unread,
Mar 14, 2016, 3:27:47 PM3/14/16
to Python Programming for Autodesk Maya

Then I have no explanation for this behaviour. If you really are querying the same instance of the UI that is visually launched, you should get the currently displayed value.


On Tue, 15 Mar 2016 8:18 AM Rudi Hammad <rudih...@gmail.com> wrote:
no,I mean that, I launch my UI. And then, what I want is to query the value of the spinbox of thatsame  UI I just opened. So I execute the following line in the script editor:
controlMainWindow.ui.joints_spnBox.value()


El lunes, 14 de marzo de 2016, 19:20:40 (UTC+1), Justin Israel escribió:

So you are saying that when you click the link button, the value from the spinbox is never the one shown in the actual UI? I can understand how that could happen other than you querying a different object that the one you are editing.
You should not need to call update or repaint. Simply changing the value visually should allow you to pull the new value, programmatically.


On Tue, 15 Mar 2016 6:39 AM Rudi Hammad <rudih...@gmail.com> wrote:
sorry,I meant he value that I get is NOT the one that I put in the ui spinebox


El lunes, 14 de marzo de 2016, 18:36:08 (UTC+1), Rudi Hammad escribió:
sure. I have this code that create my UI

ui code

I want to query the value of the spine box jntNumber = self.ui.joints_spnBox.value()
so, having my environment setup okey, I try the following in the maya python interpreter :

import setupTools_UIs.createRibbon_UI as crUI; reload(crUI)
controlMainWindow = crUI.ControlMainWindow()
controlMainWindow.ui.joints_spnBox.update()
controlMainWindow.ui.joints_spnBox.value()

but the value that I get is now the one that I put in the ui spinebox. it is always the same.
I was trying to update the
joints_spnBox, thinking that i would get the new value, but it doesn´t

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/2dcc39d9-d27e-4cac-a00a-5e0cc7957cc8%40googlegroups.com.

Marcus Ottosson

unread,
Mar 14, 2016, 3:36:47 PM3/14/16
to python_in...@googlegroups.com
I can't run your code with imports of your own personal modules.

If you make a small example, only containing this problem and nothing else, I can take a closer look.


For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Rudi Hammad

unread,
Mar 14, 2016, 4:13:25 PM3/14/16
to Python Programming for Autodesk Maya
ok, I thought you just wanted to read it to cacht if something is weird in the code.
I hope you can run this

http://pastebin.com/32zXAMdR

by the way, my workflow is doing all in qtDesigner and the do the compileUi. So don´t really code the ui in pyside, I just generate the code doing the compileUi. It muuch easier, and I have many other thing to work one before getting in depth with pyside,
Am I loosing a lot pysde "power" using qtDesigner? should I forget about the qtDesigner and code the ui myself?
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.



--
Marcus Ottosson
konstr...@gmail.com

Marcus Ottosson

unread,
Mar 14, 2016, 4:26:04 PM3/14/16
to python_in...@googlegroups.com

Thanks, that works.

The problem isn’t happening here. Running your code, and adding this to the bottom, works as expected.

myWin.ui.joints_spnBox.setValue(6)
assert myWin.ui.joints_spnBox.value() == 6

It sets the GUI to show the value 6, and retrieves it correctly. I’m on Windows, running Maya 2015.


To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.



--
Marcus Ottosson
konstr...@gmail.com

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/bd1696a7-4c8c-4138-a5a5-13492c9dbfd8%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Rudi Hammad

unread,
Mar 14, 2016, 5:04:47 PM3/14/16
to Python Programming for Autodesk Maya
Thanks Marcus.it works. I was doing

controlMainWindow = ControlMainWindow()
controlMainWindow.ui.joints_spnBox.value()

so I wasn´t asking the value of the actual window widget as Justin said. I was querying the object ."joints_spnBox" inside of the...wait wait...what? I am confuse agian. why mine isn´t working?
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.



--
Marcus Ottosson
konstr...@gmail.com

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.



--
Marcus Ottosson
konstr...@gmail.com

Reply all
Reply to author
Forward
0 new messages