Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. EDITED How to verify "show" ?
Forum Updated to NodeBB v4.3 + New Features

EDITED How to verify "show" ?

Scheduled Pinned Locked Moved Unsolved Qt for Python
10 Posts 3 Posters 792 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by Anonymous_Banned275
    #1

    EDIT
    As expected , I have something missing in my code.
    I'll work on that, however, I have one more beginner question .

    This line of code prints / "returns" "None".

    print(self.windows[name].show())

    telling me that there is nothing to show...

    So I tried this

       if(self.windows[name].show() == "None"):
                    print(self.windows[name].show())
    

    and I failed miserably, my code is wrong...
    OK, I can work on that also ...

    However, what "return value " does
    windows[name].show() gives when there is a window to be shown?

    Yes, I can search for it in my book, but if you do mind telling me I would appreciate that.

    The code I am "reverse engineering" has no error checking, hence it is harder to decode when things fails.

    Thanks

    I have added a new QtDesigner form , into PyQt created application , created in PyCharm using external tools.

    I am having a Python issue - the code runs fine , but fails to physically show the new form .

    See highlighted text in the code snippet.

    I expect the window / dialog to show and I do not know how else I can debug the code if there is something missing.

    I would like to know if there is a way to verify "show" actually processed the code AKA I am looking for a "return " value or something similar.

    I hope somebody with good knowledge (user) of Python can help.
    Such help will be much appreciated.
    Thanks

        def display_window(self, name):
            if __debug__:
                debug_text = " def display_window(self, name): ??  FAILS TDW ***********************"
                from inspect import currentframe, getframeinfo
                print("\tCurrent line ", getframeinfo(currentframe()).lineno)
                # EJ_DEBUG.DEBUG_TRACE.DEBUG_TRACE_EXTENDED(" windows ??", getframeinfo(currentframe()).lineno, __file__)
                # EJ_DEBUG.DEBUG_TRACE.TEST_FUNCTION(debug_text)
            **self.windows[name].show() 
            QtWidgets.QApplication.setActiveWindow(self.windows[name])**
    
    S JonBJ 2 Replies Last reply
    0
    • A Anonymous_Banned275

      EDIT
      As expected , I have something missing in my code.
      I'll work on that, however, I have one more beginner question .

      This line of code prints / "returns" "None".

      print(self.windows[name].show())

      telling me that there is nothing to show...

      So I tried this

         if(self.windows[name].show() == "None"):
                      print(self.windows[name].show())
      

      and I failed miserably, my code is wrong...
      OK, I can work on that also ...

      However, what "return value " does
      windows[name].show() gives when there is a window to be shown?

      Yes, I can search for it in my book, but if you do mind telling me I would appreciate that.

      The code I am "reverse engineering" has no error checking, hence it is harder to decode when things fails.

      Thanks

      I have added a new QtDesigner form , into PyQt created application , created in PyCharm using external tools.

      I am having a Python issue - the code runs fine , but fails to physically show the new form .

      See highlighted text in the code snippet.

      I expect the window / dialog to show and I do not know how else I can debug the code if there is something missing.

      I would like to know if there is a way to verify "show" actually processed the code AKA I am looking for a "return " value or something similar.

      I hope somebody with good knowledge (user) of Python can help.
      Such help will be much appreciated.
      Thanks

          def display_window(self, name):
              if __debug__:
                  debug_text = " def display_window(self, name): ??  FAILS TDW ***********************"
                  from inspect import currentframe, getframeinfo
                  print("\tCurrent line ", getframeinfo(currentframe()).lineno)
                  # EJ_DEBUG.DEBUG_TRACE.DEBUG_TRACE_EXTENDED(" windows ??", getframeinfo(currentframe()).lineno, __file__)
                  # EJ_DEBUG.DEBUG_TRACE.TEST_FUNCTION(debug_text)
              **self.windows[name].show() 
              QtWidgets.QApplication.setActiveWindow(self.windows[name])**
      
      S Offline
      S Offline
      StarterKit
      wrote on last edited by StarterKit
      #2

      @AnneRanch, I would propose you to start with Hello Qt for Python examples.
      This link look good also.

      A 1 Reply Last reply
      0
      • S StarterKit

        @AnneRanch, I would propose you to start with Hello Qt for Python examples.
        This link look good also.

        A Offline
        A Offline
        Anonymous_Banned275
        wrote on last edited by
        #3

        @StarterKit Would it be possible if you kindly remove your post. It is giving a wrong impression to other forum participants that my post call for coding help has been answered.
        Thank you very much for all your support, it has been very helpful in finding solutions. It is contributions like your which makes this forum very valuable to beginners like me.

        S 1 Reply Last reply
        0
        • A Anonymous_Banned275

          EDIT
          As expected , I have something missing in my code.
          I'll work on that, however, I have one more beginner question .

          This line of code prints / "returns" "None".

          print(self.windows[name].show())

          telling me that there is nothing to show...

          So I tried this

             if(self.windows[name].show() == "None"):
                          print(self.windows[name].show())
          

          and I failed miserably, my code is wrong...
          OK, I can work on that also ...

          However, what "return value " does
          windows[name].show() gives when there is a window to be shown?

          Yes, I can search for it in my book, but if you do mind telling me I would appreciate that.

          The code I am "reverse engineering" has no error checking, hence it is harder to decode when things fails.

          Thanks

          I have added a new QtDesigner form , into PyQt created application , created in PyCharm using external tools.

          I am having a Python issue - the code runs fine , but fails to physically show the new form .

          See highlighted text in the code snippet.

          I expect the window / dialog to show and I do not know how else I can debug the code if there is something missing.

          I would like to know if there is a way to verify "show" actually processed the code AKA I am looking for a "return " value or something similar.

          I hope somebody with good knowledge (user) of Python can help.
          Such help will be much appreciated.
          Thanks

              def display_window(self, name):
                  if __debug__:
                      debug_text = " def display_window(self, name): ??  FAILS TDW ***********************"
                      from inspect import currentframe, getframeinfo
                      print("\tCurrent line ", getframeinfo(currentframe()).lineno)
                      # EJ_DEBUG.DEBUG_TRACE.DEBUG_TRACE_EXTENDED(" windows ??", getframeinfo(currentframe()).lineno, __file__)
                      # EJ_DEBUG.DEBUG_TRACE.TEST_FUNCTION(debug_text)
                  **self.windows[name].show() 
                  QtWidgets.QApplication.setActiveWindow(self.windows[name])**
          
          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by JonB
          #4

          @AnneRanch
          QWidget.show() does not return any result, either in Python or C++. Consequently you cannot test its result against anything or print it. It never fails.

          Note that calling show() does not show the widget/window at the time of the call. It merely sets an internal flag to say that it should be shown. That will actually happen the next time the Qt top-level event loop is entered.

          QWidget has an event, showEvent() (https://doc.qt.io/qtforpython-6/PySide6/QtWidgets/QWidget.html#PySide6.QtWidgets.PySide6.QtWidgets.QWidget.showEvent for PySide6, PyQt6 does not provide its own documentation but it's the same), which will be called if/when it was hidden and now becomes shown. Being an event, not a signal, you cannot connect a slot to that. If you wish to "see" that event arriving you have to sub-class whatever widget and override its showEvent(event) method.

          A 2 Replies Last reply
          2
          • A Anonymous_Banned275

            @StarterKit Would it be possible if you kindly remove your post. It is giving a wrong impression to other forum participants that my post call for coding help has been answered.
            Thank you very much for all your support, it has been very helpful in finding solutions. It is contributions like your which makes this forum very valuable to beginners like me.

            S Offline
            S Offline
            StarterKit
            wrote on last edited by StarterKit
            #5

            @AnneRanch said in EDITED How to verify "show" ?:

            @StarterKit Would it be possible if you kindly remove your post. It is giving a wrong impression to other forum participants that my post call for coding help has been answered.
            Thank you very much for all your support, it has been very helpful in finding solutions. It is contributions like your which makes this forum very valuable to beginners like me.

            @AnneRanch, I don't like to remove my posts in order to keep the full history of discussion that might be valuable for understanding of the full story. I also try to edit my posts only to fix some typos or improve style for better understanding. If I have an updated information I create a new post and story flows.
            (You may mark your post "EDITED", but why someone should try to understand what exactly was edited? And why anyone should keep track of all his/her posts and see should (s)he update/delete it after your editions?)

            From your explanation I got a feeling that you don't understand a basic principles of how windowed GUI works and how Qt operates with it. This is why I gave you basic links - my intention was to highlight the difference with your code and make you thinking of it.
            @JonB gave more precise comment about exact line that you asked about. But, again my feeling only, it might be hard for you to understand his comment if you miss the basics.

            1 Reply Last reply
            0
            • JonBJ JonB

              @AnneRanch
              QWidget.show() does not return any result, either in Python or C++. Consequently you cannot test its result against anything or print it. It never fails.

              Note that calling show() does not show the widget/window at the time of the call. It merely sets an internal flag to say that it should be shown. That will actually happen the next time the Qt top-level event loop is entered.

              QWidget has an event, showEvent() (https://doc.qt.io/qtforpython-6/PySide6/QtWidgets/QWidget.html#PySide6.QtWidgets.PySide6.QtWidgets.QWidget.showEvent for PySide6, PyQt6 does not provide its own documentation but it's the same), which will be called if/when it was hidden and now becomes shown. Being an event, not a signal, you cannot connect a slot to that. If you wish to "see" that event arriving you have to sub-class whatever widget and override its showEvent(event) method.

              A Offline
              A Offline
              Anonymous_Banned275
              wrote on last edited by Anonymous_Banned275
              #6

              @JonB Thanks for the reply. I appreciate your inputs.
              I found a working code - which actually shows the dialog - and tested "show" to find out that it "prints" same text - "None" - hence my debug method was useless.

              I believe the "no show" is a result of something is missing in the dialog build code.

              The application has "main window" and "sub windows". The dialog I am trying to show is initialized / executed from the sub window I have added . I can run another tested / working sub sub window and then my add does work.
              I may try just to copy and modify that sub sub window ...

              I did used PyCharm external tool to build new dialog and that is the problem - the QtDesigner build very basic form and I feel it is missing stuff to integrate with existing application.

              So I have two choices - trying to find what is missing or copy and modify working dialog.

              I think I do "cut and modify and paste" and chalk-up the usage of "external tools" as an "attempt to educate myself ".

              Cheers

              1 Reply Last reply
              0
              • JonBJ JonB

                @AnneRanch
                QWidget.show() does not return any result, either in Python or C++. Consequently you cannot test its result against anything or print it. It never fails.

                Note that calling show() does not show the widget/window at the time of the call. It merely sets an internal flag to say that it should be shown. That will actually happen the next time the Qt top-level event loop is entered.

                QWidget has an event, showEvent() (https://doc.qt.io/qtforpython-6/PySide6/QtWidgets/QWidget.html#PySide6.QtWidgets.PySide6.QtWidgets.QWidget.showEvent for PySide6, PyQt6 does not provide its own documentation but it's the same), which will be called if/when it was hidden and now becomes shown. Being an event, not a signal, you cannot connect a slot to that. If you wish to "see" that event arriving you have to sub-class whatever widget and override its showEvent(event) method.

                A Offline
                A Offline
                Anonymous_Banned275
                wrote on last edited by
                #7

                @JonB Well, I cheated...
                I did copy a working dialog and modified it.
                It is a royal pain to write Python / Qt GUI code , I do miss QtDesigner..
                I dread when I decide to actually locate button where I want it.

                Since I decided NOT to get into Python too deep I am still struggling with "on the fly debugging" .

                It seems that the creators of Python build a language with the idea that everybody writes a perfectly working code , hence there is no need for "step by step / on the fly " de-bugging.
                But that is my opinion and that and a dime may did get me a cup of coffee 100 years ago...

                Cheers

                JonBJ S 2 Replies Last reply
                0
                • A Anonymous_Banned275

                  @JonB Well, I cheated...
                  I did copy a working dialog and modified it.
                  It is a royal pain to write Python / Qt GUI code , I do miss QtDesigner..
                  I dread when I decide to actually locate button where I want it.

                  Since I decided NOT to get into Python too deep I am still struggling with "on the fly debugging" .

                  It seems that the creators of Python build a language with the idea that everybody writes a perfectly working code , hence there is no need for "step by step / on the fly " de-bugging.
                  But that is my opinion and that and a dime may did get me a cup of coffee 100 years ago...

                  Cheers

                  JonBJ Online
                  JonBJ Online
                  JonB
                  wrote on last edited by
                  #8

                  @AnneRanch
                  PyCharm has an integrated Python debugger, if you run your code inside it. I found it rather it good. I take it you have discovered this.

                  A 1 Reply Last reply
                  1
                  • A Anonymous_Banned275

                    @JonB Well, I cheated...
                    I did copy a working dialog and modified it.
                    It is a royal pain to write Python / Qt GUI code , I do miss QtDesigner..
                    I dread when I decide to actually locate button where I want it.

                    Since I decided NOT to get into Python too deep I am still struggling with "on the fly debugging" .

                    It seems that the creators of Python build a language with the idea that everybody writes a perfectly working code , hence there is no need for "step by step / on the fly " de-bugging.
                    But that is my opinion and that and a dime may did get me a cup of coffee 100 years ago...

                    Cheers

                    S Offline
                    S Offline
                    StarterKit
                    wrote on last edited by
                    #9

                    @AnneRanch , I'm wondering about your statements:

                    I do miss QtDesigner

                    You have Qt Designer available. It even works for custom Python widgets now. So I don't understand why you complain about it. It is only your choice. If you have reason to do dialog by hand - no problem. But no one forbids you to use Qt Designer and create the whole dialog or its part in WYSIWYG environment.

                    hence there is no need for "step by step / on the fly " de-bugging.

                    As @JonB mentioned - there are a lot of debug capabilities built in PyCharm. You may put breakpoint at any place you need and then step further with F7/F8 button.

                    1 Reply Last reply
                    0
                    • JonBJ JonB

                      @AnneRanch
                      PyCharm has an integrated Python debugger, if you run your code inside it. I found it rather it good. I take it you have discovered this.

                      A Offline
                      A Offline
                      Anonymous_Banned275
                      wrote on last edited by
                      #10

                      @JonB I am running the Python code in debug mode and I have few debug "flags" in my code. The "problem" is with my little knowledge how Python works.
                      If I set a breakpoints inside class and run it will stop at the breakpoints, which is good, but it does not actually execute the class GUI code.
                      It sort of verify the code flow...

                      I will add some "button pushed" code to dig into this .

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved