# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file ui_demo_window.ui
#
# Created by: PyQt5 UI code generator 5.8.2
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_DemoWindow(object):
def setupUi(self, DemoWindow):
DemoWindow.setObjectName("DemoWindow")
DemoWindow.resize(800, 600)
self.
centralwidget = QtWidgets.
QWidget(DemoWindow
) self.centralwidget.setObjectName("centralwidget")
DemoWindow.setCentralWidget(self.centralwidget)
self.
menubar = QtWidgets.
QMenuBar(DemoWindow
) self.
menubar.
setGeometry(QtCore.
QRect(0,
0,
800,
25)) self.menubar.setObjectName("menubar")
self.
menuFile = QtWidgets.
QMenu(self.
menubar) self.menuFile.setObjectName("menuFile")
DemoWindow.setMenuBar(self.menubar)
self.statusbar.setObjectName("statusbar")
DemoWindow.setStatusBar(self.statusbar)
self.
close_action = QtWidgets.
QAction(DemoWindow
) self.close_action.setObjectName("close_action")
self.menuFile.addAction(self.close_action)
self.menubar.addAction(self.menuFile.menuAction())
self.retranslateUi(DemoWindow)
self.close_action.triggered.connect(DemoWindow.close)
def retranslateUi(self, DemoWindow):
DemoWindow.setWindowTitle(_translate("DemoWindow", "MainWindow"))
self.menuFile.setTitle(_translate("DemoWindow", "File"))
self.close_action.setText(_translate("DemoWindow", "Close"))
self.close_action.setShortcut(_translate("DemoWindow", "Ctrl+C"))
### AND HERE'S MY CODE
import sys
from PyQt5 import QtWidgets, QtGui, QtCore
class DemoWindow
(QtWidgets.
QMainWindow, Ui_DemoWindow
): def __init__(self, parent=None):
self.setupUi(self)
if __name__ == "__main__":
#########################################
sys._excepthook = sys.excepthook
def exception_hook(exctype, value, traceback):
sys._excepthook(exctype, value, traceback)
sys.exit(1)
sys.excepthook = exception_hook
##########################################
window = DemoWindow()
window.show()
sys.exit(app.exec_())
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file ui_demo_window.ui
#
# Created by: PyQt5 UI code generator 5.8.2
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_DemoWindow(object):
def setupUi(self, DemoWindow):
DemoWindow.setObjectName("DemoWindow")
DemoWindow.resize(800, 600)
self.centralwidget = QtWidgets.QWidget(DemoWindow)
self.centralwidget.setObjectName("centralwidget")
DemoWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(DemoWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 25))
self.menubar.setObjectName("menubar")
self.menuFile = QtWidgets.QMenu(self.menubar)
self.menuFile.setObjectName("menuFile")
DemoWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(DemoWindow)
self.statusbar.setObjectName("statusbar")
DemoWindow.setStatusBar(self.statusbar)
self.close_action = QtWidgets.QAction(DemoWindow)
self.close_action.setObjectName("close_action")
self.menuFile.addAction(self.close_action)
self.menubar.addAction(self.menuFile.menuAction())
self.retranslateUi(DemoWindow)
self.close_action.triggered.connect(DemoWindow.close)
QtCore.QMetaObject.connectSlotsByName(DemoWindow)
def retranslateUi(self, DemoWindow):
_translate = QtCore.QCoreApplication.translate
DemoWindow.setWindowTitle(_translate("DemoWindow", "MainWindow"))
self.menuFile.setTitle(_translate("DemoWindow", "File"))
self.close_action.setText(_translate("DemoWindow", "Close"))
self.close_action.setShortcut(_translate("DemoWindow", "Ctrl+C"))
### AND HERE'S MY CODE
import sys
from PyQt5 import QtWidgets, QtGui, QtCore
class DemoWindow(QtWidgets.QMainWindow, Ui_DemoWindow):
def __init__(self, parent=None):
QtWidgets.QMainWindow.__init__(self, parent)
self.setupUi(self)
if __name__ == "__main__":
#########################################
sys._excepthook = sys.excepthook
def exception_hook(exctype, value, traceback):
sys._excepthook(exctype, value, traceback)
sys.exit(1)
sys.excepthook = exception_hook
##########################################
app = QtWidgets.QApplication(sys.argv)
window = DemoWindow()
window.show()
sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DemoWindow</class>
<widget class="QMainWindow" name="DemoWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget"/>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>25</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
<property name="title">
<string>File</string>
</property>
<addaction name="close_action"/>
</widget>
<addaction name="menuFile"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<action name="close_action">
<property name="text">
<string>Close</string>
</property>
<property name="shortcut">
<string>Ctrl+C</string>
</property>
</action>
</widget>
<resources/>
<connections>
<connection>
<sender>close_action</sender>
<signal>triggered()</signal>
<receiver>DemoWindow</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
<y>299</y>
</hint>
</hints>
</connection>
</connections>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DemoWindow</class>
<widget class="QMainWindow" name="DemoWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget"/>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>25</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
<property name="title">
<string>File</string>
</property>
<addaction name="close_action"/>
</widget>
<addaction name="menuFile"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<action name="close_action">
<property name="text">
<string>Close</string>
</property>
<property name="shortcut">
<string>Ctrl+C</string>
</property>
</action>
</widget>
<resources/>
<connections>
<connection>
<sender>close_action</sender>
<signal>triggered()</signal>
<receiver>DemoWindow</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
<y>299</y>
</hint>
</hints>
</connection>
</connections>
</ui>
To copy to clipboard, switch view to plain text mode
Bookmarks