import inspect from qtpy.QtCore import QObject, Signal from qtpyvcp.utilities.logger import getLogger LOG = getLogger(__name__) def isDataChan(obj): return isinstance(obj, DataChannel) class DataPlugin(QObject): """DataPlugin.""" def __init__(self): super(DataPlugin, self).__init__() self.channels = {name: obj for name, obj in inspect.getmembers(self, isDataChan)} def getChannel(self, url): """Get data channel from URL. Args: url (str) : The URL of the channel to get. Returns: tuple : (chan_obj, chan_exp) """ chan, sep, query = url.partition('?')
# 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/>. from collections import OrderedDict from qtpy.QtCore import Qt from qtpy.QtWidgets import QComboBox, QDialog, QHBoxLayout, QLabel, \ QDoubleSpinBox, QPushButton, QVBoxLayout from qtpyvcp.utilities.info import Info from qtpyvcp.utilities import logger from qtpyvcp.actions.machine_actions import issue_mdi Log = logger.getLogger(__name__) class OffsetsDialog(QDialog): def __init__(self, parent=None): super(OffsetsDialog, self).__init__(parent=parent) self.info = Info() self.log = Log axis_list = self.info.getAxisList() self.axis_combo = QComboBox() for axis in axis_list: self.axis_combo.addItem(axis.upper(), axis)
#!/usr/bin/env python import os from qtpy.QtCore import Slot, QRegExp from qtpy.QtGui import QFontDatabase, QRegExpValidator from qtpy.QtWidgets import QAbstractButton from qtpyvcp import actions from qtpyvcp.utilities import logger from qtpyvcp.widgets.form_widgets.main_window import VCPMainWindow import probe_basic_rc LOG = logger.getLogger('QtPyVCP.' + __name__) VCP_DIR = os.path.abspath(os.path.dirname(__file__)) # Add custom fonts QFontDatabase.addApplicationFont(os.path.join(VCP_DIR, 'fonts/BebasKai.ttf')) class ProbeBasic(VCPMainWindow): """Main window class for the ProbeBasic VCP.""" def __init__(self, *args, **kwargs): super(ProbeBasic, self).__init__(*args, **kwargs) self.run_from_line_Num.setValidator(QRegExpValidator( QRegExp("[0-9]*"))) self.btnMdiBksp.clicked.connect(self.mdiBackSpace_clicked) self.btnMdiSpace.clicked.connect(self.mdiSpace_clicked) @Slot(QAbstractButton)
from qtpyvcp.widgets.form_widgets.main_window import VCPMainWindow # Setup logging from qtpyvcp.utilities import logger LOG = logger.getLogger('qtpyvcp.' + __name__) from qtpy import QtGui import resources_rc import qtpyvcp.actions.machine_actions as actions class MyMainWindow(VCPMainWindow): """Main window class for the VCP.""" def __init__(self, *args, **kwargs): super(MyMainWindow, self).__init__(*args, **kwargs) #self.UiComponents() #actions.jog.set_linear_speed(1) # add any custom methods here def UiComponents(self): #self.playButton.setIcon(QtGui.QIcon('play.svg')) pass
import os import ast import ConfigParser from qtpyvcp.utilities.logger import getLogger log = getLogger(__name__) class RuntimeConfig(object): def __init__(self, fname='~/.qtpyvcprc'): self.fname = fname self._cp = ConfigParser.RawConfigParser() self._cp.optionxform = str self.require_write = False self.getters = { bool: self.getBool, float: self.getFloat, int: self.getInt, list: self.getList, dict: self.getDict, str: self.getStr, } def read(self, fname=None): self.fname = os.path.abspath(os.path.expanduser(fname or self.fname)) self._cp.read(self.fname) return self def write(self, fname=None):
import os import sys import hiyapyco from jinja2.nativetypes import NativeEnvironment from jinja2 import Environment, FileSystemLoader, Undefined, make_logging_undefined from qtpyvcp.utilities.logger import getLogger, logLevelFromName LOG = getLogger(__name__) hiyapyco_logger = getLogger('qtpyvcp.config_loader.hiyapyco') hiyapyco_logger.setLevel(os.getenv('HIYAPYCO_LOG_LEVEL', 'ERROR')) hiyapyco.logger = hiyapyco_logger LogUndefined = make_logging_undefined(logger=LOG, base=Undefined) def load_config_files(*files): """Load and merge YAML config files. Files that come earlier in the list take precedence over files that come later in the list. Args: *files (list) : Variable number of file paths. Example:: load_config_files(file1, file2, file3, ...): """
def log(self): if self._log is None: self._log = getLogger(self.__module__) return self._log return self._log