Re: [Maya-Python] Qt.py and .ui files

2016-09-20 Thread Marcus Ottosson
Ok, we’ve made an alpha version of this to test with.

If you’re interested in compiling Qt Designer files for use across
bindings, your help would be most appreciated. The rule is, .ui files are
first compiled with the PySide2 compiler, and then converted to Qt.py.

$ pip install Qt.py
$ pyside2-uic my_ui.ui -o my_ui.py
$ python -m Qt --convert my_ui.py# Creating "my_ui_backup.py"..#
Successfully converted "my_ui.py"

The resulting Python module should be compatible with every binding. If
it’s not, submit a bug report or pull-request and we’ll see it fixed!

In Maya 2017, the compiler executable will be located in your Maya
installation directory, alongside mayapy and maya.

Let me know how that works for you!
​

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAFeBykPjOk4UfjSP%2BJW_P-roa9qm5MHFDix_JDgW6KPw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Qt.py and .ui files

2016-09-08 Thread Jason Brummett - gmail
W c

Sent from my Virgin Mobile Android-Powered Device

- Reply message -
From: "Justin Israel" 
To: 
Subject: [Maya-Python] Qt.py and .ui files
Date: Thu, Sep 8, 2016 2:38 am
On Thu, 8 Sep 2016, 7:09 PM Marcus Ottosson  wrote:
Good thoughts.
I've always wanted a reason to get into AST, perhaps now is the time.
Thanks Justin.
Sweet. Let us know if you end up going down that path. Would love to see it in 
action. 



-- 

You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.

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

To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAw-4OzCXB4T5qTKdxf9G8x%2BgY3M%2BpMLMTByyOtHEEJow%40mail.gmail.com.

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





-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3aQFgm0BbA0La_ibx%3DFV-ExARHoOecAWE68XUXUwZbQg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/57d1d8a1.4e47620a.7ea7.03ce%40mx.google.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Qt.py and .ui files

2016-09-08 Thread Marcus Ottosson
Will do.

The current plan is:

1. Test the plain `.replace()` method on ~10.000 or more random .ui files
from GitHub
2. I expect to encounter plenty of edge cases, and if I do, look into AST.
3. If that fails, look into whatever the
https://github.com/rferrazz/pyqt4topyqt5 project is doing and try that.

I'm sure each of these approaches will have warts of its own, so if there
are any other suggestions, I'm all ears.

On 8 September 2016 at 09:38, Justin Israel  wrote:

>
>
> On Thu, 8 Sep 2016, 7:09 PM Marcus Ottosson 
> wrote:
>
>> Good thoughts.
>>
>> I've always wanted a reason to get into AST, perhaps now is the time.
>>
>> Thanks Justin.
>>
>
> Sweet. Let us know if you end up going down that path. Would love to see
> it in action.
>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to python_inside_maya+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/
>> msgid/python_inside_maya/CAFRtmOAw-4OzCXB4T5qTKdxf9G8x%
>> 2BgY3M%2BpMLMTByyOtHEEJow%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/python_inside_maya/CAPGFgA3aQFgm0BbA0La_ibx%3DFV-
> ExARHoOecAWE68XUXUwZbQg%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
*Marcus Ottosson*
konstrukt...@gmail.com

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBtaE9MvSgfBRxYm_%2BQbxzdRHm5fW_9dELnoOWqq4-sZw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Qt.py and .ui files

2016-09-08 Thread Justin Israel
On Thu, 8 Sep 2016, 7:09 PM Marcus Ottosson  wrote:

> Good thoughts.
>
> I've always wanted a reason to get into AST, perhaps now is the time.
>
> Thanks Justin.
>

Sweet. Let us know if you end up going down that path. Would love to see it
in action.

> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAw-4OzCXB4T5qTKdxf9G8x%2BgY3M%2BpMLMTByyOtHEEJow%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3aQFgm0BbA0La_ibx%3DFV-ExARHoOecAWE68XUXUwZbQg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Qt.py and .ui files

2016-09-08 Thread Marcus Ottosson
Good thoughts.

I've always wanted a reason to get into AST, perhaps now is the time.

Thanks Justin.

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAw-4OzCXB4T5qTKdxf9G8x%2BgY3M%2BpMLMTByyOtHEEJow%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Qt.py and .ui files

2016-09-07 Thread Justin Israel
On Thu, Sep 8, 2016 at 10:23 AM Marcus Ottosson 
wrote:

> That's a good idea!
>
> I'm expecting this initial proposal to mostly get the conversation started
> and iterate on it until all is well. Considering the source files are all
> automatically generated by another program, I'm expecting a finite set of
> edge cases. This does sound like one of them.
>

