Screenshot of QtDesigner window only - python-3.x

Is it possible to get screenshot of certain window and not the entire computer screen?
My window is written with QtDesigner using main window template.The window is use to display results of calculations. How can I take a screenshot of just the one window? Is pyscreenshot able to do this?
I understand that I can do part of the screen using bbox, but if the user moves the window, it won't take the screenshot correctly.
I'm currently using pyscreenshot and it takes a screenshot of entire screen.

I've found a solution based off other posts.
Found in: Python Screenshot of inactive window PrintWindow + win32gui
To solve issue with importing modules, I downloaded pywin32 for python and use these as my imports
import win32gui
import win32ui
from ctypes import windll
from PIL import Image

Related

Adding a button to align with ttk notebook caused a geometry problem

I have found out a method to get a button to align with ttk.Notebook.
import tkinter as tk
from tkinter import ttk
root = tk.Tk()
notebook = ttk.Notebook(root)
ttk.Button(notebook).pack()
notebook.pack(fill='both', expand=1)
label = ttk.Label(notebook, text='Text', font='Arial 50')
notebook.add(label, text='Tab')
root.mainloop()
However, this caused a problem that the geometry manager only displays the button. I have to maximise the window in order to see all the contents.
In my another bigger gui, this is just a little bit of the window. I can’t see the content inside the notebook even I maximise the window.
So, how can I get it working? Thanks for any ideas!
This is due to the fact that you're calling pack on a button inside the notebook. The button is empty so it has a size of zero, and calling pack on the button causes the notebook to shrink to the size of the button.
You shouldn't ever call pack or grid on widgets that are direct children of a notebook, they should only ever be added with the add method of the notebook.
It's not clear where you want the button, but it shouldn't be a child of the notebook. If you make it a child of the root window (eg: ttk.Button(root), you can add it to the root window with pack to get it to be either above, below, or to one of the sides of the notebook.

Why does a borderless Kivy Window shift content down and to the right?

Using Kivy, I want to remove the default border from the App window (removing the close, minimize and maximize buttons). Based on the Kivy docs, I want to set the borderless value of my Window to True. However, doing so moves the content of my window down and to the right, exposing the black background color on the top and left sides of the window.
Screenshot of Window with borderless=False
Screenshot of Window with borderless=True
In the above images, the white within the window is coming from the Window.clearcolor, and the black in the borderless=True image is what I want to remove, or overlay with the rest of my content.
In the following snippet I have removed all the code that makes up the inner widgets of the kivy App, replacing them with an empty GridLayout to show where the content will be.
from kivy.app import App
from kivy.uix.gridlayout import GridLayout
from kivy.core.window import Window
class MyApp(App):
def build(self):
self.title = 'My App'
Window.clearcolor = (1, 1, 1, 1)
Window.size = (300, 430)
Window.borderless = True # This is what is being changed
return GridLayout()
if __name__ == '__main__':
MyApp().run()
I have read the answers to similar questions regarding removing the default Kivy window border and how to position a borderless Kivy window.
Can anyone help diagnose how to shift the contents of my window back to the upper left corner when borderless is set to True?
Note: This is my first Stackoverflow question, please let me know how to improve it if need be!
Well, I'm not sure what the exact issue was, but after troubleshooting several different things within PyCharm (where my original project files were held), on a whim I tried opening the same project with Sublime and the issue is no longer present. When I run the identical code in Sublime, I get the intended result:
Beautiful! Just how I wanted it. =) I'm sure I somehow goofed up the Kivy settings in Pycharm somehow without realizing it, maybe something with the builder strings? I'm honestly at a loss. But I suppose if by any off chance someone else comes across this, switch up your IDE for a clean slate and give it another go.

How to remove the balls that appear in the kivy window?

I was wondering if it is possible, I believe so, removes the balls that appear in the window of the kivy when I click on it with the right button. It seems to me that it is a pattern, and I see no use.
I think it's a simple thing to solve...
I also have another question, and not to need to post a new question, here goes.
Let's assume I made a kivy window without borders:
from kivy import Config
Config.set('graphics', 'borderless', '1')
Now my doubt. How do I move the window by dragging the mouse?
Place this code at the top of your main .py file:
from kivy.config import Config
Config.set('input', 'mouse', 'mouse,disable_multitouch')
See the documentation.
Just left-click on the ball you want to remove

Exporting Bokeh Plots

Matplotlib when you invoke the show function, it will open a small python window and show the chart. How can I make Bokeh do the same? I don't want to save a file or open a browser windows. I want to to output like matplotlib. Why? Because I want to show its graphs inside Microsoft Power BI. So it has to produce some sort of image I guess.
Bokeh's normal operation is to generate web content, i.e. HTML+JS that can drive interactive visualizations in the browser. Doing that is explicitly the main reason it was created. However, it is possible to export Bokeh plots as PNG files:
from bokeh.io import export_png
export_png(plot, filename="plot.png")
Note that this will save a file to disk, not open any sort of application window. There is nothing built into Bokeh to auto-open except Bokeh HTML output to browsers.

Python tkinter : How to change my file icon?

I don't want the python icon I want to change my icon
So,how to change my executable file icon
I tried this
from tkinter import *
import os
top=Tk()
os.file.icon('pyt.ico')
top.mainloop()
but it is showing error
Your indentation is wrong. However:
top.wm_iconbitmap('path_to_youricon.ico')

Resources