Пример #1
0
    def __init__(self, parent: QWidget=None) -> None:
        super(MainWindow, self).__init__(parent)
        uic.loadUi(os.path.join(getResourcesPath(), 'ui', 'mainwindow.ui'),
                   self)
        self.actionExit.triggered.connect(QApplication.quit)
        self.actionLoad_G_Code.triggered.connect(self.askGCodeFile)
        self.actionPrint.triggered.connect(self.actionPrintSlot)
        self.actionClear.triggered.connect(self.actionClearSlot)
        self.actionZoomIn.triggered.connect(self.zoomIn)
        self.actionZoomOut.triggered.connect(self.zoomOut)
        self.actionResetZoom.triggered.connect(self.resetZoom)
        self.actionSetPenWidth.triggered.connect(self.askPenWidth)
        self.actionShowMovement.toggled.connect(self.actionShowMovementSlot)
        self.checkBoxActionShowMovement = QCheckBox(
            self.actionShowMovement.text(), self.toolBar)
        self.checkBoxActionShowMovement.setChecked(True)
        # noinspection PyUnresolvedReferences
        self.checkBoxActionShowMovement.toggled.connect(
            self.actionShowMovementSlot)
        self.toolBar.insertWidget(self.actionSetMoveLineColor,
                                  self.checkBoxActionShowMovement)
        self.actionSetMoveLineColor.triggered.connect(
            self.actionSetMoveLineColorSlot)

        self.zoomFactor = 1
        self._precision = 1
        self._moveLineColor = Qt.green
        self.material = None
        self.scene = QGraphicsScene()
        self.graphicsView.setScene(self.scene)
        self.graphicsView.scale(1, -1)
        self.graphicsView.setBackgroundBrush(QBrush(Qt.lightGray))
        self.clearScene()
        self.updateStatusBar()
Пример #2
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        uic.loadUi(os.path.join(getResourcesPath(), 'ui', 'mainwindow.ui'),
                   self)
        self.actionLoadPicture.triggered.connect(self.loadFile)
        self.actionShuffle.triggered.connect(self.shuffle)
        self.actionExit.triggered.connect(QCoreApplication.instance().quit)
        self.labels = self.findChildren(Tile)
        # counter for how many moves have been done.
        self.moves = 0
        # counter for how many seconds have passed.
        self.time = 0
        # thread which will update the label of passed time.
        self.timer = None
        # initial position of the labels is their perfect position.
        for label in self.labels:
            label.perfectPos = label.pos()
            label.moved.connect(self.successfulMove)

        # translation stuff.
        self.labelMovesHeader.setText(self.tr("Moves"))
        self.labelTimeHeader.setText(self.tr("Time"))
        self.menuFile.setTitle(self.tr("File"))
        self.actionLoadPicture.setText(self.tr("Load picture"))
        self.actionExit.setText(self.tr("Exit"))
        self.actionShuffle.setText(self.tr("Shuffle"))
Пример #3
0
def main(argv=None):
    if not argv:
        argv = sys.argv

    app = QApplication(argv)

    translator = QTranslator()
    translator.load("qt_" + QLocale.system().name(), os.path.join(
        getResourcesPath(), "translations"))
    app.installTranslator(translator)

    myTranslator = QTranslator()
    myTranslator.load("Tiles_" + QLocale.system().name(), os.path.join(
        getResourcesPath(), "translations"))
    app.installTranslator(myTranslator)

    window = MainWindow()
    window.show()
    return app.exec_()
Пример #4
0
 def askGCodeFile(self) -> None:
     # noinspection PyCallByClass, PyTypeChecker
     filetuple = QFileDialog.getOpenFileName(self,
                                             'Select G Code file',
                                             getResourcesPath(),
                                             'G Code files (*.gcode);;'
                                             'Text files (*.txt);;'
                                             'All Files (*.*)')
     if filetuple:
         if os.path.isfile(filetuple[0]):
             self.loadGCode(filetuple[0])
