def __init__(self, title="Calendar"): super(CalendarWidget, self).__init__() self.setWindowTitle(title) layout = QtGui.QGridLayout() layout.setColumnStretch(1, 1) self.cal = QtGui.QCalendarWidget(self) self.cal.setGridVisible(True) self.cal.clicked[QtCore.QDate].connect(self.show_date) layout.addWidget(self.cal, 0, 0, 1, 2) self.date_label = QtGui.QLabel() self.date = self.cal.selectedDate() self.date_label.setText(self.date.toString()) layout.addWidget(self.date_label, 1, 0) button_box = QtGui.QDialogButtonBox() confirm_button = button_box.addButton(QtGui.QDialogButtonBox.Ok) confirm_button.clicked.connect(self.confirm) layout.addWidget(button_box, 1, 1) self.setLayout(layout) self.show() self.raise_()
def __init__(self, topics=None, terms=None, addr=None, parent=None, **kwargs): super().__init__(parent) self.terms = terms self.update_rate = kwargs.get('update_rate', 30) self.grid = QtGui.QGridLayout(self) self.table = pg.TableWidget() self.last_updated = QtWidgets.QLabel(parent=self) self.grid.addWidget(self.table, 0, 0) self.grid.setRowStretch(0, 10) self.grid.addWidget(self.last_updated, 1, 0) self.fetcher = None if addr: self.fetcher = AsyncFetcher(topics, terms, addr, parent=self, ratelimit=1.0 / self.update_rate) self.fetcher.start()
def __init__(self): QtGui.QWidget.__init__(self) self.data = {} self.gv = pg.GraphicsView() self.gl = GraphicsLayout() self.gv.setCentralItem(self.gl) self.layout = QtGui.QGridLayout() self.layout.addWidget(self.gv, 1, 1, 1, 1) self.setLayout(self.layout)
def __init__(self, parent, title="Language selection", name="Language codes", instruction="Click button when you are done"): super(LanguageSelector, self).__init__( None, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.qm_files_choices = {} self.parent = parent qm_files = utils.find_qm_files() # ========= check boxes ============== group_box = QtGui.QGroupBox(name) group_box_layout = QtGui.QGridLayout() for i, locale in enumerate(qm_files): check_box = QtGui.QCheckBox(locale) check_box.setAutoExclusive(True) self.qm_files_choices[check_box] = locale check_box.toggled.connect(self.check_box_toggled) group_box_layout.addWidget(check_box, i / 4, i % 4) # adding default language option. When using the PyQt distribution # no "en" files were found and yet "en" was the obvious default. # We need this option in case we want to revert a change. check_box = QtGui.QCheckBox("default") check_box.setAutoExclusive(True) self.qm_files_choices[check_box] = "default" check_box.toggled.connect(self.check_box_toggled) i = len(qm_files) group_box_layout.addWidget(check_box, i / 4, i % 4) group_box.setLayout(group_box_layout) # ========= buttons ============== button_box = QtGui.QDialogButtonBox() confirm_button = button_box.addButton(QtGui.QDialogButtonBox.Ok) confirm_button.clicked.connect(self.confirm) # ========= finalizing layout ==== main_layout = QtGui.QVBoxLayout() main_layout.addWidget(group_box) main_layout.addWidget(QtGui.QLabel(instruction)) main_layout.addWidget(button_box) self.setLayout(main_layout) self.setWindowTitle(title) self.show() self.raise_()
def __init__(self, labels=None, title="Demo", masks=None, parent=None): super(MultipleFieldsDialog, self).__init__( None, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) if parent is None: raise Exception("Parent must be a valid object") self.parent = parent self.parent.o_dict = OrderedDict() self.setWindowTitle(title) # set up a special case for quick demo if labels is None: labels = ["Regular field", "Masked field"] masks = [False, True] self.setWindowTitle("MultipleFieldsDialog demo") if masks is not None: assert len(masks) == len(labels) layout = QtGui.QGridLayout() layout.setColumnStretch(1, 1) layout.setColumnMinimumWidth(1, 250) self._labels_ = [] self.fields = [] for index, choice in enumerate(labels): self._labels_.append(QtGui.QLabel()) self._labels_[index].setText(choice) self.fields.append(QtGui.QLineEdit()) self.fields[index].setText('') self.parent.o_dict[choice] = '' if masks is not None and masks[index]: self.fields[index].setEchoMode(QtGui.QLineEdit.Password) layout.addWidget(self._labels_[index], index, 0) layout.addWidget(self.fields[index], index, 1) button_box = QtGui.QDialogButtonBox() confirm_button = button_box.addButton(QtGui.QDialogButtonBox.Ok) layout.addWidget(button_box, index + 1, 1) confirm_button.clicked.connect(self.confirm) self.setLayout(layout) self.setWindowTitle(title) self.show() self.raise_()
def __init__(self, choices=None, title="Title"): super(MultipleChoicesDialog, self).__init__( None, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) if choices is None: choices = ["Item %d" % i for i in range(10)] self.setWindowTitle(title) self.selection = [] main_widget = QtGui.QWidget() main_layout = QtGui.QVBoxLayout() main_widget.setLayout(main_layout) self.choices_widget = QtGui.QListWidget() self.choices_widget.setSelectionMode( QtGui.QAbstractItemView.ExtendedSelection) for choice in choices: item = QtGui.QListWidgetItem() item.setText(choice) self.choices_widget.addItem(item) main_layout.addWidget(self.choices_widget) button_box_layout = QtGui.QGridLayout() selection_completed_btn = QtGui.QPushButton("Ok") selection_completed_btn.clicked.connect(self.selection_completed) select_all_btn = QtGui.QPushButton("Select all") select_all_btn.clicked.connect(self.select_all) clear_all_btn = QtGui.QPushButton("Clear all") clear_all_btn.clicked.connect(self.clear_all) cancel_btn = QtGui.QPushButton("Cancel") cancel_btn.clicked.connect(self.cancel) button_box = QtGui.QWidget() button_box_layout.addWidget(selection_completed_btn, 0, 0) button_box_layout.addWidget(cancel_btn, 0, 1) button_box_layout.addWidget(select_all_btn, 1, 0) button_box_layout.addWidget(clear_all_btn, 1, 1) button_box.setLayout(button_box_layout) main_layout.addWidget(button_box) self.setLayout(main_layout) self.show() self.raise_()
from sharppy.sharptab.constants import * from sharppy.sounding import prof, plot_title # Setup Application app = QtGui.QApplication(sys.argv) mainWindow = QtGui.QMainWindow() x = 1180 y = 800 mainWindow.setGeometry(0, 0, x, y) title = 'SHARPpy: Sounding and Hodograph Analysis and Research Program ' title += 'in Python' mainWindow.setWindowTitle(title) mainWindow.setStyleSheet("QMainWindow {background-color: rgb(0, 0, 0);}") centralWidget = QtWidgets.QFrame() mainWindow.setCentralWidget(centralWidget) grid = QtGui.QGridLayout() grid.setHorizontalSpacing(0) grid.setVerticalSpacing(2) centralWidget.setLayout(grid) # Handle the Upper Left ## plot the main sounding #print prof.right_scp, prof.left_scp brand = 'SHARPpy Beta' sound = plotSkewT(prof, pcl=prof.mupcl, title=plot_title, brand=brand) sound.setContentsMargins(0, 0, 0, 0) grid.addWidget(sound, 0, 0, 3, 1) # Handle the Upper Right urparent = QtWidgets.QFrame() urparent_grid = QtGui.QGridLayout()
def create_layout(self): ok_cancel_box = QtGui.QHBoxLayout() ok_cancel_box.addWidget(self.apply_button) ok_cancel_box.addWidget(self.ok_button) ok_cancel_box.addWidget(self.cancel_button) # x axis; yplane # x axis; zplane mode = 2 grid = QtGui.QGridLayout() irow = 0 grid.addWidget(self.axis, irow, 0) grid.addWidget(self.combo_axis, irow, 1) irow += 1 grid.addWidget(self.plane, irow, 0) grid.addWidget(self.combo_plane, irow, 1) irow += 1 grid.addWidget(self.origin, irow, 0) grid.addWidget(self.origin_x_edit, irow, 1) grid.addWidget(self.origin_y_edit, irow, 2) grid.addWidget(self.origin_z_edit, irow, 3) grid.addWidget(self.origin_default_button, irow, 4) irow += 1 grid.addWidget(self.normal, irow, 0) grid.addWidget(self.normal_x_edit, irow, 1) grid.addWidget(self.normal_y_edit, irow, 2) grid.addWidget(self.normal_z_edit, irow, 3) grid.addWidget(self.normal_default_button, irow, 4) irow += 1 grid.addWidget(self.snap, irow, 0) grid.addWidget(self.snap_normal_xy_button, irow, 1) grid.addWidget(self.snap_normal_yz_button, irow, 2) grid.addWidget(self.snap_normal_xz_button, irow, 3) irow += 1 grid.addWidget(self.point_a, irow, 0) grid.addWidget(self.ax_edit, irow, 1) grid.addWidget(self.ay_edit, irow, 2) grid.addWidget(self.az_edit, irow, 3) irow += 1 grid.addWidget(self.point_b, irow, 0) grid.addWidget(self.bx_edit, irow, 1) grid.addWidget(self.by_edit, irow, 2) grid.addWidget(self.bz_edit, irow, 3) irow += 1 vbox = QtGui.QVBoxLayout() vbox.addWidget(self.name) vbox.addLayout(grid) vbox.addStretch() vbox.addWidget(self.check_apply) vbox.addLayout(ok_cancel_box) #Create central widget, add layout and set #central_widget = QtGui.QWidget() #central_widget.setLayout(vbox) #self.setCentralWidget(central_widget) self.setLayout(vbox)
def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) MainWindow.resize(1115, 652) self.centralwidget = QtGui.QWidget(MainWindow) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.horizontalLayout_2 = QtGui.QHBoxLayout(self.centralwidget) self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) self.tabMain = QtGui.QTabWidget(self.centralwidget) self.tabMain.setObjectName(_fromUtf8("tabMain")) self.tab = QtGui.QWidget() self.tab.setObjectName(_fromUtf8("tab")) self.verticalLayout_3 = QtGui.QVBoxLayout(self.tab) self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3")) self.gridLayout_4 = QtGui.QGridLayout() self.gridLayout_4.setObjectName(_fromUtf8("gridLayout_4")) self.label_6 = QtGui.QLabel(self.tab) self.label_6.setObjectName(_fromUtf8("label_6")) self.gridLayout_4.addWidget(self.label_6, 0, 0, 1, 1) self.txtLambda0 = QtGui.QLineEdit(self.tab) self.txtLambda0.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.txtLambda0.setObjectName(_fromUtf8("txtLambda0")) self.gridLayout_4.addWidget(self.txtLambda0, 0, 1, 1, 1) self.label = QtGui.QLabel(self.tab) self.label.setObjectName(_fromUtf8("label")) self.gridLayout_4.addWidget(self.label, 1, 0, 1, 1) self.cbSuperstrate = QtGui.QComboBox(self.tab) font = QtGui.QFont() font.setBold(False) font.setWeight(50) self.cbSuperstrate.setFont(font) self.cbSuperstrate.setLayoutDirection(QtCore.Qt.LeftToRight) self.cbSuperstrate.setStyleSheet(_fromUtf8("text-align: right;")) self.cbSuperstrate.setEditable(True) self.cbSuperstrate.setObjectName(_fromUtf8("cbSuperstrate")) self.gridLayout_4.addWidget(self.cbSuperstrate, 1, 1, 1, 1) self.verticalLayout_3.addLayout(self.gridLayout_4) self.tblStack = QtGui.QTableWidget(self.tab) self.tblStack.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOff) self.tblStack.setAlternatingRowColors(True) self.tblStack.setSelectionMode(QtGui.QAbstractItemView.SingleSelection) self.tblStack.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) self.tblStack.setObjectName(_fromUtf8("tblStack")) self.tblStack.setColumnCount(2) self.tblStack.setRowCount(1) item = QtGui.QTableWidgetItem() self.tblStack.setVerticalHeaderItem(0, item) item = QtGui.QTableWidgetItem() self.tblStack.setHorizontalHeaderItem(0, item) item = QtGui.QTableWidgetItem() self.tblStack.setHorizontalHeaderItem(1, item) item = QtGui.QTableWidgetItem() item.setTextAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.tblStack.setItem(0, 0, item) item = QtGui.QTableWidgetItem() self.tblStack.setItem(0, 1, item) self.tblStack.horizontalHeader().setSortIndicatorShown(False) self.tblStack.horizontalHeader().setStretchLastSection(True) self.tblStack.verticalHeader().setVisible(False) self.verticalLayout_3.addWidget(self.tblStack) self.horizontalLayout_7 = QtGui.QHBoxLayout() self.horizontalLayout_7.setObjectName(_fromUtf8("horizontalLayout_7")) self.btnAddLayer = QtGui.QPushButton(self.tab) self.btnAddLayer.setText(_fromUtf8("")) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(_fromUtf8("gui/icons/list-add.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.btnAddLayer.setIcon(icon) self.btnAddLayer.setObjectName(_fromUtf8("btnAddLayer")) self.horizontalLayout_7.addWidget(self.btnAddLayer) self.btnRemoveLayer = QtGui.QPushButton(self.tab) self.btnRemoveLayer.setText(_fromUtf8("")) icon1 = QtGui.QIcon() icon1.addPixmap(QtGui.QPixmap(_fromUtf8("gui/icons/list-remove.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.btnRemoveLayer.setIcon(icon1) self.btnRemoveLayer.setObjectName(_fromUtf8("btnRemoveLayer")) self.horizontalLayout_7.addWidget(self.btnRemoveLayer) spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout_7.addItem(spacerItem) self.verticalLayout_3.addLayout(self.horizontalLayout_7) self.horizontalLayout_4 = QtGui.QHBoxLayout() self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4")) self.label_2 = QtGui.QLabel(self.tab) self.label_2.setObjectName(_fromUtf8("label_2")) self.horizontalLayout_4.addWidget(self.label_2) self.cbSubstrate = QtGui.QComboBox(self.tab) self.cbSubstrate.setEditable(True) self.cbSubstrate.setObjectName(_fromUtf8("cbSubstrate")) self.horizontalLayout_4.addWidget(self.cbSubstrate) self.verticalLayout_3.addLayout(self.horizontalLayout_4) self.tabMain.addTab(self.tab, _fromUtf8("")) self.tab_3 = QtGui.QWidget() self.tab_3.setObjectName(_fromUtf8("tab_3")) self.tabMain.addTab(self.tab_3, _fromUtf8("")) self.tab_2 = QtGui.QWidget() self.tab_2.setObjectName(_fromUtf8("tab_2")) self.verticalLayout_4 = QtGui.QVBoxLayout(self.tab_2) self.verticalLayout_4.setObjectName(_fromUtf8("verticalLayout_4")) self.horizontalLayout_11 = QtGui.QHBoxLayout() self.horizontalLayout_11.setObjectName( _fromUtf8("horizontalLayout_11")) self.label_5 = QtGui.QLabel(self.tab_2) self.label_5.setObjectName(_fromUtf8("label_5")) self.horizontalLayout_11.addWidget(self.label_5) self.cbPlotType = QtGui.QComboBox(self.tab_2) self.cbPlotType.setObjectName(_fromUtf8("cbPlotType")) self.horizontalLayout_11.addWidget(self.cbPlotType) self.horizontalLayout_11.setStretch(1, 1) self.verticalLayout_4.addLayout(self.horizontalLayout_11) self.groupBox = QtGui.QGroupBox(self.tab_2) self.groupBox.setMinimumSize(QtCore.QSize(0, 0)) self.groupBox.setMaximumSize(QtCore.QSize(16777215, 220)) self.groupBox.setObjectName(_fromUtf8("groupBox")) self.horizontalLayout_8 = QtGui.QHBoxLayout(self.groupBox) self.horizontalLayout_8.setObjectName(_fromUtf8("horizontalLayout_8")) self.horizontalLayout_9 = QtGui.QHBoxLayout() self.horizontalLayout_9.setObjectName(_fromUtf8("horizontalLayout_9")) self.groupBox_2 = QtGui.QGroupBox(self.groupBox) self.groupBox_2.setObjectName(_fromUtf8("groupBox_2")) self.gridLayout = QtGui.QGridLayout(self.groupBox_2) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) self.lineEdit_2 = QtGui.QLineEdit(self.groupBox_2) self.lineEdit_2.setEnabled(False) self.lineEdit_2.setMaximumSize(QtCore.QSize(50, 16777215)) self.lineEdit_2.setObjectName(_fromUtf8("lineEdit_2")) self.gridLayout.addWidget(self.lineEdit_2, 2, 2, 1, 1) self.radioButton = QtGui.QRadioButton(self.groupBox_2) self.radioButton.setChecked(True) self.radioButton.setObjectName(_fromUtf8("radioButton")) self.gridLayout.addWidget(self.radioButton, 0, 0, 1, 3) self.lineEdit = QtGui.QLineEdit(self.groupBox_2) self.lineEdit.setEnabled(False) self.lineEdit.setMaximumSize(QtCore.QSize(50, 16777215)) self.lineEdit.setObjectName(_fromUtf8("lineEdit")) self.gridLayout.addWidget(self.lineEdit, 2, 0, 1, 1) self.label_3 = QtGui.QLabel(self.groupBox_2) self.label_3.setObjectName(_fromUtf8("label_3")) self.gridLayout.addWidget(self.label_3, 2, 1, 1, 1) self.radioButton_2 = QtGui.QRadioButton(self.groupBox_2) self.radioButton_2.setObjectName(_fromUtf8("radioButton_2")) self.gridLayout.addWidget(self.radioButton_2, 1, 0, 1, 3) self.horizontalLayout_9.addWidget(self.groupBox_2) self.groupBox_3 = QtGui.QGroupBox(self.groupBox) self.groupBox_3.setObjectName(_fromUtf8("groupBox_3")) self.verticalLayout_2 = QtGui.QVBoxLayout(self.groupBox_3) self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) self.radioButton_3 = QtGui.QRadioButton(self.groupBox_3) self.radioButton_3.setChecked(True) self.radioButton_3.setObjectName(_fromUtf8("radioButton_3")) self.verticalLayout_2.addWidget(self.radioButton_3) self.radioButton_4 = QtGui.QRadioButton(self.groupBox_3) self.radioButton_4.setObjectName(_fromUtf8("radioButton_4")) self.verticalLayout_2.addWidget(self.radioButton_4) self.horizontalLayout_9.addWidget(self.groupBox_3) self.horizontalLayout_8.addLayout(self.horizontalLayout_9) self.verticalLayout_4.addWidget(self.groupBox) self.groupBox_4 = QtGui.QGroupBox(self.tab_2) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.groupBox_4.sizePolicy().hasHeightForWidth()) self.groupBox_4.setSizePolicy(sizePolicy) self.groupBox_4.setMinimumSize(QtCore.QSize(0, 0)) self.groupBox_4.setMaximumSize(QtCore.QSize(16777215, 220)) self.groupBox_4.setObjectName(_fromUtf8("groupBox_4")) self.horizontalLayout_6 = QtGui.QHBoxLayout(self.groupBox_4) self.horizontalLayout_6.setObjectName(_fromUtf8("horizontalLayout_6")) self.horizontalLayout_10 = QtGui.QHBoxLayout() self.horizontalLayout_10.setObjectName( _fromUtf8("horizontalLayout_10")) self.groupBox_5 = QtGui.QGroupBox(self.groupBox_4) self.groupBox_5.setObjectName(_fromUtf8("groupBox_5")) self.gridLayout_2 = QtGui.QGridLayout(self.groupBox_5) self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2")) self.radioButton_7 = QtGui.QRadioButton(self.groupBox_5) self.radioButton_7.setChecked(True) self.radioButton_7.setObjectName(_fromUtf8("radioButton_7")) self.gridLayout_2.addWidget(self.radioButton_7, 0, 0, 1, 3) self.radioButton_8 = QtGui.QRadioButton(self.groupBox_5) self.radioButton_8.setObjectName(_fromUtf8("radioButton_8")) self.gridLayout_2.addWidget(self.radioButton_8, 1, 0, 1, 3) self.lineEdit_3 = QtGui.QLineEdit(self.groupBox_5) self.lineEdit_3.setEnabled(False) self.lineEdit_3.setMaximumSize(QtCore.QSize(50, 16777215)) self.lineEdit_3.setObjectName(_fromUtf8("lineEdit_3")) self.gridLayout_2.addWidget(self.lineEdit_3, 2, 0, 1, 1) self.label_4 = QtGui.QLabel(self.groupBox_5) self.label_4.setObjectName(_fromUtf8("label_4")) self.gridLayout_2.addWidget(self.label_4, 2, 1, 1, 1) self.lineEdit_4 = QtGui.QLineEdit(self.groupBox_5) self.lineEdit_4.setEnabled(False) self.lineEdit_4.setMaximumSize(QtCore.QSize(50, 16777215)) self.lineEdit_4.setObjectName(_fromUtf8("lineEdit_4")) self.gridLayout_2.addWidget(self.lineEdit_4, 2, 2, 1, 1) self.horizontalLayout_10.addWidget(self.groupBox_5) self.groupBox_6 = QtGui.QGroupBox(self.groupBox_4) self.groupBox_6.setObjectName(_fromUtf8("groupBox_6")) self.verticalLayout_5 = QtGui.QVBoxLayout(self.groupBox_6) self.verticalLayout_5.setObjectName(_fromUtf8("verticalLayout_5")) self.radioButton_5 = QtGui.QRadioButton(self.groupBox_6) self.radioButton_5.setChecked(True) self.radioButton_5.setObjectName(_fromUtf8("radioButton_5")) self.verticalLayout_5.addWidget(self.radioButton_5) self.radioButton_6 = QtGui.QRadioButton(self.groupBox_6) self.radioButton_6.setObjectName(_fromUtf8("radioButton_6")) self.verticalLayout_5.addWidget(self.radioButton_6) self.horizontalLayout_10.addWidget(self.groupBox_6) self.horizontalLayout_6.addLayout(self.horizontalLayout_10) self.verticalLayout_4.addWidget(self.groupBox_4) self.groupBox_7 = QtGui.QGroupBox(self.tab_2) self.groupBox_7.setObjectName(_fromUtf8("groupBox_7")) self.gridLayout_3 = QtGui.QGridLayout(self.groupBox_7) self.gridLayout_3.setObjectName(_fromUtf8("gridLayout_3")) self.listWidget = QtGui.QListWidget(self.groupBox_7) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.listWidget.sizePolicy().hasHeightForWidth()) self.listWidget.setSizePolicy(sizePolicy) self.listWidget.setMaximumSize(QtCore.QSize(130, 16777215)) self.listWidget.setObjectName(_fromUtf8("listWidget")) self.gridLayout_3.addWidget(self.listWidget, 0, 0, 5, 1) self.pushButton = QtGui.QPushButton(self.groupBox_7) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.pushButton.sizePolicy().hasHeightForWidth()) self.pushButton.setSizePolicy(sizePolicy) self.pushButton.setObjectName(_fromUtf8("pushButton")) self.gridLayout_3.addWidget(self.pushButton, 0, 1, 1, 1) self.pushButton_5 = QtGui.QPushButton(self.groupBox_7) self.pushButton_5.setObjectName(_fromUtf8("pushButton_5")) self.gridLayout_3.addWidget(self.pushButton_5, 1, 1, 1, 1) self.pushButton_4 = QtGui.QPushButton(self.groupBox_7) self.pushButton_4.setObjectName(_fromUtf8("pushButton_4")) self.gridLayout_3.addWidget(self.pushButton_4, 2, 1, 1, 1) self.pushButton_2 = QtGui.QPushButton(self.groupBox_7) self.pushButton_2.setObjectName(_fromUtf8("pushButton_2")) self.gridLayout_3.addWidget(self.pushButton_2, 3, 1, 1, 1) self.pushButton_3 = QtGui.QPushButton(self.groupBox_7) self.pushButton_3.setObjectName(_fromUtf8("pushButton_3")) self.gridLayout_3.addWidget(self.pushButton_3, 4, 1, 1, 1) self.gridLayout_3.setColumnMinimumWidth(0, 1) self.verticalLayout_4.addWidget(self.groupBox_7) spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout_4.addItem(spacerItem1) self.tabMain.addTab(self.tab_2, _fromUtf8("")) self.horizontalLayout_2.addWidget(self.tabMain) self.verticalLayout = QtGui.QVBoxLayout() self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.pltMain = MatplotlibWidget(self.centralwidget) self.pltMain.setObjectName(_fromUtf8("pltMain")) self.verticalLayout.addWidget(self.pltMain) self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) spacerItem2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem2) self.btnUpdate = QtGui.QPushButton(self.centralwidget) self.btnUpdate.setObjectName(_fromUtf8("btnUpdate")) self.horizontalLayout.addWidget(self.btnUpdate) self.verticalLayout.addLayout(self.horizontalLayout) self.horizontalLayout_2.addLayout(self.verticalLayout) self.horizontalLayout_2.setStretch(1, 1) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 1115, 21)) self.menubar.setObjectName(_fromUtf8("menubar")) self.menuFile = QtGui.QMenu(self.menubar) self.menuFile.setObjectName(_fromUtf8("menuFile")) self.menuPlot = QtGui.QMenu(self.menubar) self.menuPlot.setObjectName(_fromUtf8("menuPlot")) MainWindow.setMenuBar(self.menubar) self.statusbar = QtGui.QStatusBar(MainWindow) self.statusbar.setObjectName(_fromUtf8("statusbar")) MainWindow.setStatusBar(self.statusbar) self.actionQuit = QtGui.QAction(MainWindow) self.actionQuit.setObjectName(_fromUtf8("actionQuit")) self.actionNew = QtGui.QAction(MainWindow) self.actionNew.setObjectName(_fromUtf8("actionNew")) self.actionSave = QtGui.QAction(MainWindow) self.actionSave.setObjectName(_fromUtf8("actionSave")) self.actionOpen = QtGui.QAction(MainWindow) self.actionOpen.setObjectName(_fromUtf8("actionOpen")) self.actionExport = QtGui.QAction(MainWindow) self.actionExport.setObjectName(_fromUtf8("actionExport")) self.menuFile.addAction(self.actionNew) self.menuFile.addAction(self.actionOpen) self.menuFile.addAction(self.actionSave) self.menuFile.addSeparator() self.menuFile.addAction(self.actionQuit) self.menuPlot.addAction(self.actionExport) self.menubar.addAction(self.menuFile.menuAction()) self.menubar.addAction(self.menuPlot.menuAction()) self.retranslateUi(MainWindow) self.tabMain.setCurrentIndex(0) QtCore.QObject.connect(self.actionQuit, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.close) QtCore.QObject.connect(self.radioButton_2, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), self.lineEdit.setEnabled) QtCore.QObject.connect(self.radioButton_2, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), self.lineEdit_2.setEnabled) QtCore.QObject.connect(self.radioButton_8, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), self.lineEdit_3.setEnabled) QtCore.QObject.connect(self.radioButton_8, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), self.lineEdit_4.setEnabled) QtCore.QMetaObject.connectSlotsByName(MainWindow)
def __init__(self, parent=None): flags = QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint super(Dialog, self).__init__(parent, flags=flags) frameStyle = QtGui.QFrame.Sunken | QtGui.QFrame.Panel layout = QtGui.QGridLayout() layout.setColumnStretch(1, 1) layout.setColumnMinimumWidth(1, 250) # generate a bunch of function-demo buttons and output labels: self.button = {} self.setStyleSheet("""QToolTip { color: black; } QLabel{ background-color: white; } QPushButton { font-weight: bold; }""") self.label = {} fxns = ['get_string', 'get_password', 'get_username_password', 'get_many_strings', 'get_new_password', 'get_int', 'get_float', 'get_choice', 'get_list_of_choices', 'get_yes_or_no', 'get_continue_or_cancel', 'get_color_hex', 'get_color_rgb', 'get_date', 'get_directory_name', 'get_file_names', 'get_save_file_name', 'get_language', 'set_font_size', 'show_file', 'show_code', 'get_abort', 'find_help'] for n, fxn in enumerate(fxns): self.button[fxn] = QtGui.QPushButton(fxn + "()") self.button[fxn].clicked.connect(getattr(self, fxn)) self.button[fxn].setToolTip(getattr(easygui_qt, fxn).__doc__) self.label[fxn] = QtGui.QLabel() self.label[fxn].setFrameStyle(frameStyle) layout.addWidget(self.button[fxn], n, 0) layout.addWidget(self.label[fxn], n, 1) # handle special-case display items separately: n += 1 self.python_version_label = QtGui.QLabel() layout.addWidget(self.python_version_label, n, 0, 2, 2) output = subprocess.check_output( ['python', '-c', "import sys;print(sys.version)"]) self.python_version_label.setText( "Python version: {}".format(output.decode())) n += 2 self.cancel_btn = QtGui.QPushButton("Quit") self.cancel_btn.clicked.connect(self.close) layout.addWidget(self.cancel_btn, n, 0) self.handle_exception_label = QtGui.QLabel() self.handle_exception_label.setToolTip( easygui_qt.handle_exception.__doc__) self.handle_exception_label.setText(" handle_exception() not shown" + " [hover mouse for more info]") layout.addWidget(self.handle_exception_label, n, 1) self._layout = layout self.setLayout(layout) self.setWindowTitle("EasyGUI_Qt Widget Launcher") self.show() self.raise_() self.activateWindow()
def create_layout(self): cancel_box = QtGui.QHBoxLayout() cancel_box.addWidget(self.close_button) grid1 = QtGui.QGridLayout() grid2 = QtGui.QGridLayout() #----------------------------------------- # setup self.radio_rectangular = QtGui.QRadioButton('Rectangular') self.radio_cylindrical = QtGui.QRadioButton('Cylindrical') self.radio_spherical = QtGui.QRadioButton('Spherical') coord_type_layout = QtGui.QHBoxLayout() coord_type_layout.addWidget(self.radio_rectangular) coord_type_layout.addWidget(self.radio_cylindrical) coord_type_layout.addWidget(self.radio_spherical) checkboxs = QtGui.QButtonGroup(self) checkboxs.addButton(self.checkbox_region_all) checkboxs.addButton(self.checkbox_region_ids) vbox1 = QtGui.QVBoxLayout() vbox1.addWidget(self.checkbox_region_all) vbox1.addWidget(self.checkbox_region_ids) #vbox1.addLayout(checkboxs) #----------------------------------------- irow = 0 grid2.addWidget(self.name, irow, 0) grid2.addWidget(self.name_edit, irow, 1) irow += 1 #| Name EngineInlet | #| RegionMode * RegionID | #| * All | #| | #| AllowedRegions: | #| Region ID 3 | #| | #| PickMode * All | #| Pick Mode x On/Off | #| Pick Angle 20 deg | #| | #| Revert | #| RenumberRegions | #| Close | grid2.addWidget(self.region_id, irow, 0) grid2.addWidget(self.region_id_edit, irow, 1) irow += 1 #grid2.addWidget(self.pick_mode, irow, 0) grid2.addWidget(self.checkbox_pick_mode, irow, 0) irow += 1 grid2.addWidget(self.pick_angle, irow, 0) grid2.addWidget(self.pick_angle_edit, irow, 1) irow += 1 #grid2.addWidget(self.pi, irow, 0) #grid2.addLayout(coord_type_layout, irow, 1) #irow += 1 #grid2.addWidget(self.location, irow, 0) #grid2.addLayout(location_layout, irow, 1) #irow += 1 #------------------------------------ vbox = QtGui.QVBoxLayout() vbox.addLayout(grid1) #vbox.addLayout(vbox1) #vbox.addStretch() vbox.addWidget(self.table) vbox.addLayout(grid2) vbox.addStretch() #vbox.addWidget(self.check_apply) vbox.addLayout(cancel_box) self.setLayout(vbox)