Profile Picture

ColourDialog Box

Posted By videodv 3 Months Ago
You don't have permission to rate!
Author
Message
videodv
videodv
Posted 3 Months Ago
View Quick Profile
Veteran Member

Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)

Group: Forum Members
Last Active: 6 hours ago
Posts: 182, Visits: 4.4K
Hi
https://forum.reallusion.com/uploads/images/5b8618cb-7e05-4ff6-a241-6187.jpg

I have been trying for quiet a while to workout hot to turn off the OK and Cancel buttons of a ColorDialg Box but so far without any luck just wondering if any one has any idea how to do this?
Here is a simple code example of what i am using.

import PySide2, RLPy, os
import PySide2
from PySide2 import *
from PySide2.QtCore import *
from PySide2.QtCore import QResource
from PySide2.QtCore import QFile
from PySide2.QtCore import QIODevice
from PySide2.QtGui import *
from PySide2.QtUiTools import QUiLoader
from PySide2.QtWidgets import *
from PySide2.shiboken2 import wrapInstance

#-- Make a global variable contain Dialog --#
colour_dialog = None

def run_script():
    global colour_dialog

    #-- Make the RL Dialog --#
    colour_dialog = RLPy.RUi.CreateRDialog()
    colour_dialog.SetWindowTitle("Colour Dialog")

    #-- Wrap to PySide Dialog --#
    pyside1_dialog = wrapInstance(int(colour_dialog.GetWindow()), QtWidgets.QDialog)
    colour_layout = pyside1_dialog.layout()

    colour = QColorDialog()

    # This is in the pyside2 documention but how do you set to hide the OK Cancel Buttons?
    # PySide2.QtWidgets.QColorDialog.ColorDialogOption
    # This enum specifies various options that affect the look and feel of a color dialog.
    # Constant     Description
    # QColorDialog.ShowAlphaChannel     Allow the user to select the alpha component of a color.
    # QColorDialog.NoButtons     Don’t display OK and Cancel buttons. (Useful for “live dialogs”.)
    # QColorDialog.DontUseNativeDialog     Use Qt’s standard color dialog instead of the operating system native color dialog.

    QColorDialog.NoButtons # When run this will not cause an error? but the buttons are still there!
    colour_layout.addWidget(colour)

    colour.currentColorChanged.connect(run_colour_changed)
    colour.colorSelected.connect(run_colour_selected)
 
    colour_dialog.Show()

def run_colour_changed(value):
    print(value)
def run_colour_selected(value):
    print(value)

Any help will be greatfully recieved.
Chris.

edited to correct typo.

Edited
3 Months Ago by videodv
videodv
videodv
Posted 3 Months Ago
View Quick Profile
Veteran Member

Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)

Group: Forum Members
Last Active: 6 hours ago
Posts: 182, Visits: 4.4K
This is part of a lager Demo UI I am working on while we wait for the next update.
This is the  full Demo UI that I have nearly got all worked out will share full code when finished if anyone would like it.

https://forum.reallusion.com/uploads/images/53ff92ab-8e8f-494e-8f99-87dd.jpg

Regards
Chris
Kelleytoons
Kelleytoons
Posted 3 Months Ago
View Quick Profile
Distinguished Member

Distinguished Member (17.5K reputation)Distinguished Member (17.5K reputation)Distinguished Member (17.5K reputation)Distinguished Member (17.5K reputation)Distinguished Member (17.5K reputation)Distinguished Member (17.5K reputation)Distinguished Member (17.5K reputation)Distinguished Member (17.5K reputation)Distinguished Member (17.5K reputation)

Group: Forum Members
Last Active: 16 minutes ago
Posts: 5.7K, Visits: 11.3K
I'm always interested in UI code (not my strongpoint) and I could see using something like this for the many color apps I have in mind (some of which I already have written).

So, yes, seeing the code would be nice (I haven't even tried to do any Pyside stuff yet, although I will eventually).



Alienware Aurora R7, Win 10, i7-8700k, 4.7GHz CPU, 32GB RAM, GTX Titan XP (12GB), Samsung 960 Pro 2TB M-2 SSD, TB+ Disk space
Mike "ex-genius" Kelley
videodv
videodv
Posted 3 Months Ago
View Quick Profile
Veteran Member

Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)

