PyQt5: How do you set the user input of a line edit to a specific variable? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: PyQt5: How do you set the user input of a line edit to a specific variable? (/thread-23333.html) Pages:
1
2
|
RE: PyQt5: How do you set the user input of a line edit to a specific variable? - Denni - Dec-23-2019 buran Wrote:I would post this nice article by Raimond Hettinger:And I would post this nice article by James Knight just one of a few posts outlining the issues with Super() Python's Super is nifty, but you can't use it Let me also include this counter point post made to someone else's declaration that Super() is good Quote:If you do use super, here are some best practices:The key I would point out here is this final statement which after fully investigated super() I fully agree with I cannot envision any implementation where this functionality would actually be needed. Or to state it another way... unless you are implementing poorly designed code due to lazy thinking there should really be no need for its use under most circumstances.Denni Wrote:This in turn makes your code more direct, less confusing and less verbose. And again not being specific is being lazy and lazy coding is always bad coding. buran Wrote:Because you edit your post - full reference what you use is just that - verbose and being very, very specific :-)Okay this makes no sense -- but I think I got it maybe -- the verbosity I am speaking of is this one PyQt.QtWidgets.QWidget.method() versus the same line of code written as follows: QWidget.method() The extra PyQt.QtWidgets. which is not needed if done succinctly only clutters up the code especially when you start referencing more than one such item on a single line such as in making calls to PyQt.QtCore.Qt.Something ,PyQt.QtCore.Qt.Something, etc... instead just referencing Qt.Something ,Qt.Something,etc... which is not all that uncommon of a thing to need to do buran Wrote:And many would prefer that. I don't say what you do is wrong, just that your statements are radical and not everyone agreeOkay I am not sure who these fictitious "many" are and further you cannot state anything that I have said is wrong because frankly it is not wrong at all and I have been pointing just how wrong your statements have been. Further claiming my statements are radical is also wrong as they are not radical at all they are held by many high-quality software engineers as opposed to the opinions of numerous programmer wanna-bes and lazy coders -- of that entire statement the only thing that had a spec of truth in it was not everyone agree which should have been pluralized -- but just because folks do not agree with this does not make it no less true -- folks used to all agree the world was flat but just because they all agreed about this false claim it did not make it true and this goes for many many things many folks seem to "agree" upon -- I say think for yourself and know for yourself. I am perfectly comfortable with anyone fully researching these topics, nay I encourage folks to do so, and if I am wrong and you can prove it please do so but so far that is not the case.Denni Wrote:On the other hand -- yes the only difference between the two statements is what name is bound; buran Wrote:And because you continue to edit your post - I am glad that now you actually agree with me :-)First the only continuing editing I have done past the first edit -- which I denoted was a cross-posting issue -- have been typo fixes. Next I do not agree with you fully only in part as I denoted. So because you chose to take my words out of context I will quote myself from that same post to remind you and anyone else reading this about your fopaux Me form that same post Wrote:...for importing RE: PyQt5: How do you set the user input of a line edit to a specific variable? - buran - Dec-23-2019 (Dec-23-2019, 06:17 PM)Denni Wrote: First the only continuing editing I have done past the first edit -- which I denoted was a cross-posting issue -- have been typo fixes.do you want me to revert your edits to your original post? currently your post in question is edited 4 times. Denni, original post Wrote:Okay @buran first off importing skip first edit - looks like just typos Denni, second edit Wrote:Okay @buran first off importing skip third edit - again looks like just typos Denni, fourth edit, content at the moment Wrote:Okay @buran first off I do stand corrected but only partially -- for importing PyQt import QtWidgets does not import the same thing as from PyQt.QtWidgets import QApplication, etc... because in the latter you have a single reference to a single method and this denotes exactly what you are using within that library within your program. This in turn makes your code more direct, less confusing and less verbose. And again not being specific is being lazy and lazy coding is always bad coding. As all can see the major edits, not typos, are in second edit and fourth edit. RE: PyQt5: How do you set the user input of a line edit to a specific variable? - buran - Dec-23-2019 @YoshikageKira, sorry for hijacking your thread for what is more like general discussion, not just answering your question. RE: PyQt5: How do you set the user input of a line edit to a specific variable? - YoshikageKira - Dec-23-2019 (Dec-23-2019, 04:07 PM)Denni Wrote: While @Axel_Erfurt nicely provided a way to do it sadly it is fraught with numerous issues. Now while none of these issues would cause the program not to run, they are ones that are either out-dated, poor/dangerous-implementation, or a bit too complex for the situation at hand. I have used his code and adjusted it to remove these elements and simplify its layout -- I added comments to outline why for some of these as some are just pure style changes (like variable naming and such) Thanks I appreciate it! But Im more looking for how to have a lineedit save the input from the user in a program, for example. I have a Qlineedit widget and the user enters in "creampie" into the line edit and they click a confirm. What would be the best way to have the program save the input in a lineedit (Hence "creampie"). RE: PyQt5: How do you set the user input of a line edit to a specific variable? - Denni - Dec-23-2019 buran Wrote:do you want me to revert your edits to your original post? currently your post in question is edited 4 times.Yep @buran I made that 2nd change and then I made that 4th change but I believe I made the note that I made an edit after that 4th change when I saw you had replied while I was making my edits. Of course all of those edits were done I think fairly quickly in succession so the timing of it all might be slightly off. Still I do not see your point? As you quoted my 4th change in your reply to my edit while leaving out the reference to the 2nd change. So you purposefully chose to pull something out of context and misrepresent what I said. Nice and no apology to go with it, typical. @YoshikageKira as for saving that information once you have gotten it into a variable state you can save that virtually anywhere you want to however, a database is typically used in this case and python incorporates sqlite3 which is a very easy and free database engine to use however when doing this you are going to want to use MVC methodology and if you do not know about MVC you should read up on that. Regardless if you want to learn this kind of stuff interactively you can join my free python-pyqt classroom or I can continue helping you here -- just post another question on this once you have looked into MVC and using sqlite3 with python --- note do not look into PyQt inter-activeness with a database as that is not MVC and frankly straight python works better for a database interface Still if you did not want to go the route of a database MVC is still a methodology you want to investigate and then you could save into a text file or Jason object within a text file RE: PyQt5: How do you set the user input of a line edit to a specific variable? - YoshikageKira - Dec-23-2019 (Dec-23-2019, 10:33 PM)Denni Wrote:buran Wrote:do you want me to revert your edits to your original post? currently your post in question is edited 4 times.Yep @buran I made that 2nd change and then I made that 4th change but I believe I made the note that I made an edit after that 4th change when I saw you had replied while I was making my edits. Of course all of those edits were done I think fairly quickly in succession so the timing of it all might be slightly off. Still I do not see your point? As you quoted my 4th change in your reply to my edit while leaving out the reference to the 2nd change. So you purposefully chose to pull something out of context and misrepresent what I said. Nice and no apology to go with it, typical. What a coincidence because I just so happen to be experimenting with sqlite3 and I am attempting to use it with my project. It would be perfect to learn the MVC to use with my project because I am attempting to have a program that allows you log information (integer related such as Volunteer hours) into a database and calculate certain information etc. Tho I do perfer to be helped here, I would love to know the code to doing would be. I could a send a massive snipet of the code that Im trying to incorporate the method into. RE: PyQt5: How do you set the user input of a line edit to a specific variable? - YoshikageKira - Dec-24-2019 (Dec-23-2019, 10:33 PM)Denni Wrote:buran Wrote:do you want me to revert your edits to your original post? currently your post in question is edited 4 times.Yep @buran I made that 2nd change and then I made that 4th change but I believe I made the note that I made an edit after that 4th change when I saw you had replied while I was making my edits. Of course all of those edits were done I think fairly quickly in succession so the timing of it all might be slightly off. Still I do not see your point? As you quoted my 4th change in your reply to my edit while leaving out the reference to the 2nd change. So you purposefully chose to pull something out of context and misrepresent what I said. Nice and no apology to go with it, typical. Do you know where I can find your python pyqt class? I would love to learn how to incorporate the sqlite3 database into my program RE: PyQt5: How do you set the user input of a line edit to a specific variable? - Denni - Dec-26-2019 @YoshikageKira yes I know where the pyqt sql class stuff is but I would strongly suggest that you do not use it especially if you are going to use sqlite3 as that is native to python and using MVC methodology you would want to build that Database Class as a python only self-contained autonomous class that takes dictionary parameters and passes back dictionary recordsets. I have a template of this that I share (for free) with my students and I can share that with you as well if you are interested. |