├── LICENSE ├── README.md ├── echopr └── ShaderConverter │ ├── Assets │ ├── Bindings │ │ ├── arnold.json │ │ ├── mantra.json │ │ ├── octane.json │ │ ├── redshift.json │ │ └── vray.json │ └── GUI │ │ ├── icons │ │ ├── arnold.png │ │ ├── mantra.png │ │ ├── octane.png │ │ ├── redshift.png │ │ └── vray.png │ │ └── shaderConv.ui │ ├── Shelf_tool.txt │ └── python │ ├── Qt.py │ └── shader_conv_echopr.py ├── git └── ui_cap.png └── packages └── shaderconv_echopr.json /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Bilal Malik 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Houdini Shader Converter 2 | ## Overview 3 | *This tool as of **v0.1** only allows converting Mantra shaders to a appropriate 3rd party shader. (See Compatibility List)* 4 | 5 | This tool allows the convertion of shaders from parameters specified inside external JSON files found in the Bindings Folder. 6 | ![HouShaderConvHeader](https://github.com/SideswipeeZ/houdini-shader-converter/blob/main/git/ui_cap.png) 7 | ## Installation 8 | *This tool can exist for both Python2 and Python 3 Builds of Houdini in the same Folder. (Tested in 18.5)* 9 | ### Manual Install 10 | 11 | To install the Tool using Manual Instructions, Extract the **echopr** and **packages** folders into your Houdini Documents folder (This Folder contains the houdini.env file.) 12 | 13 | Then Create a Shelf tool with the following: 14 | 15 | Options: 16 | * Name: **Shader_Converter_echopr** 17 | * Label: **Shader Converter 0.1** 18 | * Icon: **hicon:/SVGIcons.index?COP2_aidenoise.svg** 19 | 20 | Code: 21 | ``` 22 | import shader_conv_echopr as shaderConv 23 | 24 | shaderConvWin = shaderConv.ShaderConv() 25 | shaderConvWin.resize(360,500) 26 | shaderConvWin.show() 27 | 28 | ``` 29 | 30 | ### Auto Installer (Windows) 31 | To install the tool on Windows using the Auto-Installer, Simply download the executable binary from **Releases** and follow the instructions. 32 | 33 | ## Function 34 | To use this tool Simply select the Shader from the dropdown menu you want to convert to: Then select the appropriate shader(s) from Houdini's Network View then Finally Click Convert. 35 | 36 | By Default the location to create the new shader is specified inside of the JSON files, However you can override the location by selecting a **Material Network** from the Houdini Network View and Clicking **Set Override**. This allows you to set the target Material Network to be the new place to create the new shaders to. 37 | To reset the override Material Network, simply click **Reset Override**, this will reset the setting to use the default location specified inside of the JSON file. 38 | 39 | ## Editing JSON Parameters 40 | If you want to edit/add/remove parameters to a shader you can do so by editing the **shader_binds** and **shader_maps** objects inside of the JSON file for each specified shader. 41 | 42 | Each object name must match between all shaders to convert, however the value can be different. 43 | 44 | The JSON File contains 3 lists of objects: 45 | * **shader_details** 46 | * This contains details for the shader for the UI elements and meta data for nodes needed to create a texture node and container vopnet. 47 | 48 | 49 | * **shader_binds** 50 | * This contains details for the shader for the paramter conversion. These have been sorted into lists for ease of readablilty. 51 | * Shader parameters here can be added/changed as long as the object name remains consistant with other JSON shader parameter names. 52 | 53 | * **shader_maps** 54 | * This contains parameters for locating shader texture maps. 55 | * Shader parameters here can be added/changed as long as the object name remains consistant with other JSON shader parameter names. 56 | 57 | ### Adding Shaders 58 | You can also create new shader support for another render engine as long as you follow the template that you can obtain from the template.json file or an of the other json files. 59 | 60 | 61 | # Future Plans 62 | * Allow support for any shader to shader conversion 63 | * Add more support for parameters inside of JSON files from Default install. 64 | 65 | # Licence 66 | MIT 67 | -------------------------------------------------------------------------------- /echopr/ShaderConverter/Assets/Bindings/arnold.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader_details": [ 3 | { 4 | "houdini_node_name": "arnold::standard_surface", 5 | "houdini_container":"arnold_materialbuilder", 6 | "houdini_shader_location":"/mat/", 7 | "version": "18.5.351", 8 | "shader_givenname": "Arnold", 9 | "prefix":"Ai", 10 | "image_details":[ 11 | { 12 | "node_name":"arnold::image", 13 | "filename_parm":"filename" 14 | } 15 | ] 16 | } 17 | ], 18 | "shader_binds": [ 19 | { 20 | "base": [ 21 | { 22 | "base_intensity": "base", 23 | "base_cd_r": "base_colorr", 24 | "base_cd_g": "base_colorg", 25 | "base_cd_b": "base_colorb" 26 | } 27 | ], 28 | "specular": [ 29 | { 30 | "ior_intensity": "specular_IOR", 31 | "roughness_intensity": "specular_roughness", 32 | "anisotropy_intensity": "specular_anisotrophy" 33 | 34 | } 35 | ], 36 | "reflection": [ 37 | { 38 | "metallic_intensity": "metalness", 39 | "reflection_intensity": "specular", 40 | "coat_intensity": "coat", 41 | "coat_roughness": "coat_roughness" 42 | } 43 | ], 44 | "transparency": [ 45 | { 46 | "transparency_intensity": "transmission", 47 | "transparency_cd_r": "transmission_colorr", 48 | "transparency_cd_g": "transmission_colorg", 49 | "transparency_cd_b": "transmission_colorb", 50 | "transparency_depth": "transmission_depth" 51 | } 52 | ], 53 | "subsurface_scattering": [ 54 | { 55 | "sss_intensity": "subsurface", 56 | "sss_depth": "subsurface_scale", 57 | "sss_cd_r": "subsurface_colorr", 58 | "sss_cd_g": "subsurface_colorg", 59 | "sss_cd_b": "subsurface_colorb" 60 | } 61 | ], 62 | "sheen": [ 63 | { 64 | "sheen_intensity": "sheen" 65 | } 66 | ], 67 | "emission": [ 68 | { 69 | "emission_intensity": "emission", 70 | "emission_cd_r": "emission_colorr", 71 | "emission_cd_g": "emission_colorg", 72 | "emission_cd_b": "emission_colorb" 73 | } 74 | ], 75 | "opacity": [ 76 | { 77 | "opacity_cd_r": "opacityr", 78 | "opacity_cd_g": "opacityg", 79 | "opacity_cd_b": "opacityb" 80 | } 81 | ] 82 | } 83 | ], 84 | "shader_maps": [ 85 | { 86 | "base_map": "base_color", 87 | "roughness_map": "specular_roughness", 88 | "metallic_map": "metalness", 89 | "reflection_map": "specular", 90 | "emission_map": "emission", 91 | "opacity_map": "opacity", 92 | "normal_map":"normal" 93 | 94 | } 95 | ] 96 | } -------------------------------------------------------------------------------- /echopr/ShaderConverter/Assets/Bindings/mantra.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader_details": [ 3 | { 4 | "houdini_node_name": "principledshader::2.0", 5 | "houdini_container":"SELF", 6 | "houdini_shader_location":"/mat/", 7 | "version": "18.5.351", 8 | "shader_givenname": "Mantra", 9 | "prefix":"MA", 10 | "image_details":[ 11 | { 12 | "node_name":"SELF", 13 | "filename_parm":"_useTexture" 14 | } 15 | ] 16 | } 17 | ], 18 | "shader_binds": [ 19 | { 20 | "base": [ 21 | { 22 | "base_intensity": "albedomult", 23 | "base_cd_r": "basecolorr", 24 | "base_cd_g": "basecolorg", 25 | "base_cd_b": "basecolorb" 26 | } 27 | ], 28 | "specular": [ 29 | { 30 | "ior_intensity": "ior", 31 | "roughness_intensity": "rough", 32 | "anisotropy_intensity": "aniso" 33 | 34 | } 35 | ], 36 | "reflection": [ 37 | { 38 | "metallic_intensity": "metallic", 39 | "reflection_intensity": "reflect", 40 | "coat_intensity": "coat", 41 | "coat_roughness": "coatrough" 42 | } 43 | ], 44 | "transparency": [ 45 | { 46 | "transparency_intensity": "transparency", 47 | "transparency_cd_r": "transcolorr", 48 | "transparency_cd_g": "transcolorg", 49 | "transparency_cd_b": "transcolorb", 50 | "transparency_depth": "transdist" 51 | } 52 | ], 53 | "subsurface_scattering": [ 54 | { 55 | "sss_intensity": "sss", 56 | "sss_depth": "sssdist", 57 | "sss_cd_r": "ssscolorr", 58 | "sss_cd_g": "ssscolorg", 59 | "sss_cd_b": "ssscolorb" 60 | } 61 | ], 62 | "sheen": [ 63 | { 64 | "sheen_intensity": "sheen", 65 | "sheen_tint": "sheentint" 66 | } 67 | ], 68 | "emission": [ 69 | { 70 | "emission_intensity": "emitint", 71 | "emission_cd_r": "emitcolorr", 72 | "emission_cd_g": "emitcolorg", 73 | "emission_cd_b": "emitcolorb" 74 | } 75 | ], 76 | "opacity": [ 77 | { 78 | "opacity_intensity": "opac", 79 | "opacity_cd_r": "opaccolorr", 80 | "opacity_cd_g": "opaccolorg", 81 | "opacity_cd_b": "opaccolorb" 82 | } 83 | ] 84 | } 85 | ], 86 | "shader_maps": [ 87 | { 88 | "base_map": "basecolor_texture", 89 | "roughness_map": "rough_texture", 90 | "metallic_map": "metallic_texture", 91 | "reflection_map": "reflect_texture", 92 | "emission_map": "emitcolor_texture", 93 | "opacity_map": "opaccolor_texture", 94 | "normal_map":"baseNormal_texture" 95 | 96 | } 97 | ] 98 | } -------------------------------------------------------------------------------- /echopr/ShaderConverter/Assets/Bindings/octane.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader_details": [ 3 | { 4 | "houdini_node_name": "octane::NT_MAT_UNIVERSAL", 5 | "houdini_container":"octane_vopnet", 6 | "houdini_shader_location":"/mat/", 7 | "version": "18.5.351", 8 | "shader_givenname": "Octane", 9 | "prefix":"OCT", 10 | "image_details":[ 11 | { 12 | "node_name":"octane::NT_TEX_IMAGE", 13 | "filename_parm":"A_FILENAME" 14 | } 15 | ] 16 | } 17 | ], 18 | "shader_binds": [ 19 | { 20 | "base": [ 21 | { 22 | "base_cd_r": "albedor", 23 | "base_cd_g": "albedog", 24 | "base_cd_b": "albedob" 25 | } 26 | ], 27 | "specular": [ 28 | { 29 | "ior_intensity": "index4", 30 | "roughness_intensity": "roughness", 31 | "anisotropy_intensity": "anisotrophy" 32 | 33 | } 34 | ], 35 | "reflection": [ 36 | { 37 | "metallic_intensity": "metallic", 38 | "reflection_intensity": "specular" 39 | } 40 | ], 41 | "opacity": [ 42 | { 43 | "opacity_intensity": "opac" 44 | } 45 | ] 46 | } 47 | ], 48 | "shader_maps": [ 49 | { 50 | "base_map": "albedo", 51 | "roughness_map": "roughness", 52 | "metallic_map": "metallic", 53 | "reflection_map": "specular", 54 | "opacity_map": "opacity", 55 | "normal_map":"normal" 56 | } 57 | ] 58 | } -------------------------------------------------------------------------------- /echopr/ShaderConverter/Assets/Bindings/redshift.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader_details": [ 3 | { 4 | "houdini_node_name": "redshift::Material", 5 | "houdini_container":"redshift_vopnet", 6 | "houdini_shader_location":"/mat/", 7 | "version": "18.5.532", 8 | "shader_givenname": "Redshift", 9 | "prefix":"RS", 10 | "image_details":[ 11 | { 12 | "node_name":"redshift::TextureSampler", 13 | "filename_parm":"tex0" 14 | } 15 | ] 16 | } 17 | ], 18 | "shader_binds": [ 19 | { 20 | "base": [ 21 | { 22 | "base_intensity": "diffuse_weight", 23 | "base_cd_r": "diffuse_colorr", 24 | "base_cd_g": "diffuse_colorg", 25 | "base_cd_b": "diffuse_colorb" 26 | } 27 | ], 28 | "specular": [ 29 | { 30 | "ior_intensity": "refl_ior", 31 | "roughness_intensity": "refl_roughness", 32 | "anisotropy_intensity": "refl_aniso" 33 | 34 | } 35 | ], 36 | "reflection": [ 37 | { 38 | "reflection_intensity": "refl_weight", 39 | "coat_intensity": "coat_weight", 40 | "coat_roughness": "coat_roughness" 41 | } 42 | ], 43 | "transparency": [ 44 | { 45 | "transparency_intensity": "refr_weight", 46 | "transparency_cd_r": "refr_colorr", 47 | "transparency_cd_g": "refr_colorg", 48 | "transparency_cd_b": "refr_colorb", 49 | "transparency_depth": "refr_absorption_scale" 50 | } 51 | ], 52 | "subsurface_scattering": [ 53 | { 54 | "sss_intensity": "ms_amount", 55 | "sss_depth": "ms_radius_scale", 56 | "sss_cd_r": "ms_color0r", 57 | "sss_cd_g": "ms_color0g", 58 | "sss_cd_b": "ms_color0b" 59 | } 60 | ], 61 | "sheen": [ 62 | { 63 | "sheen_intensity": "sheen_weight" 64 | } 65 | ], 66 | "emission": [ 67 | { 68 | "emission_intensity": "emission_weight", 69 | "emission_cd_r": "emission_colorr", 70 | "emission_cd_g": "emission_colorg", 71 | "emission_cd_b": "emission_colorb" 72 | } 73 | ], 74 | "opacity": [ 75 | { 76 | "opacity_cd_r": "opacity_colorr", 77 | "opacity_cd_g": "opacity_colorg", 78 | "opacity_cd_b": "opacity_colorb" 79 | } 80 | ] 81 | } 82 | ], 83 | "shader_maps": [ 84 | { 85 | "base_map": "diffuse_color", 86 | "roughness_map": "refl_roughness", 87 | "reflection_map": "refl_weight", 88 | "emission_map": "emission_color", 89 | "opacity_map": "opacity_color" 90 | } 91 | ] 92 | } -------------------------------------------------------------------------------- /echopr/ShaderConverter/Assets/Bindings/vray.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader_details": [ 3 | { 4 | "houdini_node_name": "VRayNodeBRDFVRayMtl", 5 | "houdini_container":"vray_vop_material", 6 | "houdini_shader_location":"/mat/", 7 | "version": "18.5.532", 8 | "shader_givenname": "V-Ray", 9 | "prefix":"Vray", 10 | "image_details":[ 11 | { 12 | "node_name":"VRayNodeMetaImageFile", 13 | "filename_parm":"BitmapBuffer_file" 14 | } 15 | ] 16 | } 17 | ], 18 | "shader_binds": [ 19 | { 20 | "base": [ 21 | { 22 | "base_cd_r": "diffuser", 23 | "base_cd_g": "diffuseg", 24 | "base_cd_b": "diffuseb" 25 | } 26 | ], 27 | "specular": [ 28 | { 29 | "roughness_intensity": "roughness", 30 | "anisotropy_intensity": "anisotrophy" 31 | 32 | } 33 | ], 34 | "reflection": [ 35 | { 36 | "metallic_intensity": "metalness", 37 | "reflection_intensity": "reflect_glossiness", 38 | "coat_intensity": "coat_amount" 39 | } 40 | ], 41 | "transparency": [ 42 | { 43 | "transparency_intensity": "translucency_amount", 44 | "transparency_cd_r": "translucency_colorr", 45 | "transparency_cd_g": "translucency_colorg", 46 | "transparency_cd_b": "translucency_colorb" 47 | } 48 | ], 49 | "sheen": [ 50 | { 51 | "sheen_intensity": "sheen_glossiness" 52 | } 53 | ], 54 | "emission": [ 55 | { 56 | "emission_intensity": "self_illumination_mult", 57 | "emission_cd_r": "self_illuminationr", 58 | "emission_cd_g": "self_illuminationg", 59 | "emission_cd_b": "self_illuminationb" 60 | } 61 | ], 62 | "opacity": [ 63 | { 64 | "opacity_intensity": "opacity" 65 | } 66 | ] 67 | } 68 | ], 69 | "shader_maps": [ 70 | { 71 | "base_map": "diffuse", 72 | "roughness_map": "roughness", 73 | "metallic_map": "metalness", 74 | "reflection_map": "reflect_glossiness", 75 | "emission_map": "self_illumination", 76 | "opacity_map": "opacity", 77 | "normal_map":"bump_map" 78 | 79 | } 80 | ] 81 | } -------------------------------------------------------------------------------- /echopr/ShaderConverter/Assets/GUI/icons/arnold.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SideswipeeZ/houdini-shader-converter/a4c69c279a4ad23d70123ea539848bb263b8add6/echopr/ShaderConverter/Assets/GUI/icons/arnold.png -------------------------------------------------------------------------------- /echopr/ShaderConverter/Assets/GUI/icons/mantra.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SideswipeeZ/houdini-shader-converter/a4c69c279a4ad23d70123ea539848bb263b8add6/echopr/ShaderConverter/Assets/GUI/icons/mantra.png -------------------------------------------------------------------------------- /echopr/ShaderConverter/Assets/GUI/icons/octane.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SideswipeeZ/houdini-shader-converter/a4c69c279a4ad23d70123ea539848bb263b8add6/echopr/ShaderConverter/Assets/GUI/icons/octane.png -------------------------------------------------------------------------------- /echopr/ShaderConverter/Assets/GUI/icons/redshift.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SideswipeeZ/houdini-shader-converter/a4c69c279a4ad23d70123ea539848bb263b8add6/echopr/ShaderConverter/Assets/GUI/icons/redshift.png -------------------------------------------------------------------------------- /echopr/ShaderConverter/Assets/GUI/icons/vray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SideswipeeZ/houdini-shader-converter/a4c69c279a4ad23d70123ea539848bb263b8add6/echopr/ShaderConverter/Assets/GUI/icons/vray.png -------------------------------------------------------------------------------- /echopr/ShaderConverter/Assets/GUI/shaderConv.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 361 10 | 500 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | Shader Converter 24 | 25 | 26 | Qt::AlignCenter 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | Shader Parameters 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 80 47 | 16777215 48 | 49 | 50 | 51 | Convert from: 52 | 53 | 54 | Qt::AlignCenter 55 | 56 | 57 | 58 | 59 | 60 | 61 | false 62 | 63 | 64 | 65 | 0 66 | 30 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 80 | 16777215 81 | 82 | 83 | 84 | Convert To: 85 | 86 | 87 | Qt::AlignCenter 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 0 96 | 30 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | Overrides 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 80 121 | 16777215 122 | 123 | 124 | 125 | MAT Override: 126 | 127 | 128 | 129 | 130 | 131 | 132 | true 133 | 134 | 135 | 136 | 0 137 | 30 138 | 139 | 140 | 141 | true 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 0 154 | 30 155 | 156 | 157 | 158 | border :1px solid rgb(91, 91, 91) 159 | 160 | 161 | Reset Override 162 | 163 | 164 | true 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 0 173 | 30 174 | 175 | 176 | 177 | border :1px solid rgb(91, 91, 91) 178 | 179 | 180 | Set Override 181 | 182 | 183 | true 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | Convert Shaders 196 | 197 | 198 | 199 | 200 | 201 | Select a Valid Node(s) from Network and Click Convert 202 | 203 | 204 | Qt::AlignCenter 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 0 213 | 70 214 | 215 | 216 | 217 | border :1px solid rgb(91, 91, 91) 218 | 219 | 220 | CONVERT 221 | 222 | 223 | true 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 0 235 | 0 236 | 237 | 238 | 239 | 240 | 16777215 241 | 50 242 | 243 | 244 | 245 | Console 246 | 247 | 248 | 249 | 250 | 251 | 252 | 16777215 253 | 50 254 | 255 | 256 | 257 | ... 258 | 259 | 260 | Qt::AlignCenter 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | -------------------------------------------------------------------------------- /echopr/ShaderConverter/Shelf_tool.txt: -------------------------------------------------------------------------------- 1 | Script: 2 | import shader_conv_echopr as shaderConv 3 | 4 | shaderConvWin = shaderConv.ShaderConv() 5 | shaderConvWin.resize(360,500) 6 | shaderConvWin.show() 7 | 8 | Options: 9 | Name: Shader_Converter_echopr 10 | Label: Shader Converter 0.1 11 | Icon: hicon:/SVGIcons.index?COP2_aidenoise.svg -------------------------------------------------------------------------------- /echopr/ShaderConverter/python/Qt.py: -------------------------------------------------------------------------------- 1 | """Minimal Python 2 & 3 shim around all Qt bindings 2 | 3 | DOCUMENTATION 4 | Qt.py was born in the film and visual effects industry to address 5 | the growing need for the development of software capable of running 6 | with more than one flavour of the Qt bindings for Python - PySide, 7 | PySide2, PyQt4 and PyQt5. 8 | 9 | 1. Build for one, run with all 10 | 2. Explicit is better than implicit 11 | 3. Support co-existence 12 | 13 | Default resolution order: 14 | - PySide2 15 | - PyQt5 16 | - PySide 17 | - PyQt4 18 | 19 | Usage: 20 | >> import sys 21 | >> from Qt import QtWidgets 22 | >> app = QtWidgets.QApplication(sys.argv) 23 | >> button = QtWidgets.QPushButton("Hello World") 24 | >> button.show() 25 | >> app.exec_() 26 | 27 | All members of PySide2 are mapped from other bindings, should they exist. 28 | If no equivalent member exist, it is excluded from Qt.py and inaccessible. 29 | The idea is to highlight members that exist across all supported binding, 30 | and guarantee that code that runs on one binding runs on all others. 31 | 32 | For more details, visit https://github.com/mottosso/Qt.py 33 | 34 | LICENSE 35 | 36 | See end of file for license (MIT, BSD) information. 37 | 38 | """ 39 | 40 | import os 41 | import sys 42 | import types 43 | import shutil 44 | import importlib 45 | 46 | 47 | __version__ = "1.2.0.b3" 48 | 49 | # Enable support for `from Qt import *` 50 | __all__ = [] 51 | 52 | # Flags from environment variables 53 | QT_VERBOSE = bool(os.getenv("QT_VERBOSE")) 54 | QT_PREFERRED_BINDING = os.getenv("QT_PREFERRED_BINDING", "") 55 | QT_SIP_API_HINT = os.getenv("QT_SIP_API_HINT") 56 | 57 | # Reference to Qt.py 58 | Qt = sys.modules[__name__] 59 | Qt.QtCompat = types.ModuleType("QtCompat") 60 | 61 | try: 62 | long 63 | except NameError: 64 | # Python 3 compatibility 65 | long = int 66 | 67 | 68 | """Common members of all bindings 69 | 70 | This is where each member of Qt.py is explicitly defined. 71 | It is based on a "lowest common denominator" of all bindings; 72 | including members found in each of the 4 bindings. 73 | 74 | The "_common_members" dictionary is generated using the 75 | build_membership.sh script. 76 | 77 | """ 78 | 79 | _common_members = { 80 | "QtCore": [ 81 | "QAbstractAnimation", 82 | "QAbstractEventDispatcher", 83 | "QAbstractItemModel", 84 | "QAbstractListModel", 85 | "QAbstractState", 86 | "QAbstractTableModel", 87 | "QAbstractTransition", 88 | "QAnimationGroup", 89 | "QBasicTimer", 90 | "QBitArray", 91 | "QBuffer", 92 | "QByteArray", 93 | "QByteArrayMatcher", 94 | "QChildEvent", 95 | "QCoreApplication", 96 | "QCryptographicHash", 97 | "QDataStream", 98 | "QDate", 99 | "QDateTime", 100 | "QDir", 101 | "QDirIterator", 102 | "QDynamicPropertyChangeEvent", 103 | "QEasingCurve", 104 | "QElapsedTimer", 105 | "QEvent", 106 | "QEventLoop", 107 | "QEventTransition", 108 | "QFile", 109 | "QFileInfo", 110 | "QFileSystemWatcher", 111 | "QFinalState", 112 | "QGenericArgument", 113 | "QGenericReturnArgument", 114 | "QHistoryState", 115 | "QItemSelectionRange", 116 | "QIODevice", 117 | "QLibraryInfo", 118 | "QLine", 119 | "QLineF", 120 | "QLocale", 121 | "QMargins", 122 | "QMetaClassInfo", 123 | "QMetaEnum", 124 | "QMetaMethod", 125 | "QMetaObject", 126 | "QMetaProperty", 127 | "QMimeData", 128 | "QModelIndex", 129 | "QMutex", 130 | "QMutexLocker", 131 | "QObject", 132 | "QParallelAnimationGroup", 133 | "QPauseAnimation", 134 | "QPersistentModelIndex", 135 | "QPluginLoader", 136 | "QPoint", 137 | "QPointF", 138 | "QProcess", 139 | "QProcessEnvironment", 140 | "QPropertyAnimation", 141 | "QReadLocker", 142 | "QReadWriteLock", 143 | "QRect", 144 | "QRectF", 145 | "QRegExp", 146 | "QResource", 147 | "QRunnable", 148 | "QSemaphore", 149 | "QSequentialAnimationGroup", 150 | "QSettings", 151 | "QSignalMapper", 152 | "QSignalTransition", 153 | "QSize", 154 | "QSizeF", 155 | "QSocketNotifier", 156 | "QState", 157 | "QStateMachine", 158 | "QSysInfo", 159 | "QSystemSemaphore", 160 | "QT_TRANSLATE_NOOP", 161 | "QT_TR_NOOP", 162 | "QT_TR_NOOP_UTF8", 163 | "QTemporaryFile", 164 | "QTextBoundaryFinder", 165 | "QTextCodec", 166 | "QTextDecoder", 167 | "QTextEncoder", 168 | "QTextStream", 169 | "QTextStreamManipulator", 170 | "QThread", 171 | "QThreadPool", 172 | "QTime", 173 | "QTimeLine", 174 | "QTimer", 175 | "QTimerEvent", 176 | "QTranslator", 177 | "QUrl", 178 | "QVariantAnimation", 179 | "QWaitCondition", 180 | "QWriteLocker", 181 | "QXmlStreamAttribute", 182 | "QXmlStreamAttributes", 183 | "QXmlStreamEntityDeclaration", 184 | "QXmlStreamEntityResolver", 185 | "QXmlStreamNamespaceDeclaration", 186 | "QXmlStreamNotationDeclaration", 187 | "QXmlStreamReader", 188 | "QXmlStreamWriter", 189 | "Qt", 190 | "QtCriticalMsg", 191 | "QtDebugMsg", 192 | "QtFatalMsg", 193 | "QtMsgType", 194 | "QtSystemMsg", 195 | "QtWarningMsg", 196 | "qAbs", 197 | "qAddPostRoutine", 198 | "qChecksum", 199 | "qCritical", 200 | "qDebug", 201 | "qFatal", 202 | "qFuzzyCompare", 203 | "qIsFinite", 204 | "qIsInf", 205 | "qIsNaN", 206 | "qIsNull", 207 | "qRegisterResourceData", 208 | "qUnregisterResourceData", 209 | "qVersion", 210 | "qWarning", 211 | "qrand", 212 | "qsrand" 213 | ], 214 | "QtGui": [ 215 | "QAbstractTextDocumentLayout", 216 | "QActionEvent", 217 | "QBitmap", 218 | "QBrush", 219 | "QClipboard", 220 | "QCloseEvent", 221 | "QColor", 222 | "QConicalGradient", 223 | "QContextMenuEvent", 224 | "QCursor", 225 | "QDesktopServices", 226 | "QDoubleValidator", 227 | "QDrag", 228 | "QDragEnterEvent", 229 | "QDragLeaveEvent", 230 | "QDragMoveEvent", 231 | "QDropEvent", 232 | "QFileOpenEvent", 233 | "QFocusEvent", 234 | "QFont", 235 | "QFontDatabase", 236 | "QFontInfo", 237 | "QFontMetrics", 238 | "QFontMetricsF", 239 | "QGradient", 240 | "QHelpEvent", 241 | "QHideEvent", 242 | "QHoverEvent", 243 | "QIcon", 244 | "QIconDragEvent", 245 | "QIconEngine", 246 | "QImage", 247 | "QImageIOHandler", 248 | "QImageReader", 249 | "QImageWriter", 250 | "QInputEvent", 251 | "QInputMethodEvent", 252 | "QIntValidator", 253 | "QKeyEvent", 254 | "QKeySequence", 255 | "QLinearGradient", 256 | "QMatrix2x2", 257 | "QMatrix2x3", 258 | "QMatrix2x4", 259 | "QMatrix3x2", 260 | "QMatrix3x3", 261 | "QMatrix3x4", 262 | "QMatrix4x2", 263 | "QMatrix4x3", 264 | "QMatrix4x4", 265 | "QMouseEvent", 266 | "QMoveEvent", 267 | "QMovie", 268 | "QPaintDevice", 269 | "QPaintEngine", 270 | "QPaintEngineState", 271 | "QPaintEvent", 272 | "QPainter", 273 | "QPainterPath", 274 | "QPainterPathStroker", 275 | "QPalette", 276 | "QPen", 277 | "QPicture", 278 | "QPictureIO", 279 | "QPixmap", 280 | "QPixmapCache", 281 | "QPolygon", 282 | "QPolygonF", 283 | "QQuaternion", 284 | "QRadialGradient", 285 | "QRegExpValidator", 286 | "QRegion", 287 | "QResizeEvent", 288 | "QSessionManager", 289 | "QShortcutEvent", 290 | "QShowEvent", 291 | "QStandardItem", 292 | "QStandardItemModel", 293 | "QStatusTipEvent", 294 | "QSyntaxHighlighter", 295 | "QTabletEvent", 296 | "QTextBlock", 297 | "QTextBlockFormat", 298 | "QTextBlockGroup", 299 | "QTextBlockUserData", 300 | "QTextCharFormat", 301 | "QTextCursor", 302 | "QTextDocument", 303 | "QTextDocumentFragment", 304 | "QTextFormat", 305 | "QTextFragment", 306 | "QTextFrame", 307 | "QTextFrameFormat", 308 | "QTextImageFormat", 309 | "QTextInlineObject", 310 | "QTextItem", 311 | "QTextLayout", 312 | "QTextLength", 313 | "QTextLine", 314 | "QTextList", 315 | "QTextListFormat", 316 | "QTextObject", 317 | "QTextObjectInterface", 318 | "QTextOption", 319 | "QTextTable", 320 | "QTextTableCell", 321 | "QTextTableCellFormat", 322 | "QTextTableFormat", 323 | "QTouchEvent", 324 | "QTransform", 325 | "QValidator", 326 | "QVector2D", 327 | "QVector3D", 328 | "QVector4D", 329 | "QWhatsThisClickedEvent", 330 | "QWheelEvent", 331 | "QWindowStateChangeEvent", 332 | "qAlpha", 333 | "qBlue", 334 | "qGray", 335 | "qGreen", 336 | "qIsGray", 337 | "qRed", 338 | "qRgb", 339 | "qRgba" 340 | ], 341 | "QtHelp": [ 342 | "QHelpContentItem", 343 | "QHelpContentModel", 344 | "QHelpContentWidget", 345 | "QHelpEngine", 346 | "QHelpEngineCore", 347 | "QHelpIndexModel", 348 | "QHelpIndexWidget", 349 | "QHelpSearchEngine", 350 | "QHelpSearchQuery", 351 | "QHelpSearchQueryWidget", 352 | "QHelpSearchResultWidget" 353 | ], 354 | "QtMultimedia": [ 355 | "QAbstractVideoBuffer", 356 | "QAbstractVideoSurface", 357 | "QAudio", 358 | "QAudioDeviceInfo", 359 | "QAudioFormat", 360 | "QAudioInput", 361 | "QAudioOutput", 362 | "QVideoFrame", 363 | "QVideoSurfaceFormat" 364 | ], 365 | "QtNetwork": [ 366 | "QAbstractNetworkCache", 367 | "QAbstractSocket", 368 | "QAuthenticator", 369 | "QHostAddress", 370 | "QHostInfo", 371 | "QLocalServer", 372 | "QLocalSocket", 373 | "QNetworkAccessManager", 374 | "QNetworkAddressEntry", 375 | "QNetworkCacheMetaData", 376 | "QNetworkConfiguration", 377 | "QNetworkConfigurationManager", 378 | "QNetworkCookie", 379 | "QNetworkCookieJar", 380 | "QNetworkDiskCache", 381 | "QNetworkInterface", 382 | "QNetworkProxy", 383 | "QNetworkProxyFactory", 384 | "QNetworkProxyQuery", 385 | "QNetworkReply", 386 | "QNetworkRequest", 387 | "QNetworkSession", 388 | "QSsl", 389 | "QTcpServer", 390 | "QTcpSocket", 391 | "QUdpSocket" 392 | ], 393 | "QtOpenGL": [ 394 | "QGL", 395 | "QGLContext", 396 | "QGLFormat", 397 | "QGLWidget" 398 | ], 399 | "QtPrintSupport": [ 400 | "QAbstractPrintDialog", 401 | "QPageSetupDialog", 402 | "QPrintDialog", 403 | "QPrintEngine", 404 | "QPrintPreviewDialog", 405 | "QPrintPreviewWidget", 406 | "QPrinter", 407 | "QPrinterInfo" 408 | ], 409 | "QtSql": [ 410 | "QSql", 411 | "QSqlDatabase", 412 | "QSqlDriver", 413 | "QSqlDriverCreatorBase", 414 | "QSqlError", 415 | "QSqlField", 416 | "QSqlIndex", 417 | "QSqlQuery", 418 | "QSqlQueryModel", 419 | "QSqlRecord", 420 | "QSqlRelation", 421 | "QSqlRelationalDelegate", 422 | "QSqlRelationalTableModel", 423 | "QSqlResult", 424 | "QSqlTableModel" 425 | ], 426 | "QtSvg": [ 427 | "QGraphicsSvgItem", 428 | "QSvgGenerator", 429 | "QSvgRenderer", 430 | "QSvgWidget" 431 | ], 432 | "QtTest": [ 433 | "QTest" 434 | ], 435 | "QtWidgets": [ 436 | "QAbstractButton", 437 | "QAbstractGraphicsShapeItem", 438 | "QAbstractItemDelegate", 439 | "QAbstractItemView", 440 | "QAbstractScrollArea", 441 | "QAbstractSlider", 442 | "QAbstractSpinBox", 443 | "QAction", 444 | "QActionGroup", 445 | "QApplication", 446 | "QBoxLayout", 447 | "QButtonGroup", 448 | "QCalendarWidget", 449 | "QCheckBox", 450 | "QColorDialog", 451 | "QColumnView", 452 | "QComboBox", 453 | "QCommandLinkButton", 454 | "QCommonStyle", 455 | "QCompleter", 456 | "QDataWidgetMapper", 457 | "QDateEdit", 458 | "QDateTimeEdit", 459 | "QDesktopWidget", 460 | "QDial", 461 | "QDialog", 462 | "QDialogButtonBox", 463 | "QDirModel", 464 | "QDockWidget", 465 | "QDoubleSpinBox", 466 | "QErrorMessage", 467 | "QFileDialog", 468 | "QFileIconProvider", 469 | "QFileSystemModel", 470 | "QFocusFrame", 471 | "QFontComboBox", 472 | "QFontDialog", 473 | "QFormLayout", 474 | "QFrame", 475 | "QGesture", 476 | "QGestureEvent", 477 | "QGestureRecognizer", 478 | "QGraphicsAnchor", 479 | "QGraphicsAnchorLayout", 480 | "QGraphicsBlurEffect", 481 | "QGraphicsColorizeEffect", 482 | "QGraphicsDropShadowEffect", 483 | "QGraphicsEffect", 484 | "QGraphicsEllipseItem", 485 | "QGraphicsGridLayout", 486 | "QGraphicsItem", 487 | "QGraphicsItemGroup", 488 | "QGraphicsLayout", 489 | "QGraphicsLayoutItem", 490 | "QGraphicsLineItem", 491 | "QGraphicsLinearLayout", 492 | "QGraphicsObject", 493 | "QGraphicsOpacityEffect", 494 | "QGraphicsPathItem", 495 | "QGraphicsPixmapItem", 496 | "QGraphicsPolygonItem", 497 | "QGraphicsProxyWidget", 498 | "QGraphicsRectItem", 499 | "QGraphicsRotation", 500 | "QGraphicsScale", 501 | "QGraphicsScene", 502 | "QGraphicsSceneContextMenuEvent", 503 | "QGraphicsSceneDragDropEvent", 504 | "QGraphicsSceneEvent", 505 | "QGraphicsSceneHelpEvent", 506 | "QGraphicsSceneHoverEvent", 507 | "QGraphicsSceneMouseEvent", 508 | "QGraphicsSceneMoveEvent", 509 | "QGraphicsSceneResizeEvent", 510 | "QGraphicsSceneWheelEvent", 511 | "QGraphicsSimpleTextItem", 512 | "QGraphicsTextItem", 513 | "QGraphicsTransform", 514 | "QGraphicsView", 515 | "QGraphicsWidget", 516 | "QGridLayout", 517 | "QGroupBox", 518 | "QHBoxLayout", 519 | "QHeaderView", 520 | "QInputDialog", 521 | "QItemDelegate", 522 | "QItemEditorCreatorBase", 523 | "QItemEditorFactory", 524 | "QKeyEventTransition", 525 | "QLCDNumber", 526 | "QLabel", 527 | "QLayout", 528 | "QLayoutItem", 529 | "QLineEdit", 530 | "QListView", 531 | "QListWidget", 532 | "QListWidgetItem", 533 | "QMainWindow", 534 | "QMdiArea", 535 | "QMdiSubWindow", 536 | "QMenu", 537 | "QMenuBar", 538 | "QMessageBox", 539 | "QMouseEventTransition", 540 | "QPanGesture", 541 | "QPinchGesture", 542 | "QPlainTextDocumentLayout", 543 | "QPlainTextEdit", 544 | "QProgressBar", 545 | "QProgressDialog", 546 | "QPushButton", 547 | "QRadioButton", 548 | "QRubberBand", 549 | "QScrollArea", 550 | "QScrollBar", 551 | "QShortcut", 552 | "QSizeGrip", 553 | "QSizePolicy", 554 | "QSlider", 555 | "QSpacerItem", 556 | "QSpinBox", 557 | "QSplashScreen", 558 | "QSplitter", 559 | "QSplitterHandle", 560 | "QStackedLayout", 561 | "QStackedWidget", 562 | "QStatusBar", 563 | "QStyle", 564 | "QStyleFactory", 565 | "QStyleHintReturn", 566 | "QStyleHintReturnMask", 567 | "QStyleHintReturnVariant", 568 | "QStyleOption", 569 | "QStyleOptionButton", 570 | "QStyleOptionComboBox", 571 | "QStyleOptionComplex", 572 | "QStyleOptionDockWidget", 573 | "QStyleOptionFocusRect", 574 | "QStyleOptionFrame", 575 | "QStyleOptionGraphicsItem", 576 | "QStyleOptionGroupBox", 577 | "QStyleOptionHeader", 578 | "QStyleOptionMenuItem", 579 | "QStyleOptionProgressBar", 580 | "QStyleOptionRubberBand", 581 | "QStyleOptionSizeGrip", 582 | "QStyleOptionSlider", 583 | "QStyleOptionSpinBox", 584 | "QStyleOptionTab", 585 | "QStyleOptionTabBarBase", 586 | "QStyleOptionTabWidgetFrame", 587 | "QStyleOptionTitleBar", 588 | "QStyleOptionToolBar", 589 | "QStyleOptionToolBox", 590 | "QStyleOptionToolButton", 591 | "QStyleOptionViewItem", 592 | "QStylePainter", 593 | "QStyledItemDelegate", 594 | "QSwipeGesture", 595 | "QSystemTrayIcon", 596 | "QTabBar", 597 | "QTabWidget", 598 | "QTableView", 599 | "QTableWidget", 600 | "QTableWidgetItem", 601 | "QTableWidgetSelectionRange", 602 | "QTapAndHoldGesture", 603 | "QTapGesture", 604 | "QTextBrowser", 605 | "QTextEdit", 606 | "QTimeEdit", 607 | "QToolBar", 608 | "QToolBox", 609 | "QToolButton", 610 | "QToolTip", 611 | "QTreeView", 612 | "QTreeWidget", 613 | "QTreeWidgetItem", 614 | "QTreeWidgetItemIterator", 615 | "QUndoCommand", 616 | "QUndoGroup", 617 | "QUndoStack", 618 | "QUndoView", 619 | "QVBoxLayout", 620 | "QWhatsThis", 621 | "QWidget", 622 | "QWidgetAction", 623 | "QWidgetItem", 624 | "QWizard", 625 | "QWizardPage" 626 | ], 627 | "QtX11Extras": [ 628 | "QX11Info" 629 | ], 630 | "QtXml": [ 631 | "QDomAttr", 632 | "QDomCDATASection", 633 | "QDomCharacterData", 634 | "QDomComment", 635 | "QDomDocument", 636 | "QDomDocumentFragment", 637 | "QDomDocumentType", 638 | "QDomElement", 639 | "QDomEntity", 640 | "QDomEntityReference", 641 | "QDomImplementation", 642 | "QDomNamedNodeMap", 643 | "QDomNode", 644 | "QDomNodeList", 645 | "QDomNotation", 646 | "QDomProcessingInstruction", 647 | "QDomText", 648 | "QXmlAttributes", 649 | "QXmlContentHandler", 650 | "QXmlDTDHandler", 651 | "QXmlDeclHandler", 652 | "QXmlDefaultHandler", 653 | "QXmlEntityResolver", 654 | "QXmlErrorHandler", 655 | "QXmlInputSource", 656 | "QXmlLexicalHandler", 657 | "QXmlLocator", 658 | "QXmlNamespaceSupport", 659 | "QXmlParseException", 660 | "QXmlReader", 661 | "QXmlSimpleReader" 662 | ], 663 | "QtXmlPatterns": [ 664 | "QAbstractMessageHandler", 665 | "QAbstractUriResolver", 666 | "QAbstractXmlNodeModel", 667 | "QAbstractXmlReceiver", 668 | "QSourceLocation", 669 | "QXmlFormatter", 670 | "QXmlItem", 671 | "QXmlName", 672 | "QXmlNamePool", 673 | "QXmlNodeModelIndex", 674 | "QXmlQuery", 675 | "QXmlResultItems", 676 | "QXmlSchema", 677 | "QXmlSchemaValidator", 678 | "QXmlSerializer" 679 | ] 680 | } 681 | 682 | 683 | def _qInstallMessageHandler(handler): 684 | """Install a message handler that works in all bindings 685 | 686 | Args: 687 | handler: A function that takes 3 arguments, or None 688 | """ 689 | def messageOutputHandler(*args): 690 | # In Qt4 bindings, message handlers are passed 2 arguments 691 | # In Qt5 bindings, message handlers are passed 3 arguments 692 | # The first argument is a QtMsgType 693 | # The last argument is the message to be printed 694 | # The Middle argument (if passed) is a QMessageLogContext 695 | if len(args) == 3: 696 | msgType, logContext, msg = args 697 | elif len(args) == 2: 698 | msgType, msg = args 699 | logContext = None 700 | else: 701 | raise TypeError( 702 | "handler expected 2 or 3 arguments, got {0}".format(len(args))) 703 | 704 | if isinstance(msg, bytes): 705 | # In python 3, some bindings pass a bytestring, which cannot be 706 | # used elsewhere. Decoding a python 2 or 3 bytestring object will 707 | # consistently return a unicode object. 708 | msg = msg.decode() 709 | 710 | handler(msgType, logContext, msg) 711 | 712 | passObject = messageOutputHandler if handler else handler 713 | if Qt.IsPySide or Qt.IsPyQt4: 714 | return Qt._QtCore.qInstallMsgHandler(passObject) 715 | elif Qt.IsPySide2 or Qt.IsPyQt5: 716 | return Qt._QtCore.qInstallMessageHandler(passObject) 717 | 718 | 719 | def _getcpppointer(object): 720 | if hasattr(Qt, "_shiboken2"): 721 | return getattr(Qt, "_shiboken2").getCppPointer(object)[0] 722 | elif hasattr(Qt, "_shiboken"): 723 | return getattr(Qt, "_shiboken").getCppPointer(object)[0] 724 | elif hasattr(Qt, "_sip"): 725 | return getattr(Qt, "_sip").unwrapinstance(object) 726 | raise AttributeError("'module' has no attribute 'getCppPointer'") 727 | 728 | 729 | def _wrapinstance(ptr, base=None): 730 | """Enable implicit cast of pointer to most suitable class 731 | 732 | This behaviour is available in sip per default. 733 | 734 | Based on http://nathanhorne.com/pyqtpyside-wrap-instance 735 | 736 | Usage: 737 | This mechanism kicks in under these circumstances. 738 | 1. Qt.py is using PySide 1 or 2. 739 | 2. A `base` argument is not provided. 740 | 741 | See :func:`QtCompat.wrapInstance()` 742 | 743 | Arguments: 744 | ptr (long): Pointer to QObject in memory 745 | base (QObject, optional): Base class to wrap with. Defaults to QObject, 746 | which should handle anything. 747 | 748 | """ 749 | 750 | assert isinstance(ptr, long), "Argument 'ptr' must be of type " 751 | assert (base is None) or issubclass(base, Qt.QtCore.QObject), ( 752 | "Argument 'base' must be of type ") 753 | 754 | if Qt.IsPyQt4 or Qt.IsPyQt5: 755 | func = getattr(Qt, "_sip").wrapinstance 756 | elif Qt.IsPySide2: 757 | func = getattr(Qt, "_shiboken2").wrapInstance 758 | elif Qt.IsPySide: 759 | func = getattr(Qt, "_shiboken").wrapInstance 760 | else: 761 | raise AttributeError("'module' has no attribute 'wrapInstance'") 762 | 763 | if base is None: 764 | q_object = func(long(ptr), Qt.QtCore.QObject) 765 | meta_object = q_object.metaObject() 766 | class_name = meta_object.className() 767 | super_class_name = meta_object.superClass().className() 768 | 769 | if hasattr(Qt.QtWidgets, class_name): 770 | base = getattr(Qt.QtWidgets, class_name) 771 | 772 | elif hasattr(Qt.QtWidgets, super_class_name): 773 | base = getattr(Qt.QtWidgets, super_class_name) 774 | 775 | else: 776 | base = Qt.QtCore.QObject 777 | 778 | return func(long(ptr), base) 779 | 780 | 781 | def _translate(context, sourceText, *args): 782 | # In Qt4 bindings, translate can be passed 2 or 3 arguments 783 | # In Qt5 bindings, translate can be passed 2 arguments 784 | # The first argument is disambiguation[str] 785 | # The last argument is n[int] 786 | # The middle argument can be encoding[QtCore.QCoreApplication.Encoding] 787 | if len(args) == 3: 788 | disambiguation, encoding, n = args 789 | elif len(args) == 2: 790 | disambiguation, n = args 791 | encoding = None 792 | else: 793 | raise TypeError( 794 | "Expected 4 or 5 arguments, got {0}.".format(len(args) + 2)) 795 | 796 | if hasattr(Qt.QtCore, "QCoreApplication"): 797 | app = getattr(Qt.QtCore, "QCoreApplication") 798 | else: 799 | raise NotImplementedError( 800 | "Missing QCoreApplication implementation for {binding}".format( 801 | binding=Qt.__binding__, 802 | ) 803 | ) 804 | if Qt.__binding__ in ("PySide2", "PyQt5"): 805 | sanitized_args = [context, sourceText, disambiguation, n] 806 | else: 807 | sanitized_args = [ 808 | context, 809 | sourceText, 810 | disambiguation, 811 | encoding or app.CodecForTr, 812 | n 813 | ] 814 | return app.translate(*sanitized_args) 815 | 816 | 817 | def _loadUi(uifile, baseinstance=None): 818 | """Dynamically load a user interface from the given `uifile` 819 | 820 | This function calls `uic.loadUi` if using PyQt bindings, 821 | else it implements a comparable binding for PySide. 822 | 823 | Documentation: 824 | http://pyqt.sourceforge.net/Docs/PyQt5/designer.html#PyQt5.uic.loadUi 825 | 826 | Arguments: 827 | uifile (str): Absolute path to Qt Designer file. 828 | baseinstance (QWidget): Instantiated QWidget or subclass thereof 829 | 830 | Return: 831 | baseinstance if `baseinstance` is not `None`. Otherwise 832 | return the newly created instance of the user interface. 833 | 834 | """ 835 | if hasattr(Qt, "_uic"): 836 | return Qt._uic.loadUi(uifile, baseinstance) 837 | 838 | elif hasattr(Qt, "_QtUiTools"): 839 | # Implement `PyQt5.uic.loadUi` for PySide(2) 840 | 841 | class _UiLoader(Qt._QtUiTools.QUiLoader): 842 | """Create the user interface in a base instance. 843 | 844 | Unlike `Qt._QtUiTools.QUiLoader` itself this class does not 845 | create a new instance of the top-level widget, but creates the user 846 | interface in an existing instance of the top-level class if needed. 847 | 848 | This mimics the behaviour of `PyQt5.uic.loadUi`. 849 | 850 | """ 851 | 852 | def __init__(self, baseinstance): 853 | super(_UiLoader, self).__init__(baseinstance) 854 | self.baseinstance = baseinstance 855 | self.custom_widgets = {} 856 | 857 | def _loadCustomWidgets(self, etree): 858 | """ 859 | Workaround to pyside-77 bug. 860 | 861 | From QUiLoader doc we should use registerCustomWidget method. 862 | But this causes a segfault on some platforms. 863 | 864 | Instead we fetch from customwidgets DOM node the python class 865 | objects. Then we can directly use them in createWidget method. 866 | """ 867 | 868 | def headerToModule(header): 869 | """ 870 | Translate a header file to python module path 871 | foo/bar.h => foo.bar 872 | """ 873 | # Remove header extension 874 | module = os.path.splitext(header)[0] 875 | 876 | # Replace os separator by python module separator 877 | return module.replace("/", ".").replace("\\", ".") 878 | 879 | custom_widgets = etree.find("customwidgets") 880 | 881 | if custom_widgets is None: 882 | return 883 | 884 | for custom_widget in custom_widgets: 885 | class_name = custom_widget.find("class").text 886 | header = custom_widget.find("header").text 887 | module = importlib.import_module(headerToModule(header)) 888 | self.custom_widgets[class_name] = getattr(module, 889 | class_name) 890 | 891 | def load(self, uifile, *args, **kwargs): 892 | from xml.etree.ElementTree import ElementTree 893 | 894 | # For whatever reason, if this doesn't happen then 895 | # reading an invalid or non-existing .ui file throws 896 | # a RuntimeError. 897 | etree = ElementTree() 898 | etree.parse(uifile) 899 | self._loadCustomWidgets(etree) 900 | 901 | widget = Qt._QtUiTools.QUiLoader.load( 902 | self, uifile, *args, **kwargs) 903 | 904 | # Workaround for PySide 1.0.9, see issue #208 905 | widget.parentWidget() 906 | 907 | return widget 908 | 909 | def createWidget(self, class_name, parent=None, name=""): 910 | """Called for each widget defined in ui file 911 | 912 | Overridden here to populate `baseinstance` instead. 913 | 914 | """ 915 | 916 | if parent is None and self.baseinstance: 917 | # Supposed to create the top-level widget, 918 | # return the base instance instead 919 | return self.baseinstance 920 | 921 | # For some reason, Line is not in the list of available 922 | # widgets, but works fine, so we have to special case it here. 923 | if class_name in self.availableWidgets() + ["Line"]: 924 | # Create a new widget for child widgets 925 | widget = Qt._QtUiTools.QUiLoader.createWidget(self, 926 | class_name, 927 | parent, 928 | name) 929 | elif class_name in self.custom_widgets: 930 | widget = self.custom_widgets[class_name](parent) 931 | else: 932 | raise Exception("Custom widget '%s' not supported" 933 | % class_name) 934 | 935 | if self.baseinstance: 936 | # Set an attribute for the new child widget on the base 937 | # instance, just like PyQt5.uic.loadUi does. 938 | setattr(self.baseinstance, name, widget) 939 | 940 | return widget 941 | 942 | widget = _UiLoader(baseinstance).load(uifile) 943 | Qt.QtCore.QMetaObject.connectSlotsByName(widget) 944 | 945 | return widget 946 | 947 | else: 948 | raise NotImplementedError("No implementation available for loadUi") 949 | 950 | 951 | """Misplaced members 952 | 953 | These members from the original submodule are misplaced relative PySide2 954 | 955 | """ 956 | _misplaced_members = { 957 | "PySide2": { 958 | "QtCore.QStringListModel": "QtCore.QStringListModel", 959 | "QtGui.QStringListModel": "QtCore.QStringListModel", 960 | "QtCore.Property": "QtCore.Property", 961 | "QtCore.Signal": "QtCore.Signal", 962 | "QtCore.Slot": "QtCore.Slot", 963 | "QtCore.QAbstractProxyModel": "QtCore.QAbstractProxyModel", 964 | "QtCore.QSortFilterProxyModel": "QtCore.QSortFilterProxyModel", 965 | "QtCore.QItemSelection": "QtCore.QItemSelection", 966 | "QtCore.QItemSelectionModel": "QtCore.QItemSelectionModel", 967 | "QtCore.QItemSelectionRange": "QtCore.QItemSelectionRange", 968 | "QtUiTools.QUiLoader": ["QtCompat.loadUi", _loadUi], 969 | "shiboken2.wrapInstance": ["QtCompat.wrapInstance", _wrapinstance], 970 | "shiboken2.getCppPointer": ["QtCompat.getCppPointer", _getcpppointer], 971 | "QtWidgets.qApp": "QtWidgets.QApplication.instance()", 972 | "QtCore.QCoreApplication.translate": [ 973 | "QtCompat.translate", _translate 974 | ], 975 | "QtWidgets.QApplication.translate": [ 976 | "QtCompat.translate", _translate 977 | ], 978 | "QtCore.qInstallMessageHandler": [ 979 | "QtCompat.qInstallMessageHandler", _qInstallMessageHandler 980 | ], 981 | }, 982 | "PyQt5": { 983 | "QtCore.pyqtProperty": "QtCore.Property", 984 | "QtCore.pyqtSignal": "QtCore.Signal", 985 | "QtCore.pyqtSlot": "QtCore.Slot", 986 | "QtCore.QAbstractProxyModel": "QtCore.QAbstractProxyModel", 987 | "QtCore.QSortFilterProxyModel": "QtCore.QSortFilterProxyModel", 988 | "QtCore.QStringListModel": "QtCore.QStringListModel", 989 | "QtCore.QItemSelection": "QtCore.QItemSelection", 990 | "QtCore.QItemSelectionModel": "QtCore.QItemSelectionModel", 991 | "QtCore.QItemSelectionRange": "QtCore.QItemSelectionRange", 992 | "uic.loadUi": ["QtCompat.loadUi", _loadUi], 993 | "sip.wrapinstance": ["QtCompat.wrapInstance", _wrapinstance], 994 | "sip.unwrapinstance": ["QtCompat.getCppPointer", _getcpppointer], 995 | "QtWidgets.qApp": "QtWidgets.QApplication.instance()", 996 | "QtCore.QCoreApplication.translate": [ 997 | "QtCompat.translate", _translate 998 | ], 999 | "QtWidgets.QApplication.translate": [ 1000 | "QtCompat.translate", _translate 1001 | ], 1002 | "QtCore.qInstallMessageHandler": [ 1003 | "QtCompat.qInstallMessageHandler", _qInstallMessageHandler 1004 | ], 1005 | }, 1006 | "PySide": { 1007 | "QtGui.QAbstractProxyModel": "QtCore.QAbstractProxyModel", 1008 | "QtGui.QSortFilterProxyModel": "QtCore.QSortFilterProxyModel", 1009 | "QtGui.QStringListModel": "QtCore.QStringListModel", 1010 | "QtGui.QItemSelection": "QtCore.QItemSelection", 1011 | "QtGui.QItemSelectionModel": "QtCore.QItemSelectionModel", 1012 | "QtCore.Property": "QtCore.Property", 1013 | "QtCore.Signal": "QtCore.Signal", 1014 | "QtCore.Slot": "QtCore.Slot", 1015 | "QtGui.QItemSelectionRange": "QtCore.QItemSelectionRange", 1016 | "QtGui.QAbstractPrintDialog": "QtPrintSupport.QAbstractPrintDialog", 1017 | "QtGui.QPageSetupDialog": "QtPrintSupport.QPageSetupDialog", 1018 | "QtGui.QPrintDialog": "QtPrintSupport.QPrintDialog", 1019 | "QtGui.QPrintEngine": "QtPrintSupport.QPrintEngine", 1020 | "QtGui.QPrintPreviewDialog": "QtPrintSupport.QPrintPreviewDialog", 1021 | "QtGui.QPrintPreviewWidget": "QtPrintSupport.QPrintPreviewWidget", 1022 | "QtGui.QPrinter": "QtPrintSupport.QPrinter", 1023 | "QtGui.QPrinterInfo": "QtPrintSupport.QPrinterInfo", 1024 | "QtUiTools.QUiLoader": ["QtCompat.loadUi", _loadUi], 1025 | "shiboken.wrapInstance": ["QtCompat.wrapInstance", _wrapinstance], 1026 | "shiboken.unwrapInstance": ["QtCompat.getCppPointer", _getcpppointer], 1027 | "QtGui.qApp": "QtWidgets.QApplication.instance()", 1028 | "QtCore.QCoreApplication.translate": [ 1029 | "QtCompat.translate", _translate 1030 | ], 1031 | "QtGui.QApplication.translate": [ 1032 | "QtCompat.translate", _translate 1033 | ], 1034 | "QtCore.qInstallMsgHandler": [ 1035 | "QtCompat.qInstallMessageHandler", _qInstallMessageHandler 1036 | ], 1037 | }, 1038 | "PyQt4": { 1039 | "QtGui.QAbstractProxyModel": "QtCore.QAbstractProxyModel", 1040 | "QtGui.QSortFilterProxyModel": "QtCore.QSortFilterProxyModel", 1041 | "QtGui.QItemSelection": "QtCore.QItemSelection", 1042 | "QtGui.QStringListModel": "QtCore.QStringListModel", 1043 | "QtGui.QItemSelectionModel": "QtCore.QItemSelectionModel", 1044 | "QtCore.pyqtProperty": "QtCore.Property", 1045 | "QtCore.pyqtSignal": "QtCore.Signal", 1046 | "QtCore.pyqtSlot": "QtCore.Slot", 1047 | "QtGui.QItemSelectionRange": "QtCore.QItemSelectionRange", 1048 | "QtGui.QAbstractPrintDialog": "QtPrintSupport.QAbstractPrintDialog", 1049 | "QtGui.QPageSetupDialog": "QtPrintSupport.QPageSetupDialog", 1050 | "QtGui.QPrintDialog": "QtPrintSupport.QPrintDialog", 1051 | "QtGui.QPrintEngine": "QtPrintSupport.QPrintEngine", 1052 | "QtGui.QPrintPreviewDialog": "QtPrintSupport.QPrintPreviewDialog", 1053 | "QtGui.QPrintPreviewWidget": "QtPrintSupport.QPrintPreviewWidget", 1054 | "QtGui.QPrinter": "QtPrintSupport.QPrinter", 1055 | "QtGui.QPrinterInfo": "QtPrintSupport.QPrinterInfo", 1056 | # "QtCore.pyqtSignature": "QtCore.Slot", 1057 | "uic.loadUi": ["QtCompat.loadUi", _loadUi], 1058 | "sip.wrapinstance": ["QtCompat.wrapInstance", _wrapinstance], 1059 | "sip.unwrapinstance": ["QtCompat.getCppPointer", _getcpppointer], 1060 | "QtCore.QString": "str", 1061 | "QtGui.qApp": "QtWidgets.QApplication.instance()", 1062 | "QtCore.QCoreApplication.translate": [ 1063 | "QtCompat.translate", _translate 1064 | ], 1065 | "QtGui.QApplication.translate": [ 1066 | "QtCompat.translate", _translate 1067 | ], 1068 | "QtCore.qInstallMsgHandler": [ 1069 | "QtCompat.qInstallMessageHandler", _qInstallMessageHandler 1070 | ], 1071 | } 1072 | } 1073 | 1074 | """ Compatibility Members 1075 | 1076 | This dictionary is used to build Qt.QtCompat objects that provide a consistent 1077 | interface for obsolete members, and differences in binding return values. 1078 | 1079 | { 1080 | "binding": { 1081 | "classname": { 1082 | "targetname": "binding_namespace", 1083 | } 1084 | } 1085 | } 1086 | """ 1087 | _compatibility_members = { 1088 | "PySide2": { 1089 | "QWidget": { 1090 | "grab": "QtWidgets.QWidget.grab", 1091 | }, 1092 | "QHeaderView": { 1093 | "sectionsClickable": "QtWidgets.QHeaderView.sectionsClickable", 1094 | "setSectionsClickable": 1095 | "QtWidgets.QHeaderView.setSectionsClickable", 1096 | "sectionResizeMode": "QtWidgets.QHeaderView.sectionResizeMode", 1097 | "setSectionResizeMode": 1098 | "QtWidgets.QHeaderView.setSectionResizeMode", 1099 | "sectionsMovable": "QtWidgets.QHeaderView.sectionsMovable", 1100 | "setSectionsMovable": "QtWidgets.QHeaderView.setSectionsMovable", 1101 | }, 1102 | "QFileDialog": { 1103 | "getOpenFileName": "QtWidgets.QFileDialog.getOpenFileName", 1104 | "getOpenFileNames": "QtWidgets.QFileDialog.getOpenFileNames", 1105 | "getSaveFileName": "QtWidgets.QFileDialog.getSaveFileName", 1106 | }, 1107 | }, 1108 | "PyQt5": { 1109 | "QWidget": { 1110 | "grab": "QtWidgets.QWidget.grab", 1111 | }, 1112 | "QHeaderView": { 1113 | "sectionsClickable": "QtWidgets.QHeaderView.sectionsClickable", 1114 | "setSectionsClickable": 1115 | "QtWidgets.QHeaderView.setSectionsClickable", 1116 | "sectionResizeMode": "QtWidgets.QHeaderView.sectionResizeMode", 1117 | "setSectionResizeMode": 1118 | "QtWidgets.QHeaderView.setSectionResizeMode", 1119 | "sectionsMovable": "QtWidgets.QHeaderView.sectionsMovable", 1120 | "setSectionsMovable": "QtWidgets.QHeaderView.setSectionsMovable", 1121 | }, 1122 | "QFileDialog": { 1123 | "getOpenFileName": "QtWidgets.QFileDialog.getOpenFileName", 1124 | "getOpenFileNames": "QtWidgets.QFileDialog.getOpenFileNames", 1125 | "getSaveFileName": "QtWidgets.QFileDialog.getSaveFileName", 1126 | }, 1127 | }, 1128 | "PySide": { 1129 | "QWidget": { 1130 | "grab": "QtWidgets.QPixmap.grabWidget", 1131 | }, 1132 | "QHeaderView": { 1133 | "sectionsClickable": "QtWidgets.QHeaderView.isClickable", 1134 | "setSectionsClickable": "QtWidgets.QHeaderView.setClickable", 1135 | "sectionResizeMode": "QtWidgets.QHeaderView.resizeMode", 1136 | "setSectionResizeMode": "QtWidgets.QHeaderView.setResizeMode", 1137 | "sectionsMovable": "QtWidgets.QHeaderView.isMovable", 1138 | "setSectionsMovable": "QtWidgets.QHeaderView.setMovable", 1139 | }, 1140 | "QFileDialog": { 1141 | "getOpenFileName": "QtWidgets.QFileDialog.getOpenFileName", 1142 | "getOpenFileNames": "QtWidgets.QFileDialog.getOpenFileNames", 1143 | "getSaveFileName": "QtWidgets.QFileDialog.getSaveFileName", 1144 | }, 1145 | }, 1146 | "PyQt4": { 1147 | "QWidget": { 1148 | "grab": "QtWidgets.QPixmap.grabWidget", 1149 | }, 1150 | "QHeaderView": { 1151 | "sectionsClickable": "QtWidgets.QHeaderView.isClickable", 1152 | "setSectionsClickable": "QtWidgets.QHeaderView.setClickable", 1153 | "sectionResizeMode": "QtWidgets.QHeaderView.resizeMode", 1154 | "setSectionResizeMode": "QtWidgets.QHeaderView.setResizeMode", 1155 | "sectionsMovable": "QtWidgets.QHeaderView.isMovable", 1156 | "setSectionsMovable": "QtWidgets.QHeaderView.setMovable", 1157 | }, 1158 | "QFileDialog": { 1159 | "getOpenFileName": "QtWidgets.QFileDialog.getOpenFileName", 1160 | "getOpenFileNames": "QtWidgets.QFileDialog.getOpenFileNames", 1161 | "getSaveFileName": "QtWidgets.QFileDialog.getSaveFileName", 1162 | }, 1163 | }, 1164 | } 1165 | 1166 | 1167 | def _apply_site_config(): 1168 | try: 1169 | import QtSiteConfig 1170 | except ImportError: 1171 | # If no QtSiteConfig module found, no modifications 1172 | # to _common_members are needed. 1173 | pass 1174 | else: 1175 | # Provide the ability to modify the dicts used to build Qt.py 1176 | if hasattr(QtSiteConfig, 'update_members'): 1177 | QtSiteConfig.update_members(_common_members) 1178 | 1179 | if hasattr(QtSiteConfig, 'update_misplaced_members'): 1180 | QtSiteConfig.update_misplaced_members(members=_misplaced_members) 1181 | 1182 | if hasattr(QtSiteConfig, 'update_compatibility_members'): 1183 | QtSiteConfig.update_compatibility_members( 1184 | members=_compatibility_members) 1185 | 1186 | 1187 | def _new_module(name): 1188 | return types.ModuleType(__name__ + "." + name) 1189 | 1190 | 1191 | def _import_sub_module(module, name): 1192 | """import_sub_module will mimic the function of importlib.import_module""" 1193 | module = __import__(module.__name__ + "." + name) 1194 | for level in name.split("."): 1195 | module = getattr(module, level) 1196 | return module 1197 | 1198 | 1199 | def _setup(module, extras): 1200 | """Install common submodules""" 1201 | 1202 | Qt.__binding__ = module.__name__ 1203 | 1204 | for name in list(_common_members) + extras: 1205 | try: 1206 | submodule = _import_sub_module( 1207 | module, name) 1208 | except ImportError: 1209 | try: 1210 | # For extra modules like sip and shiboken that may not be 1211 | # children of the binding. 1212 | submodule = __import__(name) 1213 | except ImportError: 1214 | continue 1215 | 1216 | setattr(Qt, "_" + name, submodule) 1217 | 1218 | if name not in extras: 1219 | # Store reference to original binding, 1220 | # but don't store speciality modules 1221 | # such as uic or QtUiTools 1222 | setattr(Qt, name, _new_module(name)) 1223 | 1224 | 1225 | def _reassign_misplaced_members(binding): 1226 | """Apply misplaced members from `binding` to Qt.py 1227 | 1228 | Arguments: 1229 | binding (dict): Misplaced members 1230 | 1231 | """ 1232 | 1233 | for src, dst in _misplaced_members[binding].items(): 1234 | dst_value = None 1235 | 1236 | src_parts = src.split(".") 1237 | src_module = src_parts[0] 1238 | src_member = None 1239 | if len(src_parts) > 1: 1240 | src_member = src_parts[1:] 1241 | 1242 | if isinstance(dst, (list, tuple)): 1243 | dst, dst_value = dst 1244 | 1245 | dst_parts = dst.split(".") 1246 | dst_module = dst_parts[0] 1247 | dst_member = None 1248 | if len(dst_parts) > 1: 1249 | dst_member = dst_parts[1] 1250 | 1251 | # Get the member we want to store in the namesapce. 1252 | if not dst_value: 1253 | try: 1254 | _part = getattr(Qt, "_" + src_module) 1255 | while src_member: 1256 | member = src_member.pop(0) 1257 | _part = getattr(_part, member) 1258 | dst_value = _part 1259 | except AttributeError: 1260 | # If the member we want to store in the namespace does not 1261 | # exist, there is no need to continue. This can happen if a 1262 | # request was made to rename a member that didn't exist, for 1263 | # example if QtWidgets isn't available on the target platform. 1264 | _log("Misplaced member has no source: {0}".format(src)) 1265 | continue 1266 | 1267 | try: 1268 | src_object = getattr(Qt, dst_module) 1269 | except AttributeError: 1270 | if dst_module not in _common_members: 1271 | # Only create the Qt parent module if its listed in 1272 | # _common_members. Without this check, if you remove QtCore 1273 | # from _common_members, the default _misplaced_members will add 1274 | # Qt.QtCore so it can add Signal, Slot, etc. 1275 | msg = 'Not creating missing member module "{m}" for "{c}"' 1276 | _log(msg.format(m=dst_module, c=dst_member)) 1277 | continue 1278 | # If the dst is valid but the Qt parent module does not exist 1279 | # then go ahead and create a new module to contain the member. 1280 | setattr(Qt, dst_module, _new_module(dst_module)) 1281 | src_object = getattr(Qt, dst_module) 1282 | # Enable direct import of the new module 1283 | sys.modules[__name__ + "." + dst_module] = src_object 1284 | 1285 | if not dst_value: 1286 | dst_value = getattr(Qt, "_" + src_module) 1287 | if src_member: 1288 | dst_value = getattr(dst_value, src_member) 1289 | 1290 | setattr( 1291 | src_object, 1292 | dst_member or dst_module, 1293 | dst_value 1294 | ) 1295 | 1296 | 1297 | def _build_compatibility_members(binding, decorators=None): 1298 | """Apply `binding` to QtCompat 1299 | 1300 | Arguments: 1301 | binding (str): Top level binding in _compatibility_members. 1302 | decorators (dict, optional): Provides the ability to decorate the 1303 | original Qt methods when needed by a binding. This can be used 1304 | to change the returned value to a standard value. The key should 1305 | be the classname, the value is a dict where the keys are the 1306 | target method names, and the values are the decorator functions. 1307 | 1308 | """ 1309 | 1310 | decorators = decorators or dict() 1311 | 1312 | # Allow optional site-level customization of the compatibility members. 1313 | # This method does not need to be implemented in QtSiteConfig. 1314 | try: 1315 | import QtSiteConfig 1316 | except ImportError: 1317 | pass 1318 | else: 1319 | if hasattr(QtSiteConfig, 'update_compatibility_decorators'): 1320 | QtSiteConfig.update_compatibility_decorators(binding, decorators) 1321 | 1322 | _QtCompat = type("QtCompat", (object,), {}) 1323 | 1324 | for classname, bindings in _compatibility_members[binding].items(): 1325 | attrs = {} 1326 | for target, binding in bindings.items(): 1327 | namespaces = binding.split('.') 1328 | try: 1329 | src_object = getattr(Qt, "_" + namespaces[0]) 1330 | except AttributeError as e: 1331 | _log("QtCompat: AttributeError: %s" % e) 1332 | # Skip reassignment of non-existing members. 1333 | # This can happen if a request was made to 1334 | # rename a member that didn't exist, for example 1335 | # if QtWidgets isn't available on the target platform. 1336 | continue 1337 | 1338 | # Walk down any remaining namespace getting the object assuming 1339 | # that if the first namespace exists the rest will exist. 1340 | for namespace in namespaces[1:]: 1341 | src_object = getattr(src_object, namespace) 1342 | 1343 | # decorate the Qt method if a decorator was provided. 1344 | if target in decorators.get(classname, []): 1345 | # staticmethod must be called on the decorated method to 1346 | # prevent a TypeError being raised when the decorated method 1347 | # is called. 1348 | src_object = staticmethod( 1349 | decorators[classname][target](src_object)) 1350 | 1351 | attrs[target] = src_object 1352 | 1353 | # Create the QtCompat class and install it into the namespace 1354 | compat_class = type(classname, (_QtCompat,), attrs) 1355 | setattr(Qt.QtCompat, classname, compat_class) 1356 | 1357 | 1358 | def _pyside2(): 1359 | """Initialise PySide2 1360 | 1361 | These functions serve to test the existence of a binding 1362 | along with set it up in such a way that it aligns with 1363 | the final step; adding members from the original binding 1364 | to Qt.py 1365 | 1366 | """ 1367 | 1368 | import PySide2 as module 1369 | extras = ["QtUiTools"] 1370 | try: 1371 | try: 1372 | # Before merge of PySide and shiboken 1373 | import shiboken2 1374 | except ImportError: 1375 | # After merge of PySide and shiboken, May 2017 1376 | from PySide2 import shiboken2 1377 | extras.append("shiboken2") 1378 | except ImportError: 1379 | pass 1380 | 1381 | _setup(module, extras) 1382 | Qt.__binding_version__ = module.__version__ 1383 | 1384 | if hasattr(Qt, "_shiboken2"): 1385 | Qt.QtCompat.wrapInstance = _wrapinstance 1386 | Qt.QtCompat.getCppPointer = _getcpppointer 1387 | Qt.QtCompat.delete = shiboken2.delete 1388 | 1389 | if hasattr(Qt, "_QtUiTools"): 1390 | Qt.QtCompat.loadUi = _loadUi 1391 | 1392 | if hasattr(Qt, "_QtCore"): 1393 | Qt.__qt_version__ = Qt._QtCore.qVersion() 1394 | 1395 | if hasattr(Qt, "_QtWidgets"): 1396 | Qt.QtCompat.setSectionResizeMode = \ 1397 | Qt._QtWidgets.QHeaderView.setSectionResizeMode 1398 | 1399 | _reassign_misplaced_members("PySide2") 1400 | _build_compatibility_members("PySide2") 1401 | 1402 | 1403 | def _pyside(): 1404 | """Initialise PySide""" 1405 | 1406 | import PySide as module 1407 | extras = ["QtUiTools"] 1408 | try: 1409 | try: 1410 | # Before merge of PySide and shiboken 1411 | import shiboken 1412 | except ImportError: 1413 | # After merge of PySide and shiboken, May 2017 1414 | from PySide import shiboken 1415 | extras.append("shiboken") 1416 | except ImportError: 1417 | pass 1418 | 1419 | _setup(module, extras) 1420 | Qt.__binding_version__ = module.__version__ 1421 | 1422 | if hasattr(Qt, "_shiboken"): 1423 | Qt.QtCompat.wrapInstance = _wrapinstance 1424 | Qt.QtCompat.getCppPointer = _getcpppointer 1425 | Qt.QtCompat.delete = shiboken.delete 1426 | 1427 | if hasattr(Qt, "_QtUiTools"): 1428 | Qt.QtCompat.loadUi = _loadUi 1429 | 1430 | if hasattr(Qt, "_QtGui"): 1431 | setattr(Qt, "QtWidgets", _new_module("QtWidgets")) 1432 | setattr(Qt, "_QtWidgets", Qt._QtGui) 1433 | if hasattr(Qt._QtGui, "QX11Info"): 1434 | setattr(Qt, "QtX11Extras", _new_module("QtX11Extras")) 1435 | Qt.QtX11Extras.QX11Info = Qt._QtGui.QX11Info 1436 | 1437 | Qt.QtCompat.setSectionResizeMode = Qt._QtGui.QHeaderView.setResizeMode 1438 | 1439 | if hasattr(Qt, "_QtCore"): 1440 | Qt.__qt_version__ = Qt._QtCore.qVersion() 1441 | 1442 | _reassign_misplaced_members("PySide") 1443 | _build_compatibility_members("PySide") 1444 | 1445 | 1446 | def _pyqt5(): 1447 | """Initialise PyQt5""" 1448 | 1449 | import PyQt5 as module 1450 | extras = ["uic"] 1451 | try: 1452 | import sip 1453 | extras.append(sip.__name__) 1454 | except ImportError: 1455 | sip = None 1456 | 1457 | _setup(module, extras) 1458 | if hasattr(Qt, "_sip"): 1459 | Qt.QtCompat.wrapInstance = _wrapinstance 1460 | Qt.QtCompat.getCppPointer = _getcpppointer 1461 | Qt.QtCompat.delete = sip.delete 1462 | 1463 | if hasattr(Qt, "_uic"): 1464 | Qt.QtCompat.loadUi = _loadUi 1465 | 1466 | if hasattr(Qt, "_QtCore"): 1467 | Qt.__binding_version__ = Qt._QtCore.PYQT_VERSION_STR 1468 | Qt.__qt_version__ = Qt._QtCore.QT_VERSION_STR 1469 | 1470 | if hasattr(Qt, "_QtWidgets"): 1471 | Qt.QtCompat.setSectionResizeMode = \ 1472 | Qt._QtWidgets.QHeaderView.setSectionResizeMode 1473 | 1474 | _reassign_misplaced_members("PyQt5") 1475 | _build_compatibility_members('PyQt5') 1476 | 1477 | 1478 | def _pyqt4(): 1479 | """Initialise PyQt4""" 1480 | 1481 | import sip 1482 | 1483 | # Validation of envivornment variable. Prevents an error if 1484 | # the variable is invalid since it's just a hint. 1485 | try: 1486 | hint = int(QT_SIP_API_HINT) 1487 | except TypeError: 1488 | hint = None # Variable was None, i.e. not set. 1489 | except ValueError: 1490 | raise ImportError("QT_SIP_API_HINT=%s must be a 1 or 2") 1491 | 1492 | for api in ("QString", 1493 | "QVariant", 1494 | "QDate", 1495 | "QDateTime", 1496 | "QTextStream", 1497 | "QTime", 1498 | "QUrl"): 1499 | try: 1500 | sip.setapi(api, hint or 2) 1501 | except AttributeError: 1502 | raise ImportError("PyQt4 < 4.6 isn't supported by Qt.py") 1503 | except ValueError: 1504 | actual = sip.getapi(api) 1505 | if not hint: 1506 | raise ImportError("API version already set to %d" % actual) 1507 | else: 1508 | # Having provided a hint indicates a soft constraint, one 1509 | # that doesn't throw an exception. 1510 | sys.stderr.write( 1511 | "Warning: API '%s' has already been set to %d.\n" 1512 | % (api, actual) 1513 | ) 1514 | 1515 | import PyQt4 as module 1516 | extras = ["uic"] 1517 | try: 1518 | import sip 1519 | extras.append(sip.__name__) 1520 | except ImportError: 1521 | sip = None 1522 | 1523 | _setup(module, extras) 1524 | if hasattr(Qt, "_sip"): 1525 | Qt.QtCompat.wrapInstance = _wrapinstance 1526 | Qt.QtCompat.getCppPointer = _getcpppointer 1527 | Qt.QtCompat.delete = sip.delete 1528 | 1529 | if hasattr(Qt, "_uic"): 1530 | Qt.QtCompat.loadUi = _loadUi 1531 | 1532 | if hasattr(Qt, "_QtGui"): 1533 | setattr(Qt, "QtWidgets", _new_module("QtWidgets")) 1534 | setattr(Qt, "_QtWidgets", Qt._QtGui) 1535 | if hasattr(Qt._QtGui, "QX11Info"): 1536 | setattr(Qt, "QtX11Extras", _new_module("QtX11Extras")) 1537 | Qt.QtX11Extras.QX11Info = Qt._QtGui.QX11Info 1538 | 1539 | Qt.QtCompat.setSectionResizeMode = \ 1540 | Qt._QtGui.QHeaderView.setResizeMode 1541 | 1542 | if hasattr(Qt, "_QtCore"): 1543 | Qt.__binding_version__ = Qt._QtCore.PYQT_VERSION_STR 1544 | Qt.__qt_version__ = Qt._QtCore.QT_VERSION_STR 1545 | 1546 | _reassign_misplaced_members("PyQt4") 1547 | 1548 | # QFileDialog QtCompat decorator 1549 | def _standardizeQFileDialog(some_function): 1550 | """Decorator that makes PyQt4 return conform to other bindings""" 1551 | def wrapper(*args, **kwargs): 1552 | ret = (some_function(*args, **kwargs)) 1553 | 1554 | # PyQt4 only returns the selected filename, force it to a 1555 | # standard return of the selected filename, and a empty string 1556 | # for the selected filter 1557 | return ret, '' 1558 | 1559 | wrapper.__doc__ = some_function.__doc__ 1560 | wrapper.__name__ = some_function.__name__ 1561 | 1562 | return wrapper 1563 | 1564 | decorators = { 1565 | "QFileDialog": { 1566 | "getOpenFileName": _standardizeQFileDialog, 1567 | "getOpenFileNames": _standardizeQFileDialog, 1568 | "getSaveFileName": _standardizeQFileDialog, 1569 | } 1570 | } 1571 | _build_compatibility_members('PyQt4', decorators) 1572 | 1573 | 1574 | def _none(): 1575 | """Internal option (used in installer)""" 1576 | 1577 | Mock = type("Mock", (), {"__getattr__": lambda Qt, attr: None}) 1578 | 1579 | Qt.__binding__ = "None" 1580 | Qt.__qt_version__ = "0.0.0" 1581 | Qt.__binding_version__ = "0.0.0" 1582 | Qt.QtCompat.loadUi = lambda uifile, baseinstance=None: None 1583 | Qt.QtCompat.setSectionResizeMode = lambda *args, **kwargs: None 1584 | 1585 | for submodule in _common_members.keys(): 1586 | setattr(Qt, submodule, Mock()) 1587 | setattr(Qt, "_" + submodule, Mock()) 1588 | 1589 | 1590 | def _log(text): 1591 | if QT_VERBOSE: 1592 | sys.stdout.write(text + "\n") 1593 | 1594 | 1595 | def _convert(lines): 1596 | """Convert compiled .ui file from PySide2 to Qt.py 1597 | 1598 | Arguments: 1599 | lines (list): Each line of of .ui file 1600 | 1601 | Usage: 1602 | >> with open("myui.py") as f: 1603 | .. lines = _convert(f.readlines()) 1604 | 1605 | """ 1606 | 1607 | def parse(line): 1608 | line = line.replace("from PySide2 import", "from Qt import QtCompat,") 1609 | line = line.replace("QtWidgets.QApplication.translate", 1610 | "QtCompat.translate") 1611 | if "QtCore.SIGNAL" in line: 1612 | raise NotImplementedError("QtCore.SIGNAL is missing from PyQt5 " 1613 | "and so Qt.py does not support it: you " 1614 | "should avoid defining signals inside " 1615 | "your ui files.") 1616 | return line 1617 | 1618 | parsed = list() 1619 | for line in lines: 1620 | line = parse(line) 1621 | parsed.append(line) 1622 | 1623 | return parsed 1624 | 1625 | 1626 | def _cli(args): 1627 | """Qt.py command-line interface""" 1628 | import argparse 1629 | 1630 | parser = argparse.ArgumentParser() 1631 | parser.add_argument("--convert", 1632 | help="Path to compiled Python module, e.g. my_ui.py") 1633 | parser.add_argument("--compile", 1634 | help="Accept raw .ui file and compile with native " 1635 | "PySide2 compiler.") 1636 | parser.add_argument("--stdout", 1637 | help="Write to stdout instead of file", 1638 | action="store_true") 1639 | parser.add_argument("--stdin", 1640 | help="Read from stdin instead of file", 1641 | action="store_true") 1642 | 1643 | args = parser.parse_args(args) 1644 | 1645 | if args.stdout: 1646 | raise NotImplementedError("--stdout") 1647 | 1648 | if args.stdin: 1649 | raise NotImplementedError("--stdin") 1650 | 1651 | if args.compile: 1652 | raise NotImplementedError("--compile") 1653 | 1654 | if args.convert: 1655 | sys.stdout.write("#\n" 1656 | "# WARNING: --convert is an ALPHA feature.\n#\n" 1657 | "# See https://github.com/mottosso/Qt.py/pull/132\n" 1658 | "# for details.\n" 1659 | "#\n") 1660 | 1661 | # 1662 | # ------> Read 1663 | # 1664 | with open(args.convert) as f: 1665 | lines = _convert(f.readlines()) 1666 | 1667 | backup = "%s_backup%s" % os.path.splitext(args.convert) 1668 | sys.stdout.write("Creating \"%s\"..\n" % backup) 1669 | shutil.copy(args.convert, backup) 1670 | 1671 | # 1672 | # <------ Write 1673 | # 1674 | with open(args.convert, "w") as f: 1675 | f.write("".join(lines)) 1676 | 1677 | sys.stdout.write("Successfully converted \"%s\"\n" % args.convert) 1678 | 1679 | 1680 | def _install(): 1681 | # Default order (customise order and content via QT_PREFERRED_BINDING) 1682 | default_order = ("PySide2", "PyQt5", "PySide", "PyQt4") 1683 | preferred_order = list( 1684 | b for b in QT_PREFERRED_BINDING.split(os.pathsep) if b 1685 | ) 1686 | 1687 | order = preferred_order or default_order 1688 | 1689 | available = { 1690 | "PySide2": _pyside2, 1691 | "PyQt5": _pyqt5, 1692 | "PySide": _pyside, 1693 | "PyQt4": _pyqt4, 1694 | "None": _none 1695 | } 1696 | 1697 | _log("Order: '%s'" % "', '".join(order)) 1698 | 1699 | # Allow site-level customization of the available modules. 1700 | _apply_site_config() 1701 | 1702 | found_binding = False 1703 | for name in order: 1704 | _log("Trying %s" % name) 1705 | 1706 | try: 1707 | available[name]() 1708 | found_binding = True 1709 | break 1710 | 1711 | except ImportError as e: 1712 | _log("ImportError: %s" % e) 1713 | 1714 | except KeyError: 1715 | _log("ImportError: Preferred binding '%s' not found." % name) 1716 | 1717 | if not found_binding: 1718 | # If not binding were found, throw this error 1719 | raise ImportError("No Qt binding were found.") 1720 | 1721 | # Install individual members 1722 | for name, members in _common_members.items(): 1723 | try: 1724 | their_submodule = getattr(Qt, "_%s" % name) 1725 | except AttributeError: 1726 | continue 1727 | 1728 | our_submodule = getattr(Qt, name) 1729 | 1730 | # Enable import * 1731 | __all__.append(name) 1732 | 1733 | # Enable direct import of submodule, 1734 | # e.g. import Qt.QtCore 1735 | sys.modules[__name__ + "." + name] = our_submodule 1736 | 1737 | for member in members: 1738 | # Accept that a submodule may miss certain members. 1739 | try: 1740 | their_member = getattr(their_submodule, member) 1741 | except AttributeError: 1742 | _log("'%s.%s' was missing." % (name, member)) 1743 | continue 1744 | 1745 | setattr(our_submodule, member, their_member) 1746 | 1747 | # Enable direct import of QtCompat 1748 | sys.modules['Qt.QtCompat'] = Qt.QtCompat 1749 | 1750 | # Backwards compatibility 1751 | if hasattr(Qt.QtCompat, 'loadUi'): 1752 | Qt.QtCompat.load_ui = Qt.QtCompat.loadUi 1753 | 1754 | 1755 | _install() 1756 | 1757 | # Setup Binding Enum states 1758 | Qt.IsPySide2 = Qt.__binding__ == 'PySide2' 1759 | Qt.IsPyQt5 = Qt.__binding__ == 'PyQt5' 1760 | Qt.IsPySide = Qt.__binding__ == 'PySide' 1761 | Qt.IsPyQt4 = Qt.__binding__ == 'PyQt4' 1762 | 1763 | """Augment QtCompat 1764 | 1765 | QtCompat contains wrappers and added functionality 1766 | to the original bindings, such as the CLI interface 1767 | and otherwise incompatible members between bindings, 1768 | such as `QHeaderView.setSectionResizeMode`. 1769 | 1770 | """ 1771 | 1772 | Qt.QtCompat._cli = _cli 1773 | Qt.QtCompat._convert = _convert 1774 | 1775 | # Enable command-line interface 1776 | if __name__ == "__main__": 1777 | _cli(sys.argv[1:]) 1778 | 1779 | 1780 | # The MIT License (MIT) 1781 | # 1782 | # Copyright (c) 2016-2017 Marcus Ottosson 1783 | # 1784 | # Permission is hereby granted, free of charge, to any person obtaining a copy 1785 | # of this software and associated documentation files (the "Software"), to deal 1786 | # in the Software without restriction, including without limitation the rights 1787 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 1788 | # copies of the Software, and to permit persons to whom the Software is 1789 | # furnished to do so, subject to the following conditions: 1790 | # 1791 | # The above copyright notice and this permission notice shall be included in 1792 | # all copies or substantial portions of the Software. 1793 | # 1794 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1795 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1796 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 1797 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 1798 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 1799 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 1800 | # SOFTWARE. 1801 | # 1802 | # In PySide(2), loadUi does not exist, so we implement it 1803 | # 1804 | # `_UiLoader` is adapted from the qtpy project, which was further influenced 1805 | # by qt-helpers which was released under a 3-clause BSD license which in turn 1806 | # is based on a solution at: 1807 | # 1808 | # - https://gist.github.com/cpbotha/1b42a20c8f3eb9bb7cb8 1809 | # 1810 | # The License for this code is as follows: 1811 | # 1812 | # qt-helpers - a common front-end to various Qt modules 1813 | # 1814 | # Copyright (c) 2015, Chris Beaumont and Thomas Robitaille 1815 | # 1816 | # All rights reserved. 1817 | # 1818 | # Redistribution and use in source and binary forms, with or without 1819 | # modification, are permitted provided that the following conditions are 1820 | # met: 1821 | # 1822 | # * Redistributions of source code must retain the above copyright 1823 | # notice, this list of conditions and the following disclaimer. 1824 | # * Redistributions in binary form must reproduce the above copyright 1825 | # notice, this list of conditions and the following disclaimer in the 1826 | # documentation and/or other materials provided with the 1827 | # distribution. 1828 | # * Neither the name of the Glue project nor the names of its contributors 1829 | # may be used to endorse or promote products derived from this software 1830 | # without specific prior written permission. 1831 | # 1832 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 1833 | # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 1834 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 1835 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 1836 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 1837 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 1838 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 1839 | # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 1840 | # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 1841 | # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 1842 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1843 | # 1844 | # Which itself was based on the solution at 1845 | # 1846 | # https://gist.github.com/cpbotha/1b42a20c8f3eb9bb7cb8 1847 | # 1848 | # which was released under the MIT license: 1849 | # 1850 | # Copyright (c) 2011 Sebastian Wiesner 1851 | # Modifications by Charl Botha 1852 | # 1853 | # Permission is hereby granted, free of charge, to any person obtaining a 1854 | # copy of this software and associated documentation files 1855 | # (the "Software"),to deal in the Software without restriction, 1856 | # including without limitation 1857 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 1858 | # and/or sell copies of the Software, and to permit persons to whom the 1859 | # Software is furnished to do so, subject to the following conditions: 1860 | # 1861 | # The above copyright notice and this permission notice shall be included 1862 | # in all copies or substantial portions of the Software. 1863 | # 1864 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 1865 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 1866 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 1867 | # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 1868 | # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 1869 | # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 1870 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 1871 | -------------------------------------------------------------------------------- /echopr/ShaderConverter/python/shader_conv_echopr.py: -------------------------------------------------------------------------------- 1 | import os, sys, hou, json, base64, re 2 | 3 | root_path = hou.getenv("ShaderConv_echopr_PATH") 4 | 5 | #Qt Import Block 6 | from Qt import QtCore, QtWidgets, QtCompat , QtGui 7 | 8 | #Class Creation 9 | class ShaderConv(QtWidgets.QMainWindow): 10 | def __init__(self, parent=hou.qt.mainWindow()): # parent=hou.qt.mainWindow() 11 | super(ShaderConv, self).__init__(parent) #QtCore.Qt.WindowStaysOnTopHint 12 | #File Interface File goes here 13 | file_interface = os.path.join(root_path, "Assets", "GUI", "shaderConv.ui") 14 | self.mw = QtCompat.loadUi(file_interface) 15 | self.setCentralWidget(self.mw) 16 | 17 | self.setWindowTitle("Shader Converter") # Set Window Title 18 | self.setStyleSheet(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/fjL4jrXTLG2L+JBpJkyp+BryWJMwLxevm/Lji/IQ8wIp2/PEh8RrkTEFuwFw2Iv/DPs3juuUiHYSI2I9OT+vEM8vI4PUk6NwF/Sj1rafEhYm9OZJq5AukETcV+bjB0wIh0/vIuIjKPIi5nTyaIew0wGv9pS49FBrV4dSp6sRGYhwwG8eI8pIX6lwRpKKTj8ynEJ9uLe5ARhbekmK9MuAX4FR1HNgJ8CxkSPrcLz2/o5ZjOjPxmGdIivSpJvB1Ix94qZA6N+xGhLUbm6DgPmQ1Od8QFgZH4T1q0BPg6Ykp5AliOjNwrRzw9fmin6XThG+yRzhOIvXwNMp/zI0jL/+uICeeriOtg1HFMGPHRTsRQ4gNzkvE8MkLzDeCXyP20kEmVpiPD3d9yHaPnnj4tSdqp5NXQyzHzSec3BcAs4Dek1rFlAbchIwb7IC3wFmQCpQ2OeEWISD2JCLwfp9rxSoiPymtFBpq4XQETTbD0Lfs6QsiLoQHpjJztEXewndYy/L07TkUE0j0nSSLORK6lCDGBRJGvi1c94t6AdHr+V5I0U8mroZdjRNpgMBhyGGOTNhgMhhzGiLTBYDDkMEakDQaDIYcxIm0wGAw5jBFpg8FgyGGMSBsMBkMOY0TaYDAYchgj0gaDwZDDGJE2GAyGHMaItMFgMOQwRqQNBoMhhzEibTAYDDmMEWmDwWDIYYxIGwwGQw5jRNpgMBhyGCPSBoPBkMMYkTYYDIYcxoi0wWAw5DBGpA0GgyGHMSJtMBgMOYwRaYPBYMhhjEgbDAZDDmNE2mAwGHIYI9IGg8GQw/x/KdvTJ8dZxbMAAAAASUVORK5CYII=' 22 | header_data = base64.b64decode(header64) 23 | header_pixmap = QtGui.QPixmap() 24 | header_pixmap.loadFromData(header_data) 25 | #Assign Pixmap to label 26 | self.mw.lbl_header.setPixmap(header_pixmap) 27 | 28 | self.clearFields() #Clear Fields 29 | self.loadInit() # Load Initial Code Binds 30 | 31 | #Set Button Bind to Convert Button 32 | self.mw.bttn_convert.clicked.connect(self.convertButton) 33 | 34 | self.mw.cmb_load1.currentIndexChanged.connect(self.changeButtonIcon) 35 | self.mw.cmb_load2.currentIndexChanged.connect(self.changeButtonIcon) 36 | 37 | self.mw.bttn_mat_override.clicked.connect(self.setOverrideMat) 38 | self.mw.bttn_mat_override_reset.clicked.connect(self.clearOverrideMat) 39 | 40 | def clearOverrideMat(self): 41 | self.mw.line_mat_override.clear() 42 | self.consoleOut("Cleared Override.") 43 | 44 | def setOverrideMat(self): 45 | selNode = hou.selectedNodes()[0] 46 | if selNode.isMaterialManager() == True: 47 | self.mw.line_mat_override.setText(selNode.path()) 48 | self.consoleOut("Set Override.") 49 | else: 50 | self.consoleOut("ERROR: Please Select a Material Network.") 51 | 52 | def consoleOut(self,message): 53 | self.mw.lbl_console.setText(message) 54 | 55 | def clearFields(self): 56 | self.mw.cmb_load1.clear() 57 | self.mw.cmb_load2.clear() 58 | 59 | def getBindPath(self): 60 | return(os.path.join(root_path, "Assets", "Bindings")) 61 | 62 | def getTargetExt(self): 63 | return(".json") 64 | 65 | def changeButtonIcon(self,basename): 66 | icoPath = os.path.join(root_path, "Assets", "GUI", "icons") 67 | try: 68 | iconPix = QtGui.QIcon(os.path.join(icoPath, basename.lower() + ".png")) 69 | return(iconPix) 70 | except: 71 | pass 72 | 73 | def loadInit(self): 74 | #bindPath = os.path.join(root_path, "Assets", "Bindings") 75 | self.consoleOut("Loading Items...") 76 | bindPath = self.getBindPath() 77 | target_ext = self.getTargetExt() 78 | indxx = 0 79 | for file in os.listdir(bindPath): 80 | if file.endswith(target_ext): 81 | #Save to List 82 | fbase_name = os.path.basename(file).split(".")[0].title() 83 | #print(fbase_name) 84 | self.mw.cmb_load1.addItem(fbase_name) 85 | self.mw.cmb_load2.addItem(fbase_name) 86 | 87 | iconData = self.changeButtonIcon(fbase_name) 88 | self.mw.cmb_load1.setItemIcon(indxx,iconData) 89 | self.mw.cmb_load2.setItemIcon(indxx,iconData) 90 | 91 | indxx += 1 #inc counter 92 | try: 93 | AllItems = [self.mw.cmb_load1.itemText(i) for i in range(self.mw.cmb_load1.count())] 94 | counter1 = 0 95 | for i in AllItems: 96 | if i == "Mantra": 97 | self.mw.cmb_load1.setCurrentIndex(counter1) 98 | else: 99 | counter1 += 1 100 | #self.mw.cmb_load1.setCurrentIndex(1) 101 | except: 102 | pass 103 | self.consoleOut("...") 104 | 105 | ############################################################ 106 | def flatten_json(self,y): 107 | out = {} 108 | 109 | def flatten(x, name=''): 110 | if type(x) is dict: 111 | for a in x: 112 | flatten(x[a], name + a + '_') 113 | elif type(x) is list: 114 | i = 0 115 | for a in x: 116 | flatten(a, name + str(i) + '-') 117 | i += 1 118 | else: 119 | name1 = re.sub(r'^.*?-','',name) 120 | out[name1[:-1]] = x 121 | 122 | flatten(y) 123 | return out 124 | ############################################################ 125 | 126 | #Get Raw File Data 127 | def getFileData(self,filePath): 128 | fileOpen = open(filePath,) 129 | data = json.load(fileOpen) 130 | fileOpen.close() 131 | return(data) 132 | 133 | def getDictErrorMsg(self): 134 | return("NULL") 135 | 136 | #Get Shader Details from json obj 137 | def getShaderDetails(self,dataObj,indx,id2): 138 | metaLst = [] 139 | dict_errormsg = self.getDictErrorMsg() 140 | for meta in dataObj['shader_details']: 141 | 142 | shader_givenname = meta.get('shader_givenname',dict_errormsg) 143 | metaLst.append(shader_givenname) 144 | #print(shader_givenname) 145 | 146 | ver = meta.get('version',dict_errormsg) 147 | metaLst.append(ver) 148 | 149 | hou_node_name = meta.get('houdini_node_name',dict_errormsg) 150 | metaLst.append(hou_node_name) 151 | 152 | hou_container = meta.get('houdini_container',dict_errormsg) 153 | metaLst.append(hou_container) 154 | 155 | hou_shopLoc = meta.get('houdini_shader_location',dict_errormsg) 156 | metaLst.append(hou_shopLoc) 157 | 158 | hou_node_name1 = "" 159 | if hou_node_name1 == "" and hou_node_name!=dict_errormsg: 160 | if hou_container == "SELF": 161 | hou_node_name1 = hou_node_name 162 | else: 163 | hou_node_name1 = hou_container 164 | 165 | 166 | prefx = meta.get('prefix',dict_errormsg) 167 | metaLst.append(prefx) 168 | 169 | #Get Image Node Data 170 | img_node = meta.get('image_details',dict_errormsg) 171 | metaLst.append(img_node) 172 | 173 | if id2 == 1: 174 | return(hou_node_name1) 175 | elif indx == 0 or indx == 1: 176 | return(metaLst) 177 | 178 | #loads shaderbinds 179 | def getShaderBinds(self,dataObj): 180 | temp_dict = {} 181 | for bindings in dataObj["shader_binds"]: 182 | temp_dict.update(bindings) 183 | return(temp_dict) 184 | 185 | #Get Shader Texture Maps 186 | def getShaderMaps(self,dataObj): 187 | map_dict = {} 188 | for maps in dataObj["shader_maps"]: 189 | map_dict.update(maps) 190 | return(map_dict) 191 | 192 | def getShaderImg(self,imgMeta): 193 | flatImgMeta = self.flatten_json(imgMeta) 194 | dict_errormsg = self.getDictErrorMsg() 195 | i_nodename = flatImgMeta.get("node_name",dict_errormsg) 196 | i_fileParm = flatImgMeta.get("filename_parm",dict_errormsg) 197 | iLst = [i_nodename,i_fileParm] 198 | return(iLst) 199 | 200 | 201 | #Create Shader 202 | def createShader(self,location,nType,container,ogShaderName,givenname,prefix): 203 | #Create Container First 204 | if container != "SELF": 205 | if self.mw.line_mat_override.text() == "": 206 | LOC = hou.node(location) 207 | else: 208 | LOC = hou.node(self.mw.line_mat_override.text()) 209 | contNode = LOC.createNode(container) 210 | contNode.moveToGoodPosition() 211 | contNode.setName((prefix+"_"+ogShaderName),unique_name=True) 212 | #Get Output node first 213 | outNode = contNode.children()[0] 214 | #Create internalNode 215 | intNode = contNode.createNode(nType) 216 | #Connect material to int node 217 | outNode.setInput(0,intNode) 218 | #Move to good location 219 | outNode.moveToGoodPosition() 220 | return(intNode) # Returns the interoir node for easy access 221 | 222 | elif container == "SELF": 223 | #mantra node process 224 | if self.mw.line_mat_override.text() == "": 225 | LOC = hou.node(location) 226 | else: 227 | LOC = hou.node(self.mw.line_mat_override.text()) 228 | contNode = LOC.createNode(nType) 229 | contNode.setName((prefix+"_"+ogShaderName),unique_name=True) 230 | contNode.moveToGoodPosition() 231 | return(contNode) 232 | 233 | 234 | def convertShader(self,shader,shaderbinds1,shaderbinds2,shader2_meta,container,maps1,maps2): 235 | #print("ConvertShader") 236 | shader_parms = [parm for parm in shader.parms() if not parm.isAtDefault()] 237 | 238 | if container == True: 239 | parentNode = shader.parent() 240 | nametopass = parentNode.name() 241 | else: 242 | nametopass = shader.name() 243 | 244 | #Flatten Shaders JSON Data 245 | #global shaderbinds1, shaderbinds2 246 | sb1 = self.flatten_json(shaderbinds1) 247 | sb2 = self.flatten_json(shaderbinds2) 248 | 249 | shader2 = self.createShader(shader2_meta[4],shader2_meta[2],shader2_meta[3],nametopass,shader2_meta[0],shader2_meta[5]) 250 | 251 | #Parm Convertion 252 | for i in shader_parms: 253 | #print(i.name()) 254 | for k1, v1 in sb1.items(): 255 | if i.name() in v1 and len(i.name()) == len(v1): 256 | #print("BOUND",v1) 257 | #Check if settings exist in other shader 258 | for k2, v2 in sb2.items(): 259 | if k1 in k2: 260 | #print("BOUND2",v2) 261 | #eval value from shader1 and copy to shader 2 262 | shader2.parm(v2).set(i.eval()) 263 | #Check for Maps. 264 | for mk1, mv1 in maps1.items(): 265 | if i.name() in mv1 and len(i.name()) == len(mv1): 266 | for mk2, mv2 in maps2.items(): 267 | if mk1 in mk2: 268 | #Create Node if not self else set parm. 269 | shader_img_meta = self.getShaderImg(shader2_meta[6]) 270 | if shader_img_meta[0] == "SELF": #This is Mainly for Mantra 271 | enableParm = i.name().split("_")[0] + str(shader_img_meta[1]) 272 | if enableParm == "baseNormal_useTexture": 273 | enableParm = "baseBumpAndNormal_enable" 274 | shader2.parm(enableParm).set(True) 275 | shader2.parm(mv2).set(str(i.eval())) 276 | else: 277 | #Create image node and connect result to appropriate shader. 278 | imgNode = shader2.parent().createNode(shader_img_meta[0]) 279 | imgNode.parm(shader_img_meta[1]).set(str(i.eval())) 280 | #Connect Shader2 to imgNode 281 | 282 | #Find Inputs for Shaders 283 | inputList = shader2.inputNames() 284 | connection_Dict = {} 285 | keys = range(len(inputList)) 286 | for r in keys: 287 | connection_Dict[r] = inputList[r] 288 | new_dict = {value:key for (key,value) in connection_Dict.items()} 289 | connection_Dict = new_dict 290 | paramTarget = connection_Dict.get(mv2, self.getDictErrorMsg()) #dict_errormsg = self.getDictErrorMsg() 291 | 292 | #Set Input for Shader2 to paramtarget 293 | shader2.setInput(paramTarget,imgNode) 294 | imgNode.moveToGoodPosition() 295 | imgNode.setName("IMG_" + mv2) 296 | 297 | 298 | def convertButton(self): 299 | self.consoleOut("Attempting to Convert from: " + self.mw.cmb_load1.currentText() + " To: " + self.mw.cmb_load2.currentText()) 300 | fileLoc1 = os.path.join(self.getBindPath(), self.mw.cmb_load1.currentText().lower() + self.getTargetExt()) 301 | fileLoc2 = os.path.join(self.getBindPath(), self.mw.cmb_load2.currentText().lower() + self.getTargetExt()) 302 | 303 | #Globals 304 | file1_data = self.getFileData(fileLoc1) 305 | file2_data = self.getFileData(fileLoc2) 306 | dict_errormsg = self.getDictErrorMsg() #Dictionary Error Parm 307 | hou_node_name1 = self.getShaderDetails(file1_data,0,1) #Used for Node Selection Filter 308 | shader1_meta = self.getShaderDetails(file1_data,0,0) 309 | shader2_meta = self.getShaderDetails(file2_data,1,0) 310 | #Shader Binds 311 | shaderbinds1 = self.getShaderBinds(file1_data) 312 | shaderbinds2 = self.getShaderBinds(file2_data) 313 | #Shader Maps 314 | shaderMap1 = self.getShaderMaps(file1_data) 315 | shaderMap2 = self.getShaderMaps(file2_data) 316 | 317 | #Get Nodes to Convert 318 | selNodes = [node for node in hou.selectedNodes() if node.type().name()==hou_node_name1] 319 | lenNodes = [] 320 | for node in selNodes: 321 | if len(node.children()) > 0: 322 | lenNodes.append(node) 323 | if len(lenNodes)>0: 324 | container = True 325 | else: 326 | container = False 327 | 328 | if container == True: 329 | newTarg = shader1_meta[2] 330 | nNodes = [] 331 | for node in selNodes: 332 | for i in node.children(): 333 | if i.type().name()==newTarg: 334 | nNodes.append(i) 335 | selNodes = nNodes 336 | 337 | if len(selNodes)>0: 338 | #process nodes 339 | #print("len>1") 340 | #Iterate over each node in selection and convert. 341 | for each in selNodes: 342 | self.convertShader(each,shaderbinds1,shaderbinds2,shader2_meta,container,shaderMap1,shaderMap2) 343 | self.consoleOut("Task Finished...") 344 | else: 345 | self.consoleOut("ERROR:No Valid Node(s) Detected.") 346 | 347 | 348 | def createWindow(): 349 | #End Block 350 | try: 351 | shaderConvWin.close() 352 | except: 353 | pass 354 | 355 | shaderConvWin = ShaderConv() 356 | shaderConvWin.resize(360,500) 357 | shaderConvWin.show() 358 | -------------------------------------------------------------------------------- /git/ui_cap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SideswipeeZ/houdini-shader-converter/a4c69c279a4ad23d70123ea539848bb263b8add6/git/ui_cap.png -------------------------------------------------------------------------------- /packages/shaderconv_echopr.json: -------------------------------------------------------------------------------- 1 | { 2 | "enable" : true, 3 | "env": 4 | [ 5 | { 6 | "HOUDINI_PATH" : 7 | { 8 | "value": "$HOUDINI_PACKAGE_PATH/../echopr/ShaderConverter", 9 | }, 10 | "ShaderConv_echopr_PATH" : 11 | { 12 | "value": "$HOUDINI_PACKAGE_PATH/../echopr/ShaderConverter", 13 | }, 14 | "PYTHONPATH" : 15 | { 16 | "value": "$HOUDINI_PACKAGE_PATH/../echopr/ShaderConverter/python", 17 | } 18 | } 19 | ] 20 | } --------------------------------------------------------------------------------