Group: Forum Members
Last Active: 6 hours ago
Posts: 182, Visits: 4.4K
Kelleytoons (1/18/2019)
I'm always interested in UI code (not my strongpoint) and I could see using something like this for the many color apps I have in mind (some of which I already have written).

So, yes, seeing the code would be nice (I haven't even tried to do any Pyside stuff yet, although I will eventually).


Hi Mik

I only started with python a when iclone 7.4 came out so still very new to me, while we wait for the update I thought I would get my head around the UI stuff so far its been faily straight forward but head scratching at times.

I have ideas with lights as well as yourself hence the ColorDialog the above. The Demo returns most of the control/Widgets values including the ColorDialog Box just a little more to work out one being how to populate the combo box with items from the scene. and of course how to get rid of the OK Cancel Buttons.

Will upload tomorrow night if I can work all out by then.

Regards
Chris.

Edited for typo Doze
Edited
3 Months Ago by videodv
jlittle
jlittle
Posted 3 Months Ago
View Quick Profile
Distinguished Member

Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)

Group: Forum Members
Last Active: Yesterday
Posts: 1.5K, Visits: 11.7K
Your statement in line 38:
QColorDialog.NoButtons
is not affecting anything since it is a constant.

Do it like this:
colour.setOptions(QColorDialog.NoButtons)
and that will work.

EDIT: Also, you will not get the "Selected" signal since that is generated by pressing the OK button. The "Changed" signal will also be repeated many times as one drags the color cursor thru the rainbow or as a screen color is picked since as the cursor moves it is sampling the colors under it.

Jeff



See my CTA Tutorials on the YouTube channel CTAStepByStep
Check out EZColors for CTA. The easy way to change Render Styled (RS) colors.

Edited
3 Months Ago by jlittle
videodv
videodv
Posted 3 Months Ago
View Quick Profile
Veteran Member

Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)

Group: Forum Members
Last Active: 6 hours ago
Posts: 182, Visits: 4.4K
jlittle (1/18/2019)
Your statement in line 38:
QColorDialog.NoButtons
is not affecting anything since it is a constant.

Do it like this:
colour.setOptions(QColorDialog.NoButtons)
and that will work.

EDIT: Also, you will not get the "Selected" signal since that is generated by pressing the OK button. The "Changed" signal will also be repeated many times as one drags the color cursor thru the rainbow or as a screen color is picked since as the cursor moves it is sampling the colors under it.

Jeff


Thanks for the help that did it.

Regards
Chris.

videodv
videodv
Posted 3 Months Ago
View Quick Profile
Veteran Member

Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)

Group: Forum Members
Last Active: 6 hours ago
Posts: 182, Visits: 4.4K
Hi

Sorry for the delay I had a couple of issues to sort out anyway If you wish to download and have a look I have included a link here, please keep in mind I am very much still learning python and PySide2 with Iclone.

Hope it helps someone.
Chris.
Attachments
Demo Project.zip (18 views, 4.00 MB)
Edited
3 Months Ago by videodv
videodv
videodv
Posted 3 Months Ago
View Quick Profile
Veteran Member

Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)Veteran Member (766 reputation)

Group: Forum Members
Last Active: 6 hours ago
Posts: 182, Visits: 4.4K
I forgot to say does anyone know how to set the size of a label or widget. I have tried many ways but still not able to find the answer.

Thanks
Chris.
jlittle
jlittle
Posted 3 Months Ago
View Quick Profile
Distinguished Member

Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)

Group: Forum Members
Last Active: Yesterday
Posts: 1.5K, Visits: 11.7K
It depend upon what you are trying to do. Have you read up on layouts? See HERE for some info on layouts.

Typically widgets will resize as the window resizes but to control how the widget resizes you have to at least set the the widgets "size policy" and min and max size to achieve your desired results. There are also other settings that can affect sizing but those are the main ones for simple layouts.

