[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] Errors without 'import "."' in QML files
From:       Louis Simons <lousimons () gmail ! com>
Date:       2016-12-09 2:29:56
Message-ID: CAJG7t=npj1BF7f1jJUvteuoHkU693j3omOpffqdqkBcASa5P9g () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Right now I don't have any way of changing it, since it won't run
otherwise.  However, I'm operating in fear that I'm creating a subtle
problem that will leave me debugging through trial and error for days due
to some definition redefining another without warning.  This happened
before I had the namespace and directory imports, and was driving me insane.

Do you know of any examples of larger project structures for working with
PyQt and QML?  I've been following the examples at
https://github.com/baoboa/pyqt5/tree/master/examples/quick/tutorials/extending,
but since they are condensed in the minimum number of files, they don't
demonstrate how to architect a project.  I've had a hard time finding any
examples of larger PyQt hybrid apps online.

On Thu, Dec 8, 2016 at 9:36 AM Cody Scott <cody@perspexis.com> wrote:

> This is strange. You shouldn't need to import anything in
> components/MainBus.qml to access MainBusButton {} since MainBusButton.qml
> is in the components/ directory.
>
> One thing is that you are registering MainBusButton in Python and it is
> also registered when you import components. So it seems to me that you are
> registering the same type twice.
>
> But the component you are using has characteristics of both. And it is
> working.
>
> Let me know if you end up changing it.
>
> On Wed, Dec 7, 2016 at 9:34 PM, Louis Simons <lousimons@gmail.com> wrote:
>
> I have been trying to learn PyQt5 by migrating an application from Kivy to
> a QtQuick/Python hybrid. I'm finally starting to understand the
> architecture a little better (I should have read the C++ docs sooner), but
> I've been running into a little weirdness. In the repository at
> https://github.com/superlou/snowman-qt-client, my root QML file is
> app.qml, which requires the following imports to use my custom registered
> types:
>
> import Snowman 1.0
> import "components"
>
> I've been having a hard time finding examples of QML projects beyond
> single-file examples, but since my components are in the "components"
> directory, it didn't seem too strange to need to explicitly tell QML where
> the components in the Snowman namespace were. However, if I leave off the
> explicit imports in MainBus.qml and MainBusButton.qml, I get lots of errors
> about undefined types and recursive definitions. This seems to be resolved
> by using something like the following:
>
> import Snowman 1.0
> import "."
>
> I haven't found any examples where 'import "."' has been required, and my
> understanding was that QML should look in the same directory for siblings
> automatically. The application seems to operate normally with the import
> scheme shown above, but this smells funny, and I wanted to make sure I'm
> understanding the proper way to structure a large project before I bake an
> anti-patten into the code. Is there a better way to handle this?
>
> Thank you,
> Louis
>
> _______________________________________________
> PyQt mailing list    PyQt@riverbankcomputing.com
> https://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
>
>

