in Education by
I am trying to use qt creator and python to generate flowcharts with values. I want to save the generated flowchart as an image after, but I cannot figure out how to do it. Here is my attempt: import sys from PyQt5 import QtWidgets, uic from PyQt5.QtGui import * from mainwindow import Ui_MainWindow class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): def __init__(self, *args, obj=None, **kwargs): super(MainWindow, self).__init__(*args, **kwargs) self.setupUi(self) app = QtWidgets.QApplication(sys.argv) window = MainWindow() window.show() screen = app.primaryScreen() screenshot = screen.grabWindow(window) screen.save('screenshot.png', 'png') JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
The fact that the show method is called does not imply that it is shown instantly, but rather that this method notifies the OS so that the window is created. A possible solution is to use a QTimer, on the other hand the grabWindow method grabs a window using the associated WID, in this case it is better to use the grab method: from functools import partial def take_screenshot(widget): pixmap = widget.grab() if not pixmap.isNull(): pixmap.save("/fullpath/of/screenshot.png", "PNG") QApplication.quit() def main(): app = QtWidgets.QApplication(sys.argv) window = MainWindow() window.show() QTimer.singleShot(500, partial(take_screenshot, window)) app.exec_() if __name__ == "__main__": main()

Related questions

0 votes
    I am ploating simple linear regression plot in R and I want to save it as JPEG or PNG file, How can I do ... it is, Is it possible? Select the correct answer from above options...
asked Jan 23, 2022 in Education by JackTerrance
0 votes
    Currently I'm using Cloudinary.com to save my users images. I know how to do some of the ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    I was trying to write a quick-and-dirty script to generate plots easily. For that, I was using the following code ( ... do I do that? Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    I need to render a vector-only SVG without antialiasing in Qt; specifically, I don't want the resulting ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    Size of the entire graphic design, including all layers you should seled the state True or false 1 Windows key to ... TV LCD v CRT Select the correct answer from above options...
asked Nov 27, 2021 in Education by JackTerrance
0 votes
    a) Yukti has created a webpage. Which tag and attribute should she use to insert an image on this webpage? plz answer this also…. Select the correct answer from above options...
asked Dec 15, 2021 in Education by JackTerrance
0 votes
    I have a csv file and I am reading this file in python using pandas. I want to read each row of ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    I program with Emacs on Ubuntu (Hardy Heron at the moment), and I like the default text coloration ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 27, 2022 in Education by JackTerrance
0 votes
    Which side of the image map can be created using JavaScript? (a) Server side (b) Client side (c) ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    Whenever we get a new release of code from our vendor, we need to perform basic tests to ensure ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 11, 2022 in Education by JackTerrance
0 votes
    with the help of _____ option we can save another copy of the picture with the another file name ?a. save as b. open c. new d. exit Select the correct answer from above options...
asked Dec 12, 2021 in Education by JackTerrance
0 votes
    As it currently stands, this question is not a good fit for our Q&A format. We expect answers to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    This is a long shot but, having come across a constrain in a form of a qt's signals, slots being ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 17, 2022 in Education by JackTerrance
0 votes
    This is a long shot but, having come across a constrain in a form of a qt's signals, slots being ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    I am trying to do some validation on the file name before it's saved. Here are my three file- ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 14, 2022 in Education by JackTerrance
...