forked from Zolko-123/FreeCAD_Assembly4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HelpCmd.py
119 lines (88 loc) · 3.31 KB
/
HelpCmd.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
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
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/env python3
# coding: utf-8
#
# HelpCmd.py
import os
from PySide import QtGui, QtCore
import FreeCADGui as Gui
import FreeCAD as App
import libAsm4 as Asm4
"""
+-----------------------------------------------+
| main class |
+-----------------------------------------------+
"""
class Asm4Help( QtGui.QDialog ):
"My tool object"
def __init__(self):
super(Asm4Help,self).__init__()
self.drawUI()
def GetResources(self):
return {"MenuText": "Help for Assembly4",
"ToolTip": "Show basic usage for FreeCAD and Assembly4",
"Pixmap" : os.path.join( Asm4.iconPath , 'Asm4_Help.svg')
}
def IsActive(self):
# is there an active document ?
if App.ActiveDocument:
return True
return False
def Activated(self):
# Now we can draw the UI
self.show()
"""
+-----------------------------------------------+
| OK |
+-----------------------------------------------+
"""
def onOK(self):
self.close()
"""
+-----------------------------------------------+
| defines the UI, only static elements |
+-----------------------------------------------+
"""
def drawUI(self):
# Our main window will be a QDialog
self.setWindowTitle('Help for FreeCAD and Assembly4')
self.setWindowIcon( QtGui.QIcon( os.path.join( Asm4.iconPath , 'FreeCad.svg' ) ) )
self.setWindowFlags( QtCore.Qt.WindowStaysOnTopHint )
self.setMinimumSize(600, 600)
self.setModal(False)
# set main window widgets layout
self.mainLayout = QtGui.QVBoxLayout(self)
# FreeCAD version info
FCmajor = App.ConfigGet('ExeVersion')
FCminor = App.ConfigGet('BuildRevision')
FCversion = FCmajor+'-'+FCminor
self.mainLayout.addWidget(QtGui.QLabel('FreeCAD version : \t'+FCversion))
# Assembly4 version info
versionPath = os.path.join( Asm4.wbPath, 'VERSION' )
versionFile = open(versionPath,"r")
Asm4version = versionFile.readlines()[1]
versionFile.close()
self.mainLayout.addWidget(QtGui.QLabel('Assembly4 version : \t'+Asm4version))
# Help text
self.helpSource = QtGui.QTextBrowser(self)
self.helpSource.setSearchPaths( [os.path.join( Asm4.wbPath, 'Resources' )] )
self.helpSource.setSource( 'Asm4_Help.html' )
self.mainLayout.addWidget(self.helpSource)
self.mainLayout.addWidget(QtGui.QLabel(' '))
# the button row definition
self.buttonLayout = QtGui.QHBoxLayout(self)
self.buttonLayout.addStretch()
# OK button
self.OkButton = QtGui.QPushButton('OK', self)
self.OkButton.setDefault(True)
self.buttonLayout.addWidget(self.OkButton)
self.mainLayout.addLayout(self.buttonLayout)
# finally, apply the layout to the main window
self.setLayout(self.mainLayout)
# Actions
self.OkButton.clicked.connect(self.onOK)
"""
+-----------------------------------------------+
| add the command to the workbench |
+-----------------------------------------------+
"""
Gui.addCommand( 'Asm4_Help', Asm4Help() )