Close console when closing tkinter window - python

If have a tkinter gui for managing pypresence commands.
Github
Problem
When I press the close button of the window the window closes, but the console stays open.
I tried other stuff, with py2exe but then sometimes the task stays, and you have do kill it manually.
But not to forget, i want that the console is there, but it should exit when i press exit in the tkinter window

Related

In Python Tkinter, I have successfully made a keybind but it only works when I am clicked into the tkinter window.

In Python Tkinter, I have successfully made a keybind but it only
works when I am clicked into the tkinter window.
I want to be able to use the keybinds even when I am interacting with other programs even when they are full screen. (I am making an auto clicker and it is not possible to open the tkinter window and then click the key when you are mid game.)
You cannot do what you want with tkinter. Tkinter bindings only work within windows created by tkinter.

Terminate Python Shell (IDLE) programmatically

I am using IDLE (Python 3.6 64-bit). Currently, I am using Tkinter to create a GUI. I have a button in my code that is supposed to terminate the program. As of now, it only closes out the "tk" root window (using root.destroy()). I want it to also close out the shell and go back to where I can edit the code (i.e. back to my IDLE). How can I do this?
When you run code from an IDLE editor window, any existing program run from IDLE is terminated. Unless your code somehow grabs control of the mouse, you should always be able to click on any editor window or its taskbar icon (on Windows) and start editing some more. Example: run the following from an IDLE editor.
import tkinter as tk
root = tk.Tk()
#root.destroy()
A tk window is dispayed. Click on the editor window, remove the '#', and run again. The first tk window disappears and a >>> prompt appears in the Shell window.
A python program run from IDLE, cannot* close its parent IDLE, anymore than a python program run in a console can close the parent console.
I am excluding things like, on *nix, getting the parent process number and issuing a 'kill ' command.

Python - How to make Tkinter window shows in the screen where terminal is currently in?

I have a python script mainly running on MacOS terminal. At certain point it will shows a Tkinter window for user to select something. My problem is that If I put the terminal window in a secondary screen (external monitor) and run the script, the Tkinter window always shows up in the primary screen (builtin monitor).
Is there a way to force the Tkinter window shows in the screen where the terminal is in?

Making a window open on top of another window in python

I'm using the subprocess library to call a program which would open a new window. The only problem is that this window opens below my terminal, which is a bit of a nuisance.
Is there any way to have the window open above my current window?

Tkinter opens console window with window

I am a complete newbie at Python. Meanwhile, I'm working with Tkinter to integrate a GUI into my application using Python 2.7. This is the code so far:
import Tkinter
top = Tkinter.Tk()
top.mainloop()
However, when I execute the file, a console window and the GUI pops up. How do I get rid of the console window during startup?
Rename your Python script as .pyw (not .pyc). This will tell the invoker to to instantiate a console window. Source
Note however, this will work for non-GUI based scripts too which can cause undesireqable behaviour - such as not being able to see your script.

Categories

Resources