def create_main_frame(self): self.fig = Figure((6.0, 4.8), dpi=100, facecolor='0.98', linewidth=6.0, edgecolor='0.93') self.axes = None self.canvas = FigureCanvas(self.fig) self.canvas.setParent(self) self.canvas.setFocusPolicy(QtCore.Qt.StrongFocus) self.canvas.setFocus() self.canvas.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.MinimumExpanding) #self.mpl_toolbar = NavigationToolbar(self.canvas, self) self.mpl_toolbar = NavbarTools(self.canvas, self) self.mpl_toolbar.actionTriggered.connect(self.copySubplotSettings) self.canvas.mpl_connect('key_press_event', self.on_key_press) vbox = QtGui.QVBoxLayout() vbox.addWidget(self.canvas) # the matplotlib canvas vbox.addWidget(self.mpl_toolbar) return vbox
def setLayoutType(self, typ): '''The basic layout is VBox or HBox. ''' self._layoutType = typ if typ == 'vbox': self._layout = QtGui.QVBoxLayout() elif typ == 'hbox': self._layout = QtGui.QHBoxLayout()
def __init__(self, dry_run=False): super().__init__() self._updater = CondaUpdater(dry_run=dry_run) self._updater.getStatus_done.connect(self.showStatus) self._updater.getStatus_done.connect(self.showOKorUpdateButton) self._updater.failed.connect(self.initFailureMode) self._updater.updateAllPkgs_done.connect(self.relaunchProc) style = ''' QProgressBar { background-color: rgb(226,226,226); border: 1px solid rgb(222,222,222); border-radius: 2px; text-align: center; } QProgressBar::chunk { background-color: #0099FF; height: 15px; width: 1px; } ''' self._pbar = QtGui.QProgressBar(self) self._pbar.setStyleSheet(style) self._updater.pdone.connect(self.pdone) self._txtbox = TextBox('') self._txtbox.wdg.setTextFormat(QtCore.Qt.RichText) self._txtbox.set_wordwrap(True) self._txtbox.set_openExternalLinks(True) self._updater.message.connect(self._txtbox.set_val) self._txtbox.set_val('Checking for updates...') self._okButton = QtGui.QPushButton("OK") self._okButton.setVisible(False) self._cancelButton = QtGui.QPushButton("Cancel") self._cancelButton.clicked.connect(self.close) hbox = QtGui.QHBoxLayout() hbox.addStretch(1) hbox.addWidget(self._okButton) hbox.addWidget(self._cancelButton) vbox = QtGui.QVBoxLayout() vbox.addWidget(self._txtbox, 1) vbox.addWidget(self._pbar) vbox.addLayout(hbox) self.setLayout(vbox) self.setGeometry(300, 300, 400, 350) self.setWindowTitle('GPI Update') self.show() self.raise_() ExecRunnable(Runnable(self._updater.getStatus))
def create_main_frame(self): self.fig = Figure((5.0, 4.0), dpi=100) self.canvas = FigureCanvas(self.fig) self.canvas.setParent(self) self.canvas.setFocusPolicy(QtCore.Qt.StrongFocus) self.canvas.setFocus() self.mpl_toolbar = NavigationToolbar(self.canvas, self) self.canvas.mpl_connect('key_press_event', self.on_key_press) vbox = QtGui.QVBoxLayout() vbox.addWidget(self.canvas) # the matplotlib canvas vbox.addWidget(self.mpl_toolbar) self.setLayout(vbox)
def __init__(self, title, parent=None): super(WindowLevel, self).__init__(title, parent) self.sl = gpi.BasicCWFCSliders() self.sl.valueChanged.connect(self.valueChanged) self.pb = gpi.BasicPushButton() self.pb.set_button_title('reset') # layout wdgLayout = QtGui.QVBoxLayout() wdgLayout.addWidget(self.sl) wdgLayout.addWidget(self.pb) self.setLayout(wdgLayout) # default self.set_min(0) self.set_max(100) self.sl.set_allvisible(True) self.reset_sliders() self.pb.valueChanged.connect(self.reset_sliders)
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 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 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
def __init__(self, title, parent=None): super(MatplotDisplay, self).__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 = QtGui.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 = QtGui.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 = QtGui.QLabel('x limits') self._ylab = QtGui.QLabel('y limits') #self._maxlab = QtGui.QLabel('max') #self._minlab = QtGui.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 = QtGui.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 = QtGui.QLineEdit() self._y_ticks = QtGui.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 = QtGui.QHBoxLayout() self._plot_title = QtGui.QLineEdit() self._plot_xlab = QtGui.QLineEdit() self._plot_ylab = QtGui.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 = QtGui.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 = QtGui.QHBoxLayout() plot_options_layout.addWidget(self._subplotso_btn) plot_options_layout.addWidget(self._lino_btn) grid_legend_lyt = QtGui.QHBoxLayout() grid_legend_lyt.addWidget(self._legend_btn) grid_legend_lyt.addWidget(self._grid_btn) autoscale_scale_lyt = QtGui.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 = QtGui.QFrame() self._hline1.setFrameStyle(QtGui.QFrame.HLine | QtGui.QFrame.Sunken) self._hline1.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) self._collapsables.append(self._hline1) self._hline2 = QtGui.QFrame() self._hline2.setFrameStyle(QtGui.QFrame.HLine | QtGui.QFrame.Sunken) self._hline2.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) self._collapsables.append(self._hline2) self._hline3 = QtGui.QFrame() self._hline3.setFrameStyle(QtGui.QFrame.HLine | QtGui.QFrame.Sunken) self._hline3.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) self._collapsables.append(self._hline3) spc = 10 self._spacer1 = QtGui.QSpacerItem(1, spc, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) self._spacer2 = QtGui.QSpacerItem(1, spc, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) self._spacer3 = QtGui.QSpacerItem(1, spc, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) self._spacer4 = QtGui.QSpacerItem(1, spc, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) self._spacer5 = QtGui.QSpacerItem(1, spc, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) self._spacer6 = QtGui.QSpacerItem(1, spc, QtGui.QSizePolicy.Expanding, QtGui.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 = QtGui.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_()
def initLayout(self, config): '''Given the config initialize all layout objects overwriting any existing layouts. ''' self._config = config self._lwList = [] # delete layout if one exists # TODO: this needs to work if Layouts are to be re-initialized #if self.layout(): # print "delete layout before setting a new one." # for lw in self._lwList: # for c in lw.children(): # c.setParent(None) # lw.setParent(None) # self.layout().setParent(None) hbox = QtGui.QVBoxLayout(self) if config == 0: top = LayoutWindow(self._graph, 'vbox', 'top') top.setFrameShape(QtGui.QFrame.StyledPanel) hbox.addWidget(top) self._lwList.append(top) elif config == 1: top = LayoutWindow(self._graph, 'hbox', 'top') top.setFrameShape(QtGui.QFrame.StyledPanel) hbox.addWidget(top) self._lwList.append(top) elif config == 2: top = LayoutWindow(self._graph, 'hbox', 'top') top.setFrameShape(QtGui.QFrame.StyledPanel) self._lwList.append(top) mid = LayoutWindow(self._graph, 'hbox', 'mid') mid.setFrameShape(QtGui.QFrame.StyledPanel) self._lwList.append(mid) bottomleft = LayoutWindow(self._graph, 'vbox', 'bottomleft') bottomleft.setFrameShape(QtGui.QFrame.StyledPanel) self._lwList.append(bottomleft) bottommid = LayoutWindow(self._graph, 'vbox', 'bottommid') bottommid.setFrameShape(QtGui.QFrame.StyledPanel) self._lwList.append(bottommid) bottomright = LayoutWindow(self._graph, 'vbox', 'bottomright') bottomright.setFrameShape(QtGui.QFrame.StyledPanel) self._lwList.append(bottomright) splitter1 = QtGui.QSplitter(QtCore.Qt.Vertical) splitter1.addWidget(top) splitter1.addWidget(mid) splitter2 = QtGui.QSplitter(QtCore.Qt.Horizontal) splitter2.addWidget(bottomleft) splitter2.addWidget(bottommid) splitter2.addWidget(bottomright) splitter3 = QtGui.QSplitter(QtCore.Qt.Vertical) splitter3.addWidget(splitter1) splitter3.addWidget(splitter2) hbox.addWidget(splitter3) elif config == 3: top = LayoutWindow(self._graph, 'vbox', 'top') top.setFrameShape(QtGui.QFrame.StyledPanel) top.changed.connect(self.columnAdjust) self.topsplitter = QtGui.QSplitter(QtCore.Qt.Horizontal) self.topsplitter.addWidget(top) bottom = LayoutWindow(self._graph, 'vbox', 'bottom') bottom.setFrameShape(QtGui.QFrame.StyledPanel) bottom.changed.connect(self.columnAdjust) self.bottomsplitter = QtGui.QSplitter(QtCore.Qt.Horizontal) self.bottomsplitter.addWidget(bottom) vsplitter = QtGui.QSplitter(QtCore.Qt.Vertical) vsplitter.addWidget(self.topsplitter) vsplitter.addWidget(self.bottomsplitter) hbox.addWidget(vsplitter) if self._labelWin: # make a label box with the unique id self.wdglabel = QtGui.QLineEdit('') labelGroup = HidableGroupBox("Node Label") labelLayout = QtGui.QVBoxLayout() labelLayout.addWidget(self.wdglabel) labelGroup.setLayout(labelLayout) hbox.addWidget(labelGroup) labelGroup.set_collapsed(True) labelGroup.setToolTip( "Displays the Label on the Canvas (Double Click)") self.setLayout(hbox)