After looking for solution for a week, I ask my question here hopping you can help me.
I work on a python project, using tkinter on a raspberry pi 4. As the raspberry allows me to use two different monitor, i would like to be able to display one window per screen.
My program is very basics. It created two differents windows (window = Tk() and root = tk.Toplevel(window)). I am trying to have window displays on screen 1 and root display on screen 2.
Do you think it is possible with tkinter or an other python library ?
thanks a lot for your kind help
---Edit----
The solution was found thanks to the comments given.
I actually used tk.geomtry to solve it. For those who are interessted :
window.geometry(f'{width}x{height}+0+0') #first window on the first screen
root.geometry(f'{width}x{height}+1920+0') #second window, with +1920 on x to put it on the second screen.
That works perfectly so thank you guys
Related
Python noob here, ive started a tkinter tutorial and no matter what method I use to change the background color it stays black. Im using vs code on mac and I made sure everything is updated. Ive also tried it in pycharm and the same problem occurs. Im not getting any errors in the terminal. Here is what I have,
from tkinter import *
window = Tk()
window.geometry("500x500")
window.title("Weather.py")
window.config(bg="blue")
window.mainloop()
Any ideas?
Update:
Tried it on another mac in the house and is seemed to work on that one. Not sure why it wont work on mine.
Link provided by #Rory did the trick... Along with several restarts of both the computer and vs code.
Im on Python 3.9 on Windows 10, and im building a text editor app. Id like to have a typewriter mode where the current text stays centred on the screen and finished/written text scrolls up the screen.
I have tried googling every variation of what that could be called or how to implement it. Ive also looked through 3 or 4 different tutorials and all the docs on every parameter of every method in Tkinters widgets. Im not asking for a complete code snippet necessarily, but im stumped as to how im going to do this.
Thanks for any help received, itd be much appreciated, even a nudge in the right direction.
Chris
In raspberry pi using Python is there any way to make a program where according to the place you click on a designed screen actions can be taken and output given accordingly.
I am using the raspbian-jessie os and have a 7 inch touch screen, I want to create buttons on the screen. When I click on a button it should execute a program.
you probably put the wrong tag, there is nothing to do with functional-programming or graphics, and still little relations with whether you are in raspberry pi or something else
you mean you are in linux and got a touch screen, and want to add some indicator on your touch? what desktop are your using, or something to do with the hardware.?
please state your question clear! and don't let me guess your expection
Look into Kivy or Qt. These are the most popular GUI interfaces for Python.
I want to take a print screen of a particular window on my PC by running the python program and it taking that screen shot, before cropping it and comparing its hex value to other hex values in a SQL server.
I have thought about letting it wait 10 seconds whilst I get the other window up and then start taking the print screens continuously until one matches.
I was just wondering if I can use python to maximize that particular window that I want to print screen automatically and then have it take a print screen.
If not, could I take a print screen (a picture) of a window that is minimized? (I think this is impossible)..
Thanks!
If you do a quick Google search, you will find this helpful tutorial that uses PIL to take a screenshot of a desktop:
http://www.blendedtechnologies.com/quick-screenshots-script-python-pil/38
Assuming you're on Windows, you would need to use PyWin32 (or possibly pywinauto) to get the window you want. These two links will help with that:
Get HWND of each Window Python
http://timgolden.me.uk/python/win32_how_do_i/find-the-window-for-my-subprocess.html
Then you could use MoveWindow to resize the window you found before taking the screenshot:
How can I get the window focused on Windows and re-size it?
I'm writing a little program that basically has a bunch of buttons that when you click one, it inputs a certain line of text into an online game I play. It would be a lot easier to use if the GUI would stay on top of the active game window so the user could be playing and then press a button on the panel without having to bring it to the front first.
Any help on how to do this would be great. Thanks
EDIT: Using tkinter
You will need to provide the information on which GUI framework you are using for detailed answer at SO.
On windows you could do something like this with the handle of your window.
import win32gui
import win32con
win32gui.SetWindowPos(hWnd, win32con.HWND_TOPMOST, 0,0,0,0,
win32con.SWP_NOMOVE | win32con.SWP_NOSIZE)
Also with Tkinter, you might want to try. I have not tried it though.
root = Tk()
root.wm_attributes("-topmost", 1)