Python Multi Document Interface with Pyside2

In this Python article we are going to learn about Multi Document Interface with Pyside2.

 so for this purpose we are using QMdiArea class. The QMdiArea widget

provides an area in which MDI windows are displayed. so QMdiArea  functions, essentially,

like a window manager for MDI windows. For instance, it draws the windows it manages on

itself and arranges them in a cascading or tile pattern. QMdiArea  is commonly used as the

center widget in a QMainWindow to create MDI applications, but can also be placed in any layout.

 

 

 

 

What is MDI Application ?

When we are going to develop GUI Applications, some times we need to open more than

one document at a time to process them, for this kind of functionality we are going to use

MDI approach. in  Multiple Document Interface (MDI) application the central widget

is instantiated with multiple instances. All these widgets will be interrelated within the main

window and share the common menu bar, toolbar, and other components. MDI applications

will use lesser resources compared with SDI applications. The MDI applications are provided

with an extra menu to manage between windows because shifting between them is not

controlled by the underlying operating system.

 

 

Also you can check more Python GUI Development tutorials with different libraries.

1: PyQt5 GUI Development Tutorials

2: TKinter GUI Development Tutorials

3: wxPython GUI Development Tutorials 

4: Kivy GUI Development Tutorials

 

 

 

 

So now this is the complete code for Python Multi Document Interface with Pyside2

 

 

 

 

This is for setting our window title

 

 

 

 

In here we are setting our window geometry like x,y position of the window and also

width and height of the window.

 

 

 

 

Also we want an icon for our window, make sure that you have added an icon in your

working directory.

 

 

 

 

In here we have created the object of our QMdiArea also we have set the QMdiArea

as central widget of our main window. 

 

 

 

These are our menu items.

 

 

 

Also we need to connect the triggered signal of menu items with our method that we will create.

 

 

 

 

This method is for creating of our sub windows , we are going to create our three

different types of sub windows and after that we add the sub window in the mdi area. 

 

 

 

What is QMdiSubWindow ?

The QMdiSubWindow class provides a subwindow class for QMdiArea. so QMdiSubWindow represents a top-level window in a QMdiArea , and consists of a title bar with window decorations, an internal widget, and (depending on the current style) a window frame and a size grip. QMdiSubWindow has its own layout, which consists of the title bar and a center area for the internal widget.

 

 

 

Finally, we have  entered to the main loop of the application. The event handling

starts from this point. also we have created the object of our Window and QApplication.

 

 

 

 

 

So if you run the complete code this will be the result

Python Multi Document Interface with Pyside2
Python Multi Document Interface with Pyside2

 

 

 

 

Cascade Style 

Python Multi Document Interface with Pyside2
Python Multi Document Interface with Pyside2

 

 

 

 

Tiled Style

Pyside2 MDI Windw
Pyside2 MDI Windw

 

 

 

 

 

Also you can watch the complete video tutorial for this article 

Subscribe and Get Free Video Courses & Articles in your Email

 

Codeloop
Share via
Copy link
Powered by Social Snap
×