def layout_widgets(self): vLayout1 = QVBoxLayout() vLayout1.addWidget(self.label1) vLayout1.addWidget(self.listWidget1) vLayout2 = QVBoxLayout() vLayout2.addWidget(self.button1) vLayout2.addWidget(self.button2) vLayout3 = QVBoxLayout() vLayout3.addWidget(self.label2) vLayout3.addWidget(self.listWidget2) hLayout1 = QHBoxLayout() hLayout1.addLayout(vLayout1) hLayout1.addLayout(vLayout2) hLayout1.addLayout(vLayout3) hButtonLayout = QHBoxLayout() hButtonLayout.addItem(self.spacer) hButtonLayout.addWidget(self.buttonBox) hFinalLayout = QGridLayout() hFinalLayout.addLayout(hLayout1, 0, 0) hFinalLayout.addLayout(hButtonLayout, 1, 0) self.setLayout(hFinalLayout)
def set_layouts(self): assert object_thread(self) self._vlayout = QVBoxLayout() self._vlayout.setSpacing(0) self._vlayout.setContentsMargins(0, 0, 0, 0) # needed in case we have a widget that changes the size # of the widget and can be hidden # this prevents the ChangeObjects dialog from being scaleable, # therefor commented out #self._vlayout.setSizeConstraint(QLayout.SetFixedSize) banner_layout = QGridLayout() banner_layout.setColumnStretch(0, 1) banner_layout.addWidget(QLabel(), 0, 1, Qt.AlignRight) banner_layout.addLayout(QVBoxLayout(), 0, 0) # TODO: allow banner widget to be supplied banner_widget = QWidget() banner_widget.setLayout(banner_layout) self._vlayout.addWidget(banner_widget) self._vlayout.addWidget(HSeparator()) self._vlayout.addWidget(QFrame(), 1) self._vlayout.addWidget(HSeparator()) self._vlayout.addWidget(QWidget()) self.setLayout(self._vlayout)
def set_layouts(self): assert object_thread( self ) self._vlayout = QVBoxLayout() self._vlayout.setSpacing(0) self._vlayout.setContentsMargins(0,0,0,0) # needed in case we have a widget that changes the size # of the widget and can be hidden # this prevents the ChangeObjects dialog from being scaleable, # therefor commented out #self._vlayout.setSizeConstraint(QLayout.SetFixedSize) banner_layout = QGridLayout() banner_layout.setColumnStretch(0, 1) banner_layout.addWidget(QLabel(), 0, 1, Qt.AlignRight) banner_layout.addLayout(QVBoxLayout(), 0, 0) # TODO: allow banner widget to be supplied banner_widget = QWidget() banner_widget.setLayout(banner_layout) self._vlayout.addWidget(banner_widget) self._vlayout.addWidget(HSeparator()) self._vlayout.addWidget(QFrame(), 1) self._vlayout.addWidget(HSeparator()) self._vlayout.addWidget(QWidget()) self.setLayout(self._vlayout)
def __init__(self, value=0, parent=None): super(okno_podzialu, self).__init__(parent) self.aa = str(value) self.setWindowTitle("Divide Ringwidth") self.resize(150, 80) self.s = QSlider(Qt.Horizontal) self.s.setMinimum(1) self.s.setMaximum(int(self.aa)) self.wart1 = QLabel("1") self.wart2 = QLabel(self.aa) self.lab = QLabel("Length = " + self.aa + " [1/100mm]") self.ok = QPushButton("OK") self.anuluj = QPushButton("Anuluj") layout = QGridLayout() layout.addWidget(self.wart1, 0, 0) layout.addWidget(self.s, 0, 1) layout.addWidget(self.wart2, 0, 2) layout.addWidget(self.lab, 1, 0, 1, 3) layout1 = QHBoxLayout() layout1.addWidget(self.ok) layout1.addWidget(self.anuluj) layout.addLayout(layout1, 2, 0, 1, 3) self.setLayout(layout) self.connect(self.s, SIGNAL("valueChanged(int)"), self.uaktualnij) self.connect(self.anuluj, SIGNAL("clicked()"), self.anulowanie) self.connect(self.ok, SIGNAL("clicked()"), self.akceptuj)
def __init__(self, parent=None): super(CreditCard, self).__init__(parent) fileLabel = QLabel("Excel files:") self.fileList = FileList(self) self.connect(self.fileList, QtCore.SIGNAL("dropped"), self.fileDrop) self.cashdepo = QPushButton("&Cash Depo") self.cashdepo.show() self.crediCard = QPushButton("C&redit Card") self.crediCard.show() self.cashdepo.clicked.connect(self.getCashDepo) self.crediCard.clicked.connect(self.getCreditCard) buttonLayout1 = QVBoxLayout() buttonLayout1.addWidget(self.cashdepo, QtCore.Qt.AlignTop) buttonLayout1.addWidget(self.crediCard) buttonLayout1.addStretch() mainLayout = QGridLayout() mainLayout.addWidget(fileLabel, 0, 0) mainLayout.addWidget(self.fileList, 1, 0) mainLayout.addLayout(buttonLayout1, 1, 1) self.setLayout(mainLayout) self.setWindowTitle("Credit Card & Cash Depo XL")
def setupGUI(self): layout = QGridLayout() self.widget = QWidget() self.widget.setLayout(layout) self.setCentralWidget(self.widget) self.setWindowTitle("Nutch Job Service") # create active job list active_label = QLabel("Active Hadoop Jobs") layout.addWidget(active_label, 0, 0) self.lv = QListView() layout.addWidget(self.lv, 1, 0, 3, 1) # Create buttons self.stop_button = QPushButton("Stop") self.refresh_button = QPushButton("Refresh") button_layout = QVBoxLayout() button_layout.addWidget(self.stop_button) button_layout.addWidget(self.refresh_button) layout.addLayout(button_layout, 1, 1) # Start Button self.new_job_layout = QHBoxLayout() self.new_job_combo = QComboBox() self.new_job_combo.addItems(["Inject", "Generate", "Fetch", "Parse", "Solr"]) self.new_job_button = QPushButton("Start New Job") self.new_job_layout.addWidget(self.new_job_combo) self.new_job_layout.addWidget(self.new_job_button) layout.addLayout(self.new_job_layout, 5, 0) # self.statusBar() self.connectSlots()
def setup_page(self): tabs = QTabWidget() names = self.get_option("names") names.pop(names.index(CUSTOM_COLOR_SCHEME_NAME)) names.insert(0, CUSTOM_COLOR_SCHEME_NAME) fieldnames = { "background": _("Background:"), "currentline": _("Current line:"), "occurence": _("Occurence:"), "ctrlclick": _("Link:"), "sideareas": _("Side areas:"), "matched_p": _("Matched parentheses:"), "unmatched_p": _("Unmatched parentheses:"), "normal": _("Normal text:"), "keyword": _("Keyword:"), "builtin": _("Builtin:"), "definition": _("Definition:"), "comment": _("Comment:"), "string": _("String:"), "number": _("Number:"), "instance": _("Instance:"), } from SMlib.widgets.sourcecode import syntaxhighlighters assert all([key in fieldnames for key in syntaxhighlighters.COLOR_SCHEME_KEYS]) for tabname in names: cs_group = QGroupBox(_("Color scheme")) cs_layout = QGridLayout() for row, key in enumerate(syntaxhighlighters.COLOR_SCHEME_KEYS): option = "%s/%s" % (tabname, key) value = self.get_option(option) name = fieldnames[key] if isinstance(value, basestring): label, clayout = self.create_coloredit(name, option, without_layout=True) label.setAlignment(Qt.AlignRight|Qt.AlignVCenter) cs_layout.addWidget(label, row+1, 0) cs_layout.addLayout(clayout, row+1, 1) else: label, clayout, cb_bold, cb_italic = self.create_scedit( name, option, without_layout=True) label.setAlignment(Qt.AlignRight|Qt.AlignVCenter) cs_layout.addWidget(label, row+1, 0) cs_layout.addLayout(clayout, row+1, 1) cs_layout.addWidget(cb_bold, row+1, 2) cs_layout.addWidget(cb_italic, row+1, 3) cs_group.setLayout(cs_layout) if tabname in sh.COLOR_SCHEME_NAMES: def_btn = self.create_button(_("Reset to default values"), lambda: self.reset_to_default(tabname)) tabs.addTab(self.create_tab(cs_group, def_btn), tabname) else: tabs.addTab(self.create_tab(cs_group), tabname) vlayout = QVBoxLayout() vlayout.addWidget(tabs) self.setLayout(vlayout)
def __init__(self, parent=None, fixedTime=''): self.fixedTime = fixedTime self.default_quote_font_size = 40 self.default_author_font_size = 37 self.min_font_size = 10 QWidget.__init__(self) #set up the main quote area self.stackIndex = 0 self.setObjectName("clockWidget") self.setStyleSheet(myStyleSheet) vlayout = QVBoxLayout() self.font = QFont() self.font.setFamily("Times") self.font.setPointSize(self.default_quote_font_size) self.font.setBold(False) self.font.setWeight(50) self.timeLabel = QTextEdit() self.timeLabel.setFixedSize(750, 340) # 400) self.timeLabel.setFont(self.font) self.timeLabel.setObjectName("timeLabel") self.timeLabel.setText("Some great quote goes here!") self.timeLabel.setReadOnly(True) self.timeLabel.mousePressEvent = self.toggleStack self.timeLabel.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) #we make this a stack widget so we can display the quit button and quote, dialog boxes are ugly with full screen apps self.stack = QStackedWidget() self.stack.addWidget(self.timeLabel) self.quitWidget = quitW() self.stack.addWidget(self.quitWidget) self.stack.setCurrentIndex(self.stackIndex) vlayout.addWidget(self.stack) #set up the author area self.authLabel = QTextEdit() self.authLabel.setFixedSize(680, 81) self.fonta = QFont() self.fonta.setFamily("Times") self.fonta.setPointSize(self.default_author_font_size) self.authLabel.setFont(self.fonta) self.authLabel.setObjectName("authorLabel") self.authLabel.setText("Title, Author") self.authLabel.setAlignment(Qt.AlignRight) self.authLabel.setReadOnly(True) self.authLabel.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) vlayout.addWidget(self.authLabel) #add the layouts to the widget mainLayout = QGridLayout() mainLayout.addLayout(vlayout, 0, 1) self.setLayout(mainLayout) self.loadData() #set up the timer to run every second self.timer = QTimer(self) self.timer.timeout.connect(self.Time) self.currentMin = 61 #to ensure it triggers time diff check at start up self.Time() self.timer.start(1000)
def __init__(self): QWizardPage.__init__(self) self.setTitle('New Project Data') self.setSubTitle( 'Complete the following fields to create the Project Structure') g_box = QGridLayout(self) #Names of the blanks to complete self.lbl_Name = QLabel('New Project Name:') self.lbl_Place = QLabel('Project Location:') self.lbl_Folder = QLabel('Projet Folder:') self.lbl_Description = QLabel('Project Description:') self.lbl_License = QLabel('Project License:') g_box.addWidget(self.lbl_Name, 0, 0, Qt.AlignRight) g_box.addWidget(self.lbl_Place, 1, 0, Qt.AlignRight) g_box.addWidget(self.lbl_Folder, 2, 0, Qt.AlignRight) g_box.addWidget(self.lbl_Description, 3, 0, Qt.AlignTop) g_box.addWidget(self.lbl_License, 4, 0, Qt.AlignRight) #Blanks on de right of the grid self.txtName = QLineEdit() self.registerField('projectName*', self.txtName) #Here comes a LineEdit and a PushButton in a HBoxLayout h_Place = QHBoxLayout() self.txtPlace = QLineEdit() self.txtPlace.setReadOnly(True) self.registerField('place*', self.txtPlace) self.btnExamine = QPushButton('Examine...') h_Place.addWidget(self.txtPlace) h_Place.addWidget(self.btnExamine) #Now lets continue with the rest self.txtFolder = QLineEdit() self.txtDescription = QPlainTextEdit() self.cboLicense = QComboBox() self.cboLicense.setFixedWidth(250) self.cboLicense.addItem('Apache License 2.0') self.cboLicense.addItem('Artistic License/GPL') self.cboLicense.addItem('Eclipse Public License 1.0') self.cboLicense.addItem('GNU General Public License v2') self.cboLicense.addItem('GNU General Public License v3') self.cboLicense.addItem('GNU Lesser General Public License') self.cboLicense.addItem('MIT License') self.cboLicense.addItem('Mozilla Public License 1.1') self.cboLicense.addItem('New BSD License') self.cboLicense.addItem('Other Open Source') self.cboLicense.addItem('Other') self.cboLicense.setCurrentIndex(4) g_box.addWidget(self.txtName, 0, 1) g_box.addLayout(h_Place, 1, 1) g_box.addWidget(self.txtFolder, 2, 1) g_box.addWidget(self.txtDescription, 3, 1) g_box.addWidget(self.cboLicense, 4, 1) #Signal self.connect(self.btnExamine, SIGNAL('clicked()'), self.load_folder)
def __init__(self): QMainWindow.__init__(self) layout = QGridLayout(self) layout.setMargin(2) btnFiles = QPushButton(u'Файлы', self) btnVideo = QPushButton(u'Видео', self) btnPlay = QPushButton(u'Play/Pause', self) btnStop = QPushButton(u'Stop', self) btnMute = QPushButton(u'Mute', self) btnMute.setCheckable(True) btnMainMenu = QPushButton(u'Main', self) self.sldVolume = QSlider(Qt.Vertical, self) self.sldPosition = QSlider(Qt.Horizontal, self) self.layMain = QStackedLayout() btnFiles.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) btnVideo.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) btnPlay.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) btnStop.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) btnMute.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) btnMainMenu.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.sldVolume.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding) self.sldPosition.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) layout.addWidget(btnFiles, 0, 0) layout.addWidget(btnVideo, 0, 1) layout.addWidget(btnPlay, 0, 3) layout.addWidget(btnStop, 0, 4) layout.addWidget(btnMute, 0, 5) layout.addWidget(btnMainMenu, 2, 5) layout.addWidget(self.sldVolume, 1, 5) layout.addWidget(self.sldPosition, 2, 0, 1, 5) layout.addLayout(self.layMain, 1, 0, 1, 5) fileBrowser = CFileBrowser(self) self.videoWidget = QWidget(self) self.exitMenu = CExitMenu(self) self.mplayer = MPlayerControl(self, self.videoWidget) fileBrowser.chosen.connect(self.startPlay) btnFiles.clicked.connect(lambda: self.selectMode(0)) btnVideo.clicked.connect(lambda: self.selectMode(1)) btnMainMenu.clicked.connect(lambda: self.selectMode(2)) self.sldPosition.valueChanged.connect(self.mplayer.seek) self.sldVolume.valueChanged.connect(self.mplayer.setvol) btnMute.clicked.connect(lambda: self.mplayer.mute(btnMute.isChecked())) btnPlay.clicked.connect(self.mplayer.play) btnStop.clicked.connect(self.mplayer.stop) self.sldVolume.setValue(QtGui.qApp.settings['volume']) self.mplayer.percent_position.connect(self.on_mplayer_position) self.layMain.addWidget(fileBrowser) self.layMain.addWidget(self.videoWidget) self.layMain.addWidget(self.exitMenu)
def __init__(self): QWizardPage.__init__(self) self.setTitle('New Project Data') self.setSubTitle('Complete the following fields to create the Project Structure') g_box = QGridLayout(self) #Names of the blanks to complete self.lbl_Name = QLabel('New Project Name:') self.lbl_Place = QLabel('Project Location:') self.lbl_Folder = QLabel('Projet Folder:') self.lbl_Description = QLabel('Project Description:') self.lbl_License = QLabel('Project License:') g_box.addWidget(self.lbl_Name, 0, 0,Qt.AlignRight) g_box.addWidget(self.lbl_Place, 1, 0,Qt.AlignRight) g_box.addWidget(self.lbl_Folder, 2, 0,Qt.AlignRight) g_box.addWidget(self.lbl_Description, 3, 0,Qt.AlignTop) g_box.addWidget(self.lbl_License, 4, 0,Qt.AlignRight) #Blanks on de right of the grid self.txtName = QLineEdit() self.registerField('projectName*', self.txtName) #Here comes a LineEdit and a PushButton in a HBoxLayout h_Place = QHBoxLayout() self.txtPlace = QLineEdit() self.txtPlace.setReadOnly(True) self.registerField('place*', self.txtPlace) self.btnExamine = QPushButton('Examine...') h_Place.addWidget(self.txtPlace) h_Place.addWidget(self.btnExamine) #Now lets continue with the rest self.txtFolder = QLineEdit() self.txtDescription = QPlainTextEdit() self.cboLicense = QComboBox() self.cboLicense.setFixedWidth(250) self.cboLicense.addItem('Apache License 2.0') self.cboLicense.addItem('Artistic License/GPL') self.cboLicense.addItem('Eclipse Public License 1.0') self.cboLicense.addItem('GNU General Public License v2') self.cboLicense.addItem('GNU General Public License v3') self.cboLicense.addItem('GNU Lesser General Public License') self.cboLicense.addItem('MIT License') self.cboLicense.addItem('Mozilla Public License 1.1') self.cboLicense.addItem('New BSD License') self.cboLicense.addItem('Other Open Source') self.cboLicense.addItem('Other') self.cboLicense.setCurrentIndex(4) g_box.addWidget(self.txtName, 0,1) g_box.addLayout(h_Place, 1, 1) g_box.addWidget(self.txtFolder, 2,1) g_box.addWidget(self.txtDescription, 3,1) g_box.addWidget(self.cboLicense, 4,1) #Signal self.connect(self.btnExamine, SIGNAL('clicked()'), self.load_folder)
def setupUi(self, option): option.setWindowTitle(QApplication.translate("option", "Option")) main_layout = QGridLayout(option) main_layout.setSpacing(5) main_layout.setContentsMargins(10, 10, 10, 10) main_layout.setColumnStretch(1, 1) self.list_option = self.createListOption() main_layout.addWidget(self.list_option, 0, 0) self.page_container = QStackedLayout() self.page_container.setContentsMargins(0, 0, 0, 0) main_layout.addLayout(self.page_container, 0, 1) self.populatePages() main_layout.addWidget(self.createLine(), 1, 0, 1, 2) close_layout = QHBoxLayout() close_layout.setContentsMargins(0, 0, 5, 0) close_layout.setSpacing(5) close_option = QPushButton() close_option.setText(QApplication.translate("option", "Close")) option.connect(close_option, QtCore.SIGNAL("clicked()"), option.accept) close_layout.addWidget(close_option) main_layout.addLayout(close_layout, 2, 1, 1, 2, Qt.AlignRight) self.list_option.setCurrentRow(0) self.page_container.setCurrentIndex(0) option.setTabOrder(self.list_option, self.list_conn) option.setTabOrder(self.list_conn, self.name_conn) option.setTabOrder(self.name_conn, self.host_conn) option.setTabOrder(self.host_conn, self.port_conn) option.setTabOrder(self.port_conn, self.save_conn) option.setTabOrder(self.save_conn, self.delete_conn) option.setTabOrder(self.delete_conn, self.list_conn_account) option.setTabOrder(self.list_conn_account, self.list_account) option.setTabOrder(self.list_account, self.delete_account) option.setTabOrder(self.delete_account, self.list_conn_alias) option.setTabOrder(self.list_conn_alias, self.list_alias) option.setTabOrder(self.list_alias, self.label_alias) option.setTabOrder(self.label_alias, self.body_alias) option.setTabOrder(self.body_alias, self.save_alias) option.setTabOrder(self.save_alias, self.delete_alias) option.setTabOrder(self.delete_alias, self.list_conn_macro) option.setTabOrder(self.list_conn_macro, self.list_macro) option.setTabOrder(self.list_macro, self.register_macro) option.setTabOrder(self.register_macro, self.keys_macro) option.setTabOrder(self.keys_macro, self.command_macro) option.setTabOrder(self.command_macro, self.save_macro) option.setTabOrder(self.save_macro, self.delete_macro) option.setTabOrder(self.delete_macro, self.echo_color_button) option.setTabOrder(self.echo_color_button, self.save_log)
def __init__(self, parent=None): QPushButton.__init__(self) vlayout = QVBoxLayout() self.button = QPushButton('Quit?') self.font = QFont() self.font.setFamily("Times") self.font.setPointSize(40) self.font.setBold(False) self.button.setFont(self.font) vlayout.addWidget(self.button) mainLayout = QGridLayout() mainLayout.addLayout(vlayout, 0, 1) self.setLayout(mainLayout)
def initUI(self): grid = QGridLayout() sub_vbox = QVBoxLayout() sub_vbox.addWidget(InformationWidget()) sub_vbox.addWidget(BasisTypeWidget()) sub_vbox.addWidget(TargetSpaceWidget()) sub_vbox.addWidget(StopingCriteriumWidget()) sub_vbox.addWidget(QWidget()) grid.addLayout(sub_vbox, 0, 0, 0, 2) grid.addWidget(OrbitalWidget(), 0, 2) self.setLayout(grid) self.setWindowTitle("Group Box") self.resize(480, 320)
def layoutMetronomeWidget(self, layout): grid = QGridLayout() grid.addWidget(self.metronomeLabel, 0, 0) box = QHBoxLayout(spacing=0) box.addWidget(self.metronomeNote) box.addWidget(self.metronomeEqualSign) box.addWidget(self.metronomeValue) box.addWidget(self.metronomeTempo) grid.addLayout(box, 0, 1) grid.addWidget(self.metronomeRound, 1, 1) layout.addLayout(grid)
def layoutMetronomeWidget(self, layout): grid = QGridLayout() grid.addWidget(self.metronomeLabel, 0, 0) box = QHBoxLayout(spacing=0) box.addWidget(self.metronomeNote) box.addWidget(self.metronomeEqualSign) box.addWidget(self.metronomeValue) box.addWidget(self.metronomeTempo) grid.addLayout(box, 0, 1) grid.addWidget(self.metronomeRound, 1, 1) layout.addLayout(grid)
def __init__(self, parent): QDialog.__init__(self, parent, Qt.Dialog) self.setWindowTitle('NINJA - Preferences') self.setMaximumSize(QSize(0,0)) self.setModal(True) main_box = QVBoxLayout(self) self.GeneralTab = TabGeneral() self.EditTab = TabEdit() self.ColorsTab = TabColors() self.InterfaceTab = TabInterface(parent) self.CSSTab = TabCSS() self.TemplatesTab = TabTemplates() self.Tabs = QTabWidget() self.Tabs.setTabPosition(2) self.Tabs.setMovable(False) #Tabs self.Tabs.addTab(self.GeneralTab, "General") #self.Tabs.addTab(self.EditTab, "Edit") #self.Tabs.addTab(self.ColorsTab, "Colors") self.Tabs.addTab(self.InterfaceTab, "Interface") #self.Tabs.addTab(self.CSSTab, "CSS") #self.Tabs.addTab(self.TemplatesTab, "Templates") #Footer Buttons self.btn_save = QPushButton('&Save') self.btn_cancel = QPushButton('&Cancel') h_footer = QHBoxLayout() h_footer.addWidget(self.btn_save) h_footer.addWidget(self.btn_cancel) g_footer = QGridLayout() g_footer.addLayout(h_footer, 0, 0, Qt.AlignRight) main_box.addWidget(self.Tabs) main_box.addLayout(g_footer) def save_changes(): self.GeneralTab.save_state() self.InterfaceTab.save_state(parent) self.close() def cancel_changes(): parent.reload_panels_position() self.close() #SIGNAL self.connect(self.btn_cancel, SIGNAL("clicked()"), cancel_changes) self.connect(self.btn_save, SIGNAL("clicked()"), save_changes)
def __init__(self, parent): QWidget.__init__(self, parent) self.parent = parent self.feuille = parent.feuille gbs = QGridLayout() gbs.setSpacing(10) gbs.addWidget(QLabel(u"Titre : "), 1, 1) self.titre = titre = QLineEdit(self) titre.setText(self.feuille.infos("titre")) titre.setMinimumWidth(300) gbs.addWidget(titre, 1, 2) gbs.addWidget(QLabel(u"Auteur : "), 2, 1) self.auteur = auteur = QLineEdit(self) auteur.setText(self.feuille.infos("auteur")) auteur.setMinimumWidth(300) gbs.addWidget(auteur, 2, 2) gbs.addWidget(QLabel(u"Version : "), 3, 1) self.version = version = QLineEdit(self) version.setText(self.feuille.infos("version")) version.setMinimumWidth(300) gbs.addWidget(version, 3, 2) gbs.addWidget(QLabel(u"Resumé : "), 4, 1) self.resume = resume = QTextEdit(self) resume.setPlainText(self.feuille.infos("resume")) resume.setMinimumSize(300, 50) gbs.addWidget(resume, 4, 2) gbs.addWidget(QLabel(u"Notes : "), 5, 1) self.notes = notes = QTextEdit(self) notes.setPlainText(self.feuille.infos("notes")) notes.setMinimumSize(300, 100) gbs.addWidget(notes, 5, 2) boutons = QGridLayout() boutons.setSpacing(10) ok = QPushButton(u'OK', clicked=self.ok) appliquer = QPushButton(u"Appliquer", clicked=self.appliquer) effacer = QPushButton(u"Effacer", clicked=self.effacer) annuler = QPushButton(u"Annuler", clicked=self.parent.parent.close) boutons.addWidget(ok, 1, 0) boutons.addWidget(appliquer, 1, 1) boutons.addWidget(effacer, 1, 2) boutons.addWidget(annuler, 1, 3) gbs.addLayout(boutons, 6, 2) self.setLayout(gbs)
def __init__(self, parent): QDialog.__init__(self, parent, Qt.Dialog) self.setWindowTitle('NINJA - Preferences') self.setMaximumSize(QSize(0, 0)) self.setModal(True) main_box = QVBoxLayout(self) self.GeneralTab = TabGeneral() self.EditTab = TabEdit() self.ColorsTab = TabColors() self.InterfaceTab = TabInterface(parent) self.CSSTab = TabCSS() self.TemplatesTab = TabTemplates() self.Tabs = QTabWidget() self.Tabs.setTabPosition(2) self.Tabs.setMovable(False) #Tabs self.Tabs.addTab(self.GeneralTab, "General") #self.Tabs.addTab(self.EditTab, "Edit") #self.Tabs.addTab(self.ColorsTab, "Colors") self.Tabs.addTab(self.InterfaceTab, "Interface") #self.Tabs.addTab(self.CSSTab, "CSS") #self.Tabs.addTab(self.TemplatesTab, "Templates") #Footer Buttons self.btn_save = QPushButton('&Save') self.btn_cancel = QPushButton('&Cancel') h_footer = QHBoxLayout() h_footer.addWidget(self.btn_save) h_footer.addWidget(self.btn_cancel) g_footer = QGridLayout() g_footer.addLayout(h_footer, 0, 0, Qt.AlignRight) main_box.addWidget(self.Tabs) main_box.addLayout(g_footer) def save_changes(): self.GeneralTab.save_state() self.InterfaceTab.save_state(parent) self.close() def cancel_changes(): parent.reload_panels_position() self.close() #SIGNAL self.connect(self.btn_cancel, SIGNAL("clicked()"), cancel_changes) self.connect(self.btn_save, SIGNAL("clicked()"), save_changes)
def __init__(self, parent = None): super(Form, self).__init__(parent) data = self.getData() self.tags = data[0] self.yan = data[1] self.give_copy_imformation = 1 self.tag_label = QLabel(u"&tag") self.LineEdit = QLineEdit() self.tag_label.setBuddy(self.LineEdit) self.LineEdit2 = QLineEdit() self.LineEdit2.setVisible(False) self.yan_label = QLabel(u'&yan') self.yan_ComboBox = QComboBox() self.yan_label.setBuddy(self.yan_ComboBox) self.tag_ComboBox = QComboBox() editlayout = QHBoxLayout() editlayout.addWidget(self.LineEdit) editlayout.addWidget(self.LineEdit2) layout = QGridLayout() layout.addWidget(self.tag_label, 0, 0) layout.addLayout(editlayout, 0, 1) layout.addWidget(self.tag_ComboBox, 1, 1) layout.addWidget(self.yan_label, 2, 0) layout.addWidget(self.yan_ComboBox, 2, 1) self.tag_ComboBox.addItems(self.tags) self.setLayout(layout) self.setWindowTitle(u"o3o") self.setWindowIcon(QIcon('o3o.ico')) self.setWindowFlags(Qt.WindowMinimizeButtonHint | Qt.WindowMaximizeButtonHint) self.set_yan_combobox() self.connect(self.LineEdit, SIGNAL("textChanged(QString)"), self.set_tag_combobox) self.connect(self.tag_ComboBox, SIGNAL("activated(QString)"), self.set_yan_combobox) self.connect(self.tag_ComboBox, SIGNAL("currentIndexChanged(QString)"), self.set_yan_combobox) self.connect(self.yan_ComboBox, SIGNAL("activated(QString)"), self.copy_text) self.connect(self.yan_ComboBox, SIGNAL("currentIndexChanged(QString)"), self.copy_text) self.connect(self.LineEdit, SIGNAL("returnPressed()"), self.popup)
def __init__(self,Depth = None,Pressure = None, Temperature = None,usercontrol=None,fo=None,mgwa=None,mgri=None): super(iron_profile,self).__init__() self.Depth = np.array(Depth) self.Pressure = np.array(Pressure) self.Temperature = np.array(Temperature) self.OL_iron = fo self.WA_iron = mgwa self.RI_iron = mgri self.usercontrol=usercontrol self.OL_function = self.usercontrol['OL_function'] self.WA_function = self.usercontrol['WA_function'] self.RI_function = self.usercontrol['RI_function'] self.figure = Figure(dpi=200) self.ax = self.figure.add_subplot(111) self.canvas = FigureCanvas(self.figure) self.toolbar = NavigationToolbar(self.canvas, self) layout_main = QGridLayout() layout_main.addWidget(self.canvas,0,0,1,1) layout_main.addWidget(self.toolbar,1,0,1,1) self.BTN_layout() self.iron_funtion() layout_main.addLayout(self.layout_BTN,2,0,1,1) self.LAYOUT = QGridLayout() self.LAYOUT.addLayout(self.layout_control,0,0,1,1) self.LAYOUT.addLayout(layout_main,0,1,1,1) self.setLayout(self.LAYOUT) for i in range(len(self.Depth)): if self.Depth[i] >=410: n1=i break for i in range(n1,len(self.Depth)): if self.Depth[i] >=520: n2=i break #print (n1,n2) self.ax.plot(self.Depth[0:n1],self.OL_iron[0:n1]*100,'b') self.ax.plot(self.Depth[n1:n2],self.WA_iron[n1:n2]*100,'r') self.ax.plot(self.Depth[n2:],self.RI_iron[n2:]*100,'y') self.ax.set_ylim(-1,101) self.ax.set_xlabel('Depth (km)', fontname="Times New Roman",fontsize=10) self.ax.set_ylabel('iron content (fo number)', fontname="Times New Roman",fontsize=10) self.canvas.draw()
class CombinedValueRangeWidget(QWidget): def __init__(self, parent = None): super(CombinedValueRangeWidget, self).__init__(parent) self.roiWidgets = [] self.roiLayout = QGridLayout(self) self.setLayout(self.roiLayout) hbox = QHBoxLayout() hbox.addWidget(QLabel("min"),0,Qt.Alignment(Qt.AlignLeft)) hbox.addWidget(QLabel("max"),0,Qt.Alignment(Qt.AlignLeft)) self.roiLayout.addLayout(hbox, 0,1) self.roiLayout.addWidget(QLabel("Export Full Range"), 0, 2) self.roiLayout.addItem(QSpacerItem(0,0,QSizePolicy.Expanding, QSizePolicy.Minimum),0,3) self.roiCheckBoxes = [] self.setFocusPolicy(Qt.TabFocus) self.lastInChain = super(CombinedValueRangeWidget, self).nextInFocusChain() def addRanges(self, keys, extents): for key, extent in zip(keys, extents): w = ValueRangeWidget(self) w.setFocusPolicy(Qt.TabFocus) w.setDType(numpy.uint32) w.setValues(0,extent) w.setLimits(0,extent) #w.setLabels("min:","max:") self.roiWidgets.append(w) row = self.roiLayout.rowCount() align = Qt.Alignment(Qt.AlignLeft) check = QCheckBox() self.roiCheckBoxes.append(check) check.setChecked(True) check.setFocusPolicy(Qt.ClickFocus) w.changedSignal.connect(partial(check.setChecked,False)) if extent == 1: w.setEnabled(False) check.toggled.connect(partial(check.setChecked, True)) #w.setBackgroundColor("gray", [0,1]) self.roiLayout.addWidget(QLabel(key + ": "),row, 0, align) self.roiLayout.addWidget(self.roiWidgets[-1],row, 1, align) self.roiLayout.addWidget(check,row, 2, align) def focusInEvent(self, QFocusEvent): if len(self.roiWidgets) > 0: self.roiWidgets[0].setFocus()
def layout_widgets(self): hLayoutButton = QHBoxLayout() hLayoutButton.addWidget(self.buttonBox) hLayoutButton.addStretch() vLayoutSettingsLeft = QVBoxLayout() vLayoutSettingsLeft.addWidget(self.TableLabel1) vLayoutSettingsLeft.addWidget(self.ListOfSettings) #yara setting frame layout frameLayout = QGridLayout() frameLayout.addWidget(self.labelRulesPath, 0, 0) frameLayout.addWidget(self.inputRulesPath, 0, 1) self.yaraSettingFrame.setLayout(frameLayout) #foo settings frame frameLayoutFoo = QGridLayout() frameLayoutFoo.addWidget(self.labelFoo, 0, 0) frameLayoutFoo.addWidget(self.inputDumpDirPath, 0, 1) self.dump_dirSettingFrame.setLayout(frameLayoutFoo) #bar settings frame frameLayoutBar = QVBoxLayout() frameLayoutBar.addWidget(self.labelBar) self.barSettingFrame.setLayout(frameLayoutBar) settingWindowsLayout = QGridLayout() settingWindowsLayout.addLayout(vLayoutSettingsLeft, 0, 0) settingWindowsLayout.addWidget(self.yaraSettingFrame, 0, 1) settingWindowsLayout.addWidget(self.dump_dirSettingFrame, 0, 1) settingWindowsLayout.addWidget(self.barSettingFrame, 0, 1) settingWindowsLayout.addLayout(hLayoutButton, 1, 0) ''' ################################################# <-| # vbox # vbox # | # listOption# yaraframe # | grid # # # | # # # | ################################################# | # vbox button # | ################################################# <-| ''' self.setLayout(settingWindowsLayout)
def __init__(self, settings, parent=None): super(SettingsDialog, self).__init__(parent) self.settings = settings self.setWindowTitle('Settings') layout = QVBoxLayout() settings_layout = QGridLayout() username_label = QLabel('Username:'******'Password:'******'Deck:') settings_layout.addWidget(deck_label, 2, 0) self.deck_edit = QLineEdit() settings_layout.addWidget(self.deck_edit, 2, 1) moc_label = QLabel('Minimize on close:') settings_layout.addWidget(moc_label, 3, 0) moc_layout = QHBoxLayout() self.moc_radio_button = QRadioButton('Yes', self) moc_layout.addWidget(self.moc_radio_button) self.nomoc_radio_button = QRadioButton('No', self) moc_layout.addWidget(self.nomoc_radio_button) settings_layout.addLayout(moc_layout, 3, 1) layout.addLayout(settings_layout) button_layout = QHBoxLayout() accept_button = QPushButton('&Accept') accept_button.clicked.connect(self.accept) button_layout.addWidget(accept_button) reject_button = QPushButton('&Cancel') reject_button.clicked.connect(self.reject) button_layout.addWidget(reject_button) layout.addLayout(button_layout) self.setLayout(layout)
def __init__(self): super(NewSessionPagePermutations, self).__init__() self.setTitle(_('Configuration of permutations')) self.setSubTitle(_('Select the position of each question' ' and its choices in every model of the exam.')) layout = QGridLayout() self.question_list = QListWidget() self.permutation_grid = QGridLayout() self.alternatives_rows = {} layout.addWidget(QLabel(_('Questions of model A')), 0, 0, 1, 1) layout.addWidget(self.question_list, 1, 0, 1, 1) layout.addWidget(QLabel(_('Model equivalence')), 0, 1, 1, 5) self.permutation_grid.setVerticalSpacing(20) layout.addLayout(self.permutation_grid, 1, 1, 1, 5) layout.setColumnStretch(0, 1) layout.setColumnStretch(1, 5) self.setLayout(layout)
def __init__(self, parent=None): super(NewTaskDialog, self).__init__(parent) # task name nameLabel = QLabel(self.tr("Name:")) self.name = QLineEdit() nameLabel.setBuddy(self.name) # priority priorityLabel = QLabel(self.tr("Priority:")) self.priority = QComboBox() priorityLabel.setBuddy(self.priority) dateLabel = QLabel(self.tr("Deadline:")) self.deadline = QDateEdit() dateLabel.setBuddy(self.deadline) self.deadline.setCalendarPopup(True) self.deadline.calendarWidget().setFirstDayOfWeek(Qt.Monday) self.deadline.setDate(QDate(date.today())) createButton = QPushButton(self.tr("Save")) cancelButton = QPushButton(self.tr("Cancel")) buttonLayout = QHBoxLayout() buttonLayout.addStretch() buttonLayout.addWidget(createButton) buttonLayout.addWidget(cancelButton) layout = QGridLayout() layout.addWidget(nameLabel, 0, 0) layout.addWidget(self.name, 0, 1) layout.addWidget(priorityLabel, 1, 0) layout.addWidget(self.priority, 1, 1) layout.addWidget(dateLabel, 2, 0) layout.addWidget(self.deadline, 2, 1) layout.addLayout(buttonLayout, 3, 0, 3, 2) self.setLayout(layout) self.connect(self.deadline, SIGNAL("dateChanged(const QDate&)"), self, SLOT("changed()")) self.connect(createButton, SIGNAL("clicked()"), self, SLOT("accept()")) self.connect(cancelButton, SIGNAL("clicked()"), self, SLOT("reject()")) self.setWindowTitle(self.tr("Task")) self.resize(350, 120) self.setMinimumSize(QSize(250, 120)) self.setMaximumSize(QSize(450, 120))
def __init__(self): super(NewSessionPagePermutations, self).__init__() self.setTitle(_('Configuration of permutations')) self.setSubTitle(_('Select the position of each question' ' and its choices in every model of the exam.')) layout = QGridLayout() self.question_list = QListWidget() self.permutation_grid = QGridLayout() self.alternatives_rows = {} layout.addWidget(QLabel(_('Questions of model A')), 0, 0, 1, 1) layout.addWidget(self.question_list, 1, 0, 1, 1) layout.addWidget(QLabel(_('Model equivalence')), 0, 1, 1, 5) self.permutation_grid.setVerticalSpacing(20) layout.addLayout(self.permutation_grid, 1, 1, 1, 5) layout.setColumnStretch(0, 1) layout.setColumnStretch(1, 5) self.setLayout(layout)
def __init__(self, parent=None, fixedTime=''): super(Form, self).__init__(parent) self.showFullScreen() self.setObjectName("MainWindow") self.resize(800, 480) self.setMaximumSize(QSize(800, 480)) self.setStyleSheet(myStyleSheet) vlayout = QVBoxLayout() self.quitButton = QPushButton() self.quitButton.setFixedSize(20, 20) self.quitButton.setText("Quit") self.clock = clockWidget(fixedTime=fixedTime) vlayout.addWidget(self.clock) mainLayout = QGridLayout() mainLayout.addLayout(vlayout, 0, 1) self.setLayout(mainLayout)
def initUI(self): self.setWindowTitle(APPNAME) file_menu = self.menuBar().addMenu('File') new_proj_action = create_action(self, 'New Project', self.new_project) open_proj_action = create_action(self, 'Open Project', self.open_project) import_orosMat_action = create_action(self, 'Import Oros Mat', self.import_orosMat) quit_action = create_action(self, 'Quit', self.quit) add_actions(file_menu, (new_proj_action, open_proj_action, None, import_orosMat_action, None, quit_action)) progress_bar = QProgressBar(self) progress_bar.setFixedWidth(200) progress_bar.setTextVisible(False) progress_bar.setVisible(False) self.progress_bar = progress_bar self.statusBar().addPermanentWidget(progress_bar) self.toolBar = self.addToolBar('Curves') main_widget = QWidget(self) main_layout = QGridLayout(main_widget) side_layout = QGridLayout() plot_widget = PlotWidget(main_widget) self.plot_widget = plot_widget list_widget = ListWidget() prop_widget = PropertyWidget() list_widget.registerPropertyWindow(prop_widget) side_layout.addWidget(list_widget, 0, 0) side_layout.addWidget(prop_widget, 1, 0) side_layout.setRowStretch(0, 2) side_layout.setRowStretch(1, 1) self.list_widget = list_widget main_layout.addLayout(side_layout, 0, 0) main_layout.addWidget(plot_widget, 0, 1) main_layout.setColumnStretch(0, 1) main_layout.setColumnStretch(1, 3) self.setCentralWidget(main_widget)
def __init__(self, parent=None, date=None): if date: self.date = date else: self.date = datetime.date.today() super(MonthFullWidget, self).__init__(parent) self.button_left = None self.button_right = None self.month_title = None self.month_widget = None self.title_layout = self._month_title_layout() self.cal_layout = self._month_cal_layout() grid_layout = QGridLayout() grid_layout.addLayout(self.title_layout, 0, 0) grid_layout.addLayout(self.cal_layout, 30, 0) self.setLayout(grid_layout) self._connections()
def set_layouts(self): self._vlayout = QVBoxLayout() self._vlayout.setSpacing(0) self._vlayout.setContentsMargins(0, 0, 0, 0) banner_layout = QGridLayout() banner_layout.setColumnStretch(0, 1) banner_layout.addWidget(QLabel(), 0, 1, Qt.AlignRight) banner_layout.addLayout(QVBoxLayout(), 0, 0) # TODO: allow banner widget to be supplied banner_widget = QWidget() banner_widget.setLayout(banner_layout) self._vlayout.addWidget(banner_widget) self._vlayout.addWidget(HSeparator()) self._vlayout.addWidget(QFrame(), 1) self._vlayout.addWidget(HSeparator()) self._vlayout.addWidget(QWidget()) self.setLayout(self._vlayout)
def set_layouts(self): self._vlayout = QVBoxLayout() self._vlayout.setSpacing(0) self._vlayout.setContentsMargins(0,0,0,0) banner_layout = QGridLayout() banner_layout.setColumnStretch(0, 1) banner_layout.addWidget(QLabel(), 0, 1, Qt.AlignRight) banner_layout.addLayout(QVBoxLayout(), 0, 0) # TODO: allow banner widget to be supplied banner_widget = QWidget() banner_widget.setLayout(banner_layout) self._vlayout.addWidget(banner_widget) self._vlayout.addWidget(HSeparator()) self._vlayout.addWidget(QFrame(), 1) self._vlayout.addWidget(HSeparator()) self._vlayout.addWidget(QWidget()) self.setLayout(self._vlayout)
def __init__(self, game): QWidget.__init__(self, None) self.game = None self.setWindowTitle(m18n('Scoring for this Hand') + ' - Kajongg') self.nameLabels = [None] * 4 self.spValues = [None] * 4 self.windLabels = [None] * 4 self.wonBoxes = [None] * 4 self.detailsLayout = [None] * 4 self.details = [None] * 4 self.__tilePixMaps = [] self.__meldPixMaps = [] grid = QGridLayout(self) pGrid = QGridLayout() grid.addLayout(pGrid, 0, 0, 2, 1) pGrid.addWidget(QLabel(m18nc('kajongg', "Player")), 0, 0) pGrid.addWidget(QLabel(m18nc('kajongg', "Wind")), 0, 1) pGrid.addWidget(QLabel(m18nc('kajongg', 'Score')), 0, 2) pGrid.addWidget(QLabel(m18n("Winner")), 0, 3) self.detailTabs = QTabWidget() self.detailTabs.setDocumentMode(True) pGrid.addWidget(self.detailTabs, 0, 4, 8, 1) for idx in range(4): self.setupUiForPlayer(pGrid, idx) self.draw = QCheckBox(m18nc('kajongg','Draw')) self.draw.clicked.connect(self.wonChanged) btnPenalties = QPushButton(m18n("&Penalties")) btnPenalties.clicked.connect(self.penalty) self.btnSave = QPushButton(m18n('&Save Hand')) self.btnSave.setEnabled(False) self.setupUILastTileMeld(pGrid) pGrid.setRowStretch(87, 10) pGrid.addWidget(self.draw, 7, 3) self.cbLastTile.currentIndexChanged.connect(self.slotLastTile) self.cbLastMeld.currentIndexChanged.connect(self.slotInputChanged) btnBox = QHBoxLayout() btnBox.addWidget(btnPenalties) btnBox.addWidget(self.btnSave) pGrid.addLayout(btnBox, 8, 4) StateSaver(self) self.refresh(game)
def add_to_grid(*items): """Add items to a QGrid layout easily. Keyword arguments: *items -- list with lists of items to be added. items in the same list will be added to the same line of grid. """ layout = QGridLayout() # for now it adds only 1 item per cell. for x, _list in enumerate(items): for y, item in enumerate(_list): if isinstance(item, QWidget): layout.addWidget(item, x, y) elif isinstance(item, QLayout): layout.addLayout(item, x, y) elif isinstance(item, QSpacerItem): layout.addItem(item, x, y) elif item is None: pass else: raise TypeError("Argument of wrong type!") return layout
def add_to_grid(*items): """Add items to a QGrid layout easily. Keyword arguments: *items -- list with lists of items to be added. items in the same list will be added to the same line of grid. """ layout = QGridLayout() # for now it adds only 1 item per cell. for x, _list in enumerate(items): for y, item in enumerate(_list): if isinstance(item, QWidget): layout.addWidget(item, x, y) elif isinstance(item, QLayout): layout.addLayout(item, x, y) elif isinstance(item, QSpacerItem): layout.addItem(item, x, y) elif item is None: pass else: raise TypeError("Argument of wrong type!") return layout
def main(): ''' >>> main() ''' app = QApplication(sys.argv) week = MonthWidget() wd = QWidget() button_left = QPushButton("<") button_left.setMaximumSize(20, 30) button_right = QPushButton(">") button_right.setMaximumSize(20, 30) font = QFont("Arial") font.setPointSize(18) font.setBold(True) month_title = QLabel('title') month_title.setFont(font) month_title.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) vlayout = QHBoxLayout() vlayout.addWidget(button_left) vlayout.addWidget(button_right) vlayout.addWidget(month_title, 0, Qt.AlignHCenter) layout = QHBoxLayout() layout.addWidget(week) grid_layout = QGridLayout() grid_layout.addLayout(vlayout, 0, 0) grid_layout.addLayout(layout, 30, 0) wd.setLayout(grid_layout) wd.show() sys.exit(app.exec_())
def __init__(self, parent=None): QDialog.__init__(self, parent) self.setWindowTitle(self.tr("NINJA-IDE - Preferences")) self.setModal(True) self.setMaximumSize(QSize(0, 0)) self.overlay = ui_tools.Overlay(self) self.overlay.hide() #Tabs vbox = QVBoxLayout(self) self._tabs = QTabWidget() self._tabs.setTabPosition(QTabWidget.West) self._tabs.setMovable(False) self._general = GeneralTab() self._interface = InterfaceTab(self) self._editor = EditorTab() self._plugins = plugin_preferences.PluginPreferences() self._tabs.addTab(self._general, self.tr("General")) self._tabs.addTab(self._interface, self.tr("Interface")) self._tabs.addTab(self._editor, self.tr("Editor")) self._tabs.addTab(self._plugins, self.tr("Plugins")) #Buttons (save-cancel) hbox = QHBoxLayout() self._btnSave = QPushButton(self.tr("Save")) self._btnCancel = QPushButton(self.tr("Cancel")) hbox = QHBoxLayout() hbox.addWidget(self._btnCancel) hbox.addWidget(self._btnSave) gridFooter = QGridLayout() gridFooter.addLayout(hbox, 0, 0, Qt.AlignRight) vbox.addWidget(self._tabs) vbox.addLayout(gridFooter) self.connect(self._btnSave, SIGNAL("clicked()"), self._save) self.connect(self._btnCancel, SIGNAL("clicked()"), self.close)
def setup_dynamically(self): font = QFont() font.setBold(False) lineEdit_list = [] Layout = QGridLayout() row = 0 col = 0 values = self.sheet.row_values(3, 1) for x in range(1, len(values)): if values[x-1] == "!": break else: cell = self.sheet.cell_value(1, x) tool_tip = self.sheet.cell_value(2, x) Layout2 = QVBoxLayout() label = QLabel(str(cell)) label.setFont(font) lineedit = QLineEdit() lineedit.setFont(font) lineedit.setToolTip(str(tool_tip)) lineedit.setEnabled(0) Layout2.addWidget(label) Layout2.addWidget(lineedit) vert_spacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Maximum) Layout2.addItem(vert_spacer) Layout.addLayout(Layout2, row, col) lineEdit_list.append(lineedit) if x > 0: if x % 5 == 0: row += 1 col = 0 vert_spacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Maximum) Layout.addItem(vert_spacer) else: col += 1 self.groupBox2.setLayout(Layout) return lineEdit_list
def __init__(self, Depth=None, Pressure=None, Temperature=None, usercontrol=None): super(water_profile, self).__init__() self.Depth = np.array(Depth) self.Pressure = np.array(Pressure) self.Temperature = np.array(Temperature) self.OL_water = np.ones(len(Depth)) self.WA_water = np.zeros(len(Depth)) self.RI_water = np.zeros(len(Depth)) self.usercontrol = usercontrol self.OL_function = self.usercontrol['OL_function'] self.WA_function = self.usercontrol['WA_function'] self.RI_function = self.usercontrol['RI_function'] self.OL = self.usercontrol['OLcoefficient'] self.WA = self.usercontrol['WAcoefficient'] self.RI = self.usercontrol['RIcoefficient'] self.figure = Figure(dpi=200) self.ax = self.figure.add_subplot(111) self.canvas = FigureCanvas(self.figure) self.toolbar = NavigationToolbar(self.canvas, self) layout_main = QGridLayout() layout_main.addWidget(self.canvas, 0, 0, 1, 1) layout_main.addWidget(self.toolbar, 1, 0, 1, 1) self.BTN_layout() self.water_funtion() layout_main.addLayout(self.layout_BTN, 2, 0, 1, 1) self.LAYOUT = QGridLayout() self.LAYOUT.addLayout(self.layout_control, 0, 0, 1, 1) self.LAYOUT.addLayout(layout_main, 0, 1, 1, 1) self.setLayout(self.LAYOUT) self.plot()
def __init__(self, main): QDialog.__init__(self, main) self.setWindowTitle('NINJA - Preferences') self.setMaximumSize(QSize(0, 0)) #self.setFixedWidth(600) self.setModal(True) self._main = main #Tabs vbox = QVBoxLayout(self) self.tabs = QTabWidget() self.tabs.setTabPosition(QTabWidget.West) self.tabs.setMovable(False) self.general = GeneralTab() self.interface = InterfaceTab(self._main) self.skins = SkinsTab() self.editor = EditorTab(self._main) self.tabs.addTab(self.general, 'General') self.tabs.addTab(self.interface, 'Interface') self.tabs.addTab(self.editor, 'Editor') self.tabs.addTab(self.skins, 'Skins') #Buttons (save-cancel) hbox = QHBoxLayout() self.btnSave = QPushButton('Save') self.btnCancel = QPushButton('Cancel') hbox = QHBoxLayout() hbox.addWidget(self.btnCancel) hbox.addWidget(self.btnSave) gridFooter = QGridLayout() gridFooter.addLayout(hbox, 0, 0, Qt.AlignRight) vbox.addWidget(self.tabs) vbox.addLayout(gridFooter) self.connect(self.btnSave, SIGNAL("clicked()"), self._save) self.connect(self.btnCancel, SIGNAL("clicked()"), self.close)
def __init__(self, main): QDialog.__init__(self, main) self.setWindowTitle('NINJA - Preferences') self.setMaximumSize(QSize(0, 0)) #self.setFixedWidth(600) self.setModal(True) self._main = main #Tabs vbox = QVBoxLayout(self) self.tabs = QTabWidget() self.tabs.setTabPosition(QTabWidget.West) self.tabs.setMovable(False) self.general = GeneralTab() self.interface = InterfaceTab(self._main) self.skins = SkinsTab() self.editor = EditorTab(self._main) self.tabs.addTab(self.general, 'General') self.tabs.addTab(self.interface, 'Interface') self.tabs.addTab(self.editor, 'Editor') self.tabs.addTab(self.skins, 'Skins') #Buttons (save-cancel) hbox = QHBoxLayout() self.btnSave = QPushButton('Save') self.btnCancel = QPushButton('Cancel') hbox = QHBoxLayout() hbox.addWidget(self.btnCancel) hbox.addWidget(self.btnSave) gridFooter = QGridLayout() gridFooter.addLayout(hbox, 0, 0, Qt.AlignRight) vbox.addWidget(self.tabs) vbox.addLayout(gridFooter) self.connect(self.btnSave, SIGNAL("clicked()"), self._save) self.connect(self.btnCancel, SIGNAL("clicked()"), self.close)
class DefaultSelectParameterWidget(SelectParameterWidget): """Widget class for Default Select Parameter.""" def __init__(self, parameter, parent=None): """Constructor :param parameter: A DefaultSelectParameter object. :type parameter: DefaultSelectParameter """ super(DefaultSelectParameterWidget, self).__init__(parameter, parent) self.default_layout = QHBoxLayout() self.radio_button_layout = QHBoxLayout() self.radio_button_widget = QWidget() self.default_label = QLabel(tr('Default')) # Create radio button group self.default_input_button_group = QButtonGroup() # Define string enabler for radio button self.radio_button_enabler = self.input.itemData(0, Qt.UserRole) for i in range(len(self._parameter.default_labels)): if '%s' in self._parameter.default_labels[i]: label = (self._parameter.default_labels[i] % self._parameter.default_values[i]) else: label = self._parameter.default_labels[i] radio_button = QRadioButton(label) self.radio_button_layout.addWidget(radio_button) self.default_input_button_group.addButton(radio_button, i) if self._parameter.default_value == \ self._parameter.default_values[i]: radio_button.setChecked(True) # Create double spin box for custom value self.custom_value = QDoubleSpinBox() if self._parameter.default_values[-1]: self.custom_value.setValue(self._parameter.default_values[-1]) has_min = False if self._parameter.minimum is not None: has_min = True self.custom_value.setMinimum(self._parameter.minimum) has_max = False if self._parameter.maximum is not None: has_max = True self.custom_value.setMaximum(self._parameter.maximum) if has_min and has_max: step = (self._parameter.maximum - self._parameter.minimum) / 100.0 self.custom_value.setSingleStep(step) self.radio_button_layout.addWidget(self.custom_value) self.toggle_custom_value() # Reset the layout self.input_layout.setParent(None) self.help_layout.setParent(None) self.label.setParent(None) self.inner_input_layout.setParent(None) self.input_layout = QGridLayout() self.input_layout.setSpacing(0) self.input_layout.addWidget(self.label, 0, 0) self.input_layout.addLayout(self.inner_input_layout, 0, 1) self.input_layout.addWidget(self.default_label, 1, 0) self.input_layout.addLayout(self.radio_button_layout, 1, 1) self.main_layout.addLayout(self.input_layout) self.main_layout.addLayout(self.help_layout) # check every added combobox, it could have been toggled by # the existing keyword self.toggle_input() # Connect # noinspection PyUnresolvedReferences self.input.currentIndexChanged.connect(self.toggle_input) self.default_input_button_group.buttonClicked.connect( self.toggle_custom_value) def raise_invalid_type_exception(self): message = 'Expecting element type of %s' % ( self._parameter.element_type.__name__) err = ValueError(message) return err def get_parameter(self): """Obtain list parameter object from the current widget state. :returns: A DefaultSelectParameter from the current state of widget. """ current_index = self.input.currentIndex() selected_value = self.input.itemData(current_index, Qt.UserRole) if hasattr(selected_value, 'toPyObject'): selected_value = selected_value.toPyObject() try: self._parameter.value = selected_value except ValueError: err = self.raise_invalid_type_exception() raise err radio_button_checked_id = self.default_input_button_group.checkedId() # No radio button checked, then default value = None if radio_button_checked_id == -1: self._parameter.default = None # The last radio button (custom) is checked, get the value from the # line edit elif (radio_button_checked_id == len(self._parameter.default_values) - 1): self._parameter.default_values[radio_button_checked_id] \ = self.custom_value.value() self._parameter.default = self.custom_value.value() else: self._parameter.default = self._parameter.default_values[ radio_button_checked_id] return self._parameter def set_default(self, default): """Set default value by item's string. :param default: The default. :type default: str, int :returns: True if success, else False. :rtype: bool """ # Find index of choice try: default_index = self._parameter.default_values.index(default) self.default_input_button_group.button(default_index).setChecked( True) except ValueError: last_index = len(self._parameter.default_values) - 1 self.default_input_button_group.button(last_index).setChecked(True) self.custom_value.setValue(default) self.toggle_custom_value() def toggle_custom_value(self): radio_button_checked_id = self.default_input_button_group.checkedId() if (radio_button_checked_id == len(self._parameter.default_values) - 1): self.custom_value.setDisabled(False) else: self.custom_value.setDisabled(True) def toggle_input(self): """Change behaviour of radio button based on input.""" current_index = self.input.currentIndex() # If current input is not a radio button enabler, disable radio button. if self.input.itemData(current_index, Qt.UserRole) != (self.radio_button_enabler): self.disable_radio_button() # Otherwise, enable radio button. else: self.enable_radio_button() def set_selected_radio_button(self): """Set selected radio button to 'Do not report'.""" dont_use_button = self.default_input_button_group.button( len(self._parameter.default_values) - 2) dont_use_button.setChecked(True) def disable_radio_button(self): """Disable radio button group and custom value input area.""" checked = self.default_input_button_group.checkedButton() if checked: self.default_input_button_group.setExclusive(False) checked.setChecked(False) self.default_input_button_group.setExclusive(True) for button in self.default_input_button_group.buttons(): button.setDisabled(True) self.custom_value.setDisabled(True) def enable_radio_button(self): """Enable radio button and custom value input area then set selected radio button to 'Do not report'. """ for button in self.default_input_button_group.buttons(): button.setEnabled(True) self.set_selected_radio_button() self.custom_value.setEnabled(True)
def setupUI(self, mainData): #### #Creation of supporting layouts baseLayout = QVBoxLayout() controlsLayout = QGridLayout() #This is everything except the buttons #### #Mode controls modeGrpBox = QGroupBox("Mode:") self.modeRadBtns = [QRadioButton("Live"), QRadioButton("Offline")] for i in range(len(self.modeRadBtns)): self.modeRadBtns[i].setChecked(mainData.mode[i]) self.modeRadBtns[i].clicked.connect(self.modeRadBtnClick) modeLayout = QHBoxLayout() self.addWidgetListToLayout(self.modeRadBtns, modeLayout) modeGrpBox.setLayout(modeLayout) controlsLayout.addWidget(modeGrpBox, 0, 0) #### #Calib controls calibLayout = QVBoxLayout() calibGrpBox = QGroupBox("Calibration Type:") self.calibRadBtns = [QRadioButton("Calibration"), QRadioButton("Calibration F1"), QRadioButton("Calibration F2")] for i in range(len(self.calibRadBtns)): self.calibRadBtns[i].clicked.connect(self.calibRadBtnClick) self.calibRadBtns[i].setChecked(mainData.calibType[i]) calibGrpLayout = QVBoxLayout() self.addWidgetListToLayout(self.calibRadBtns, calibGrpLayout) calibGrpBox.setLayout(calibGrpLayout) calibLayout.addWidget(calibGrpBox) calibConfBtn = QPushButton("Configure Calibration...") calibConfBtn.clicked.connect(self.calibConfClick) calibLayout.addWidget(calibConfBtn) controlsLayout.addLayout(calibLayout, 1, 0, 3, 1) #### #Data location dataDirGrpBox = QGroupBox("Data directory:") self.dataDirTextBox = QLineEdit() self.dataDirTextBox.setText(str(mainData.dataDir)) self.dataDirTextBox.textChanged.connect(self.dataDirPathChanged) self.browseDataDirBtn = QPushButton("Browse...") self.browseDataDirBtn.clicked.connect(self.dataDirBrowseBtnClick) dataDirLayout = QHBoxLayout() dataDirLayout.addWidget(self.dataDirTextBox) dataDirLayout.addWidget(self.browseDataDirBtn) dataDirGrpBox.setLayout(dataDirLayout) controlsLayout.addWidget(dataDirGrpBox, 0, 1, 1, 2) #### #US/DS selector fileGrpBox = QGroupBox("Spectrum data files (US/DS) :") self.prevUSDSPairBtn = QPushButton("<") self.prevUSDSPairBtn.setFixedWidth(40) self.prevUSDSPairBtn.clicked.connect(self.changeUSDSPairBtnClick) self.nextUSDSPairBtn = QPushButton(">") self.nextUSDSPairBtn.clicked.connect(self.changeUSDSPairBtnClick) self.nextUSDSPairBtn.setFixedWidth(40) self.usdsPairTextBoxes = [] for i in range(2): self.usdsPairTextBoxes.append(QLineEdit()) #Set initial values of USDS pair boxes. if mainData.usdsPair[i] == '': self.usdsPairTextBoxes[i].setText(mainData.usdsPair[i]) else: self.usdsPairTextBoxes[i].setText(os.path.basename(mainData.usdsPair[i])) self.usdsPairTextBoxes[i].textChanged.connect(self.usdsPairTextChanged) self.usdsPairTextBoxes[i].setFixedWidth(100) fileLayout = QHBoxLayout() fileLayout.addWidget(self.prevUSDSPairBtn) fileLayout.addWidget(self.usdsPairTextBoxes[0]) fileLayout.addWidget(self.usdsPairTextBoxes[1]) fileLayout.addWidget(self.nextUSDSPairBtn) fileGrpBox.setLayout(fileLayout) controlsLayout.addWidget(fileGrpBox, 1, 1, 1, 2) ### #Integration range # - N.B. set text values before setting the textchanged slot integRangeGrpBox = QGroupBox("Integration Range:") integRangeLayout = QGridLayout() integrationTextInputWidth = 40 integElemNames = ["Beginning:", "End:", "Window Size:"] integElemLabels = [] integNmLabels = [] self.integElemTextBoxes = [] colNr, rowNr = 0, 0 for i in range(len(integElemNames)): integElemLabels.append(QLabel(integElemNames[i])) self.integElemTextBoxes.append(QLineEdit()) self.integElemTextBoxes[i].setFixedWidth(integrationTextInputWidth) self.integElemTextBoxes[i].setText(str(mainData.integrationConf[i])) self.integElemTextBoxes[i].textChanged.connect(self.integConfigChanged) integNmLabels.append(QLabel("nm")) colNr = i%2 if colNr == 0: rowNr += 1 integRangeLayout.addWidget(integElemLabels[i], rowNr, 3*colNr) integRangeLayout.addWidget(self.integElemTextBoxes[i], rowNr, (3*colNr)+1) integRangeLayout.addWidget(integNmLabels[i], rowNr, (3*colNr)+2) integRangeGrpBox.setLayout(integRangeLayout) controlsLayout.addWidget(integRangeGrpBox, 2, 1, 2, 2) ### #Calculation results planckTempLabel = QLabel("Average T(Planck):") self.planckTempValLabel = QLabel() self.planckTempValLabel.setFixedWidth(50) self.planckTempValLabel.setAlignment(QtCore.Qt.AlignRight) planckKLabel = QLabel("K") planckKLabel.setAlignment(QtCore.Qt.AlignLeft) dPlancKTempLabel = QLabel(u"\u0394 T(Planck):") self.dPlanckTempValLabel = QLabel() self.dPlanckTempValLabel.setFixedWidth(50) self.dPlanckTempValLabel.setAlignment(QtCore.Qt.AlignRight) dPlanckKLabel = QLabel("K") dPlanckKLabel.setAlignment(QtCore.Qt.AlignLeft) wienTempLabel = QLabel("Average T(Wien):") self.wienTempValLabel = QLabel() self.wienTempValLabel.setFixedWidth(50) self.wienTempValLabel.setAlignment(QtCore.Qt.AlignRight) wienKLabel = QLabel("K") wienKLabel.setAlignment(QtCore.Qt.AlignLeft) dWienTempLabel = QLabel(u"\u0394 T(Wien):") self.dWienTempValLabel = QLabel() self.dWienTempValLabel.setFixedWidth(50) self.dWienTempValLabel.setAlignment(QtCore.Qt.AlignRight) dWienKLabel = QLabel("K") dWienKLabel.setAlignment(QtCore.Qt.AlignLeft) self.updateTTextLabels() resultsLayout = QGridLayout() resultsLayout.addWidget(planckTempLabel, 0, 0) resultsLayout.addWidget(self.planckTempValLabel, 0, 1, alignment=QtCore.Qt.AlignRight) resultsLayout.addWidget(planckKLabel, 0, 2, alignment=QtCore.Qt.AlignLeft) resultsLayout.addWidget(dPlancKTempLabel, 1, 0) resultsLayout.addWidget(self.dPlanckTempValLabel, 1, 1, alignment=QtCore.Qt.AlignRight) resultsLayout.addWidget(dPlanckKLabel, 1, 2, alignment=QtCore.Qt.AlignLeft) resultsLayout.addWidget(wienTempLabel, 0, 3) resultsLayout.addWidget(self.wienTempValLabel, 0, 4, alignment=QtCore.Qt.AlignRight) resultsLayout.addWidget(wienKLabel, 0, 5, alignment=QtCore.Qt.AlignLeft) resultsLayout.addWidget(dWienTempLabel, 1, 3) resultsLayout.addWidget(self.dWienTempValLabel, 1, 4, alignment=QtCore.Qt.AlignRight) resultsLayout.addWidget(dWienKLabel, 1, 5, alignment=QtCore.Qt.AlignLeft) controlsLayout.addLayout(resultsLayout, 4, 0, 1, 3) #### #Control buttons self.runBtn = QPushButton('Run') self.runBtn.clicked.connect(self.runBtnClicked) self.stopBtn = QPushButton('Stop') self.stopBtn.clicked.connect(self.stopBtnClicked) quitBtn = QPushButton('Quit') quitBtn.clicked.connect(QtCore.QCoreApplication.instance().quit)#TODO Add control to kill plots properly buttonLayout = QHBoxLayout() buttonLayout.addWidget(self.runBtn) buttonLayout.addWidget(self.stopBtn) buttonLayout.addWidget(quitBtn) #### #Add the 1st tier layouts & set the base layout baseLayout.addLayout(controlsLayout) baseLayout.addLayout(buttonLayout) self.setLayout(baseLayout)
def __init__(self): QWizardPage.__init__(self) self.setTitle(self.tr("New Project Data")) self.setSubTitle(self.tr( "Complete the following fields to create the Project Structure")) gbox = QGridLayout(self) #Names of the fields to complete self.lblName = QLabel(self.tr("New Project Name (*):")) self.lblPlace = QLabel(self.tr("Project Location (*):")) self.lblDescription = QLabel(self.tr("Project Description:")) self.lblLicense = QLabel(self.tr("Project License:")) self.lblVenvFolder = QLabel(self.tr("Virtualenv Folder:")) gbox.addWidget(self.lblName, 0, 0, Qt.AlignRight) gbox.addWidget(self.lblPlace, 1, 0, Qt.AlignRight) gbox.addWidget(self.lblDescription, 2, 0, Qt.AlignTop) gbox.addWidget(self.lblLicense, 3, 0, Qt.AlignRight) gbox.addWidget(self.lblVenvFolder, 4, 0, Qt.AlignRight) #Fields on de right of the grid #Name self.txtName = QLineEdit() #Location hPlace = QHBoxLayout() self.txtPlace = QLineEdit() self.txtPlace.setReadOnly(True) self.btnExamine = QPushButton(self.tr("Examine...")) hPlace.addWidget(self.txtPlace) hPlace.addWidget(self.btnExamine) #Virtualenv vPlace = QHBoxLayout() self.vtxtPlace = QLineEdit() self.vtxtPlace.setReadOnly(True) self.vbtnExamine = QPushButton(self.tr("Examine...")) vPlace.addWidget(self.vtxtPlace) vPlace.addWidget(self.vbtnExamine) #Project Description self.txtDescription = QPlainTextEdit() #Project License self.cboLicense = QComboBox() self.cboLicense.setFixedWidth(250) self.cboLicense.addItem('Apache License 2.0') self.cboLicense.addItem('Artistic License/GPL') self.cboLicense.addItem('Eclipse Public License 1.0') self.cboLicense.addItem('GNU General Public License v2') self.cboLicense.addItem('GNU General Public License v3') self.cboLicense.addItem('GNU Lesser General Public License') self.cboLicense.addItem('MIT License') self.cboLicense.addItem('Mozilla Public License 1.1') self.cboLicense.addItem('New BSD License') self.cboLicense.addItem('Other Open Source') self.cboLicense.addItem('Other') self.cboLicense.setCurrentIndex(4) #Add to Grid gbox.addWidget(self.txtName, 0, 1) gbox.addLayout(hPlace, 1, 1) gbox.addWidget(self.txtDescription, 2, 1) gbox.addWidget(self.cboLicense, 3, 1) gbox.addLayout(vPlace, 4, 1) #Signal self.connect(self.btnExamine, SIGNAL('clicked()'), self.load_folder) self.connect(self.vbtnExamine, SIGNAL('clicked()'), self.load_folder_venv) self.connect(self.txtName, SIGNAL('textChanged(const QString&)'), lambda: self.emit(SIGNAL("completeChanged()")))
class CombinedValueRangeWidget(QWidget): def __init__(self, parent = None): super(CombinedValueRangeWidget, self).__init__(parent) self.roiWidgets = [] self.roiLayout = QGridLayout(self) self.setLayout(self.roiLayout) hbox = QHBoxLayout() hbox.addWidget(QLabel("min"),0,Qt.Alignment(Qt.AlignLeft)) hbox.addWidget(QLabel("max"),0,Qt.Alignment(Qt.AlignLeft)) self.roiLayout.addLayout(hbox, 0,1) self.roiLayout.addWidget(QLabel("Export Full Range"), 0, 2) self.roiLayout.addItem(QSpacerItem(0,0,QSizePolicy.Expanding, QSizePolicy.Minimum),0,3) self.roiCheckBoxes = [] self.setFocusPolicy(Qt.TabFocus) self.lastInChain = super(CombinedValueRangeWidget, self).nextInFocusChain() def addRanges(self, keys, extents): for key, extent in zip(keys, extents): w = ValueRangeWidget(self) w.setFocusPolicy(Qt.TabFocus) w.setDType(numpy.uint32) w.setValues(0,extent) w.setLimits(0,extent) #w.setLabels("min:","max:") self.roiWidgets.append(w) row = self.roiLayout.rowCount() align = Qt.Alignment(Qt.AlignLeft) check = QCheckBox() self.roiCheckBoxes.append(check) check.setChecked(True) check.setFocusPolicy(Qt.ClickFocus) if extent == 1: w.setEnabled(False) self.roiLayout.addWidget(QLabel(key + ": "),row, 0, align) self.roiLayout.addWidget(self.roiWidgets[-1],row, 1, align) self.roiLayout.addWidget(check,row, 2, align) def onChanged(i): val1,val2 = self.roiWidgets[i].getValues() lim1,lim2 = self.roiWidgets[i].getLimits() #limits are stored as ranges if val1==lim1 and val2==lim2: self.roiCheckBoxes[i].setChecked(True) else: self.roiCheckBoxes[i].setChecked(False) def onCheck(i, state): if state == 0: return self.roiWidgets[i].setValues(0,extents[i]) self.roiCheckBoxes[i].setChecked(True) for i, check in enumerate(self.roiCheckBoxes): check.stateChanged.connect(partial(onCheck, i)) self.roiWidgets[i].changedSignal.connect(partial(onChanged, i)) def focusInEvent(self, QFocusEvent): if len(self.roiWidgets) > 0: self.roiWidgets[0].setFocus()
def __init__(self, parent=None): super(DataDialog, self).__init__(parent) self.pagetitle = 'School Data' stylesheet = Valid().background() + Valid().font() self.setStyleSheet(stylesheet) Form1 = QFormLayout() Form2 = QGridLayout() data = Valid().pullData('datas', '', {'pubID':'datas'}) data_arr = {} for d in data: data_arr[d['name']] = d['description'] namex = None alias = None motto = None address = None city = '' state = '' country = '' pmb = '' zipx = '' email1 = '' email2 = '' phone1 = '' phone2 = '' color1 = '' color2 = '' try: if(data_arr and data_arr['namex']): namex = data_arr['namex'] print(namex) except: pass try: if(data_arr and data_arr['alias']): alias = data_arr['alias'] except: pass try: if(data_arr and data_arr['motto']): motto = data_arr['motto'] except: pass try: if(data_arr and data_arr['address']): address = data_arr['address'] except: pass try: if(data_arr and data_arr['city']): city = data_arr['city'] except: pass try: if(data_arr and data_arr['state']): state = data_arr['state'] except: pass try: if(data_arr and data_arr['country']): country = data_arr['country'] except: pass try: if(data_arr and data_arr['pmb']): pmb = data_arr['pmb'] except: pass try: if(data_arr and data_arr['zip']): zipx = data_arr['zip'] except: pass try: if(data_arr and data_arr['email1']): email1 = data_arr['email1'] except: pass try: if(data_arr and data_arr['email2']): email2 = data_arr['email2'] except: pass try: if(data_arr and data_arr['phone1']): phone1 = data_arr['phone1'] except: pass try: if(data_arr and data_arr['phone2']): phone2 = data_arr['phone2'] except: pass try: if(data_arr and data_arr['color1']): color1 = data_arr['color1'] except: pass try: if(data_arr and data_arr['color2']): color2 = data_arr['color2'] except: pass #title self.schoolName = QLabel("School Name") self.schoolNameData = QLineEdit() self.schoolNameData.setObjectName("name") self.schoolNameData.setPlaceholderText("e.g. HERITAGE SCHOOL") if namex: self.schoolNameData.setText(namex) self.schoolAlias = QLabel("School Alias") self.schoolAliasData = QLineEdit() self.schoolAliasData.setObjectName("alias") self.schoolAliasData.setPlaceholderText("e.g. HERITAGE, HTS, HS ") if alias: self.schoolAliasData.setText(alias) self.schoolMotto = QLabel("Motto") self.schoolMottoData = QLineEdit() self.schoolMottoData.setObjectName("motto") self.schoolMottoData.setPlaceholderText("e.g. Training a Nation ") if motto: self.schoolMottoData.setText(motto) self.schoolAddress = QLabel("Address") self.schoolAddressData = QLineEdit() self.schoolAddressData.setObjectName("address") self.schoolAddressData.setPlaceholderText("e.g. 12. Lincon Street ") if address: self.schoolAddressData.setText(address) self.schoolCity = QLabel("City") self.schoolCityData = QLineEdit() self.schoolCityData.setObjectName("city") self.schoolCityData.setPlaceholderText("Abuja") if city: self.schoolCityData.setText(city) self.schoolState = QLabel("State/Region") self.schoolStateData = QLineEdit() self.schoolStateData.setObjectName("state") self.schoolStateData.setPlaceholderText("California") if state: self.schoolStateData.setText(state) self.schoolCountry = QLabel("Country") self.schoolCountryData = QLineEdit() self.schoolCountryData.setObjectName("country") self.schoolCountryData.setPlaceholderText("USA") if country: self.schoolCountryData.setText(country) self.schoolEmail1 = QLabel("Email") self.schoolEmail1Data = QLineEdit() self.schoolEmail1Data.setObjectName("email") self.schoolEmail1Data.setPlaceholderText("e.g. [email protected]") if email1: self.schoolEmail1Data.setText(email1) self.schoolEmail2 = QLabel("Alternate Email") self.schoolEmail2Data = QLineEdit() self.schoolEmail2Data.setObjectName("aemail") self.schoolEmail2Data.setPlaceholderText("e.g. [email protected]") if email2: self.schoolEmail2Data.setText(email2) self.schoolPhone1 = QLabel("Phone Number") self.schoolPhone1Data = QLineEdit() self.schoolPhone1Data.setObjectName("phone") self.schoolPhone1Data.setPlaceholderText("") if phone1: self.schoolPhone1Data.setText(phone1) self.schoolPhone2 = QLabel("Alternate Phone Number") self.schoolPhone2Data = QLineEdit() self.schoolPhone2Data.setObjectName("aphone") self.schoolPhone2Data.setPlaceholderText("") if phone2: self.schoolPhone2Data.setText(phone2) self.schoolZip = QLabel("Zip Code") self.schoolZipData = QLineEdit() self.schoolZipData.setObjectName("zip") self.schoolZipData.setPlaceholderText("XXXXXX") if zipx: self.schoolZipData.setText(zipx) self.schoolPmb = QLabel("Mail Box/Bag") self.schoolPmbData = QLineEdit() self.schoolPmbData.setObjectName("pmb") self.schoolPmbData.setPlaceholderText("e.g. P.O.Box 2020") if pmb: self.schoolPmbData.setText(pmb) self.colorLbl = QLabel("Pick School's primary and secondary colors. White and Black colors would be ignored") self.colorPrimary = QPushButton('Select') self.colorSecondary = QPushButton('Select') self.colorPrimaryLbl = QLineEdit() self.colorSecondaryLbl = QLineEdit() self.colorPrimaryLbls = QLabel('Primary Color') self.colorSecondaryLbls = QLabel('Secondary Color') if color1: self.colorPrimaryLbl.setText(color1) if color2: self.colorSecondaryLbl.setText(color2) if color1: self.colorPrimaryLbl.setStyleSheet("background-color:"+ color1 +"") if color2: self.colorSecondaryLbl.setStyleSheet("background-color:"+ color2 +"") self.connect(self.colorPrimary, SIGNAL("clicked()"), lambda x= 0: self.color_picker(x)) self.connect(self.colorSecondary, SIGNAL("clicked()"), lambda x = 1: self.color_picker(x)) Form1.addRow(self.schoolName, self.schoolNameData) Form1.addRow(self.schoolAlias, self.schoolAliasData) Form1.addRow(self.schoolMotto, self.schoolMottoData) Form1.addRow(self.schoolAddress, self.schoolAddressData) Form1.addRow(self.schoolCity, self.schoolCityData) Form1.addRow(self.schoolState, self.schoolStateData) Form1.addRow(self.schoolCountry, self.schoolCountryData) Form1.addRow(self.schoolEmail1, self.schoolEmail1Data) Form1.addRow(self.schoolEmail2, self.schoolEmail2Data) Form1.addRow(self.schoolPhone1, self.schoolPhone1Data) Form1.addRow(self.schoolPhone2, self.schoolPhone2Data) Form1.addRow(self.schoolZip, self.schoolZipData) Form1.addRow(self.schoolPmb, self.schoolPmbData) Form2.addWidget(self.colorPrimaryLbls, 0, 0) Form2.addWidget(self.colorPrimaryLbl, 0, 1) Form2.addWidget(self.colorPrimary, 0, 2) Form2.addWidget(self.colorSecondaryLbls, 1, 0) Form2.addWidget(self.colorSecondaryLbl, 1, 1) Form2.addWidget(self.colorSecondary, 1, 2) groupBox1 = QGroupBox('School Data') groupBox1.setLayout(Form1) Gbo = QGridLayout() Gbo.addWidget(self.colorLbl, 0, 0) Gbo.addLayout(Form2, 1, 0) groupBox2 = QGroupBox('School Colors') groupBox2.setLayout(Gbo) self.pb = QPushButton() self.pb.setObjectName("Add") self.pb.setText("Save") self.pb1 = QPushButton() self.pb1.setObjectName("Cancel") self.pb1.setText("Close") hbo = QHBoxLayout() hbo.addWidget(self.pb1) hbo.addStretch() hbo.addWidget(self.pb) groupBox3 = QGroupBox('') groupBox3.setLayout(hbo) grid = QGridLayout() grid.addWidget(groupBox1, 0, 0) grid.addWidget(groupBox2, 1, 0) grid.addWidget(groupBox3, 2, 0) self.setLayout(grid) self.connect(self.pb, SIGNAL("clicked()"), lambda: self.button_click()) self.connect(self.pb1, SIGNAL("clicked()"), lambda: self.button_close(self)) self.setWindowTitle(self.pagetitle)
class AboutWidget(QWidget): """ Common About Dialog for the Freeseer Project. This should be used for the about dialog when including one in GUIs. Layout: Logo | About Infos | Buttons """ def __init__(self, parent=None): QWidget.__init__(self, parent) self.current_language = "en_US" self.uiTranslator = QTranslator() self.uiTranslator.load(":/languages/tr_en_US.qm") self.fontSize = self.font().pixelSize() self.fontUnit = "px" if self.fontSize == -1: # Font is set as points, not pixels. self.fontUnit = "pt" self.fontSize = self.font().pointSize() icon = QIcon() self.logoPixmap = QPixmap(_fromUtf8(":/freeseer/logo.png")) icon.addPixmap(self.logoPixmap, QIcon.Normal, QIcon.Off) self.setWindowIcon(icon) self.mainLayout = QGridLayout() self.setLayout(self.mainLayout) # Logo self.logo = QLabel("Logo") # To offset the logo so that it's to the right of the title self.logo.setStyleSheet("QLabel {{ margin-left: {} {} }}".format( 90 + (self.fontSize * 2.5), self.fontUnit)) self.logo.setPixmap(self.logoPixmap.scaledToHeight(80)) self.mainLayout.addWidget(self.logo, 0, 0, Qt.AlignTop) # Info self.aboutInfo = QLabel("About Info", openExternalLinks=True) self.aboutInfo.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.aboutInfo.setWordWrap(True) self.mainLayout.addWidget(self.aboutInfo, 0, 0) # Buttons self.buttonsLayout = QHBoxLayout() self.issueButton = QPushButton("Report an issue") self.docsButton = QPushButton("Freeseer documentation") self.contactButton = QPushButton("Contact us") self.buttonsLayout.insertWidget(0, self.docsButton) self.buttonsLayout.insertWidget(1, self.issueButton) self.buttonsLayout.insertWidget(2, self.contactButton) self.mainLayout.addLayout(self.buttonsLayout, 2, 0) self.connect(self.docsButton, SIGNAL('clicked()'), self.openDocsUrl) self.connect(self.issueButton, SIGNAL('clicked()'), self.openNewIssueUrl) self.connect(self.contactButton, SIGNAL('clicked()'), self.openContactUrl) self.retranslate() def retranslate(self, language=None): if language is not None: self.current_language = language self.uiTranslator.load(":/languages/tr_%s.qm" % self.current_language) # # Main Text # self.descriptionString = self.uiTranslator.translate( "AboutDialog", "Freeseer is a video capture utility capable of capturing presentations. It captures " "video sources such as usb, firewire, or local desktop along with audio and mixes them " "together to produce a video.") self.copyrightString = self.uiTranslator.translate( "AboutDialog", 'Copyright (C) 2014 The Free and ' 'Open Source Software Learning Centre') self.licenseTextString = self.uiTranslator.translate( "AboutDialog", "Freeseer is licensed under the GPL " "version 3. This software is provided 'as-is',without any express or implied warranty. In " "no event will the authors be held liable for any damages arising from the use of this software." ) self.aboutInfoString = u'<h1>' + NAME.capitalize() + u'</h1>' + \ u'<br><b>' + self.uiTranslator.translate("AboutDialog", "Version") + \ ": " + __version__ + u'</b>' + \ u'<p>' + self.descriptionString + u'</p>' + \ u'<p>' + self.copyrightString + u'</p>' + \ u'<p><a href="' + URL + u'">' + URL + u'</a></p>' \ u'<p>' + self.licenseTextString + u'</p>' \ u'<p>' + self.uiTranslator.translate("AboutDialog", "Record button graphics by") + \ u': <a href="' + RECORD_BUTTON_LINK + u'">' + RECORD_BUTTON_ARTIST + u'</a></p>' \ u'<p>' + self.uiTranslator.translate("AboutDialog", "Headphones graphics by") + \ u': <a href="' + HEADPHONES_LINK + u'">' + HEADPHONES_ARTIST + u'</a></p><br>' self.aboutInfo.setText(self.aboutInfoString) # --- End Main Text def openDocsUrl(self): """Opens a link to the Freeseer online documentation""" url = QUrl("http://freeseer.readthedocs.org") QDesktopServices.openUrl(url) def openNewIssueUrl(self): """Opens a link to the Freeseer new issue page""" url = QUrl("https://github.com/Freeseer/freeseer/issues/new") QDesktopServices.openUrl(url) def openContactUrl(self): """Opens a link to Freeseer's contact information""" url = QUrl("http://freeseer.readthedocs.org/en/latest/contact.html") QDesktopServices.openUrl(url)
class ArrayEditor(QDialog): """Array Editor Dialog""" def __init__(self, parent=None): super(ArrayEditor, self).__init__(parent) def setup_and_check(self, data, title='', xy=False, readonly=False): """ Setup ArrayEditor: return False if data is not supported, True otherwise """ self.arraywidget = None self.is_record_array = data.dtype.names is not None if data.ndim > 2: self.error(self.tr("Arrays with more than 2 dimensions " "are not supported")) return False if not self.is_record_array: dtn = data.dtype.name if dtn not in SUPPORTED_FORMATS and not dtn.startswith('string') \ and not dtn.startswith('unicode'): arr = self.tr("%1 arrays").arg(data.dtype.name) self.error(self.tr("%1 are currently not supported").arg(arr)) return False self.layout = QGridLayout() self.setLayout(self.layout) self.setWindowIcon(get_icon('arredit.png')) title = self.tr("Array editor") + \ "%s" % (" - "+str(title) if str(title) else "") if readonly: title += ' (' + self.tr('read only') + ')' self.setWindowTitle(title) self.resize(600, 500) # Stack widget self.stack = QStackedWidget(self) if self.is_record_array: for name in data.dtype.names: self.stack.addWidget(ArrayEditorWidget(self, data[name], xy, readonly)) else: self.stack.addWidget(ArrayEditorWidget(self, data, xy, readonly)) self.arraywidget = self.stack.currentWidget() self.connect(self.stack, SIGNAL('currentChanged(int)'), self.current_widget_changed) self.layout.addWidget(self.stack, 1, 0) # Buttons configuration btn_layout = QHBoxLayout() if self.is_record_array: btn_layout.addWidget(QLabel(self.tr("Record array fields:"))) ra_combo = QComboBox(self) self.connect(ra_combo, SIGNAL('currentIndexChanged(int)'), self.stack.setCurrentIndex) names = [] for name in data.dtype.names: field = data.dtype.fields[name] text = name if len(field) >= 3: title = field[2] if not isinstance(title, basestring): title = repr(title) text += ' - '+title names.append(text) ra_combo.addItems(names) btn_layout.addWidget(ra_combo) btn_layout.addStretch() bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.connect(bbox, SIGNAL("accepted()"), SLOT("accept()")) self.connect(bbox, SIGNAL("rejected()"), SLOT("reject()")) btn_layout.addWidget(bbox) self.layout.addLayout(btn_layout, 2, 0) self.setMinimumSize(400, 300) # Make the dialog act as a window self.setWindowFlags(Qt.Window) return True def current_widget_changed(self, index): self.arraywidget = self.stack.widget(index) def accept(self): """Reimplement Qt method""" for index in range(self.stack.count()): self.stack.widget(index).accept_changes() QDialog.accept(self) def error(self, message): """An error occured, closing the dialog box""" QMessageBox.critical(self, self.tr("Array editor"), message) self.setAttribute(Qt.WA_DeleteOnClose) self.reject() def reject(self): """Reimplement Qt method""" if self.arraywidget is not None: for index in range(self.stack.count()): self.stack.widget(index).reject_changes() QDialog.reject(self)
def __init__(self, term, row, parent=None): super(EditReportDialog, self).__init__(parent) self.term = term self.sid = term self.row = row terms = self.pullOnes('terms', self.term) datas = self.pullOnes('datas', self.row) session = self.pullOnes('session', terms['sessionID']) self.termname = str( session['name']) + ' ' + terms['name'] + ' Term Report' self.pagetitle = self.termname ko = 0 #prepare data d = datas['description'] d = d.split(':::') _title = d[0] _theme = d[1] _font = d[2] _ass = d[3] _gra = d[4] _set = d[5] _ass_list = _ass.split('::') _gra_list = _gra.split('::') _set_list = _set.split('::') _cla_list = _set.split('::') layout1 = QGridLayout() Form1 = QFormLayout() Form2 = QFormLayout() #title self.title = QLabel("Report Title") self.titleData = QLineEdit() self.titleData.setObjectName("name") self.titleData.setText(_title) tree = QTreeWidget() tree.setItemDelegate(Delegate()) tree.setHeaderLabel("Which grading system will you be using?") tree1 = QTreeWidget() tree1.setHeaderLabel("Choose Assessments and classes") tree2 = QTreeWidget() tree2.setHeaderLabel("Report Card Settings") self.ass_arr = {} parent = QTreeWidgetItem(tree1) parent.setText(0, "Select Assessments") parent.setFlags(parent.flags() | Qt.ItemIsTristate | Qt.ItemIsUserCheckable) arr = self.pullCas() if arr and len(arr) > 0: for val in arr: dt = self.pullOne(val['name']) child = QTreeWidgetItem(parent) child.setFlags(child.flags() | Qt.ItemIsUserCheckable) child.setText(0, str(dt['name']).upper()) self.ass_arr[val['id']] = child if str(val['id']) in _ass_list: child.setCheckState(0, Qt.Checked) else: child.setCheckState(0, Qt.Unchecked) ko += 1 self.cla_arr = {} parent1 = QTreeWidgetItem(tree1) parent1.setText(0, "Select Class") parent1.setFlags(parent1.flags() | Qt.ItemIsTristate | Qt.ItemIsUserCheckable) arr = self.pullClass() if arr and len(arr) > 0: for val in arr: child = QTreeWidgetItem(parent1) child.setFlags(child.flags() | Qt.ItemIsUserCheckable) child.setText(0, str(val['name']).upper()) self.cla_arr[val['id']] = child va = str(val['id']) if (va in _cla_list): child.setCheckState(0, Qt.Checked) else: child.setCheckState(0, Qt.Unchecked) ko += 1 self.gra_arr = {} parent2 = QTreeWidgetItem(tree) parent2.setText(0, "Select Grade") arr = self.pullGrade() if arr and len(arr) > 0: for val in arr: child = QTreeWidgetItem(parent2) child.setFlags(child.flags() | Qt.ItemIsUserCheckable) child.setText(0, str(val['name']).upper()) self.gra_arr[val['id']] = child if str(val['id']) in _gra_list: child.setCheckState(0, Qt.Checked) else: child.setCheckState(0, Qt.Unchecked) ko += 1 self.set_arr = {} parent3 = QTreeWidgetItem(tree2) parent3.setText(0, "Include ...") parent3.setFlags(parent3.flags() | Qt.ItemIsTristate | Qt.ItemIsUserCheckable) arr = { 1: 'School Number', 2: 'Class Position', 3: 'Class Unit Position', 4: 'Total (100%)', 5: 'Total', 6: 'Grading', 7: 'Subject Average', 8: 'Ranking', 9: 'Ranking and Student Population', 10: 'Student Passport', 11: 'School Logo', 12: 'School Address', 13: 'Students Address', 14: 'Attendance', 15: 'Fees Owed', 16: 'Test/Assesments' } if arr and len(arr) > 0: for val in arr: child = QTreeWidgetItem(parent3) child.setFlags(child.flags() | Qt.ItemIsUserCheckable) child.setText(0, str(arr[val]).upper()) self.set_arr[val] = child if str(val) in _set_list: child.setCheckState(0, Qt.Checked) else: child.setCheckState(0, Qt.Unchecked) child1 = QTreeWidgetItem(parent3) child1.setFlags(child1.flags() | Qt.ItemIsUserCheckable) child1.setText(0, 'AFFECTIVE DOMAIN REPORT') self.set_arr['aff'] = child1 if 'aff' in _set_list: child1.setCheckState(0, Qt.Checked) else: child1.setCheckState(0, Qt.Unchecked) child2 = QTreeWidgetItem(child1) child2.setFlags(child2.flags() | Qt.ItemIsTristate | Qt.ItemIsUserCheckable) child2.setText(0, 'TABLE') self.set_arr['afftable'] = child2 if 'afftable' in _set_list: child2.setCheckState(0, Qt.Checked) else: child2.setCheckState(0, Qt.Unchecked) child3 = QTreeWidgetItem(child1) child3.setFlags(child3.flags() | Qt.ItemIsUserCheckable) child3.setText(0, 'GRAPH') self.set_arr['affgraph'] = child3 if 'affgraph' in _set_list: child3.setCheckState(0, Qt.Checked) else: child3.setCheckState(0, Qt.Unchecked) child4 = QTreeWidgetItem(parent3) child4.setFlags(child4.flags() | Qt.ItemIsTristate | Qt.ItemIsUserCheckable) child4.setText(0, 'PYSCHOMOTOR DOMAIN REPORT') self.set_arr['psy'] = child4 if 'psy' in _set_list: child4.setCheckState(0, Qt.Checked) else: child4.setCheckState(0, Qt.Unchecked) child5 = QTreeWidgetItem(child4) child5.setFlags(child5.flags() | Qt.ItemIsUserCheckable) child5.setText(0, 'TABLE') self.set_arr['psytable'] = child5 if 'psytable' in _set_list: child5.setCheckState(0, Qt.Checked) else: child5.setCheckState(0, Qt.Unchecked) child6 = QTreeWidgetItem(child4) child6.setFlags(child6.flags() | Qt.ItemIsUserCheckable) child6.setText(0, 'GRAPH') self.set_arr['psygraph'] = child6 if 'psygraph' in _set_list: child6.setCheckState(0, Qt.Checked) else: child6.setCheckState(0, Qt.Unchecked) tree.expandAll() tree1.expandAll() tree2.expandAll() #tree.show() self.l5 = QLabel("Theme Color") self.pbc = QPushButton() self.pbc.setObjectName("Pickcolor") self.pbc.setText("Click to change") self.le5 = QLineEdit() self.le5.setObjectName("Showcolor") self.le5.setText(_theme) self.pbc.setStyleSheet("background-color: " + _theme + "; color: white") self.connect(self.pbc, SIGNAL("clicked()"), lambda: self.color_picker()) self.l6 = QLabel("Pick Theme Font") self.pbf = QPushButton() self.pbf.setObjectName("Pickfont") self.pbf.setText(_font) self.le6 = QLineEdit() self.le6.setObjectName("Showcolor") self.le6.setText("#000000") self.pbf.setStyleSheet("color: black") self.connect(self.pbf, SIGNAL("clicked()"), lambda: self.font_picker()) self.lv_box = QHBoxLayout() self.lv_box.addWidget(self.pbc) self.lv_box.addWidget(self.le5) self.lv_box1 = QHBoxLayout() self.lv_box1.addWidget(self.pbf) self.lv_box1.addWidget(self.le6) Form1.addRow(self.title, self.titleData) Form2.addRow(self.l5, self.lv_box) Form2.addRow(self.l6, self.lv_box1) Gbo = QGridLayout() Gbo.addLayout(Form1, 0, 0, 1, 2) Gbo.addWidget(tree, 1, 0) Gbo.addWidget(tree1, 1, 1) Gbo.addWidget(tree2, 2, 0) Gbo.addLayout(Form2, 2, 1) groupBox1 = QGroupBox('Academic Report Setup') groupBox1.setLayout(Gbo) self.pb = QPushButton() self.pb.setObjectName("Add") self.pb.setText("Add Assessment") self.pb1 = QPushButton() self.pb1.setObjectName("Cancel") self.pb1.setText("Cancel") hbo = QHBoxLayout() hbo.addWidget(self.pb1) hbo.addStretch() hbo.addWidget(self.pb) groupBox2 = QGroupBox('') groupBox2.setLayout(hbo) grid = QGridLayout() grid.addWidget(groupBox1, 0, 0) grid.addWidget(groupBox2, 1, 0) self.setLayout(grid) self.connect(self.pb, SIGNAL("clicked()"), lambda: self.button_click(self)) self.connect(self.pb1, SIGNAL("clicked()"), lambda: self.button_close(self)) self.setWindowTitle(self.pagetitle)
class ConDlg(QDialog): """ A connection dialog for setting database connection parameters. """ def __init__(self, mc, con_info, stat_bar_msg): """ Constructor. :param mc: A reference to the main class. :type mc: object :param con_info: A connection information. :type con_info: dict :param stat_bar_msg: A status bar message. :type stat_bar_msg: str """ super(QDialog, self).__init__() self.mc = mc self._setup_self(con_info, stat_bar_msg) def _setup_self(self, con_info, stat_bar_msg): """ Sets up self. :param con_info: A connection information. :type con_info: dict :param stat_bar_msg: A status bar message. :type stat_bar_msg: str """ self.setObjectName(u'ConnDlg') self.setWindowTitle(u'Connection Parameters') self.grid_lyt = QGridLayout(self) self.grid_lyt.setObjectName(u'grid_lyt') self.grid_lyt.setColumnMinimumWidth(1, 300) self._build_wdgs(con_info, stat_bar_msg) def _build_wdgs(self, con_info, stat_bar_msg): """ Builds own widgets. :param con_info: A connection information. :type con_info: dict :param stat_bar_msg: A status bar message. :type stat_bar_msg: str """ self.host_lbl = QLabel(self) self.host_lbl.setObjectName(u'host_lbl') self.host_lbl.setText(self.mc.host_str.title()) self.grid_lyt.addWidget(self.host_lbl, 0, 0, 1, 1) self.host_le = QLineEdit(self) self.host_le.setObjectName(u'host_le') self.grid_lyt.addWidget(self.host_le, 0, 1, 1, 1) self.port_lbl = QLabel(self) self.port_lbl.setObjectName(u'port_lbl') self.port_lbl.setText(self.mc.port_str.title()) self.grid_lyt.addWidget(self.port_lbl, 1, 0, 1, 1) self.port_le = QLineEdit(self) self.port_le.setObjectName(u'port_le') self.grid_lyt.addWidget(self.port_le, 1, 1, 1, 1) self.db_lbl = QLabel(self) self.db_lbl.setObjectName(u'db_lbl') self.db_lbl.setText(self.mc.db_str.title()) self.grid_lyt.addWidget(self.db_lbl, 2, 0, 1, 1) self.db_le = QLineEdit(self) self.db_le.setObjectName(u'db_le') self.grid_lyt.addWidget(self.db_le, 2, 1, 1, 1) self.usr_lbl = QLabel(self) self.usr_lbl.setObjectName(u'usr_lbl') self.usr_lbl.setText(self.mc.usr_str.title()) self.grid_lyt.addWidget(self.usr_lbl, 3, 0, 1, 1) self.usr_le = QLineEdit(self) self.usr_le.setObjectName(u'usr_le') self.grid_lyt.addWidget(self.usr_le, 3, 1, 1, 1) self.pwd_lbl = QLabel(self) self.pwd_lbl.setObjectName(u'pwd_lbl') self.pwd_lbl.setText(self.mc.pwd_str.title()) self.grid_lyt.addWidget(self.pwd_lbl, 4, 0, 1, 1) self.pwd_le = QLineEdit(self) self.pwd_le.setObjectName(u'pwd_le') self.pwd_le.setEchoMode(QLineEdit.Password) self.grid_lyt.addWidget(self.pwd_le, 4, 1, 1, 1) self.con_dict = {} self.con_dict[self.mc.host_str] = self.host_le self.con_dict[self.mc.port_str] = self.port_le self.con_dict[self.mc.db_str] = self.db_le self.con_dict[self.mc.usr_str] = self.usr_le self.con_dict[self.mc.pwd_str] = self.pwd_le self._ins_con_info(con_info) self.btn_lyt = QHBoxLayout() self.grid_lyt.addLayout(self.btn_lyt, 5, 0, 1, 2) self.test_btn = QPushButton(self) self.test_btn.setObjectName(u'test_btn') self.test_btn.setText(u'Test and Save') self.test_btn.clicked.connect(self._test_con) self.btn_lyt.addWidget(self.test_btn) self.ok_btn = QPushButton(self) self.ok_btn.setObjectName(u'ok_btn') self.ok_btn.setText(u'OK') self.ok_btn.setDisabled(True) self.ok_btn.clicked.connect(self.close) self.btn_lyt.addWidget(self.ok_btn) def _ins_con_info(self, con_info): """ Inserts a connection information into line edits. :param con_info: A connection information. :type con_info: dict """ for conn_str, conn_le in self.con_dict.iteritems(): conn_le.setText(con_info[conn_str]) def _test_con(self): """ Tests a connection. """ msg_dur = 5000 try: self._enable_wdgs(False) if self.ok_btn.isEnabled(): self.ok_btn.setEnabled(False) QgsApplication.processEvents() con_info = self._con_info self._save_con_info(con_info) QgsApplication.processEvents() self.mc.con = db.get_con(con_info) if db.chck_nofa_tbls(self.mc.con): QMessageBox.information( self, u'Success', u'Connection to NOFA database succeeded.') self.ok_btn.setEnabled(True) else: QMessageBox.warning( self, u'Success - not NOFA', u'Connection succeeded but the database is not NOFA.') self.ok_btn.setEnabled(False) self.mc.con.close() self.mc.con = None except psycopg2.OperationalError: self.mc.con = None self.ok_btn.setEnabled(False) QMessageBox.warning(self, u'Fail', u'Connection failed.') finally: self._enable_wdgs(True) @property def _con_info(self): """ Returns a connection information from line edits. :returns: A connection information dictionary. :rtype: dict """ con_info = {} for con_str, con_le in self.con_dict.iteritems(): con_info[con_str] = con_le.text() return con_info def _save_con_info(self, con_info): """ Saves a connection information to settings of the main class. :param con_info: A connection information. :type con_info: dict """ for con_str, con_val in con_info.iteritems(): self.mc.settings.setValue(con_str, con_val) def _enable_wdgs(self, bl): """ Enables or disables line edits and push buttons. :param bl: True to enable widgets, False to disable widgets. :type bl: bool """ for con_str, con_le in self.con_dict.iteritems(): con_le.setEnabled(bl) self.test_btn.setEnabled(bl)
class ArrayEditor(QDialog): """Array Editor Dialog""" def __init__(self, parent=None): QDialog.__init__(self, parent) # Destroying the C++ object right after closing the dialog box, # otherwise it may be garbage-collected in another QThread # (e.g. the editor's analysis thread in Spyder), thus leading to # a segmentation fault on UNIX or an application crash on Windows self.setAttribute(Qt.WA_DeleteOnClose) self.data = None self.arraywidget = None self.stack = None self.layout = None def setup_and_check(self, data, title='', readonly=False, xlabels=None, ylabels=None): """ Setup ArrayEditor: return False if data is not supported, True otherwise """ self.data = data is_record_array = data.dtype.names is not None is_masked_array = isinstance(data, np.ma.MaskedArray) if data.size == 0: self.error(_("Array is empty")) return False if data.ndim > 2: self.error(_("Arrays with more than 2 dimensions " "are not supported")) return False if xlabels is not None and len(xlabels) != self.data.shape[1]: self.error(_("The 'xlabels' argument length " "do no match array column number")) return False if ylabels is not None and len(ylabels) != self.data.shape[0]: self.error(_("The 'ylabels' argument length " "do no match array row number")) return False if not is_record_array: dtn = data.dtype.name if dtn not in SUPPORTED_FORMATS and not dtn.startswith('string') \ and not dtn.startswith('unicode'): arr = _("%s arrays") % data.dtype.name self.error(_("%s are currently not supported") % arr) return False self.layout = QGridLayout() self.setLayout(self.layout) self.setWindowIcon(get_icon('arredit.png')) if title: title = unicode(title) # in case title is not a string else: title = _("Array editor") if readonly: title += ' (' + _('read only') + ')' self.setWindowTitle(title) self.resize(600, 500) # Stack widget self.stack = QStackedWidget(self) if is_record_array: for name in data.dtype.names: self.stack.addWidget(ArrayEditorWidget(self, data[name], readonly, xlabels, ylabels)) elif is_masked_array: self.stack.addWidget(ArrayEditorWidget(self, data, readonly, xlabels, ylabels)) self.stack.addWidget(ArrayEditorWidget(self, data.data, readonly, xlabels, ylabels)) self.stack.addWidget(ArrayEditorWidget(self, data.mask, readonly, xlabels, ylabels)) else: self.stack.addWidget(ArrayEditorWidget(self, data, readonly, xlabels, ylabels)) self.arraywidget = self.stack.currentWidget() self.connect(self.stack, SIGNAL('currentChanged(int)'), self.current_widget_changed) self.layout.addWidget(self.stack, 1, 0) # Buttons configuration btn_layout = QHBoxLayout() if is_record_array or is_masked_array: if is_record_array: btn_layout.addWidget(QLabel(_("Record array fields:"))) names = [] for name in data.dtype.names: field = data.dtype.fields[name] text = name if len(field) >= 3: title = field[2] if not isinstance(title, basestring): title = repr(title) text += ' - '+title names.append(text) else: names = [_('Masked data'), _('Data'), _('Mask')] ra_combo = QComboBox(self) self.connect(ra_combo, SIGNAL('currentIndexChanged(int)'), self.stack.setCurrentIndex) ra_combo.addItems(names) btn_layout.addWidget(ra_combo) if is_masked_array: label = QLabel(_("<u>Warning</u>: changes are applied separately")) label.setToolTip(_("For performance reasons, changes applied "\ "to masked array won't be reflected in "\ "array's data (and vice-versa).")) btn_layout.addWidget(label) btn_layout.addStretch() bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.connect(bbox, SIGNAL("accepted()"), SLOT("accept()")) self.connect(bbox, SIGNAL("rejected()"), SLOT("reject()")) btn_layout.addWidget(bbox) self.layout.addLayout(btn_layout, 2, 0) self.setMinimumSize(400, 300) # Make the dialog act as a window self.setWindowFlags(Qt.Window) return True def current_widget_changed(self, index): self.arraywidget = self.stack.widget(index) def accept(self): """Reimplement Qt method""" for index in range(self.stack.count()): self.stack.widget(index).accept_changes() QDialog.accept(self) def get_value(self): """Return modified array -- this is *not* a copy""" # It is import to avoid accessing Qt C++ object as it has probably # already been destroyed, due to the Qt.WA_DeleteOnClose attribute return self.data def error(self, message): """An error occured, closing the dialog box""" QMessageBox.critical(self, _("Array editor"), message) self.setAttribute(Qt.WA_DeleteOnClose) self.reject() def reject(self): """Reimplement Qt method""" if self.arraywidget is not None: for index in range(self.stack.count()): self.stack.widget(index).reject_changes() QDialog.reject(self)
class AboutWidget(QWidgetWithDpi): """ Common About Dialog for the Freeseer Project. This should be used for the about dialog when including one in GUIs. Layout: Logo | About Infos | Buttons """ def __init__(self, parent=None): super(AboutWidget, self).__init__(parent) self.current_language = "en_US" self.uiTranslator = QTranslator() self.uiTranslator.load(":/languages/tr_en_US.qm") self.fontSize = self.font().pixelSize() self.fontUnit = "px" if self.fontSize == -1: # Font is set as points, not pixels. self.fontUnit = "pt" self.fontSize = self.font().pointSize() icon = QIcon() self.logoPixmap = QPixmap(_fromUtf8(":/freeseer/logo.png")) icon.addPixmap(self.logoPixmap, QIcon.Normal, QIcon.Off) self.setWindowIcon(icon) self.mainLayout = QGridLayout() self.setLayout(self.mainLayout) # Logo self.logo = QLabel("Logo") # To offset the logo so that it's to the right of the title self.logo.setStyleSheet("QLabel {{ margin-left: {} {} }}" .format(self.set_width_with_dpi(90) + (self.fontSize * 2.5), self.fontUnit)) self.logo.setPixmap(self.logoPixmap.scaledToHeight(self.set_height_with_dpi(80))) self.mainLayout.addWidget(self.logo, 0, 0, Qt.AlignTop) # Info self.aboutInfo = QLabel("About Info", openExternalLinks=True) self.aboutInfo.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.aboutInfo.setWordWrap(True) self.mainLayout.addWidget(self.aboutInfo, 0, 0) # Buttons self.buttonsLayout = QHBoxLayout() self.issueButton = QPushButton("Report an issue") self.docsButton = QPushButton("Freeseer documentation") self.contactButton = QPushButton("Contact us") self.buttonsLayout.insertWidget(0, self.docsButton) self.buttonsLayout.insertWidget(1, self.issueButton) self.buttonsLayout.insertWidget(2, self.contactButton) self.mainLayout.addLayout(self.buttonsLayout, 2, 0) self.connect(self.docsButton, SIGNAL('clicked()'), self.openDocsUrl) self.connect(self.issueButton, SIGNAL('clicked()'), self.openNewIssueUrl) self.connect(self.contactButton, SIGNAL('clicked()'), self.openContactUrl) self.retranslate() def retranslate(self, language=None): if language is not None: self.current_language = language self.uiTranslator.load(":/languages/tr_%s.qm" % self.current_language) # # Main Text # self.descriptionString = self.uiTranslator.translate("AboutDialog", "Freeseer is a video capture utility capable of capturing presentations. It captures " "video sources such as usb, firewire, or local desktop along with audio and mixes them " "together to produce a video.") self.copyrightString = self.uiTranslator.translate("AboutDialog", 'Copyright (C) 2014 The Free and ' 'Open Source Software Learning Centre') self.licenseTextString = self.uiTranslator.translate("AboutDialog", "Freeseer is licensed under the GPL " "version 3. This software is provided 'as-is',without any express or implied warranty. In " "no event will the authors be held liable for any damages arising from the use of this software.") self.aboutInfoString = u'<h1>' + NAME.capitalize() + u'</h1>' + \ u'<br><b>' + self.uiTranslator.translate("AboutDialog", "Version") + \ ": " + __version__ + u'</b>' + \ u'<p>' + self.descriptionString + u'</p>' + \ u'<p>' + self.copyrightString + u'</p>' + \ u'<p><a href="' + URL + u'">' + URL + u'</a></p>' \ u'<p>' + self.licenseTextString + u'</p>' \ u'<p>' + self.uiTranslator.translate("AboutDialog", "Record button graphics by") + \ u': <a href="' + RECORD_BUTTON_LINK + u'">' + RECORD_BUTTON_ARTIST + u'</a></p>' \ u'<p>' + self.uiTranslator.translate("AboutDialog", "Headphones graphics by") + \ u': <a href="' + HEADPHONES_LINK + u'">' + HEADPHONES_ARTIST + u'</a></p><br>' self.aboutInfo.setText(self.aboutInfoString) # --- End Main Text def openDocsUrl(self): """Opens a link to the Freeseer online documentation""" url = QUrl("http://freeseer.readthedocs.org") QDesktopServices.openUrl(url) def openNewIssueUrl(self): """Opens a link to the Freeseer new issue page""" url = QUrl("https://github.com/Freeseer/freeseer/issues/new") QDesktopServices.openUrl(url) def openContactUrl(self): """Opens a link to Freeseer's contact information""" url = QUrl("http://freeseer.readthedocs.org/en/latest/contact.html") QDesktopServices.openUrl(url)
def __init__(self, term, parent=None): super(TermFeeDialog, self).__init__(parent) self.term = term terms = self.pullOnes('terms', self.term) session = self.pullOnes('session', terms['sessionID']) self.termname = str( session['name']) + ' ' + terms['name'] + ' Term Report' self.pagetitle = self.termname #pull all CA ko = 0 feesText = QLabel('Select Fee') feesAmountText = QLabel('Amount') self.feesPop = QLabel('Total:') self.feesAmount = QLineEdit() self.feesAmount.setObjectName("schno") self.feesAmount.setPlaceholderText("000.00") self.feesCombo = QComboBox() self.arr = self.pullFees() self.hol = {} ko = 0 if self.arr and len(self.arr) > 0: for val in self.arr: self.feesCombo.addItem(val['name'].upper()) self.hol[ko] = val['id'] ko += 1 self.tree1 = QTreeWidget() self.tree1.setHeaderLabel("Choose Class") self.cla_arr = {} parent1 = QTreeWidgetItem(self.tree1) parent1.setText(0, "Select Class") parent1.setFlags(parent1.flags() | Qt.ItemIsTristate | Qt.ItemIsUserCheckable) arr1 = self.pullClass() if arr1 and len(arr1) > 0: for val in arr1: child = QTreeWidgetItem(parent1) child.setFlags(child.flags() | Qt.ItemIsUserCheckable) child.setText(0, str(val['name']).upper()) self.cla_arr[val['id']] = child if (val['active'] == 0): child.setCheckState(0, Qt.Unchecked) else: child.setCheckState(0, Qt.Unchecked) ko += 1 self.tree1.itemClicked.connect(lambda x=7: self.getClass(x)) self.hw = QFormLayout() self.hw.addRow(feesText, self.feesCombo) self.hw1 = QFormLayout() self.hw1.addRow(feesAmountText, self.feesAmount) layout1 = QGridLayout() layout1.addLayout(self.hw, 0, 0) layout1.addWidget(self.tree1, 1, 0) layout1.addLayout(self.hw1, 2, 0) layout2 = QGridLayout() layout2.addWidget(self.feesPop, 0, 0) groupBox1 = QGroupBox('Fees Settings') groupBox1.setLayout(layout1) self.pb = QPushButton() self.pb.setObjectName("Add") self.pb.setText("Add Fees") self.pb1 = QPushButton() self.pb1.setObjectName("Cancel") self.pb1.setText("Cancel") hbo = QHBoxLayout() hbo.addWidget(self.pb1) hbo.addStretch() hbo.addWidget(self.pb) groupBox2 = QGroupBox('') groupBox2.setLayout(hbo) groupBox3 = QGroupBox('') groupBox3.setLayout(layout2) grid = QGridLayout() grid.addWidget(groupBox1, 0, 0) grid.addWidget(groupBox3, 1, 0) grid.addWidget(groupBox2, 2, 0) self.setLayout(grid) self.connect(self.pb, SIGNAL("clicked()"), lambda: self.button_click()) self.connect(self.pb1, SIGNAL("clicked()"), lambda: self.button_close(self)) self.setWindowTitle(self.pagetitle)
class RefDlg(QDialog): """ A dialog for adding new reference. """ def __init__(self, mc, iw): """ Constructor. :param mc: A reference to the main class. :type mc: object :param iw: A reference to the insert window. :type iw: QMainWindow """ super(QDialog, self).__init__() self.mc = mc self.iw = iw self._setup_self() def _setup_self(self): """ Sets up self. """ self.setObjectName(u'RefDlg') self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) self.setWindowTitle(u'Add Reference') self.grid_lyt = QGridLayout(self) self.grid_lyt.setObjectName(u'grid_lyt') self.grid_lyt.setColumnMinimumWidth(1, 300) self._build_wdgs() def _build_wdgs(self): """ Builds own widgets. """ self.ttl_lbl = QLabel(self) self.ttl_lbl.setObjectName(u'ttl_lbl') self.ttl_lbl.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.ttl_lbl.setText(u'title') self.grid_lyt.addWidget(self.ttl_lbl, 0, 0, 1, 1) self.ttl_le = QLineEdit(self) self.ttl_le.setObjectName(u'ttl_le') self.grid_lyt.addWidget(self.ttl_le, 0, 1, 1, 1) self.au_lbl = QLabel(self) self.au_lbl.setObjectName(u'au_lbl') self.au_lbl.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.au_lbl.setText(u'author(s)') self.grid_lyt.addWidget(self.au_lbl, 1, 0, 1, 1) self.au_le = QLineEdit(self) self.au_le.setObjectName(u'au_le') self.grid_lyt.addWidget(self.au_le, 1, 1, 1, 1) self.yr_lbl = QLabel(self) self.yr_lbl.setObjectName(u'yr_lbl') self.yr_lbl.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.yr_lbl.setText(u'year') self.grid_lyt.addWidget(self.yr_lbl, 2, 0, 1, 1) today_dt = QDate.currentDate() self.yr_mde = de.MtyDe(self) self.yr_mde.setObjectName(u'yr_mde') self.yr_mde.setDisplayFormat('yyyy') self.grid_lyt.addWidget(self.yr_mde, 2, 1, 1, 1) self.isbn_lbl = QLabel(self) self.isbn_lbl.setObjectName(u'isbn_lbl') self.isbn_lbl.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.isbn_lbl.setText(u'isbn') self.grid_lyt.addWidget(self.isbn_lbl, 3, 0, 1, 1) self.isbn_le = QLineEdit(self) self.isbn_le.setObjectName(u'isbn_le') self.grid_lyt.addWidget(self.isbn_le, 3, 1, 1, 1) self.issn_lbl = QLabel(self) self.issn_lbl.setObjectName(u'issn_lbl') self.issn_lbl.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.issn_lbl.setText(u'issn') self.grid_lyt.addWidget(self.issn_lbl, 4, 0, 1, 1) self.issn_le = QLineEdit(self) self.issn_le.setObjectName(u'issn_le') self.grid_lyt.addWidget(self.issn_le, 4, 1, 1, 1) self.tp_lbl = QLabel(self) self.tp_lbl.setObjectName(u'tp_lbl') self.tp_lbl.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.tp_lbl.setText(u'referenceType') self.grid_lyt.addWidget(self.tp_lbl, 5, 0, 1, 1) self.tp_cb = QComboBox(self) self.tp_cb.setObjectName(u'tp_cb') self.grid_lyt.addWidget(self.tp_cb, 5, 1, 1, 1) self.jrn_lbl = QLabel(self) self.jrn_lbl.setObjectName(u'jrn_lbl') self.jrn_lbl.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.jrn_lbl.setText(u'journalName') self.grid_lyt.addWidget(self.jrn_lbl, 6, 0, 1, 1) self.jrn_le = QLineEdit(self) self.jrn_le.setObjectName(u'jrn_le') self.grid_lyt.addWidget(self.jrn_le, 6, 1, 1, 1) self.vol_lbl = QLabel(self) self.vol_lbl.setObjectName(u'vol_lbl') self.vol_lbl.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.vol_lbl.setText(u'volume') self.grid_lyt.addWidget(self.vol_lbl, 7, 0, 1, 1) self.vol_le = QLineEdit(self) self.vol_le.setObjectName(u'vol_le') self.grid_lyt.addWidget(self.vol_le, 7, 1, 1, 1) self.pg_lbl = QLabel(self) self.pg_lbl.setObjectName(u'pg_lbl') self.pg_lbl.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.pg_lbl.setText(u'page') self.grid_lyt.addWidget(self.pg_lbl, 8, 0, 1, 1) self.pg_le = QLineEdit(self) self.pg_le.setObjectName(u'pg_le') self.grid_lyt.addWidget(self.pg_le, 8, 1, 1, 1) self.mand_wdgs = [self.ttl_le, self.au_le, self.yr_mde, self.tp_cb] self.iw.set_mand_wdgs(self.mand_wdgs) # temporary workaround self.vol_le.setValidator(vald.LenIntVald(self.vol_le, 1, 32767)) self._fetch_ref_data() # to keep order self.input_wdgs = [ self.ttl_le, self.au_le, self.yr_mde, self.isbn_le, self.issn_le, self.tp_cb, self.jrn_le, self.vol_le, self.pg_le ] self.btn_lyt = QHBoxLayout() self.grid_lyt.addLayout(self.btn_lyt, 9, 1, 1, 1) self.sv_btn = QPushButton(self) self.sv_btn.setObjectName(u'sv_btn') self.sv_btn.setText(u'Save') self.sv_btn.clicked.connect(self._save_ref) self.btn_lyt.addWidget(self.sv_btn) self.cl_btn = QPushButton(self) self.cl_btn.setObjectName(u'ok_btn') self.cl_btn.setText(u'Close') self.cl_btn.clicked.connect(self.close) self.btn_lyt.addWidget(self.cl_btn) def _fetch_ref_data(self): """ Fetches data from the NOFA database and populates widgets. """ ref_cb_dict = self._ref_cb_dict self.iw.pop_cb(ref_cb_dict) @property def _ref_cb_dict(self): """ Returns a reference combo box dictionary. :returns: | A reference combo box dictionary: | - key - combo_box_name | - value - [<fill method>, [<arguments>], <default value>] :rtype: dict. """ ref_cb_dict = { self.tp_cb: [db.get_reftp_list, [self.mc.con], self.iw.sel_str] } return ref_cb_dict def _save_ref(self): """ Saves a reference into the database. """ try: self.iw.chck_mand_wdgs(self.mand_wdgs, exc.MandNotFldExc) ref_list = self.iw.get_wdg_list(self.input_wdgs) # temporary fix ref_list[2] = ref_list[2].year id = db.ins_ref(self.mc.con, ref_list) db.ins_ref_log(self.mc.con, id, self.mc.con_info[self.mc.usr_str]) self.iw.pop_ref_cb() self.iw.upd_ref( db.get_ref_str(ref_list[1], ref_list[0], ref_list[2], id)) QMessageBox.information(self, u'Saved', u'Reference saved.') except exc.MandNotFldExc as e: e.wdg.setFocus() QMessageBox.warning(self, u'Mandatory Fields', u'Fill/select all mandatory fields.')
def createWidgets(self): """ """ self.listingTab = QTabWidget() self.listingTab.setMinimumWidth(650) layoutGrid = QGridLayout() self.testSetPath = QLineEdit() self.testSetName = QLineEdit() self.testsTable = TestsTableView(self, core=self.core()) self.testcasesTable = TestcasesTableView(self, core=self.core()) self.stepsTable = StepsTableView(self, core=self.core()) self.listingTab.addTab( self.testsTable, "Test(s)") self.listingTab.addTab( self.testcasesTable, "Testcase(s)") self.listingTab.addTab( self.stepsTable, "Steps(s)") self.ignoreTestcases = QCheckBox("Ignore testcase(s)") if self.core().settings().cfg()["export-results"]["ignore-testcase"]: self.ignoreTestcases.setCheckState(Qt.Checked) self.ignoreUncomplete = QCheckBox("Ignore uncomplete result(s)") if self.core().settings().cfg()["export-results"]["ignore-uncomplete"]: self.ignoreUncomplete.setCheckState(Qt.Checked) self.addMissingFoldersCheckBox = QCheckBox(self.tr("Create missing folders")) if self.core().settings().cfg()["export-results"]["add-folders"]: self.addMissingFoldersCheckBox.setCheckState(Qt.Checked) self.addTestsetCheckBox = QCheckBox(self.tr("Create testset")) if self.core().settings().cfg()["export-results"]["add-testset"]: self.addTestsetCheckBox.setCheckState(Qt.Checked) self.addTestinstanceCheckBox = QCheckBox(self.tr("Add test instance in testset")) if self.core().settings().cfg()["export-results"]["add-testinstance"]: self.addTestinstanceCheckBox.setCheckState(Qt.Checked) optionsLayout = QHBoxLayout() optionsLayout.addWidget(self.ignoreTestcases) optionsLayout.addWidget(self.ignoreUncomplete) optionsLayout.addStretch(1) optionsTsLayout = QHBoxLayout() optionsTsLayout.addWidget(self.addTestsetCheckBox) optionsTsLayout.addWidget(self.addTestinstanceCheckBox) optionsTsLayout.addStretch(1) layoutGrid.addWidget(QLabel("Remote Test Set Path:"), 0, 0) layoutGrid.addWidget(self.testSetPath, 0, 1) layoutGrid.addWidget(self.addMissingFoldersCheckBox, 1, 1) layoutGrid.addWidget(QLabel("Remote Test Set Name:"), 2, 0) layoutGrid.addWidget(self.testSetName, 2, 1) layoutGrid.addLayout(optionsTsLayout, 3, 1) layoutGrid.addWidget(QLabel("Local result(s):"), 4, 0) layoutGrid.addLayout(optionsLayout, 4, 1) layoutGrid.addWidget(QLabel("Test(s) Verdict:"), 5, 0) layoutGrid.addWidget(self.listingTab, 5, 1) self.exportStatusLabel = QLabel( "Status: Disconnected", self) self.exportButton = QPushButton(self.tr("Export Result"), self) self.exportButton.setMinimumWidth(300) layoutRight = QHBoxLayout() layoutRight.addWidget(self.exportButton) layoutRight.addWidget(self.exportStatusLabel) layoutRight.addStretch(1) layoutGrid.addWidget(QLabel("Controls:"), 6, 0) layoutGrid.addLayout(layoutRight, 6, 1) layoutMain = QHBoxLayout() layoutMain.addLayout(layoutGrid) self.setLayout(layoutMain)
def __init__(self, parent=None): super(LayerSelectionPage, self).__init__(parent) self.parent = parent #convenience link self.confconn_link = self.parent.parent.confconn #flag top prevent read read action on keyword delete. New logic makes this redundant #self.keywordbypass = False QToolTip.setFont(QFont('SansSerif', 10)) #label filterlabel = QLabel('Filter') availablelabel = QLabel('Available Layers') selectionlabel = QLabel('Layer Selections') keywordlabel = QLabel('Keyword') explainlabel = QLabel("Edit Group assignments using this dialog or to simply initialise the Layer-Config just click 'Finish'") #selection buttons chooseallbutton = QPushButton('>>') chooseallbutton.setFixedWidth(self.XFER_BW) chooseallbutton.clicked.connect(self.doChooseAllClickAction) choosebutton = QPushButton('>') choosebutton.setFixedWidth(self.XFER_BW) choosebutton.clicked.connect(self.doChooseClickAction) rejectbutton = QPushButton('<') rejectbutton.setFixedWidth(self.XFER_BW) rejectbutton.clicked.connect(self.doRejectClickAction) rejectallbutton = QPushButton('<<') rejectallbutton.setFixedWidth(self.XFER_BW) rejectallbutton.clicked.connect(self.doRejectAllClickAction) #operation buttons finishbutton = QPushButton('Finish') finishbutton.setToolTip('Finish and Close layer selection dialog') finishbutton.clicked.connect(self.parent.close) resetbutton = QPushButton('Reset') resetbutton.font() resetbutton.setToolTip('Read Layer from LDS GetCapabilities request. Overwrites current Layer Config') resetbutton.clicked.connect(self.doResetClickAction) self.available_sfpm = LDSSFPAvailableModel(self) self.selection_sfpm = LDSSFPSelectionModel(self) self.available_sfpm.setSourceModel(self.parent.available_model) self.selection_sfpm.setSourceModel(self.parent.selection_model) #textedits filteredit = QLineEdit('') filteredit.setToolTip('Filter Available-Layers pane (filter operates across Name and Title fields and accepts Regex expressions)') filteredit.textChanged.connect(self.available_sfpm.setActiveFilter) self.keywordcombo = QComboBox() self.keywordcombo.setToolTip('Select or Add a unique identifier to be saved in layer config (keyword)') self.keywordcombo.addItems(list(self.confconn_link.assigned)) self.keywordcombo.setEditable(True) self.keywordcombo.activated.connect(self.doKeyComboChangeAction) lgindex = self.confconn_link.getLayerGroupIndex(self.confconn_link.lgval,col=1) lgentry = self.confconn_link.lglist[lgindex] if LU.assessNone(lgindex) else None #keywordedit = self.keywordcombo.lineEdit().text().toUtf8().data().decode('utf8')# for writing #if no entry or layer indicated then blank self.keywordcombo.lineEdit().setText('' if lgentry is None or lgentry[0]==LORG.LAYER else lgentry[1])#self.confconn_link.lgval)#TODO. group only #header headmodel = QStandardItemModel() headmodel.setHorizontalHeaderLabels([i[2] for i in self.colparams][:self.parent.available_model.columnCount()]) headview1 = QHeaderView(Qt.Horizontal) headview1.setModel(headmodel) headview1.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) headview2 = QHeaderView(Qt.Horizontal) headview2.setModel(headmodel) headview2.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) #table self.available = QTableView() self.available.setSelectionBehavior(QAbstractItemView.SelectRows) self.available.setSelectionMode(QAbstractItemView.MultiSelection) self.selection = QTableView() self.selection.setSelectionBehavior(QAbstractItemView.SelectRows) self.selection.setSelectionMode(QAbstractItemView.MultiSelection) #interesting, must set model after selection attributes but before headers else row selections/headers don't work properly self.available.setModel(self.available_sfpm) self.selection.setModel(self.selection_sfpm) self.available.setSortingEnabled(True) self.available.setHorizontalHeader(headview1) self.selection.setSortingEnabled(True) self.selection.setHorizontalHeader(headview2) for cp in self.colparams: self.available.setColumnWidth(cp[0],cp[1]) self.selection.setColumnWidth(cp[0],cp[1]) self.available.verticalHeader().setVisible(False) self.available.horizontalHeader().setVisible(True) self.selection.verticalHeader().setVisible(False) self.selection.horizontalHeader().setVisible(True) #layout vbox00 = QVBoxLayout() vbox00.addWidget(availablelabel) vbox00.addWidget(self.available) vbox01 = QVBoxLayout() vbox01.addWidget(chooseallbutton) vbox01.addWidget(choosebutton) vbox01.addWidget(rejectbutton) vbox01.addWidget(rejectallbutton) vbox02 = QVBoxLayout() vbox02.addWidget(selectionlabel) vbox02.addWidget(self.selection) vbox10 = QVBoxLayout() vbox10.addWidget(filterlabel) vbox10.addWidget(filteredit) hbox12 = QHBoxLayout() hbox12.addWidget(keywordlabel) hbox12.addStretch(1) #hbox12.addWidget(inspbutton) #hbox12.addWidget(addbutton) #hbox12.addWidget(delbutton) vbox12 = QVBoxLayout() vbox12.addLayout(hbox12) vbox12.addWidget(self.keywordcombo) #00|01|02 #10|11|12 grid0 = QGridLayout() grid0.addLayout(vbox00,1,0) grid0.addLayout(vbox01,1,1) grid0.addLayout(vbox02,1,2) grid0.addLayout(vbox10,0,0) grid0.addLayout(vbox12,0,2) hbox2 = QHBoxLayout() hbox2.addWidget(resetbutton) hbox2.addStretch(1) hbox2.addWidget(explainlabel) hbox2.addWidget(finishbutton) #gbox1.setLayout(hbox2) vbox3 = QVBoxLayout() vbox3.addLayout(grid0) #vbox3.addLayout(hbox3) #vbox3.addWidget(line0) vbox3.addLayout(hbox2) self.setLayout(vbox3)