True. This problem can occur in an edge case. And you are write about it
being a smaller surface space for problems since its auto generated. But
part of the output is not auto-generated, such as any text a user may have
set into widgets. That is a wide open variable.


>
> But, don't you feel working at the abstract tree-level is perhaps a tad
> premature? Spontaneously I'd first try splitting lines at file-open, via
> e.g. file.readlines().
>

When it comes to modifying source code in the form of a code generator that
you are providing to others, maybe its not so premature. Since you don't
have control over what ends up being in the UI file, you may end up string
replacing things you didn't expect. Again my example being someone using a
newline character in some text of their widget. Or using words that you
have set up to be replaced, where you intended for them to be modules or
function names, and someone used them elsewhere.


>
> Another reason for going with .replace() as opposed to jumping straight
> into regular expressions is readability and maintainability. I want to
> enable others to understand the conversion and make changes to it where
> necessary. Both re and AST carry the potential of making these options
> fairly limited.
>

Definitely agree that adding another replace() line is trivial. And you
have structured it in a way where it's at the top and easy to see. But
again, doing text replacement could have unwanted effects since you have no
control over doing syntax-safe replacements here. You just see a line and
replace matching text. It could be possible to use the AST approach, but
expose it as some kind of high level thing like making a canned set of
refactor options, which get added to a list?

* replace module name x with y
* replace class name x with y
* replace function name x with y
* replace method name MyClass.x with MyClass.y

I 100% agree that this is a more complicated solution than string
replacements. It just depends if your refactors will get more complicated
or end up being more fragile in the way they are currently done.


>
> Thanks, and if you have any ui files (I know you generally don't work with
> them, neither do I) do let me know!
>

If I used UI files anymore, I would definitely share them! :-)


>
> On 7 Sep 2016, at 22:38, Justin Israel  wrote:
>
> Hey Marcus,
>
> It's a cool goal that you are trying to make everyone's workflows more
> compatible and consistent. Keep it up.
>
> Quick question about the approach to providing the convert
> functionality... Do you think splitting the file on a '\n' and doing
> line-by-line string replacements is a viable approach? Could it be possible
> to break the code if someone has a '\n' in some text of their widget or the
> word 'PySide2"? I know its pretty specific right now with the 2
> replacements its doing, but you might end up adding more changes once you
> get feedback.
> Have you looked at a safe approach that parses and rewrites the AST?
> Something like the rope project
> 
> or even the ast stdlib module if you are really against dependencies? At
> least you could be sure that you are only refactoring, say, the renaming of
> an import. Or renaming a method of a class.
>
> Just throwing that out there to see if it helps.
>
> Justin
>
> On Thu, Sep 8, 2016 at 9:00 AM Marcus Ottosson 
> wrote:
>
>> Hi all,
>>
>> Many of you have been asking about working with ui files in a way
>> maintains the cross-binding benefit of Qt.py.
>>
>> The problem has been that:
>>
>>- a) PySide and PyQt implement the in-memory loading mechanism
>>loadUi() differently and
>>- b) Files compiled via the command-line leave artifacts behind that
>>make it difficult to run the result on another binding.
>>
>> One suggestion was to:
>>
>>1. Compile to Python via PySide2
>>2. Convert to cross-compatible Qt.py code afterwards.
>>
>> So that’s what is happening here.
>>
>>- https://github.com/mottosso/Qt.py/pull/132
>>
>> $ pyside2-uic my_ui.ui -o my_ui.py
>> $ python -m Qt --convert my_ui.py
>> $ cat my_ui_.py
>>
>> What we need now is:
>>
>>1. Loads of .ui files to test with (if you have a stash, now’s the
>>time to share!)
>>2. Your feedback on whether this approach is one worth pursuing
>>
>> Let me know what you think!
>>
>> Best,
>> Marcus
>> ​
>> --
>> *Marcus Ottosson*
>> konstrukt...@gmail.com
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group

Re: [Maya-Python] Qt.py and .ui files

2016-09-07 Thread Marcus Ottosson
That's a good idea!

I'm expecting this initial proposal to mostly get the conversation started and 
iterate on it until all is well. Considering the source files are all 
automatically generated by another program, I'm expecting a finite set of edge 
cases. This does sound like one of them.

But, don't you feel working at the abstract tree-level is perhaps a tad 
premature? Spontaneously I'd first try splitting lines at file-open, via e.g. 
file.readlines().

Another reason for going with .replace() as opposed to jumping straight into 
regular expressions is readability and maintainability. I want to enable others 
to understand the conversion and make changes to it where necessary. Both re 
and AST carry the potential of making these options fairly limited.

