Skip to content

Tag: python

How to grab a desktop screenshot with PyQt?

Can I take a screenshot from desktop or any window with PyQt? How to handle keyPressEvent on desktop? Thanks. Answer Example of how to take a screenshot of the desktop: If you want to take a screenshot of a specific window, replace QApplication.desktop() with the widget you want to take a screenshot of.

I am getting the error ‘redefined-outer-name’

When running my lint, I am getting the error below: Here is my snippet of code in that line: Answer That happens because you have a local name identical to a global name. The local name takes precedence, of course, but it hides the global name, makes it inaccesible, and cause confusion to the reader. Solution…

check if .one() is empty sqlAlchemy

I am running a query based off of other ids for the query. The problem i have is that sometimes the query won’t find a result. Instead of having the entire program crash, how can I check to see if the result will be None? This is the query I have: When the code gets executed and no results are

get table columns from sqlAlchemy table model

I have a table where I would like to fetch all the column names however after browsing the interwebs I could not find a way that works. This is what my table looks like: I would like to be able to print all the column names from a for loop. ex: This is pretty easy with regular sql but I

How to reverse an int in python?

I’m creating a python script which prints out the whole song of ’99 bottles of beer’, but reversed. The only thing I cannot reverse is the numbers, being integers, not strings. This is my full script, I understand my reverse function takes a string as an argument, however I do not know how t…