1818import sys
1919import os
2020import json
21- from PyQt5 .QtCore import QProcess , QRegExp
21+ from PyQt5 .QtCore import QProcess , QRegExp , QFile
2222from PyQt5 import QtGui , QtWidgets , uic
2323from qtvcp .widgets .widget_baseclass import _HalWidgetBase
2424from qtvcp .core import Action , Status , Info , Path
3636SUBPROGRAM = os .path .abspath (os .path .join (current_dir , 'probe_subprog.py' ))
3737CONFIG_DIR = os .getcwd ()
3838
39+ # can use/favours local image and help files
40+ HELP = PATH .find_widget_path ()
41+
3942class BasicProbe (QtWidgets .QWidget , _HalWidgetBase ):
4043 def __init__ (self , parent = None ):
4144 super (BasicProbe , self ).__init__ (parent )
@@ -57,6 +60,10 @@ def __init__(self, parent=None):
5760 self .dialog = uic .loadUi (self .filename )
5861 except AttributeError as e :
5962 LOG .critical (e )
63+ self .helpPages = ['basic_help.html' ,'basic_help1.html' ,'basic_help2.html' ,
64+ 'basic_help3.html' ,'basic_help4.html' ,'basic_help5.html' ,
65+ 'basic_help6.html' ,'basic_help7.html' ]
66+ self .currentHelpPage = 0
6067
6168 self .probe_list = ["OUTSIDE CORNERS" , "INSIDE CORNERS" , "EDGE ANGLE" , "BOSS and POCKETS" ,
6269 "RIDGE and VALLEY" , "CALIBRATE" ]
@@ -244,32 +251,43 @@ def set_statusbar(self, msg, priority = 2):
244251# Main button handler routines
245252 def probe_help_clicked (self ):
246253 self .dialog .show ()
254+ self .update_help_page ()
247255
248256 def help_close_clicked (self ):
249257 self .dialog .hide ()
250258
251259 def help_prev_clicked (self ):
252- i = self .dialog .probe_help_widget .currentIndex ()
253- if i > 0 :
254- self .dialog .probe_help_widget .setCurrentIndex (i - 1 )
260+ self .currentHelpPage -= 1
261+ if self .currentHelpPage < 0 :
262+ self .currentHelpPage = 0
263+ self .update_help_page ()
255264
256265 def help_next_clicked (self ):
257- i = self .dialog .probe_help_widget .currentIndex ()
258- if i < 5 :
259- self .dialog .probe_help_widget .setCurrentIndex (i + 1 )
266+ self .currentHelpPage += 1
267+ if self .currentHelpPage > len (self .helpPages )- 1 :
268+ self .currentHelpPage = len (self .helpPages )- 1
269+ self .update_help_page ()
260270
261271 def cmb_probe_select_changed (self , index ):
262272 self .stackedWidget_probe_buttons .setCurrentIndex (index )
263273
264- def probe_help_prev_clicked (self ):
265- i = self .probe_help_widget .currentIndex ()
266- if i > 0 :
267- self .probe_help_widget .setCurrentIndex (i - 1 )
268-
269- def probe_help_next_clicked (self ):
270- i = self .probe_help_widget .currentIndex ()
271- if i < 5 :
272- self .probe_help_widget .setCurrentIndex (i + 1 )
274+ def update_help_page (self ):
275+
276+ try :
277+ pagePath = os .path .join (HELP , self .helpPages [self .currentHelpPage ])
278+ if not os .path .exists (pagePath ): raise Exception ("Missing File: {}" .format (pagePath ))
279+ file = QFile (pagePath )
280+ file .open (QFile .ReadOnly )
281+ html = file .readAll ()
282+ html = str (html , encoding = 'utf8' )
283+ html = html .replace ("../images/widgets/" ,"{}/widgets/" .format (INFO .IMAGE_PATH ))
284+ self .dialog .html_textEdit .setHtml (html )
285+ except Exception as e :
286+ print (e )
287+ self .dialog .html_textEdit .setHtml ('''
288+ <h1 style=" margin-top:18px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:xx-large; font-weight:600;">Basic Probe Help not available</span> </h1>
289+ {}
290+ ''' .format (e ))
273291
274292 def probe_btn_clicked (self , button ):
275293 cmd = button .property ('probe' )
0 commit comments