[Attachment #5 (text/html)]

<div dir="ltr"><div>Right now I don&#39;t have any way of changing it, since it \
won&#39;t run otherwise.   However, I&#39;m operating in fear that I&#39;m creating a \
subtle problem that will leave me debugging through trial and error for days due to \
some definition redefining another without warning.   This happened before I had the \
namespace and directory imports, and was driving me insane.</div><div><br></div>Do \
you know of any examples of larger project structures for working with PyQt and QML?  \
I&#39;ve been following the examples at  <a \
href="https://github.com/baoboa/pyqt5/tree/master/examples/quick/tutorials/extending"> \
https://github.com/baoboa/pyqt5/tree/master/examples/quick/tutorials/extending</a>, \
but since they are condensed in the minimum number of files, they don&#39;t \
demonstrate how to architect a project.   I&#39;ve had a hard time finding any \
examples of larger PyQt hybrid apps online.</div><br><div class="gmail_quote"><div \
dir="ltr">On Thu, Dec 8, 2016 at 9:36 AM Cody Scott &lt;<a \
href="mailto:cody@perspexis.com">cody@perspexis.com</a>&gt; \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" \
class="gmail_msg">This is strange. You shouldn&#39;t need to import anything in \
components/MainBus.qml to access MainBusButton {} since MainBusButton.qml is in the \
components/ directory.<div class="gmail_msg"><br class="gmail_msg"></div><div \
class="gmail_msg">One thing is that you are registering MainBusButton in Python and \
it is also registered when you import components. So it seems to me that you are \
registering the same type twice.</div><div class="gmail_msg"><br \
class="gmail_msg"></div><div class="gmail_msg">But the component you are using has \
characteristics of both. And it is working.</div><div class="gmail_msg"><br \
class="gmail_msg"></div><div class="gmail_msg">Let me know if you end up changing \
it.</div></div><div class="gmail_extra gmail_msg"><br class="gmail_msg"><div \
class="gmail_quote gmail_msg"></div></div><div class="gmail_extra gmail_msg"><div \
class="gmail_quote gmail_msg">On Wed, Dec 7, 2016 at 9:34 PM, Louis Simons <span \
dir="ltr" class="gmail_msg">&lt;<a href="mailto:lousimons@gmail.com" \
class="gmail_msg" target="_blank">lousimons@gmail.com</a>&gt;</span> wrote:<br \
class="gmail_msg"></div></div><div class="gmail_extra gmail_msg"><div \
class="gmail_quote gmail_msg"><blockquote class="gmail_quote gmail_msg" \
style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" \
class="gmail_msg">I have been trying to learn PyQt5 by migrating an application from \
Kivy to a QtQuick/Python hybrid.  I&#39;m finally starting to understand the \
architecture a little better (I should have read the C++ docs sooner), but I&#39;ve \
been running into a little weirdness.  In the repository at <a \
href="https://github.com/superlou/snowman-qt-client" class="gmail_msg" \
target="_blank">https://github.com/superlou/snowman-qt-client</a>, my root QML file \
is app.qml, which requires the following imports to use my custom registered \
types:<br class="gmail_msg"><br class="gmail_msg">import Snowman 1.0<br \
class="gmail_msg"> import &quot;components&quot;<br class="gmail_msg"><br \
class="gmail_msg">I&#39;ve been having a hard time finding examples of QML projects \
beyond single-file examples, but since my components are in the \
&quot;components&quot; directory, it didn&#39;t seem too strange to need to \
explicitly tell QML where the components in the Snowman namespace were. However, if I \
leave off the explicit imports in MainBus.qml and MainBusButton.qml, I get lots of \
errors about undefined types and recursive definitions. This seems to be resolved by \
using something like the following:<br class="gmail_msg"><br class="gmail_msg">import \
Snowman 1.0<br class="gmail_msg"> import &quot;.&quot;<br class="gmail_msg"><br \
class="gmail_msg">I haven&#39;t found any examples where &#39;import \
&quot;.&quot;&#39; has been required, and my understanding was that QML should look \
in the same directory for siblings automatically.  The application seems to operate \
normally with the import scheme shown above, but this smells funny, and I wanted to \
make sure I&#39;m understanding the proper way to structure a large project before I \
bake an anti-patten into the code.  Is there a better way to handle this?<br \
class="gmail_msg"><br class="gmail_msg">Thank you,<br class="gmail_msg">Louis<br \
class="gmail_msg"></div> <br class="gmail_msg"></blockquote></div></div><div \
class="gmail_extra gmail_msg"><div class="gmail_quote gmail_msg"><blockquote \
class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">_______________________________________________<br \
class="gmail_msg"> PyQt mailing list      <a \
href="mailto:PyQt@riverbankcomputing.com" class="gmail_msg" \
target="_blank">PyQt@riverbankcomputing.com</a><br class="gmail_msg"> <a \
href="https://www.riverbankcomputing.com/mailman/listinfo/pyqt" rel="noreferrer" \
class="gmail_msg" target="_blank">https://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br \
class="gmail_msg"></blockquote></div><br class="gmail_msg"></div> </blockquote></div>


[Attachment #6 (text/plain)]

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic