def __init__(self, opts, vcp_file=None): super(VCPApplication, self).__init__(opts.command_line_args or []) qApp = QApplication.instance() from QtPyVCP.core import Status, Action, Prefs, Info self.info = Info() self.prefs = Prefs() self.status = Status() self.action = Action() if opts.theme is not None: self.setStyle(QStyleFactory.create(opts.theme)) if opts.stylesheet is not None: self.loadStylesheet(opts.stylesheet) self.window = self.loadVCPMainWindow(opts, vcp_file) if self.window is not None: self.window.show() # Performance monitoring if opts.perfmon: import psutil self.perf = psutil.Process() self.perf_timer = QTimer() self.perf_timer.setInterval(2000) self.perf_timer.timeout.connect(self.logPerformance) self.perf_timer.start() self.aboutToQuit.connect(self.status.onShutdown)
from QtPyVCP.widgets.form_widgets.main_window import VCPMainWindow try: import probe_basic_ui except ImportError: from QtPyVCP.tools.qcompile import compile compile(packages=[ os.path.dirname(__file__), ]) import probe_basic_ui LOG = logger.getLogger('QtPyVCP.' + __name__) STATUS = Status() ACTION = Action() PREFS = Prefs() INFO = Info() VCP_DIR = os.path.abspath(os.path.dirname(__file__)) UI_FILE = os.path.join(VCP_DIR, 'probe_basic.ui') QSS_FILE = os.path.join(VCP_DIR, 'probe_basic.qss') class ProbeBasic(VCPMainWindow): """Main window class for the ProbeBasic VCP.""" def __init__(self, *args, **kwargs): super(ProbeBasic, self).__init__(*args, **kwargs) s = time.time() app = QApplication.instance()
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with QtPyVCP. If not, see <http://www.gnu.org/licenses/>. # Description: # Generic button for calling a NGCGUI style subroutines. Useful for probing # quill-up, go home, goto etc functionality. import os import re from PyQt5.QtWidgets import QPushButton, qApp from PyQt5.QtCore import Qt, QEvent, pyqtSlot, pyqtProperty from QtPyVCP.core import Info INFO = Info() from QtPyVCP.actions.machine_actions import issue_mdi from QtPyVCP.utilities import logger LOG = logger.getLogger(__name__) # input: #<param_name> = #1 (=0.125 comment) # result: [("param_name", "1", "0.125", "comment")] # if a group is not present it will be an empty string PARSE_POSITIONAL_ARGS = re.compile( r' *# *<([a-z0-9_-]+)> *= *#([0-9]+) *(?:\(= *([0-9.+-]+[0-9.]*?|) *(.*)\))?', re.I) SUBROUTINE_PATH = INFO.getSubroutinePath()
#!/usr/bin/env python import os from PyQt5.QtWidgets import QLineEdit, QCompleter from PyQt5.QtCore import Qt, QEvent, QStringListModel from PyQt5.QtGui import QKeySequence, QValidator from QtPyVCP.core import Status, Action, Info STATUS = Status() ACTION = Action() INFO = Info() MDI_HISTORY_FILE = INFO.getMDIHistoryFile() class Validator(QValidator): def validate(self, string, pos): # eventually could do some actual validating here return QValidator.Acceptable, string.upper(), pos class MDIEntry(QLineEdit): def __init__(self, parent=None): super(MDIEntry, self).__init__(parent) self.model = QStringListModel() completer = QCompleter() completer.setCaseSensitivity(Qt.CaseInsensitive) completer.setModel(self.model) self.setCompleter(completer)