Python Forum

Full Version: what have you learned recently?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
what have you learned recently that impacts your programming in Python or anything else you regularly do?
so, what you learn (if anything) does not affect what you do, either at work, or at home, or anywhere else?
I just came back into coding from a 4 week hiatus (vacation)

In that regard I just picked up how to make pygame recognize my mouse input, I was also able to find out how to pinpoint where my mouse is at any given time and create outputs based on where I perform certain actions with the mouse.

It's a very minor thing but it helps me move forward, I have a small little project I want to make now and I'm very motivated Big Grin
can your mouse go offscreen? if it can, do you get an offscreen position? is there a way for the code to change the mouse position.

years ago a friend of mine made a program that took over the mouse and window manager so that every time you click on a window it would move them around so that nothing was under the mouse. if he was around today i'd suggest he do it for the mouse hovering over a window, too.
(Jul-19-2022, 12:25 AM)Skaperen Wrote: [ -> ]can your mouse go offscreen? if it can, do you get an offscreen position? is there a way for the code to change the mouse position.

years ago a friend of mine made a program that took over the mouse and window manager so that every time you click on a window it would move them around so that nothing was under the mouse. if he was around today i'd suggest he do it for the mouse hovering over a window, too.

There is probably a way, but I do not know how. I'm only using it to move a crosshair to a target that I want to eliminate (I'm making a minigame)

There is however a suprsingly huge amount of decent examples out and about, so if one wanted to, they could probably make it in no time.
(Jul-20-2022, 10:47 PM)Jan_97 Wrote: [ -> ]There is probably a way, but I do not know how. I'm only using it to move a crosshair to a target that I want to eliminate (I'm making a minigame)
sounds like something i should put in my text editor for python mode.
Today I learned that Linux has the two commands 'true' and 'false'. They are part of GNU coreutils:
  • /usr/bin/true does nothing, successfully.
  • /usr/bin/false does nothing, unsuccessfully
One can add ignored command line arguments.

I need it because some file extensions trigger "share with skype" by default and I don't want that and I don't know how to get rid of it, so I updated a configuration file to replace 'skype' by '/usr/bin/true'.
After receiving error messages like "Image has no attribute open",
I could not figure out why a simple img = Image.open(x.jpg), refused to do it's job.
Especially since it worked the previous 1_000 times.
from PIL import Image
After a while it was revealed that it was a "circular" problem.
tkinter also has an "Image" keyword and it competes for attention with the Image
from pillow.
The solution is to import it this way:
import PIL.Image
Happy. Cool
Paul
A nice way to get the number of days, for any given number of hours, without using any dependences.

This could be extended to weeks for days, months for weeks, and so on.

day   =  24 # number of hours in a day
hours = 172 # number of given hours
days, hrs = hours//day, hours%day
print("{} Days, {} hrs".format(days, hrs))

# output = 7 Days, 4 hrs
(Sep-01-2022, 06:54 AM)rob101 Wrote: [ -> ]days, hrs = hours//day, hours%day
A shorter way
days, hrs = divmod(hours, day)
Pages: 1 2