def about(self): # Display image = QtGui.QImage(LOGO_PATH) dispbox = DisplayBox('') dispbox.set_pixmap(QtGui.QPixmap.fromImage(image)) dispbox.set_scale(0.157) dispbox.set_interp(True) # Text tab = ' ' txt = '<center><font size=4><b>Graphical Programming Interface (GPI)</b></font><br><b><a href=http://gpilab.com>gpilab.com</a></b><br><br>' +\ 'Nicholas Zwart<br>Barrow Neurological Institute<br>Phoenix, Arizona' +\ '<br><br>' +\ tab + 'Release: '+ str(VERSION) + ' (' + str(RELEASE_DATE) +')' +\ '<p>'+\ 'GPI is a graphical development environment designed for rapid prototyping '+\ 'of numeric algorithms.'+\ '</p>'+\ '<p>'+\ 'GPI development is sponsored by Philips Healthcare.'+\ '</p></center>' txtbox = TextBox('') txtbox.set_val(txt) txtbox.set_wordwrap(True) txtbox.set_openExternalLinks(True) # set layout wdgvbox = QtGui.QVBoxLayout() wdgvbox.addWidget(dispbox) wdgvbox.addWidget(txtbox) wdgvbox.setStretch(0, 2) # set master widget self.aboutWdg = QtGui.QWidget() self.aboutWdg.setLayout(wdgvbox) # self.aboutWdg.setSizePolicy(QtGui.QSizePolicy.Minimum, \ # QtGui.QSizePolicy.Preferred) # self.aboutWdg.setMaximumWidth(420) self.aboutWdg.show() self.aboutWdg.raise_() log.debug(str(dispbox.sizeHint()))
def generateNewNodeListWindow(self): # the New Node window self._list_win = QtGui.QWidget() self._list_win.setFixedWidth(500) self._new_node_list = QtGui.QListWidget(self._list_win) self._create_button = QtGui.QPushButton("Create Node", self._list_win) self._create_button.setDisabled(True) self._create_button.clicked.connect(self._createNewNode) button_layout = QtGui.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 = QtGui.QLabel("GPI Libraries", self._list_win) node_name_layout = QtGui.QHBoxLayout() new_node_name_label = QtGui.QLabel("Name:", self._list_win) self._new_node_name_field = QtGui.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 = QtGui.QLabel("Path:", self._list_win) self._new_node_path = '' self._new_node_path_field = QtGui.QLabel(NOPATH_MESSAGE, self._list_win) self._new_node_path_field.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)) path_layout = QtGui.QHBoxLayout() path_layout.addWidget(new_node_path_label) path_layout.addWidget(self._new_node_path_field) list_layout = QtGui.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)
def console(self): log.debug("MainCanvas(): console()") self.txtbox = TextEdit('Console') # Redirect stdio sys.stdout = Tee(sys.stdout) sys.stderr = Tee(sys.stderr) # NOTE: this is only good for QThread NOT Multiprocess. sys.stdout.newStreamTxt.connect(self.consoleWrite) sys.stderr.newStreamTxt.connect(self.consoleWrite) # set layout wdgvbox = QtGui.QVBoxLayout() wdgvbox.addWidget(self.txtbox) # set master widget self.consoleWdg = QtGui.QWidget() self.consoleWdg.setLayout(wdgvbox) self.consoleWdg.show() self.consoleWdg.raise_()
def __init__(self, image_path): # find the limiting desktop dimension (w or h) pm = QtGui.QPixmap.fromImage(QtGui.QImage(image_path)) g = QtGui.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 = QtGui.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 = QtGui.QTextEdit(lic) self.lic.setReadOnly(True) button_title = 'Agree' self.wdg1 = QtGui.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 = QtGui.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 = QtGui.QLabel(buf) self.prompt.setAlignment(QtCore.Qt.AlignCenter) self.prompt.setFont(f) wdgLayout = QtGui.QHBoxLayout() #wdgLayout.setContentsMargins(0, 0, 0, 0) # no spaces around this item #wdgLayout.setSpacing(0) #wdgLayout.addSpacerItem(QtGui.QSpacerItem(iw/2,1,hPolicy=QtGui.QSizePolicy.Minimum)) wdgLayout.addWidget(self.prompt) wdgLayout.addWidget(self.wdg1) #wdgLayout.addSpacerItem(QtGui.QSpacerItem(int(iw*0.01),1,hPolicy=QtGui.QSizePolicy.Minimum)) wdgLayout.addWidget(self.wdg2) #wdgLayout.addSpacerItem(QtGui.QSpacerItem(1,1,hPolicy=QtGui.QSizePolicy.MinimumExpanding)) # a small panel vbox_p = QtGui.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 = QtGui.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( QtGui.QSpacerItem(iw, (1 - 0.28) * ih, hPolicy=QtGui.QSizePolicy.Minimum, vPolicy=QtGui.QSizePolicy.Minimum)) #vbox.addWidget(self.lic) vbox.addWidget(panel) #vbox.addLayout(wdgLayout) if INCLUDE_EULA: self.setLayout(vbox) self._accept = False