If all you want to do is restrict a label to it's minimum size, based on it's contents, then set the Horizontal size policy to "Fixed".
If you want a button to be a specific width then set the Horizontal size policy to "Fixed" and set the minimumSize to the desired button width.

If minimumSize is zero (0) it will be just big enough to contain the button label.


The Qt layout system is very flexible and I find it easier to use the Qt designer to layout screens then to build them programmatically.
I got the Qt designer from here and it works great:
The-any-Key (12/30/2018)
Instead of downloading GB of data to use the QT Designer. I would suggest this: https://build-system.fman.io/qt-designer-download



Jeff



See my CTA Tutorials on the YouTube channel CTAStepByStep
Check out EZColors for CTA. The easy way to change Render Styled (RS) colors.

Edited
3 Months Ago by jlittle
RobertoColombo
RobertoColombo
Posted 3 Months Ago
View Quick Profile
Distinguished Member

Distinguished Member (6.5K reputation)Distinguished Member (6.5K reputation)Distinguished Member (6.5K reputation)Distinguished Member (6.5K reputation)Distinguished Member (6.5K reputation)Distinguished Member (6.5K reputation)Distinguished Member (6.5K reputation)Distinguished Member (6.5K reputation)Distinguished Member (6.5K reputation)

Group: Forum Members
Last Active: 2 Months Ago
Posts: 1.6K, Visits: 3.0K
Hi,

the "trick" is to use QT Creator is to organize your GUI with layouts, as also suggested by Jeff.

The best way I got so far is to string widgets together as much as possible with nested layouts.
For example, imagine you have a label and a text input control and you want to have them always staying close on the same line.
Then, you can select both the widgets and then apply an horizontal layout.
Here is a picture, which should clarify what i mean and how i managed to keep everything under control.
It is a snapshot of Qt creator.
All the red boxes are layouts.
For example, the label X, Y, Z are linked with an horizontal layout to their input fields.
Then there is another horizontal layout that put all the widgets on the same row together. etc. etc.

Here is Qt Creator GUI.

https://forum.reallusion.com/uploads/images/fbca2916-d57c-49ff-96b1-a383.jpg

Here is the result in iClone.

https://forum.reallusion.com/uploads/images/2143550e-f434-4255-80b1-ba9d.jpg

No constraints have been used so far.
You have basically 4 layout types to choose from, and they are selectable either by a right-click pop-up menu or by the icon tools on the top bar.
If you need to change anything, you will have to break the layouts... so better to plan ahead (if ever possible...) how your GUI is going to look (I am not able at all... if fact I had to break and rebuild the layouts so many times... Sad )

I started using the constraints like min and max, but I dropped them soon because it was a mess to keep everything under curb when the GUI was "growing" in complexity.
So, I used this method to string together group of widgets as far as they shall always stay together,
The advantage of doing like this is that the all widgets always perfectly fit in the space.
Obviously sometimes they fit too much, like the wide input fields of the "Area" and "extension" groups: when the GUI is really the final one, I will apply the min/max coinstraints to reduce them.

It is also important to have a top level layout to the full Dialog widget otherwise you get an empty window in iClone.

Then, of course, if you use QtCreator, you need to get the handlers to the various controls in order to be able to use them.
Your "friend" for this is the findChild() function of your GUI object.
My suggestion is to spend some time to assign meaningful names to the various widget objects, so that referring them in the code would be more meaningful than findChild(..., "widget_16" ) WinkWinkWink

Cheers

   Roberto



My PC:
OS: Windows 10 Pro English 64-bit / CPU: Intel i7-9700 3.6GHz / MB: ASUS ROG Strix Z390  RAM: 32GB DDR4 2.6GHz / HD: 2TB+3TB  /  
SSD: 2x512GB Samsung 860 EVO / 
VB: Palit GTX2080 TI GamingPro 11GB / AB: embedded in the MB and VB (audio from the VB with an HDMI splitter) / DirectX: 12

Edited
3 Months Ago by RobertoColombo



Reading This Topic