Пример #5
0
    def __init__(self, sshServer, sshUser, sshPassword, parent=None):
        super(MainWindow, self).__init__(parent)
        uic.loadUi(os.path.join(getResourcesPath(), 'ui', 'mainwindow.ui'),
                   self)

        self.ssh = paramiko.SSHClient()
        self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        self.ssh.connect(sshServer, username=sshUser, password=sshPassword)
        if self.isServerPlaying():
            self.pushButtonPlaypause.setIcon(self.pushButtonPlaypause.style().standardIcon(QStyle.SP_MediaPause))
            self.isPlaying = True
        else:
            self.pushButtonPlaypause.setIcon(self.pushButtonPlaypause.style().standardIcon(QStyle.SP_MediaPlay))
            self.isPlaying = False
        self.pushButtonPlaypause.clicked.connect(self.playpause)
Пример #6
0
 def __init__(self, parent=None):
     super(MainWindow, self).__init__(parent)
     uic.loadUi(os.path.join(getResourcesPath(), 'ui', 'mainwindow.ui'),
                self)
Пример #7
0
    def __init__(self, HNItem, parent=None):
        super().__init__(parent)
        self.listWidget = self.parent()
        self.stackedWidget = self.listWidget.parent()
        self.mainWindow = self.stackedWidget.parent().parent()
        uic.loadUi(os.path.join(getResourcesPath(), 'ui', 'storywidget.ui'),
                   self)
        self.pos = HNItem['pos']
        self.kids = HNItem['kids'] if 'kids' in HNItem else []
        self.commentsTree = CommentTree()
        self.commentsTree.setVerticalScrollMode(
            QAbstractItemView.ScrollPerPixel)
        self.commentsTree.setSelectionMode(QAbstractItemView.NoSelection)
        self.commentsTree.setAttribute(Qt.WA_MacShowFocusRect, 0)
        self.commentsTree.header().hide()
        self.fetchedComment.connect(self.addComment)

        # format position
        self.labelPosition.setText('%2d. ' % self.pos)
        self.labelPosition.setStyleSheet(
            'QLabel { font-size : 12pt; color: gray}')

        # format title
        self.labelTitle.setText('%s ' % HNItem['title'])
        self.labelTitle.setStyleSheet('QLabel { font-size : 12pt; }')
        self.labelTitle.underlineTextOnHover = False
        self.labelTitle.clicked.connect(self.openURL)

        # format url
        try:
            # if story has a source url
            self.labelTitle.url = HNItem['url']

            # format url nicely (eg http://www.google.com/ -> google.com)
            netloc = urlparse(self.labelTitle.url).netloc
            if netloc.startswith('www.'):
                netloc = netloc[4:]
            self.labelURL.setText('(%s)' % netloc)
            self.labelURL.setStyleSheet(
                'QLabel { font-size: 11pt; color : gray; }')
        except KeyError as e:
            # story doesn't have a source url. Don't display labelURL.
            # story is a job.
            # TODO: infer URL of job...
            self.labelTitle.url = ""
            self.labelURL.setVisible(False)
            self.labelComments.setVisible(False)

        # format subtitle and comments (if existing)
        if HNItem['type'] == 'job':
            self.labelSubtitle.setText(format_time(HNItem['time']))
        else:
            self.labelSubtitle.setText('%d points by %s %s | ' %
                                       (HNItem['score'],
                                        HNItem['by'],
                                        format_time(HNItem['time'])))
            self.labelComments.commentCount = HNItem['descendants']
            self.labelComments.setNormalText()
        self.labelSubtitle.setStyleSheet(
            'QLabel { font-size : 9pt; color: gray }')
        self.labelComments.setStyleSheet(
            'QLabel { font-size : 9pt; color: gray }')
        self.labelComments.clicked.connect(self.openComments)
Пример #8
0
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import os
import math

from utilities import getResourcesPath
from utilities.types import number

gcodeDir = os.path.join(getResourcesPath(), 'gcode')
steps = []


def move(x: number, y: number) -> None:
    steps.append('G0 X%f Y%f' % (x, y))


def cut(x: number, y: number) -> None:
    steps.append('G1 X%f Y%f' % (x, y))


def comment(cmt: str) -> None:
    steps.append('; ' + cmt)

Пример #9
0
 def __init__(self, parent=None):
     super(LoginWindow, self).__init__(parent)
     uic.loadUi(os.path.join(getResourcesPath(), 'ui', 'loginwindow.ui'),
                self)
     self.pushButtonConnect.clicked.connect(self.connect)