Thanks, and if you have any ui files (I know you generally don't work with 
them, neither do I) do let me know!

> On 7 Sep 2016, at 22:38, Justin Israel  wrote:
> 
> Hey Marcus,
> 
> It's a cool goal that you are trying to make everyone's workflows more 
> compatible and consistent. Keep it up.
> 
> Quick question about the approach to providing the convert functionality... 
> Do you think splitting the file on a '\n' and doing line-by-line string 
> replacements is a viable approach? Could it be possible to break the code if 
> someone has a '\n' in some text of their widget or the word 'PySide2"? I know 
> its pretty specific right now with the 2 replacements its doing, but you 
> might end up adding more changes once you get feedback. 
> Have you looked at a safe approach that parses and rewrites the AST? 
> Something like the rope project   or even the ast stdlib module if you are 
> really against dependencies? At least you could be sure that you are only 
> refactoring, say, the renaming of an import. Or renaming a method of a class.
> 
> Just throwing that out there to see if it helps.
> 
> Justin
> 
>> On Thu, Sep 8, 2016 at 9:00 AM Marcus Ottosson  
>> wrote:
>> Hi all,
>> 
>> Many of you have been asking about working with ui files in a way maintains 
>> the cross-binding benefit of Qt.py.
>> 
>> The problem has been that:
>> 
>> a) PySide and PyQt implement the in-memory loading mechanism loadUi() 
>> differently and
>> b) Files compiled via the command-line leave artifacts behind that make it 
>> difficult to run the result on another binding.
>> One suggestion was to:
>> 
>> Compile to Python via PySide2
>> Convert to cross-compatible Qt.py code afterwards.
>> So that’s what is happening here.
>> 
>> https://github.com/mottosso/Qt.py/pull/132
>> $ pyside2-uic my_ui.ui -o my_ui.py
>> $ python -m Qt --convert my_ui.py
>> $ cat my_ui_.py
>> What we need now is:
>> 
>> Loads of .ui files to test with (if you have a stash, now’s the time to 
>> share!)
>> Your feedback on whether this approach is one worth pursuing
>> Let me know what you think!
>> 
>> Best,
>> Marcus
>> 
>> -- 
>> Marcus Ottosson
>> konstrukt...@gmail.com
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to python_inside_maya+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAjdKbcXmfG1LNSyA514-HC9XC3UkxtXq0fNUb6Nj%2BAJg%40mail.gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1oNG3qmkTXajcrfnTGLvoonZJ_PBmmnjSO3kqZYVEA9Q%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/2060697B-7EFD-436A-8CDD-6E18347070E5%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Qt.py and .ui files

2016-09-07 Thread Justin Israel
Hey Marcus,

It's a cool goal that you are trying to make everyone's workflows more
compatible and consistent. Keep it up.

Quick question about the approach to providing the convert functionality...
Do you think splitting the file on a '\n' and doing line-by-line string
replacements is a viable approach? Could it be possible to break the code
if someone has a '\n' in some text of their widget or the word 'PySide2"? I
know its pretty specific right now with the 2 replacements its doing, but
you might end up adding more changes once you get feedback.
Have you looked at a safe approach that parses and rewrites the AST?
Something like the rope project

or even the ast stdlib module if you are really against dependencies? At
least you could be sure that you are only refactoring, say, the renaming of
an import. Or renaming a method of a class.

Just throwing that out there to see if it helps.

Justin

On Thu, Sep 8, 2016 at 9:00 AM Marcus Ottosson 
wrote:

> Hi all,
>
> Many of you have been asking about working with ui files in a way
> maintains the cross-binding benefit of Qt.py.
>
> The problem has been that:
>
>- a) PySide and PyQt implement the in-memory loading mechanism loadUi()
>differently and
>- b) Files compiled via the command-line leave artifacts behind that
>make it difficult to run the result on another binding.
>
> One suggestion was to:
>
>1. Compile to Python via PySide2
>2. Convert to cross-compatible Qt.py code afterwards.
>
> So that’s what is happening here.
>
>- https://github.com/mottosso/Qt.py/pull/132
>
> $ pyside2-uic my_ui.ui -o my_ui.py
> $ python -m Qt --convert my_ui.py
> $ cat my_ui_.py
>
> What we need now is:
>
>1. Loads of .ui files to test with (if you have a stash, now’s the
>time to share!)
>2. Your feedback on whether this approach is one worth pursuing
>
> Let me know what you think!
>
> Best,
> Marcus
> ​
> --
> *Marcus Ottosson*
> konstrukt...@gmail.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAjdKbcXmfG1LNSyA514-HC9XC3UkxtXq0fNUb6Nj%2BAJg%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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