Closing a file and come back to an especific window - python

I developed a GUI, which cointain 3 windows, to display some tutorials. It's working but when I open a file(tutorial) and finish reading it, I would like to close it and come back to the second Window, however the GUI returns to the first one. How can I fix it?
This is the sequence:
First Window
Second Window
Opened Tutorial
First Window

Related

Python script to close a specific window when it opens

I am searching for a way to close a specific window of a program immediately after it opens. Specifically, I am using the BUFF addon for Overwolf and after every game I play, this annoying overlay window opens up and blocks part of my screen. To close it windows Alt+Tab'ing out, I need to wait 10 seconds (that means if I'm not willing to subscribe to BUFF premium), and Alt+Tab'ing out after every game is just as annoying.
Is there any way that I can run a Python script while I'm playing that closes this window every time it opens immediately? I'm thinking of something that continously searches for a window with a specific name or maybe something that listens for the event of a window opening and then checking its name/title. I don't even know if Python can access these processes, but I guess it's worth to just ask.
And before I need to edit the post, I'm using Windows 11.

Make Python code open in a simple window on Windows

I wrote some simple Python code which prints out a few lines of text every minute. I want to keep it open on my desktop, kind of like a live ticker. Is there a way to open the code in a new window which doesn't have a blinking cursor and takes up as little space as possible?

Windows - finding the window in focus and handling focus change events

I write a python program that should run when a certain window is open and in focus.
For this, I need 2 things:
I need to know how to find which window has focus currently.
I need to know if there is a focus change event.
Tried using win32api and win32gui with no success.
How can I do it?
Example to clerify - say I want to write "geronimo" every time I focus notepad.
I run the program (notepad closed, nothing happens)
I open notepad (it should write geronimo)
I change focus to chrome (nothing happens)
I change focus back to notepad (writes geronimo again)
This script tracks the focus of windows, it can be changed to suit the need.
https://gist.github.com/keturn/6695625

Selenium::Python::Pop Up Window

I am trying to automate some basic web browser manipulation. As part of this sequence there is a popup window that must be dealt with. Once the python code the causes the popup window to appear happens, no other code past that point will run until I manually close that window. Then all remaining code runs fine.
I've try this below to try to deal with handling the popup but to no avail:
for handle in browser.window_handles:
print "Handle = ",handle
browswer.switch_to_window(handle);
elem=browser.find_element_by_tag_name("title")
print elem.get_attrbitue("value")
I cannot even get a basic 'print' command to execute until I close the popup window. Is there a need to set some type of event handler BEFORE the code is called that brings the popup menu?
Thanks for any suggestions.

tkinter: Help fixing photo image error created when same window opened twice

I think I've pretty much narrowed down the problem, so I'll put it out here:
I made a change to the program I am working on. The change makes a certain tkinter window reopen when an error occurs. This was done by moving it to a function, and having the script call the function if it needed to. This solved users having to restart the program.
All the windows in my program have an icon that is called and implemented in every window using the following lines:
Thumbnail = PhotoImage(file = "C:\\Users\\Owatch\\Pictures\\NetSendClient\\files\\GIF\\TK_ICON.gif")
Window.tk.call("wm","iconphoto",Window._w, Thumbnail)
This works fine for every single window across the program. However, it continues to generate an error when the same window is called to open a second time.
Error:
File "C:\Users\Owatch\Documents\Unisung\Produced Content\NetSendClient[0.9]\files\Program_Files\NS[9].py", line 208, in SCN
Window.tk.call("wm","iconphoto",Window._w, Thumbnail)
_tkinter.TclError: can't use "pyimage4" as iconphoto: not a photo image
I'm not sure why this error occurs the second time the window is opened. To give some more information on why it needs to be reopened. When a user presses a button inside this window, it triggers a function that calls the window to be destroyed before it is later reopened. So maybe it's because it's not being cleanly disposed of or something. I don't know. Thanks for helping!
The problem was created by a confliction between multiple windows using the same icon simultaneously.
I cannot go any more specific than that, but the issue was resolved by eliminating temporary and toplevel windows that did not destroy themselves before another opened.
I hope this can be of some assistance to other individuals. I am afraid I cannot provide any more information than this.

Categories

Resources