Do something?
This commit is contained in:
parent
3ee3c5ae08
commit
561d7de3fa
31
main.py
Normal file → Executable file
31
main.py
Normal file → Executable file
@ -8,5 +8,36 @@
|
|||||||
# Distributed under terms of the MIT license.
|
# Distributed under terms of the MIT license.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
import PyQt5.QtGui as qtg
|
||||||
|
import PyQt5.QtWidgets as qtw
|
||||||
|
import sys
|
||||||
|
|
||||||
|
class BadWitch:
|
||||||
|
def __init__(self, Argv):
|
||||||
|
# Initialize UI
|
||||||
|
self.app = qtw.QApplication(Argv)
|
||||||
|
self.main_window = qtw.QMainWindow()
|
||||||
|
# Initialize a UI helper
|
||||||
|
self.ui = Ui_MainHelper()
|
||||||
|
# Build the application
|
||||||
|
self.ui.create_actions(self.app, self.main_window)
|
||||||
|
self.ui.create_menus(self.app, self.main_window)
|
||||||
|
self.ui.build_mainwindow(self.app, self.main_window)
|
||||||
|
def show_application(self):
|
||||||
|
self.main_window.show()
|
||||||
|
self.app.exec_()
|
||||||
|
|
||||||
|
class Ui_MainHelper:
|
||||||
|
def create_actions(self, App, MainWindow):
|
||||||
|
self.action_exit = qtw.QAction(qtg.QIcon.fromTheme("application-exit"), "Quit")
|
||||||
|
self.action_exit.triggered.connect(App.closeAllWindows)
|
||||||
|
def create_menus(self, App, MainWindow):
|
||||||
|
self.menu_file = qtw.QMenu("File")
|
||||||
|
def build_mainwindow(self, App, MainWindow):
|
||||||
|
self.menu_file.addAction(self.action_exit)
|
||||||
|
MainWindow.menuBar().addMenu(self.menu_file)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
bw = BadWitch(sys.argv)
|
||||||
|
bw.show_application()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user