Making a window open on top of another window in python - 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?

Related

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?

Hide console window of python .py on windows

I found this answers on Stackoverflow but nothing works for me
How to hide console window in python?
Hiding the console window
Hide console window with Tkinter and cx_Freeze
I'm trying to hide console window, on windows at least. But with solutions above still I have window open
The only difference maybe I have to mark, I run python application with process from C# application, but as I understand it can't be a reason of some key different if I write all directives from the python code. Now I'm not sure how to figure out
You need to use the pythonw.exe program as it won't open a terminal when ran.

A new text-mode window in Python

I've used Tkinter or wxWidgets for some projects: this opens a new window in graphical mode (GUI) in which you can do what you want.
Can I ask Python to open a new text-mode window (let's say 80x25 terminal), independant from the terminal where I run myscript.py,
in the same way that a Tkinter window is independant from the current terminal where I run myscript.py?
What do I want to achieve? Having a GUI, but in textmode! (this might sound tricky because G in GUI means graphical!)
Does tkInter, wxWidget, pyglet, etc. have a feature to open a text-mode terminal-look GUI? With 80x25 text display?
For this you will need to make a seperate script but it works.
Use this code in your launcher script.
from sys import executable
from subprocess import Popen, CREATE_NEW_CONSOLE
Popen([executable, 'myscript.py'], creationflags=CREATE_NEW_CONSOLE)
input('Enter to exit from this launcher script...')
Source

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