Python Forum
[PyQt] Why lineEdit is showing text like this ??
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] Why lineEdit is showing text like this ??
#11
(Sep-06-2019, 10:38 PM)Axel_Erfurt Wrote:
(Sep-06-2019, 09:07 PM)alandmoore Wrote: I was of the impression that this should not be necessary in Python 3. Can you explain why it should be done?

I did not wrote it. In my code I wrote

class lineEdit(QtWidgets.QLineEdit):
     def __init__(self, parent):
        super().__init__(parent)  

My mistake, I was replying to Denni's response. I'm not clear why one should still do the older method in Python 3.
Reply
#12
Perhaps it does not need to be done any more but I was getting errors when not referencing the class within super() so I assumed it was a necessary feature that if not done might cause issues. I rarely use super() I normally just code it as follows:

class MyLineEdit(QLineEdit):
     def __init__(self, parent):
        QLineEdit.__init__(parent)
Next the Designer versus real PyQt code. I have shown numerous individuals what the difference is between what the Designer creates and what actual PyQt code would look like and once they see how actual PyQt code looks like they find that it is actually as fast to create the initial object using it (and faster if you have done it at least once and have template to copy/paste from) and perhaps 5 times to 10 times easier to work with post creation since it no longer is some black box that you do not understand how it works.

That being said if you post an MRE (Minimal Reproducible Example) of your code with the UI -- I will show you how to code the Designer part so that you can then do away with using it going forward. Your code will be the much better for as will your sanity ;)
Reply
#13
(Sep-10-2019, 01:34 PM)Denni Wrote: I rarely use super() I normally just code it as follows:

That works, but if you ever end up in a multiple inheritance situation, super() does some good sleuthing to find the right upstream methods.
Reply
#14
Yeah I thoroughly investigated using super() versus not using super() and I am going to stay with not using it -- as per the cons -- (these are summations there were a lot more details) one will rarely if ever see a situation where the benefit of using super() versus not using it comes into play and using super(), acknowledged by the person for using super, has the potential of causing issues unless used carefully. Once I finished weighing the pros and cons -- the ultimate pro was its quicker because it saves you from having to copy/paste a few lines of code (frankly that level of laziness I have seen done in coding before and it never came to a good ending). Further I agree with being explicit is better, So unless there is some kind of solid argument somewhere that I did not see that compels me to do otherwise using super() will not appear in my code and I will suggest to others to not use it as well.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyGUI] Showing text in QTableView sequence 0 3,033 Jan-20-2019, 05:00 PM
Last Post: sequence
  [PyQt] Need Help about comboBox and lineEdit DeanONeil 1 2,664 Oct-13-2017, 05:42 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020