Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I want to print some data from spreadsheet. I decided to use python. How can I call out a "Print preview"? For example like this:
I tried something like this:
os.startfile('test.txt', 'print')
but it doesn't make a print preview.
I am using Python 3.9.
Use this (tested on Windows 10):
import subprocess
subprocess.call(['notepad', '/p', "test.txt"])
On Linux use:
import os
os.system("lp text.txt")
As to previewing the file on screen, just use print function. If you want graphics use tkinter or any other graphics library (PyQt, etc)
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
How do I open an app like Minecraft using os or subprocess? I went through a few videos and none of them worked. Do I just use the name of the app or its location?
For this example, you could use:
subprocess.run(r'"C:\path_to_minecraft\minecraft"',shell=True)
Or if you have Windows shortcuts you add the .lnk extension in the call:
subprocess.run(r'"C:\path_to_minecraft\minecraft.lnk"',shell=True)
this works.
import os
os.system("your app.exe")
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am creating a python tkinter application which always stays on the desktop. To do this, I need to check whether any other window is maximized or not, similar to WS_MAXIMIZE in Visual Basic .NET, or GetWindowPlacement API. Is there any way to do this?
Looking forward to your replies!
You can use pip install pygetwindow to get pygetwindow
import pygetwindow as gw
notepadWindow = gw.getWindowsWithTitle('Untitled')[0]
notepadWindow.isMaximized
Here I have a notepad open and am checking if it is maximised or minimsed!
Documentation for help: https://pypi.org/project/PyGetWindow/
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
The community reviewed whether to reopen this question last year and left it closed:
Original close reason(s) were not resolved
Improve this question
I'm making Tetris game with Python in Linux, but I can't move terminal cursor to what I want to position
How can move cursor position?? in Python
This seems like a duplicate, however referring to this answer, it appears that you should be using the colorama module to make this task easier and after doing so you should be able to move your cursor around by simply using
def move (y, x):
print("\033[%d;%dH" % (y, x))
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want to create a hyperlink in my wx widget which opens linked folder on clicking. Please help me how to build that.
Thanks.
os.system("start C:")
will launch a file window (on windows at least) ... it has nothing to do with wx
unless you are talking about opening a FilePickerDialog?
I have also been informed that
os.system("explorer C:")
would also work
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Is there a way to define what window is being used in python? Such as, if I have three separate Firefox windows open, how would i get a python program to know which one I am looking at/scrolling through/clicking on/typing in? I am having a really hard time trying to find a good way of describing this so if you don't understand please tell me so i can elaborate. I cant really decide what to type into Google to solve this so anything would help. i am using Windows 7.
Here is a simple example:
import win32gui
win = win32gui
while True:
print(win.GetWindowText(win.GetActiveWindow()))
If the module is documented well enough try help(win32gui) after it is imported.