EDITED How to verify "show" ?
-
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.
Thanksdef 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])**
-
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.
Thanksdef 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])**
@AnneRanch, I would propose you to start with Hello Qt for Python examples.
This link look good also. -
@AnneRanch, I would propose you to start with Hello Qt for Python examples.
This link look good also.@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. -
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.
Thanksdef 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])**
@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 itsshowEvent(event)
method. -
@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 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. -
@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 itsshowEvent(event)
method.@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
-
@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 itsshowEvent(event)
method.@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
-
@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
-
@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
@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.
-
@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.@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 .