예제 #1
0
    def _init_toolbar(self):
        self.basedir = os.path.join(matplotlib.rcParams[ 'datapath' ],'images')

        for text, tooltip_text, image_file, callback in self.toolitems:
            if text is None:
                self.addSeparator()
            else:
                a = self.addAction(self._icon(image_file + '.png'),
                                         text, getattr(self, callback))
                self._actions[callback] = a
                if callback in ['zoom', 'pan']:
                    a.setCheckable(True)
                if tooltip_text is not None:
                    a.setToolTip(tooltip_text)

        # Add the x,y location widget at the right side of the toolbar
        # The stretch factor is 1 which means any resizing of the toolbar
        # will resize this label instead of the buttons.
        if self.coordinates:
            self.locLabel = QtWidgets.QLabel( "", self )
            self.locLabel.setAlignment(
                    QtCore.Qt.AlignRight | QtCore.Qt.AlignTop )
            self.locLabel.setSizePolicy(
                QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                  QtWidgets.QSizePolicy.Ignored))
            labelAction = self.addWidget(self.locLabel)
            labelAction.setVisible(True)
예제 #2
0
    def __init__(self, title, parent=None):
        super(TextBoxes, self).__init__(title, parent)

        # at least one text box
        self.boxes = []
        self.boxes.append(QtWidgets.QLabel())
        self.vbox = QtWidgets.QVBoxLayout()
        self.vbox.setSpacing(0)
        for box in self.boxes:
            self.vbox.addWidget(box)
        self.setLayout(self.vbox)
예제 #3
0
    def generateNewNodeListWindow(self):
        # the New Node window
        self._list_win = QtWidgets.QWidget()
        self._list_win.setFixedWidth(500)
        self._new_node_list = QtWidgets.QListWidget(self._list_win)

        self._create_button = QtWidgets.QPushButton("Create Node", self._list_win)
        self._create_button.setDisabled(True)
        self._create_button.clicked.connect(self._createNewNode)
        button_layout = QtWidgets.QHBoxLayout()
        button_layout.addStretch(1)
        button_layout.addWidget(self._create_button)

        self._new_node_list.itemDoubleClicked.connect(self._listItemDoubleClicked)
        self._new_node_list.itemClicked.connect(self._listItemClicked)

        self._list_label = QtWidgets.QLabel("GPI Libraries", self._list_win)

        node_name_layout = QtWidgets.QHBoxLayout()
        new_node_name_label = QtWidgets.QLabel("Name:", self._list_win)
        self._new_node_name_field = QtWidgets.QLineEdit(self._list_win)
        self._new_node_name_field.setPlaceholderText("NewNodeName_GPI.py")
        self._new_node_name_field.textChanged.connect(self._newNodeNameEdited)
        node_name_layout.addWidget(new_node_name_label)
        node_name_layout.addWidget(self._new_node_name_field)

        new_node_path_label = QtWidgets.QLabel("Path:", self._list_win)
        self._new_node_path = ''
        self._new_node_path_field = QtWidgets.QLabel(NOPATH_MESSAGE, self._list_win)
        self._new_node_path_field.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed))
        path_layout = QtWidgets.QHBoxLayout()
        path_layout.addWidget(new_node_path_label)
        path_layout.addWidget(self._new_node_path_field)

        list_layout = QtWidgets.QVBoxLayout()
        list_layout.addWidget(self._list_label)
        list_layout.addWidget(self._new_node_list)
        list_layout.addLayout(node_name_layout)
        list_layout.addLayout(path_layout)
        list_layout.addLayout(button_layout)
        self._list_win.setLayout(list_layout)
예제 #4
0
    def set_length(self, length):
        # add specified number of text boxes
        while length > len(self.boxes):
            newbox = QtWidgets.QLabel()
            self.boxes.append(newbox)
            self.vbox.addWidget(newbox)
        while length < len(self.boxes):
            oldbox = self.boxes.pop()
            oldbox.setParent(None)

        if length != len(self.boxes):
            log.critical("StringBoxes: length not properly set!")
