How to change Windows resolution scaling using python - python

I'm trying to create a script that would automate a workflow with Python, I'm using PyAutoGui to find a image on screen and it locates and clicks on it.
The problem is that it will work with machines with my display settings (1920x1080, 100% scale), and will fail to locate when the scaling is changed (resolution can change, and it will work fine though). There's a good answer explaining how it works here: Running Pyautogui on a different computer with different resolution.
If the problem is with scaling, how can I programmatically do this step-by-step, that would work with any kind of display settings? I couldn't find any definitive answers so far:
Something that could do this with Python:
Start the program, get and save current scaling to variable
Change scaling to 100%
..... Code
Change scaling back to how it was and end the program

Related

VTK Render Mouse Interaction (Python)

I want to visualize one or more STL file(s) using a vtk render viewport inside my application. I was able to get it all running with this example here: https://kitware.github.io/vtk-examples/site/Python/IO/ReadSTL/
My question is as follows: I have a mouse to control it and it is just unbelievable how bad default the controls of the camera are. It is almost impossible to get the model rotated intentionally or focus on a certain part. I am confused as I could not find any topic here or elsewhere discussing this. Normally I would read through other threads to find an answer, but there doesn't seem to be any. So, maybe you can point me to an approach or even certain functions of how I can change these settings, that would be really great! Basically I want to mimic the camera behavior of say, Paraview or a common CAD tool. Like zooming with mouse wheel, rotating with RMB and holding down the wheel to pan.
Some background on my project: I have written a python program and created a quite ok UI using tkinter. However, recently I was thinking of rewriting some basic parts of it and also upgrading everything visually and in terms of handling. So, I want to move to Qt widgets and, there shall be a VTK rendering viewport inside my application to show some of the stuff that can be interacted with.
I was able to find a solution in the tutorials. By explicitly defining the vtkInteractorStyle with
style = vtk.vtkInteractorStyleTrackballCamera()
The handling is just as I wanted it to be.

Colab - Box for input() in python code too long so I need to scroll back to read the question

I plan to use colab notebooks to teach my pupils (12-13 year olds) Python. We will start with using input() and display with print() to ask simple questions and display the answer.
One problem I have come across is when I use input() in a code cell with an input string a really long input box is produced (in the output area) to get the input value. It is so long that the window scrolls to the end of this empty input box, and you have to scroll back to read the question, even when the window is at full screen width . This is really strange as the input box is completely empty does not need to to be bigger than the window or frame.
Are there settings I can change to prevent this or can I do something with the css to reduce the size of this input box?
This may seem a trivial problem, but little things like this can be distracting and add to the frustration of learning the language so I would like to prevent it if I can.
I have attached a picture that shows the problem.
picture that shows the problem.
I looked at the problem you are trying to solve. Colab fits inside my window perfectly when I size the window to full screen. I think this might be a problem with your browser. Are you using the latest version of Firefox or Chrome?
I just encountered the same problem. For me, it was because I was plotting a graph using the matplotlib.pyplot library before prompting for the input. After I removed that, it worked just fine.

wxPython - Screen resolution 3000x2000 and DPI on 200% problem

I wrote an Tool with a wxPython GUI. On Full HD and less everything runs fine. A friend of mine tested a bit with my tool and he uses a Microsoft Surface Book laptop with a screen resolution of 3000x2000 and DPI set to 200% on Windows 10.
And he has the problem that everything in my GUI is very small.
I tried to prevent that with this piece of code:
import ctypes
try:
ctypes.windll.shcore.SetProcessDpiAwareness(True)
except:
pass
But that didnt help at all. Does anybody have experience with a problem like that? What else could i try?
I think there is already a question similar to this in Stackoverflow. Anyway.
So far I think the only thing you can do is to set the app to use System (Enhanced) in the High DPI scaling override box.
It does not matter if you do not have a .exe file. You can change the properties of the resulting python app window when you run it as python myApp.py.
If the picture is not enough, there are more details in the first question here.

Kivy/Python rotates the display (test,buttons, pictures). Test programs that worked, are now rotated

I am learning Python & Kivy: (Life was a lot easier using assembly for embedded controllers).
Now the whole display is rotated 90 degrees CCW. Demo programs that used to work are now displayed rotated.
Presumably I did something that set a permanent "rotate display" flag while running Python. Where and how can I reset it? I rebooted the computer but no improvement.
Win-7 64. Python 3.4
I ran into this problem a while back when I was learning Kivy. I even left a frustrated comment on a youtube video.
There's a file at c:\users\[username]\.kivy\config.ini which you need to modify or delete.

Python Script (main) + Blender "face" animation

SO I am infact doing something very similar to this user posts:
https://stackoverflow.com/questions/6800292/python-ai-and-3d-animation
but it has no answers and I couldn't contact the user.
Basically I have a functioning python script that answers me with an action accordingly to my voice command. (Fetch emails, weather forecast, turn lights ON/OFF, etc), it has been made using the pyspeech library which is pretty darn good.
Now I want to give my programm a "face"! I thought about modelling the face with Blender (have some knowledge and would build up on it) and I know I could animate it, so the lips move and such.
So I want to know if it is at all possible to:
Load the "face" that I made from blender from my main python script (so when my programm start the face would be there on the screen too)
Run from the script the animations such that when for example when my programm says "You're welcome" I would run the animation that the lips move on the face to simulate it is speaking.
I know that blender has a good python integration (maybe correct is to say it is built on?) and that is why I thought it would be a good program to use.
Hope someone can help and tell me if that is at all possible and maybe show me some right way to go, my googling just showed me always python scripting with Blender which is not what I exactly need here... I think...
Cheers,
Flavio
Indeed, what you want is possible.
If all you want is to play pre-rendered animation videos based on decisions on your program, any GUI that allows you to embedd and play video in a widget will do for your application.
You could rool out your own GUI using Pygame (which has video support, but you will need one of the "minor" more or less "amateur" widget toolkits made for pygame to make up the remaining of your application, as pygame is pretty low level.
On a higher level, although I'had not embedded video, I think you could go with PyQT4 (googled a bit, not that many examples either, buthints that there are eamples in QT4 source) or GTK+ (the samething, it looks like there are more examples).
Another option would be to build your application to run inside the Blener Game Engine itself - It offers both a high level Toolkit, and ways to customize behaviors to user actions (even without coding).
The major drawback in doing this is: I don't know which are the options to distribute an application that needs Blender Game Engine nowadays - your users will need to install Blender (but it is likely Blender folks made an easy way to jhandle this).
On the upper hand: you get the most flexibility, it would even be possible to render some sequences in realtime (as opposed to pre-rendered videos) in your app.
One thing: Blender nowadays use Python 3.x - if the other libraries you need are Python 2, you willl need to make one different process for the GUI inside Blender, and exchange data with your application's backeend in Python 2 (for example using jsonrpc or xmlrpc - that is enoguh simple in Python).

Categories

Resources