-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMenuExample.py
46 lines (31 loc) · 1 KB
/
MenuExample.py
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
"""
Created on 14 Apr 2016
@author: neil.butcher
"""
import sys
from PySide6 import QtWidgets
from pyqt_units import Measurement, menu
class MenuWidget(QtWidgets.QTableWidget):
def __init__(self, parent = None):
QtWidgets.QTableWidget.__init__(self, parent)
def contextMenuEvent(self, event):
m = menu(self)
action = m.exec_(self.mapToGlobal(event.pos()))
class MenuWindow(QtWidgets.QMainWindow):
def __init__(self,measurements):
super(MenuWindow, self).__init__()
w = MenuWidget(self)
self.setCentralWidget(w)
menubar = self.menuBar()
m = menu(self,measurements)
menubar.addMenu(m)
def main():
length_measurement = Measurement('Length')
time_measurement = Measurement('Time')
speed_measurement = Measurement('Speed')
app = QtWidgets.QApplication(sys.argv)
mainWindow = MenuWindow([length_measurement,time_measurement])
mainWindow.show()
sys.exit(app.exec_())
if __name__ == "__main__":
main()