예제 #5
0
파일: edge.py 프로젝트: schudds/framework
    def __init__(self, graph, destPort, sourcePort):
        super(EdgeTracer, self).__init__()

        # show a faux copy of the delete menu
        menu = QtWidgets.QMenu()
        menu.addAction("Delete")

        # position of pipe end based on port type
        bindout_y = 5
        bindin_y = -1
        p1 = self.mapFromItem(sourcePort, 3.5, bindin_y)
        p2 = self.mapFromItem(destPort, 3.5, bindout_y)

        pos = graph.mapToGlobal(graph.mapFromScene((p1 - p2) / 2 + p2))

        # render the menu without executing it
        try:
            # PyQt4
            menupixmap = QtGui.QPixmap().grabWidget(menu)
        except AttributeError:
            menupixmap = menu.grab()  # QtGui.QPixmap().grabWidget(menu)

        # round edges
        #mask = menupixmap.createMaskFromColor(QtGui.QColor(255, 255, 255), QtCore.Qt.MaskOutColor)
        #p = QtGui.QPainter(menupixmap)
        #p.setRenderHint(QtGui.QPainter.Antialiasing)
        #p.drawRoundedRect(0,0,menupixmap.width(),menupixmap.height(), 5,5)
        #p.drawPixmap(menupixmap.rect(), mask, mask.rect())
        #p.end()

        # display the menu image (as a dummy menu as its being built)
        # TODO: this could probably be moved to the FauxMenu
        self._tracer = QtWidgets.QLabel()
        self._tracer.setWindowFlags(QtCore.Qt.Tool
                                    | QtCore.Qt.FramelessWindowHint)
        self._tracer.move(pos)
        self._tracer.setPixmap(menupixmap)
        self._tracer.show()
        self._tracer.raise_()

        # draw a faux selected line
        line = QtCore.QLineF(p1, p2)
        self.setPen(
            QtGui.QPen(QtGui.QColor(QtCore.Qt.red), 2, QtCore.Qt.DashLine,
                       QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
        self.setLine(line)
        self.setZValue(0)

        # cleanup both menu item and line by removing from scene (parent).
        self._timer = QtCore.QTimer()
        self._timer.singleShot(300, lambda: graph.scene().removeItem(self))
예제 #6
0
    def __init__(self, title, parent=None):
        super().__init__(title, parent)

        self._val = {}
        self._val['size'] = 1
        self._val['width'] = 1

        self.sb = gpi.BasicSpinBox()  # size
        self.sb.set_label('size:')
        self.sb.set_min(1)
        self.sb.set_val(1)
        self.sb.set_max(gpi.GPI_INT_MAX)

        self.slb = gpi.BasicSlider()  # width
        self.slb.set_min(1)
        self.slb.set_val(1)
        self.slb.set_max(1)

        self.slider_label = QtWidgets.QLabel('width:')

        self.sb.valueChanged.connect(self.sizeChange)
        self.slb.valueChanged.connect(self.widthChange)

        hbox = QtWidgets.QHBoxLayout()
        hbox.addWidget(self.slider_label)
        hbox.addWidget(self.slb)
        hbox.setStretch(0, 0)
        hbox.setSpacing(5)

        hboxGroup = QtWidgets.QHBoxLayout()
        hboxGroup.addWidget(self.sb)
        hboxGroup.addLayout(hbox)
        hboxGroup.setStretch(0, 0)
        hboxGroup.setContentsMargins(0, 0, 0, 0)  # we don't need margins here
        hboxGroup.setSpacing(30)
        self.setLayout(hboxGroup)
예제 #7
0
    def __init__(self, title, parent=None):
        super().__init__(title, parent)

        # gpi interface
        self._collapsables = []
        self._subplotSettings = {}
        #self._subplotPosition = {'right': 0.9, 'bottom': 0.12, 'top': 0.9, 'wspace': 0.2, 'hspace': 0.2, 'left': 0.125}
        self._subplotPosition = {'right': 0.913, 'bottom': 0.119, 'top': 0.912, 'wspace': 0.2, 'hspace': 0.2, 'left': 0.111}
        #self._subplot_keepers = ['yscale', 'xscale'] # linear, log
        self._subplot_keepers = []
        self._lineSettings = []
        self._line_keepers = ['linewidth', 'linestyle', 'label', 'marker', 'markeredgecolor', 'markerfacecolor', 'markersize', 'color', 'alpha']

        # since drawing is slow, don't do it as often, use the timer as a
        # debouncer
        self._on_draw_cnt = 0
        self._updatetimer = QtCore.QTimer()
        self._updatetimer.setSingleShot(True)
        self._updatetimer.timeout.connect(self._on_draw)
        self._updatetimer.setInterval(10)

        # plot specific UI side panel
        #  -sets options for plot window so this needs to be run first
        vbox = QtWidgets.QVBoxLayout()
        vbox.setContentsMargins(0, 0, 0, 0)  # no spaces around this item
        vbox.setSpacing(0)

        # AUTOSCALE
        self._autoscale_btn = gpi.widgets.BasicPushButton(self)
        self._autoscale_btn.set_toggle(True)
        self._autoscale_btn.set_button_title('autoscale')
        self._autoscale_btn.valueChanged.connect(self.on_draw)
        self._collapsables.append(self._autoscale_btn)

        # GRID
        self._grid_btn = gpi.widgets.BasicPushButton(self)
        self._grid_btn.set_toggle(True)
        self._grid_btn.set_button_title('grid')
        self._grid_btn.valueChanged.connect(self.on_draw)
        self._collapsables.append(self._grid_btn)

        # X/Y LIMITS
        lims = QtWidgets.QGridLayout()
        self._xl = gpi.widgets.BasicDoubleSpinBox(self)
        self._xh = gpi.widgets.BasicDoubleSpinBox(self)
        self._yl = gpi.widgets.BasicDoubleSpinBox(self)
        self._yh = gpi.widgets.BasicDoubleSpinBox(self)
        self._xl.valueChanged.connect(self.on_draw)
        self._xh.valueChanged.connect(self.on_draw)
        self._yl.valueChanged.connect(self.on_draw)
        self._yh.valueChanged.connect(self.on_draw)
        self._xl.set_immediate(True)
        self._xh.set_immediate(True)
        self._yl.set_immediate(True)
        self._yh.set_immediate(True)
        self._xl.set_label('max')
        self._xh.set_label('min')
        self._xl.set_decimals(7)
        self._xh.set_decimals(7)
        self._yl.set_decimals(7)
        self._yh.set_decimals(7)
        self._xlab = QtWidgets.QLabel('x limits')
        self._ylab = QtWidgets.QLabel('y limits')
        #self._maxlab = QtWidgets.QLabel('max')
        #self._minlab = QtWidgets.QLabel('min')
        #lims.addWidget(self._maxlab,1,0,1,1)
        #lims.addWidget(self._minlab,2,0,1,1)
        lims.addWidget(self._xlab,0,1,1,1,alignment=QtCore.Qt.AlignHCenter)
        lims.addWidget(self._xh,1,1,1,1,alignment=QtCore.Qt.AlignHCenter)
        lims.addWidget(self._xl,2,1,1,1,alignment=QtCore.Qt.AlignHCenter)
        lims.addWidget(self._ylab,0,2,1,1,alignment=QtCore.Qt.AlignHCenter)
        lims.addWidget(self._yh,1,2,1,1,alignment=QtCore.Qt.AlignHCenter)
        lims.addWidget(self._yl,2,2,1,1,alignment=QtCore.Qt.AlignHCenter)
        self._collapsables.append(self._xlab)
        self._collapsables.append(self._ylab)
        self._collapsables.append(self._xl)
        self._collapsables.append(self._xh)
        self._collapsables.append(self._yl)
        self._collapsables.append(self._yh)
        #self._collapsables.append(self._minlab)
        #self._collapsables.append(self._maxlab)

        # TICK MARKS
        ticks = QtWidgets.QGridLayout()
        self._x_numticks = gpi.widgets.BasicSpinBox(self)
        self._x_numticks.valueChanged.connect(self.on_draw)
        self._y_numticks = gpi.widgets.BasicSpinBox(self)
        self._y_numticks.valueChanged.connect(self.on_draw)
        self._x_ticks = QtWidgets.QLineEdit()
        self._y_ticks = QtWidgets.QLineEdit()
        self._x_ticks.textChanged.connect(lambda txt: self.check_validticks(self._x_ticks))
        self._y_ticks.textChanged.connect(lambda txt: self.check_validticks(self._y_ticks))
        self._x_ticks.setPlaceholderText('comma separated list of x labels')
        self._y_ticks.setPlaceholderText('comma separated list of y labels')
        self._x_ticks.returnPressed.connect(self.on_draw)
        self._y_ticks.returnPressed.connect(self.on_draw)
        self._x_numticks.set_immediate(True)
        self._y_numticks.set_immediate(True)
        self._x_numticks.set_min(2)
        self._y_numticks.set_min(2)
        self._x_numticks.set_max(100)
        self._y_numticks.set_max(100)
        self._x_numticks.set_val(5)
        self._y_numticks.set_val(5)
        self._x_numticks.set_label('x ticks')
        self._y_numticks.set_label('y ticks')
        ticks.addWidget(self._x_numticks, 0,0,1,1)
        ticks.addWidget(self._y_numticks, 1,0,1,1)
        ticks.addWidget(self._x_ticks, 0,1,1,1)
        ticks.addWidget(self._y_ticks, 1,1,1,1)
        self._collapsables.append(self._x_numticks)
        self._collapsables.append(self._y_numticks)
        self._collapsables.append(self._x_ticks)
        self._collapsables.append(self._y_ticks)

        # TITLE, XLABEL, YLABEL
        plotlabels = QtWidgets.QHBoxLayout()
        self._plot_title = QtWidgets.QLineEdit()
        self._plot_xlab = QtWidgets.QLineEdit()
        self._plot_ylab = QtWidgets.QLineEdit()
        self._plot_title.setPlaceholderText('title')
        self._plot_xlab.setPlaceholderText('x label')
        self._plot_ylab.setPlaceholderText('y label')
        self._plot_title.returnPressed.connect(self.on_draw)
        self._plot_xlab.returnPressed.connect(self.on_draw)
        self._plot_ylab.returnPressed.connect(self.on_draw)
        plotlabels.addWidget(self._plot_title)
        plotlabels.addWidget(self._plot_xlab)
        plotlabels.addWidget(self._plot_ylab)
        self._collapsables.append(self._plot_title)
        self._collapsables.append(self._plot_xlab)
        self._collapsables.append(self._plot_ylab)

        # XSCALE, YSCALE
        self._xscale_btn = gpi.widgets.BasicPushButton(self)
        self._xscale_btn.set_toggle(True)
        self._xscale_btn.set_button_title('log(x)')
        self._xscale_btn.valueChanged.connect(self.on_draw)
        self._collapsables.append(self._xscale_btn)
        self._yscale_btn = gpi.widgets.BasicPushButton(self)
        self._yscale_btn.set_toggle(True)
        self._yscale_btn.set_button_title('log(y)')
        self._yscale_btn.valueChanged.connect(self.on_draw)
        self._collapsables.append(self._yscale_btn)

        scale_options_layout = QtWidgets.QHBoxLayout()
        scale_options_layout.addWidget(self._xscale_btn)
        scale_options_layout.addWidget(self._yscale_btn)

        # LEGEND
        self._legend_btn = gpi.widgets.BasicPushButton(self)
        self._legend_btn.set_toggle(True)
        self._legend_btn.set_button_title('legend')
        self._legend_btn.valueChanged.connect(self.on_draw)
        self._collapsables.append(self._legend_btn)

        # HOLD
        self._hold_btn = gpi.widgets.BasicPushButton(self)
        self._hold_btn.set_toggle(True)
        self._hold_btn.set_button_title('hold')
        #self._hold_btn.valueChanged.connect(self.on_draw)
        self._collapsables.append(self._hold_btn)

        # MOVE AXES TO ORIGIN
        # self._origin_axes_btn = gpi.widgets.BasicPushButton(self)
        # self._origin_axes_btn.set_toggle(True)
        # self._origin_axes_btn.set_button_title("axes at (0,0)")
        # self._collapsables.append(self._origin_axes_btn)

        # RESET
        self._reset_btn = gpi.widgets.BasicPushButton(self)
        self._reset_btn.set_toggle(False)
        self._reset_btn.set_button_title('reset')
        self._reset_btn.valueChanged.connect(self._init_parms_)
        self._collapsables.append(self._reset_btn)

        # X=0, Y=0
        self._xeq0_btn = gpi.widgets.BasicPushButton(self)
        self._xeq0_btn.set_toggle(True)
        self._xeq0_btn.set_button_title('x=0')
        self._xeq0_btn.set_val(True)
        self._xeq0_btn.valueChanged.connect(self.on_draw)
        self._collapsables.append(self._xeq0_btn)
        self._yeq0_btn = gpi.widgets.BasicPushButton(self)
        self._yeq0_btn.set_toggle(True)
        self._yeq0_btn.set_button_title('y=0')
        self._yeq0_btn.set_val(True)
        self._yeq0_btn.valueChanged.connect(self.on_draw)
        self._collapsables.append(self._yeq0_btn)

        # LINE OPTIONS
        self._lino_btn = gpi.widgets.BasicPushButton(self)
        self._lino_btn.set_toggle(False)
        self._lino_btn.set_button_title('line options')
        self._lino_btn.valueChanged.connect(self.lineOptionsDialog)
        self._collapsables.append(self._lino_btn)

        # SUBPLOT SPACING OPTIONS
        self._subplotso_btn = gpi.widgets.BasicPushButton(self)
        self._subplotso_btn.set_toggle(False)
        self._subplotso_btn.set_button_title('spacing options')
        self._subplotso_btn.valueChanged.connect(self.subplotSpacingOptions)
        self._collapsables.append(self._subplotso_btn)
        self.adj_window = None

        plot_options_layout = QtWidgets.QHBoxLayout()
        plot_options_layout.addWidget(self._subplotso_btn)
        plot_options_layout.addWidget(self._lino_btn)

        grid_legend_lyt = QtWidgets.QHBoxLayout()
        grid_legend_lyt.addWidget(self._legend_btn)
        grid_legend_lyt.addWidget(self._grid_btn)

        autoscale_scale_lyt = QtWidgets.QHBoxLayout()
        autoscale_scale_lyt.addWidget(self._autoscale_btn)
        autoscale_scale_lyt.addWidget(self._xscale_btn)
        autoscale_scale_lyt.addWidget(self._yscale_btn)
        autoscale_scale_lyt.addWidget(self._xeq0_btn)
        autoscale_scale_lyt.addWidget(self._yeq0_btn)

        # HLINES
        self._hline1 = QtWidgets.QFrame()
        self._hline1.setFrameStyle(QtWidgets.QFrame.HLine | QtWidgets.QFrame.Sunken)
        self._hline1.setSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
        self._collapsables.append(self._hline1)

        self._hline2 = QtWidgets.QFrame()
        self._hline2.setFrameStyle(QtWidgets.QFrame.HLine | QtWidgets.QFrame.Sunken)
        self._hline2.setSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
        self._collapsables.append(self._hline2)

        self._hline3 = QtWidgets.QFrame()
        self._hline3.setFrameStyle(QtWidgets.QFrame.HLine | QtWidgets.QFrame.Sunken)
        self._hline3.setSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
        self._collapsables.append(self._hline3)

        spc = 10
        self._spacer1 = QtWidgets.QSpacerItem(1,spc,QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        self._spacer2 = QtWidgets.QSpacerItem(1,spc,QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        self._spacer3 = QtWidgets.QSpacerItem(1,spc,QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        self._spacer4 = QtWidgets.QSpacerItem(1,spc,QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        self._spacer5 = QtWidgets.QSpacerItem(1,spc,QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        self._spacer6 = QtWidgets.QSpacerItem(1,spc,QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        self._collapsables.append(self._spacer1)
        self._collapsables.append(self._spacer2)
        self._collapsables.append(self._spacer3)
        self._collapsables.append(self._spacer4)
        self._collapsables.append(self._spacer5)
        self._collapsables.append(self._spacer6)

        # panel layout
        vbox.addLayout(plotlabels)

        vbox.addSpacerItem(self._spacer1)
        vbox.addWidget(self._hline1)
        vbox.addSpacerItem(self._spacer2)

        vbox.addLayout(lims)
        #vbox.addLayout(scale_options_layout)
        #vbox.addWidget(self._autoscale_btn)
        vbox.addLayout(autoscale_scale_lyt)

        vbox.addSpacerItem(self._spacer3)
        vbox.addWidget(self._hline2)
        vbox.addSpacerItem(self._spacer4)

        vbox.addLayout(ticks)
        #vbox.addWidget(self._legend_btn)
        vbox.addLayout(grid_legend_lyt)
        vbox.addLayout(plot_options_layout)
        #vbox.addWidget(self._lino_btn)
        #vbox.addWidget(self._subplotso_btn)

        vbox.addSpacerItem(self._spacer5)
        vbox.addWidget(self._hline3)
        vbox.addSpacerItem(self._spacer6)

        vbox.addWidget(self._hold_btn)
        # vbox.addWidget(self._origin_axes_btn)

        vbox.insertStretch(-1,1)
        vbox.addWidget(self._reset_btn)

        # plot window
        self._data = None
        self._plotwindow = self.create_main_frame()

        # put side panel and plot window together
        hbox = QtWidgets.QHBoxLayout()
        hbox.addLayout(vbox)
        hbox.addLayout(self._plotwindow)
        hbox.setStretch(0,0)
        hbox.setStretch(1,11)
        self.setLayout(hbox)

        #self._on_draw() # draw once to get initial settings
        #self.copySubplotSettings()

        # Don't hide side-panel options by default
        self.set_collapsed(False)
        self.set_grid(True)
        self.set_autoscale(True)

        # DEFAULTS
        self._init_parms_()
예제 #8
0
    def __init__(self, image_path):

        # find the limiting desktop dimension (w or h)
        pm = QtGui.QPixmap.fromImage(QtGui.QImage(image_path))
        g = QtWidgets.QDesktopWidget().availableGeometry()
        w = g.width()
        h = g.height()
        r = float(pm.width()) / pm.height()  # aspect ratio
        if (w <= pm.width()):
            h = int(w / r)
        if (h <= pm.height()):
            w = int(h * r)

        # the splash is almost useless below 500pts
        if w < 500:
            w = 500

        # resize the image based on new width
        if (w != g.width()) or (h != g.height()):
            pm = pm.scaledToWidth(int(w * 0.8),
                                  mode=QtCore.Qt.SmoothTransformation)

        # scale subsequent parameters based on new image width
        iw = pm.width()
        ih = pm.height()

        super(Splash, self).__init__(pm)

        # use a timer instead of the EULA
        self._timer = QtCore.QTimer()
        self._timer.timeout.connect(self.terms_accepted.emit)
        self._timer.setSingleShot(True)
        if not INCLUDE_EULA:
            self._timer.start(2000)

        panel = QtWidgets.QWidget()
        pal = QtGui.QPalette(QtGui.QColor(255, 255, 255))  # white
        panel.setAutoFillBackground(True)
        panel.setPalette(pal)

        lic = '''
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        '''
        self.lic = QtWidgets.QTextEdit(lic)
        self.lic.setReadOnly(True)

        button_title = 'Agree'
        self.wdg1 = QtWidgets.QPushButton(button_title, self)
        self.wdg1.setCheckable(False)
        self.wdg1.setFixedSize(int(iw * 0.2), int(iw * 0.05))
        self.wdg1.clicked[bool].connect(self.accept)

        button_title = 'Quit'
        self.wdg2 = QtWidgets.QPushButton(button_title, self)
        self.wdg2.setCheckable(False)
        self.wdg2.setFixedSize(int(iw * 0.2), int(iw * 0.05))
        self.wdg2.clicked[bool].connect(self.reject)

        buf = 'Click Agree to start GPI or Quit to exit.'
        new_fw = iw * 0.45
        for fw_i in range(20, 0, -1):
            f = QtGui.QFont('gill sans', fw_i)
            fm = QtGui.QFontMetricsF(f)
            cfw = fm.width(buf)
            if cfw < new_fw:
                break
        f = QtGui.QFont('gill sans', fw_i)

        self.prompt = QtWidgets.QLabel(buf)
        self.prompt.setAlignment(QtCore.Qt.AlignCenter)
        self.prompt.setFont(f)

        wdgLayout = QtWidgets.QHBoxLayout()
        #wdgLayout.setContentsMargins(0, 0, 0, 0)  # no spaces around this item
        #wdgLayout.setSpacing(0)
        #wdgLayout.addSpacerItem(QtWidgets.QSpacerItem(iw/2,1,hPolicy=QtWidgets.QSizePolicy.Minimum))
        wdgLayout.addWidget(self.prompt)
        wdgLayout.addWidget(self.wdg1)
        #wdgLayout.addSpacerItem(QtWidgets.QSpacerItem(int(iw*0.01),1,hPolicy=QtWidgets.QSizePolicy.Minimum))
        wdgLayout.addWidget(self.wdg2)
        #wdgLayout.addSpacerItem(QtWidgets.QSpacerItem(1,1,hPolicy=QtWidgets.QSizePolicy.MinimumExpanding))

        # a small panel
        vbox_p = QtWidgets.QVBoxLayout()
        vbox_p.setContentsMargins(10, 10, 10, 10)
        vbox_p.setSpacing(10)
        vbox_p.addWidget(self.lic)
        vbox_p.addLayout(wdgLayout)
        panel.setLayout(vbox_p)

        # white space | panel
        vbox = QtWidgets.QVBoxLayout()
        #vbox.setContentsMargins(0, 0, 0, int(iw*0.02))  # no spaces around this item
        vbox.setContentsMargins(0, 0, 0, 0)  # no spaces around this item
        vbox.setSpacing(0)

        vbox.addSpacerItem(
            QtWidgets.QSpacerItem(iw, (1 - 0.28) * ih,
                                  hPolicy=QtWidgets.QSizePolicy.Minimum,
                                  vPolicy=QtWidgets.QSizePolicy.Minimum))

        #vbox.addWidget(self.lic)
        vbox.addWidget(panel)
        #vbox.addLayout(wdgLayout)

        if INCLUDE_EULA:
            self.setLayout(vbox)

        self._accept = False
예제 #9
0
    def __init__(self, node):
        super(NodeAPI, self).__init__()

        #self.setToolTip("Double Click to Show/Hide each Widget")
        self.node = node

        self.label = ''
        self._detailLabel = ''
        self._docText = None
        self.parmList = []  # deprecated, since dicts have direct name lookup
        self.parmDict = {}  # mirror parmList for now
        self.parmSettings = {}  # for buffering wdg parms before copying to a PROCESS
        self.shdmDict = {} # for storing base addresses

        # grid for module widgets
        self.layout = QtWidgets.QGridLayout()

        # this must exist before user-widgets are added so that they can get
        # node label updates
        self.wdglabel = QtWidgets.QLineEdit(self.label)

        # allow logger to be used in initUI()
        self.log = manager.getLogger(node.getModuleName())

        try:
            self._initUI_ret = self.initUI()
        except:
            log.error('initUI() failed. '+str(node.item.fullpath)+'\n'+str(traceback.format_exc()))
            self._initUI_ret = -1  # error

        # make a label box with the unique id
        labelGroup = HidableGroupBox("Node Label")
        labelLayout = QtWidgets.QGridLayout()
        self.wdglabel.textChanged.connect(self.setLabel)
        labelLayout.addWidget(self.wdglabel, 0, 1)
        labelGroup.setLayout(labelLayout)
        self.layout.addWidget(labelGroup, len(self.parmList) + 1, 0)
        labelGroup.set_collapsed(True)
        labelGroup.setToolTip("Displays the Label on the Canvas (Double Click)")

        # make an about box with the unique id
        self.aboutGroup = HidableGroupBox("About")
        aboutLayout = QtWidgets.QGridLayout()
        self.about_button = QtWidgets.QPushButton("Open Node &Documentation")
        self.about_button.clicked.connect(self.openNodeDocumentation)
        aboutLayout.addWidget(self.about_button, 0, 1)
        self.aboutGroup.setLayout(aboutLayout)
        self.layout.addWidget(self.aboutGroup, len(self.parmList) + 2, 0)
        self.aboutGroup.set_collapsed(True)
        self.aboutGroup.setToolTip("Node Documentation (docstring + autodocs, Double Click)")

        # window (just a QTextEdit) that will show documentation text
        self.doc_text_win = QtWidgets.QTextEdit()
        self.doc_text_win.setPlainText(self.generateHelpText())
        self.doc_text_win.setReadOnly(True)
        doc_text_font = QtGui.QFont("Monospace", 14)
        self.doc_text_win.setFont(doc_text_font)
        self.doc_text_win.setLineWrapMode(QtWidgets.QTextEdit.NoWrap)
        self.doc_text_win.setWindowTitle(node.getModuleName() + " Documentation")

        hbox = QtWidgets.QHBoxLayout()
        self._statusbar_sys = QtWidgets.QLabel('')
        self._statusbar_usr = QtWidgets.QLabel('')
        hbox.addWidget(self._statusbar_sys)
        hbox.addWidget(self._statusbar_usr, 0, (QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter))

        # window resize grip
        self._grip = QtWidgets.QSizeGrip(self)
        hbox.addWidget(self._grip)

        self.layout.addLayout(hbox, len(self.parmList) + 3, 0)
        self.layout.setRowStretch(len(self.parmList) + 3, 0)

        # uid display
        # uid   = QtWidgets.QLabel("uid: "+str(self.node.getID()))
        # uid.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)
        # self.layout.addWidget(uid,len(self.parmList)+2,0)

        # instantiate the layout
        self.setLayout(self.layout)

        # run through all widget titles since each widget parent is now set.
        for parm in self.parmList:
            parm.setDispTitle()

        # instantiate the layout
        # self.setGeometry(50, 50, 300, 40)

        self.setTitle(node.getModuleName())

        self._starttime = 0
        self._startline = 0
예제 #10
0
    def __init__(self):
        super(MainCanvas, self).__init__()

        # useful for tracking number of file handles
        #self._report = QtCore.QTimer()
        #self._report.setInterval(1000)
        #self._report.timeout.connect(Specs.numOpenFiles)
        #self._report.start()

        # Flag for avoiding double call to closeEvent in PyQt5
        # https://bugreports.qt.io/browse/QTBUG-43344
        self.already_closed = False

        # A statusbar widget
        self._statusLabel = QtWidgets.QLabel()

        # for copying between canvases
        self._copybuffer = None

        # TAB WIDGET
        self.tabs = QtWidgets.QTabWidget()
        self.tabs.setTabsClosable(True)
        self.tabs.setTabPosition(QtWidgets.QTabWidget.North)
        self.tabs.tabCloseRequested.connect(self.closeCanvasTab)
        self.tabs.currentChanged.connect(self.tabChange)
        self.tabs.setMovable(True)
        self.setCentralWidget(self.tabs)
        self.tabs.show()

        # ADD TAB BUTTON
        self.addbutton = QtWidgets.QPushButton('+')
        self.addbutton.clicked[bool].connect(self.addNewCanvasTab)
        self.tabs.setCornerWidget(self.addbutton)

        # ADD CANVAS TABS
        self._canvasCnt = 1
        newGraph = GraphWidget("Canvas 1", self)
        newGraph._curState.connect(self.updateCanvasStatus)
        self.tabs.addTab(newGraph, "Canvas 1")

        # possible names for this project
        if (time.localtime().tm_mon == 4) and (time.localtime().tm_mday == 1):
            titleList = []
            titleList += ['Master Control Processor (MCP)']
            titleList += ['Code Flow GPI']
            titleList += ['Code Shepherd']
            titleList += ['Source Flow']
            titleList += ['Algorithm Processing Network (APN)']
            titleList += ['Visual Algorithm Processor (VAP)']
            titleList += ['Data-Analysing Robot Youth Lifeform (D.A.R.Y.L.)']
            titleList += [
                'Heuristically-programmed ALgorithmic computer (H.A.L.)'
            ]
            titleList += ['Johnny Five']
            titleList += ['Visual Programming Paradigm (Vpp)']
            titleList += ['Graphical Prototyping Platform (Gpp)']
            titleList += ['Node Commander (GPI)']
            titleList += ['Algorithm Dominator (GPI)']
            titleList += ['ProtoWizard (GPI)']
            titleList += ['Algorithm Maestro (GPI)']
            titleList += ['Node Guru (GPI)']
            titleList += ['Process Master (GPI)']
            titleList += ['Prototype Expert (GPI)']
            titleList += ['Algorithm Assemblage (GPI)']
            titleList += ['High Performance Algorithm Collider (GPI)']
            titleList += ['Cluster Flow (GPI)']
            titleList += ['Mothra (GPI)']
            titleList += ['Assimilator (GPI)']
            titleList += ['Algorithm Integrator (GPI)']
            titleList += ['Method Mapper (GPI)']
            titleList += ['Method Master (GPI)']
            titleList += ['Vfunc (Visual Functor)']

            from random import choice
            self.setWindowTitle(choice(titleList))

        else:
            self.setWindowTitle('Graphical Programming Interface (GPI)')

        # system tray icon (this actually works in Ubuntu)
        from .defines import ICON_PATH
        self._gpiIcon = QtGui.QIcon(ICON_PATH)
        self.setWindowIcon(self._gpiIcon)
        #self._trayicon = QtWidgets.QSystemTrayIcon(self._gpiIcon, parent=self)
        #self._trayicon.show()

        # don't bother with the menus if the gui is not up
        if not Commands.noGUI():
            self.createMenus()

            best_style = None
            qt_styles = list(QtWidgets.QStyleFactory.keys())
            if Specs.inWindows() and 'Windows' in qt_styles:
                log.debug("Choosing Windows style.")
                best_style = 'Windows'
            elif Specs.inOSX() and 'Macintosh (aqua)' in qt_styles:
                log.debug("Choosing Mac aqua style.")
                best_style = 'Macintosh (aqua)'
            elif 'Cleanlooks' in qt_styles:
                log.debug("Choosing Cleanlooks style.")
                best_style = 'Cleanlooks'

            # if 'Macintosh (aqua)' in list(QtGui.QStyleFactory.keys()):
            #     log.debug("Choosing Mac aqua style.")
            #     best_style = 'Macintosh (aqua)'
            # elif 'Cleanlooks' in list(QtGui.QStyleFactory.keys()):
            #     log.debug("Choosing Cleanlooks style.")
            #     best_style = 'Cleanlooks'

            if best_style:
                QtWidgets.QApplication.setStyle(
                    QtWidgets.QStyleFactory.create(best_style))
                QtWidgets.QApplication.setPalette(
                    QtWidgets.QApplication.style().standardPalette())

            # Status Bar
            message = "A context menu is available by right-clicking"
            self.statusBar().addPermanentWidget(self._statusLabel)
            self.statusBar().showMessage(message)

            self.updateCanvasStatus()