forked from FabriceSalvaire/CodeReview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainWindowBase.py
More file actions
107 lines (77 loc) · 3.64 KB
/
MainWindowBase.py
File metadata and controls
107 lines (77 loc) · 3.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
####################################################################################################
#
# CodeReview - A Code Review GUI
# Copyright (C) 2015 Fabrice Salvaire
#
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU
# General Public License as published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with this program. If
# not, see <http://www.gnu.org/licenses/>.
#
####################################################################################################
####################################################################################################
import logging
from PyQt5 import QtWidgets, QtCore
####################################################################################################
class MainWindowBase(QtWidgets.QMainWindow):
_logger = logging.getLogger(__name__)
##############################################
def __init__(self, title='', parent=None):
super(MainWindowBase, self).__init__(parent)
self.setWindowTitle(title)
self._application = QtWidgets.QApplication.instance()
self.init_menu()
##############################################
@property
def application(self):
return self._application
@property
def menu_bar(self):
return self.menuBar()
@property
def file_menu(self):
return self._file_menu
@property
def help_menu(self):
return self._help_menu
##############################################
def init_menu(self):
application = self._application
self._file_menu = file_menu = self.menu_bar.addMenu('File')
file_menu.addAction(application.exit_action) # Fixme: At the end
self._help_menu = help_menu = self.menu_bar.addMenu('Help')
help_menu.addAction(application.help_action)
help_menu.addSeparator()
help_menu.addAction(application.about_action)
help_menu.addAction(application.show_system_information_action)
##############################################
def show_message(self, message=None, echo=False, timeout=0):
""" Hides the normal status indications and displays the given message for the specified
number of milli-seconds (timeout). If timeout is 0 (default), the message remains displayed
until the clearMessage() slot is called or until the showMessage() slot is called again to
change the message.
Note that showMessage() is called to show temporary explanations of tool tip texts, so
passing a timeout of 0 is not sufficient to display a permanent message.
"""
status_bar = self.statusBar()
if message is None:
status_bar.clearMessage()
else:
status_bar.showMessage(message, timeout)
if echo:
self._logger.info(message)
# self.application.processEvents()
##############################################
def translate(self, text):
return self._application.translate(self.__class__.__name__, text)
####################################################################################################
#
# End
#
####################################################################################################