So, you are writing a PyQt app, and you want it to support command line arguments. So you do something like this:
opt_parser = OptionParser() opt_parser.add_option("-q", dest="quickly", action="store_true", help="Do it quickly (default=False)") (options, args) = opt_parser.parse_args(sys.argv) app = QApplication(sys.argv) : : :
Or maybe even
QApplication(). Ok, you are doing it wrong. And this is wrong in most tutorials, too. Why? Because Qt (and thus PyQt) supports a bunch of useful command line options already. So if you do it like in the first listing, and pass "-style=oxygen" or whatever, one of the following will happen.
OptParser is going to tell you it's not a valid option and abort
You will ignore the option and not do anything useful with it
You will have your own -style option and do two things with it
All three outcomes are less than ideal.
The right way to do this is:
opt_parser = OptionParser() opt_parser.add_option("-q", dest="quickly", action="store_true", help="Do it quickly (default=False)") app = QApplication(sys.argv) (options, args) = opt_parser.parse_args(app.arguments()) : : :
This way, you give PyQt a chance to process the options it recognizes, and, then, you get to handle the rest, because
app.arguments() has all Qt options removed.
The bad side of this is, you will make
--help slightly slower, since it will have to build a
QApplication to do nothing, and you will have undocumented options. Solution for both problems left as an exercise.
Two nights ago, I was at a birthday party. In it, someone (name preserved because you don't know the guy) said something like "symbols are useful to rally people for a fight".
I answered "if I ever need to rally people to a fight, I would make sure to choose some uncool symbol (maybe a naked mole rat, rampant), so I at least know they are there because they understand the issue, and not because of cool marketing". Which is probably a pretty stupid thing to say, but:
I was on my 3rd fernet
I was trolling the other guy
Fernet troll is drunk
I kinda believe it
It's stupid because only accepting the help of true believers and not actively trying to make people believe are good ways to ensure you have a very motivated tiny minority on your side (Linux Year of The Desktop analogy ges here).
But I kinda believe it anyway, because being ugly and loved is warmer than being pretty and loved, because being difficult and appreciated is more valuable than being accessible and liked. But that only works if you are truly difficult, and not intentionally so, that's just being a poseur. And truly ugly, not Charlize-Theron-on-fat-makeup ugly.
So, to what point is any of us honestly annoying? That, friends, is the issue here. And if I ever have to lead others into something, I hope I do it as myself, and they come because of a reason that is theirs and not mine.
I am not here to convince people. I am here to know people.