def init_ui(self): vbl_0 = QVBoxLayout(self) grid = QGridLayout() grid.setContentsMargins(0, 0, 0, 0) # left, top, right, bottom grid.setVerticalSpacing(2) grid.setHorizontalSpacing(2) self.label_title = QLabel(self) font = QFont() font.setPointSize(18) font.setBold(True) self.label_title.setFont(font) self.label_title.setContentsMargins(2, 5, 5, 7) self.label_title.setStyleSheet(Style.h2()) hbox = QHBoxLayout() hbox.addWidget(self.label_title, 1) hbox.setContentsMargins(0, 0, 0, 5) grid.addLayout(hbox, 1, 1, 1, 3) # ordinal = 3 self.widgets = [] for tup in self.paras.describe(): para_name = QLabel(self) para_value = QLabel(self) para_name.setContentsMargins(5, 1, 5, 1) para_value.setContentsMargins(5, 1, 5, 1) para_name.setTextInteractionFlags(Qt.TextSelectableByMouse) para_value.setTextInteractionFlags(Qt.TextSelectableByMouse) # special colors for parameters and derived values if tup[0]: para_name.setStyleSheet(Style.parameter()) para_value.setStyleSheet(Style.parameter()) else: para_name.setStyleSheet(Style.derived()) para_value.setStyleSheet(Style.derived()) # Make urls clickable if isinstance(tup[2], str) and tup[2].startswith("http"): para_value.linkActivated.connect(self.on_link_activated) self.widgets.append([para_name, para_value]) grid.addWidget(para_name, ordinal, 1) grid.addWidget(para_value, ordinal, 2) ordinal += 1 # hbox = QHBoxLayout() hbox.addLayout(grid) vbox = QVBoxLayout() vbox.addStretch(1) self.btn_run = QPushButton(_("Run...")) self.btn_run.clicked.connect(self.on_btn_run_clicked) vbox.addWidget(self.btn_run) hbox.addLayout(vbox) hbox.addStretch(1) vbl_0.addLayout(hbox) vbl_0.addStretch(1) self.setLayout(vbl_0)
def __init__(self, parent, name, conv, grid, ordinal, browse=False, width=None): ParaWidget.__init__(self, parent) self.name = name self.v2tx = conv[0] self.tx2v = conv[1] self.grid = grid self.ordinal = ordinal self.browse = browse self.label = QLabel(self) self.edit = QLineEdit() if width: self.edit.setFixedWidth(width) self.button = QPushButton() self.err_label = QLabel(self) self.err_label.setStyleSheet(Style.error()) self.err_label.setVisible(False) self.edit.textChanged.connect(self.parameter_changed) self.edit.editingFinished.connect(self.parameter_finished) self.button.clicked.connect(self.button_clicked) grid.addWidget(self.label, ordinal, 1) grid.addWidget(self.edit, ordinal, 2) if self.browse: grid.addWidget(self.button, ordinal, 3) grid.addWidget(self.err_label, ordinal + 1, 1, 1, 3) self.on_switch_language() self.on_switch_configuration()
def on_btn_run_clicked(self): if self.paras.select_mode == SelectMode.simple: selector = Selector() if self.paras.simple_select_file: selector.include(self.paras.simple_select_file) else: selector = self.ctrl.selector self.paras.is_saving_sitemaps = not self.chk_trial_run.isChecked() self.pte_events1.setPlainText("") self.pte_events2.setPlainText("") self.pte_events3.setPlainText("") self.lbl_processing.setVisible(True) self.lbl_processing_file.setVisible(True) self.btn_close.setEnabled(False) self.btn_run.setEnabled(False) self.chk_trial_run.setEnabled(False) self.btn_stop.setEnabled(True) self.btn_stop.setStyleSheet(Style.alarm()) self.executor_thread = ExecutorThread(self.paras, selector, self) self.executor_thread.signal_exception.connect(self.on_signal_exception) self.executor_thread.ask_confirmation.connect(self.on_ask_confirmation) self.executor_thread.signal_main_event.connect( self.on_signal_main_event) self.executor_thread.signal_minor_event.connect( self.on_signal_minor_event) self.executor_thread.signal_next_file.connect(self.on_signal_next_file) self.executor_thread.signal_end_processing.connect( self.on_signal_end_processing) self.executor_thread.finished.connect(self.on_executor_thread_finished) self.executor_thread.start() self.update()
def parameter_changed(self, text): try: value = self.tx2v(text) setattr(self.paras, self.name, value) self.accepted = True self.err_label.setText("") self.err_label.setVisible(False) self.edit.setStyleSheet(Style.default()) self.label.setStyleSheet(Style.default()) self.edit.setToolTip(None) except ValueError as err: self.accepted = False self.err_label.setText(str(err)) self.err_label.setVisible(True) self.edit.setStyleSheet(Style.error()) self.label.setStyleSheet(Style.error())
def __init__(self, parent): QWidget.__init__(self) self.ctrl = QApplication.instance().ctrl self.parent = parent self.setWindowTitle("About") hbox = QHBoxLayout() pic = QLabel(self) pix = QPixmap( os.path.join(self.ctrl.application_home, 'conf/img/logo_h.png')) pic.setPixmap(pix) hbox.addWidget(pic) vbox = QVBoxLayout() lbl_title = QLabel("Metadata Publishing Tool", self) lbl_title.setMinimumWidth(400) font = QFont() font.setPointSize(20) font.setBold(True) lbl_title.setFont(font) lbl_title.setContentsMargins(2, 5, 5, 7) lbl_title.setStyleSheet(Style.h2()) vbox.addWidget(lbl_title) #vbox.addSpacing(20) vbox.addStretch(1) grid = QGridLayout() grid.setContentsMargins(0, 0, 0, 0) # left, top, right, bottom grid.setVerticalSpacing(2) grid.setHorizontalSpacing(2) grid.addWidget(QLabel("Version: "), 1, 1) grid.addWidget(QLabel(version.__version__), 1, 2) grid.addWidget(QLabel("Release: "), 2, 1) grid.addWidget(QLabel(version.__release_date__), 2, 2) hbox_grid = QHBoxLayout() hbox_grid.addLayout(grid) hbox_grid.addStretch(1) vbox.addLayout(hbox_grid) vbox.addSpacing(10) txt = QTextBrowser() txt.setMinimumHeight(250) txt.setOpenExternalLinks(True) txt.setOpenLinks(False) txt.anchorClicked.connect(self.on_anchor_clicked) txt.append(version.__about__) vbox.addWidget(txt) hbox.addLayout(vbox) hbox.addStretch(1) self.setLayout(hbox) self.move(200, 200) self.setWindowFlags((self.windowFlags() | Qt.CustomizeWindowHint) & ~Qt.WindowMaximizeButtonHint & ~Qt.WindowMinimizeButtonHint) self.show()
def parameter_finished(self): try: value = self.tx2v(self.edit.text()) setattr(self.paras, self.name, value) self.paras.save_configuration() self.accepted = True self.err_label.setText("") self.err_label.setVisible(False) value = self.v2tx(getattr(self.paras, self.name)) self.edit.setText(value) self.edit.setStyleSheet(Style.default()) self.label.setStyleSheet(Style.default()) except ValueError as err: self.accepted = False self.err_label.setText(str(err)) self.err_label.setVisible(True) self.edit.setStyleSheet(Style.error()) self.label.setStyleSheet(Style.error())
def on_btn_run_clicked(self): self.work_started.emit() self.pte_events1.setPlainText("") self.pte_events2.setPlainText("") self.pte_events3.setPlainText("") self.lbl_processing.setVisible(True) self.lbl_processing_file.setVisible(True) self.btn_close.setEnabled(False) self.btn_run.setEnabled(False) self.chk_trial_run.setEnabled(False) self.btn_stop.setEnabled(True) self.btn_stop.setStyleSheet(Style.alarm())
def __init__(self, work="", title_style=Style.h2()): QWidget.__init__(self) self.ctrl = QApplication.instance().ctrl self.ctrl.switch_language.connect(self.on_switch_language) self.ctrl.switch_configuration.connect(self.on_switch_configuration) self.paras = self.ctrl.paras self.conf = GuiConf() # work should be a verb: Execute, Transport ... self.work = work self.title_style = title_style self.setWindowTitle(_(self.work)) self.executor_thread = None self.splitter_event_moved = False self.splitter_title_moved = False self.init_ui() self.show()
def init_ui(self): vbl_0 = QVBoxLayout(self) grid = QGridLayout() grid.setContentsMargins(0, 0, 0, 0) # left, top, right, bottom grid.setVerticalSpacing(5) self.label_title = QLabel(self) font = QFont() font.setPointSize(18) font.setBold(True) self.label_title.setFont(font) self.label_title.setContentsMargins(2, 5, 5, 7) self.label_title.setStyleSheet(Style.h2()) hbox = QHBoxLayout() hbox.addWidget(self.label_title, 1) hbox.setContentsMargins(0, 0, 0, 5) grid.addLayout(hbox, 1, 1, 1, 3) str_conv = (self.str2tx, self.tx2str) int_conv = (self.int2tx, self.tx2int) self.para_widgets = { "resource_dir": ParaLine(self, "resource_dir", str_conv, grid, 3, True), "metadata_dir": ParaLine(self, "metadata_dir", str_conv, grid, 5, False), "description_dir": ParaLine(self, "description_dir", str_conv, grid, 7, True), "plugin_dir": ParaLine(self, "plugin_dir", str_conv, grid, 9, True), "url_prefix": ParaLine(self, "url_prefix", str_conv, grid, 11, False), "strategy": ParaStrategyDrop(self, "strategy", grid, 13), "max_items_in_list": ParaLine(self, "max_items_in_list", int_conv, grid, 15, False, 100), "zero_fill_filename": ParaLine(self, "zero_fill_filename", int_conv, grid, 17, False, 100), "is_saving_pretty_xml": ParaCheck(self, "is_saving_pretty_xml", grid, 19), "is_saving_sitemaps": ParaCheck(self, "is_saving_sitemaps", grid, 20), "has_wellknown_at_root": ParaCheck(self, "has_wellknown_at_root", grid, 21) } self.button_reset = QPushButton(_("Reset"), self) self.button_reset.clicked.connect(self.on_button_reset_clicked) grid.addWidget(self.button_reset, 22, 3) vbl_0.addLayout(grid) vbl_0.addStretch(1) self.setLayout(vbl_0)
def on_btn_play_clicked(self): self.pte_output.setPlainText("") self.pte_exceptions.setPlainText("") selector = self.get_selector() self.player = PlayerThread(selector, self) self.player.yield_resource.connect(self.on_yield_resource) self.player.signal_exception.connect(self.on_signal_exception) self.player.signal_excluded_resource.connect( self.on_signal_excluded_resource) self.player.finished.connect(self.on_player_finished) # counters self.resource_count = 0 self.excluded_resource_count = 0 self.exception_count = 0 self.lbl_resources_counter.setText(str(self.resource_count)) self.lbl_excluded_resources_counter.setText( str(self.excluded_resource_count)) # buttons self.btn_close.setEnabled(False) self.btn_play.setEnabled(False) self.btn_stop.setEnabled(True) self.btn_stop.setStyleSheet(Style.alarm()) self.player.start() self.update()
def init_ui(self): vbl_0 = QVBoxLayout(self) self.label_title = QLabel(self) font = QFont() font.setPointSize(18) font.setBold(True) self.label_title.setFont(font) self.label_title.setContentsMargins(2, 5, 5, 7) self.label_title.setStyleSheet(Style.h2()) lbl_color = QLabel(" ", self) lbl_color.setStyleSheet(Style.configure_title()) hbox1 = QHBoxLayout() hbox1.addWidget(lbl_color) hbox1.addWidget(self.label_title, 1) self.btn_help = QPushButton(_("Help..."), self) self.btn_help.clicked.connect(self.on_button_help_clicked) hbox1.addWidget(self.btn_help) hbox1.setContentsMargins(0, 0, 0, 5) vbl_0.addLayout(hbox1) vbl_0.insertSpacing(2, 25) grid = QGridLayout() grid.setContentsMargins(0, 0, 0, 0) # left, top, right, bottom grid.setVerticalSpacing(5) self.para_widgets = { "resource_dir": ParaLine(self, "resource_dir", ParaWidget.str_conv(), grid, 3, True), "metadata_dir": ParaLine(self, "metadata_dir", ParaWidget.str_conv(), grid, 5, False), "description_dir": ParaLine(self, "description_dir", ParaWidget.str_conv(), grid, 7, True), "plugin_dir": ParaLine(self, "plugin_dir", ParaWidget.str_conv(), grid, 9, True), "url_prefix": ParaLine(self, "url_prefix", ParaWidget.str_conv(), grid, 11, False), "strategy": ParaStrategyDrop(self, "strategy", grid, 15), "max_items_in_list": ParaLine(self, "max_items_in_list", ParaWidget.int_conv(), grid, 17, False, width=100), "zero_fill_filename": ParaLine(self, "zero_fill_filename", ParaWidget.int_conv(), grid, 19, False, width=100), "is_saving_pretty_xml": ParaCheck(self, "is_saving_pretty_xml", grid, 21), "is_saving_sitemaps": ParaCheck(self, "is_saving_sitemaps", grid, 22), "has_wellknown_at_root": ParaCheck(self, "has_wellknown_at_root", grid, 23) } self.button_reset = QPushButton(_("Reset"), self) self.button_reset.clicked.connect(self.on_button_reset_clicked) grid.addWidget(self.button_reset, 24, 3) vbl_0.addLayout(grid) vbl_0.addStretch(1) self.setLayout(vbl_0)
def __init__(self, export_mode, all_resources=False): WorkWidget.__init__(self, work=export_mode + " " + "Transport", title_style=Style.transport_title()) self.chk_trial_run.setVisible(False) self.export_mode = export_mode self.all_resources = all_resources _("Transport")
def init_ui(self): vbl_0 = QVBoxLayout(self) self.label_title = QLabel(self) font = QFont() font.setPointSize(18) font.setBold(True) self.label_title.setFont(font) self.label_title.setContentsMargins(2, 5, 5, 7) self.label_title.setStyleSheet(Style.h2()) lbl_color = QLabel(" ", self) lbl_color.setStyleSheet(Style.transport_title()) hbox1 = QHBoxLayout() hbox1.addWidget(lbl_color) hbox1.addWidget(self.label_title, 1) self.btn_help = QPushButton(_("Help..."), self) self.btn_help.clicked.connect(self.on_button_help_clicked) hbox1.addWidget(self.btn_help) hbox1.setContentsMargins(0, 0, 0, 5) vbl_0.addLayout(hbox1) grid1 = QGridLayout() grid1.setContentsMargins(0, 0, 0, 0) # left, top, right, bottom grid1.setVerticalSpacing(2) grid1.setHorizontalSpacing(2) self.lbl_metadata_key = SelectableLabel(self) self.lbl_metadata_value = SelectableLabel(self) grid1.addWidget(self.lbl_metadata_key, 2, 1) grid1.addWidget(self.lbl_metadata_value, 2, 2) self.lbl_last_execution_key = SelectableLabel(self) self.lbl_last_execution_value = SelectableLabel(self) grid1.addWidget(self.lbl_last_execution_key, 3, 1) grid1.addWidget(self.lbl_last_execution_value, 3, 2) hbox2 = QHBoxLayout() hbox2.addLayout(grid1) hbox2.addStretch(1) vbl_0.addLayout(hbox2) vbl_0.insertSpacing(2, 25) # # scp group grid2 = QGridLayout() grid2.setContentsMargins(0, 0, 0, 0) # left, top, right, bottom grid2.setVerticalSpacing(5) grid2.setHorizontalSpacing(10) self.grp_scp = QGroupBox(_("Transfer files with Secure Copy Protocol (scp)")) vbox3 = QVBoxLayout() self.para_scp_widgets = { "exp_scp_server": ParaLine(self, "exp_scp_server", ParaWidget.str_conv(), grid2, 3, False), "exp_scp_port": ParaLine(self, "exp_scp_port", ParaWidget.int_conv(), grid2, 5, False, width=100), "exp_scp_user": ParaLine(self, "exp_scp_user", ParaWidget.str_conv(), grid2, 7, False), "exp_scp_document_root": ParaLine(self, "exp_scp_document_root", ParaWidget.str_conv(), grid2, 9, False), } self.lbl_server_path = QLabel(_("server_path_label")) self.edt_server_path = QLabel(self.ctrl.paras.server_path()) self.edt_server_path.setStyleSheet(Style.derived()) self.edt_server_path.setTextInteractionFlags(Qt.TextSelectableByMouse) grid2.addWidget(self.lbl_server_path, 11, 1) grid2.addWidget(self.edt_server_path, 11, 2) self.grp_scp.setLayout(vbox3) vbox3.addLayout(grid2) hbox_scp = QHBoxLayout() hbox_scp.addStretch(1) self.scp_radio_all = QRadioButton(_("Export all resources")) self.scp_radio_all.setChecked(False) self.scp_radio_latest = QRadioButton(_("Export latest changes")) self.scp_radio_latest.setChecked(True) hbox_scp.addWidget(self.scp_radio_all) hbox_scp.addWidget(self.scp_radio_latest) self.scp_button_start = QPushButton(_("Start transfer")) self.scp_button_start.clicked.connect(self.on_scp_button_start_clicked) hbox_scp.addWidget(self.scp_button_start) vbox3.addLayout(hbox_scp) vbl_0.addWidget(self.grp_scp) vbl_0.insertSpacing(4, 15) # # zip group grid3 = QGridLayout() grid3.setContentsMargins(0, 0, 0, 0) # left, top, right, bottom grid3.setVerticalSpacing(5) grid3.setHorizontalSpacing(10) self.grp_zip = QGroupBox(_("Create a .zip file")) vbox4 = QVBoxLayout() self.para_zip_widgets = { "zip_filename": ParaLine(self, "zip_filename", ParaWidget.str_conv(), grid3, 3, browse="SaveFileName") } self.grp_zip.setLayout(vbox4) vbox4.addLayout(grid3) hbox_zip = QHBoxLayout() hbox_zip.addStretch(1) self.zip_radio_all = QRadioButton(_("Zip all resources")) self.zip_radio_all.setChecked(False) self.zip_radio_latest = QRadioButton(_("Zip latest changes")) self.zip_radio_latest.setChecked(True) hbox_zip.addWidget(self.zip_radio_all) hbox_zip.addWidget(self.zip_radio_latest) self.zip_button_start = QPushButton(_("Start creation")) self.zip_button_start.clicked.connect(self.on_zip_button_start_clicked) hbox_zip.addWidget(self.zip_button_start) vbox4.addLayout(hbox_zip) vbl_0.addWidget(self.grp_zip) vbl_0.addStretch(1) self.setLayout(vbl_0)
def __init__(self): WorkWidget.__init__(self, work="Import", title_style=Style.import_title()) self.chk_trial_run.setVisible(False) _("Import")
def init_ui(self): vbl_0 = QVBoxLayout(self) self.label_title = QLabel(self) font = QFont() font.setPointSize(18) font.setBold(True) self.label_title.setFont(font) self.label_title.setContentsMargins(2, 5, 5, 7) self.label_title.setStyleSheet(Style.h2()) lbl_color = QLabel(" ", self) lbl_color.setStyleSheet(Style.import_title()) hbox1 = QHBoxLayout() hbox1.addWidget(lbl_color) hbox1.addWidget(self.label_title, 1) self.btn_help = QPushButton(_("Help..."), self) self.btn_help.clicked.connect(self.on_button_help_clicked) hbox1.addWidget(self.btn_help) hbox1.setContentsMargins(0, 0, 0, 5) vbl_0.addLayout(hbox1) vbl_0.insertSpacing(2, 25) # # scp group grid1 = QGridLayout() grid1.setContentsMargins(0, 0, 0, 0) # left, top, right, bottom grid1.setVerticalSpacing(5) grid1.setHorizontalSpacing(10) self.grp_scp = QGroupBox( _("Import files with Secure Copy Protocol (scp)")) vbox1 = QVBoxLayout() self.para_scp_widgets = { "imp_scp_server": ParaLine(self, "imp_scp_server", ParaWidget.str_conv(), grid1, 3, False), "imp_scp_port": ParaLine(self, "imp_scp_port", ParaWidget.int_conv(), grid1, 5, False, width=100), "imp_scp_user": ParaLine(self, "imp_scp_user", ParaWidget.str_conv(), grid1, 7, False), "imp_scp_remote_path": ParaLine(self, "imp_scp_remote_path", ParaWidget.str_conv(), grid1, 9, False), "imp_scp_local_path": ParaLine(self, "imp_scp_local_path", ParaWidget.str_conv(), grid1, 11, True), } self.grp_scp.setLayout(vbox1) vbox1.addLayout(grid1) hbox_scp = QHBoxLayout() hbox_scp.addStretch(1) self.scp_button_start = QPushButton(_("Start")) self.scp_button_start.clicked.connect(self.on_scp_button_start_clicked) hbox_scp.addWidget(self.scp_button_start) vbox1.addLayout(hbox_scp) vbl_0.addWidget(self.grp_scp) vbl_0.addStretch(1) self.setLayout(vbl_0)
def __init__(self): WorkWidget.__init__(self, work="Execute", title_style=Style.execute_title()) _("Execute")
def __init__(self, *__args): QLabel.__init__(self, *__args) self.setContentsMargins(5, 1, 5, 1) self.setTextInteractionFlags(Qt.TextSelectableByMouse) self.setStyleSheet(Style.derived())
def init_ui(self): vbox = QVBoxLayout() self.splitter_title = QSplitter(Qt.Vertical) self.splitter_event = QSplitter(Qt.Vertical) self.splitter_title.splitterMoved.connect(self.on_splitter_title_moved) self.splitter_event.splitterMoved.connect(self.on_splitter_event_moved) self.lbl_events_title1 = QLabel(_("Main events")) self.splitter_title.addWidget(self.lbl_events_title1) self.lbl_events_title2 = QLabel(_("Resources")) self.splitter_title.addWidget(self.lbl_events_title2) self.lbl_events_title3 = QLabel(_("Errors")) self.splitter_title.addWidget(self.lbl_events_title3) self.pte_events1 = QTextBrowser() self.pte_events1.setOpenExternalLinks(True) self.pte_events1.setOpenLinks(False) self.pte_events1.anchorClicked.connect(self.on_anchor_clicked) self.pte_events1.setLineWrapMode(QTextEdit.NoWrap) self.splitter_event.addWidget(self.pte_events1) self.pte_events2 = QTextBrowser() self.pte_events2.setOpenExternalLinks(True) self.pte_events2.setOpenLinks(False) self.pte_events2.anchorClicked.connect(self.on_anchor_clicked) self.pte_events2.setLineWrapMode(QTextEdit.NoWrap) self.splitter_event.addWidget(self.pte_events2) self.pte_events3 = QPlainTextEdit() self.pte_events3.setReadOnly(True) self.pte_events3.setLineWrapMode(QPlainTextEdit.NoWrap) self.pte_events3.setStyleSheet(Style.red_text()) self.pte_events3.setCenterOnScroll(True) self.splitter_event.addWidget(self.pte_events3) self.splitter_title.setStretchFactor(0, 5) self.splitter_title.setStretchFactor(1, 3) self.splitter_title.setStretchFactor(2, 1) self.splitter_event.setStretchFactor(0, 5) self.splitter_event.setStretchFactor(1, 3) self.splitter_event.setStretchFactor(2, 1) hbox_splitters = QHBoxLayout() hbox_splitters.addWidget(self.splitter_title, 0) hbox_splitters.addWidget(self.splitter_event, 5) vbox.addLayout(hbox_splitters) lbl_box = QHBoxLayout() self.lbl_processing = QLabel(_("Processing:")) self.lbl_processing_file = QLabel("") self.lbl_processing.setVisible(False) self.lbl_processing_file.setVisible(False) lbl_box.addWidget(self.lbl_processing) lbl_box.addWidget(self.lbl_processing_file) lbl_box.addStretch(1) vbox.addLayout(lbl_box) btn_box = QHBoxLayout() btn_box.addStretch(1) self.chk_trial_run = QCheckBox(_("Trial run")) self.chk_trial_run.setChecked(not self.paras.is_saving_sitemaps) btn_box.addWidget(self.chk_trial_run) self.btn_run = QPushButton(_("Run")) self.btn_run.clicked.connect(self.on_btn_run_clicked) btn_box.addWidget(self.btn_run) self.btn_stop = QPushButton(_("Stop")) self.btn_stop.clicked.connect(self.on_btn_stop_clicked) self.normal_style = self.btn_stop.styleSheet() self.btn_stop.setEnabled(False) btn_box.addWidget(self.btn_stop) self.btn_close = QPushButton(_("Close")) self.btn_close.clicked.connect(self.on_btn_close_clicked) btn_box.addWidget(self.btn_close) vbox.addLayout(btn_box) self.setLayout(vbox) self.resize(self.conf.execute_widget_width(), self.conf.execute_widget_height())
def init_ui(self): vbl_0 = QVBoxLayout(self) self.label_title = QLabel(_("Select resources"), self) font = QFont() font.setPointSize(18) font.setBold(True) self.label_title.setFont(font) self.label_title.setContentsMargins(2, 5, 5, 7) self.label_title.setStyleSheet(Style.h2()) lbl_color = QLabel(" ", self) lbl_color.setStyleSheet(Style.select_title()) hbox = QHBoxLayout() hbox.addWidget(lbl_color) hbox.addWidget(self.label_title, 1) self.btn_help = QPushButton(_("Help..."), self) self.btn_help.clicked.connect(self.on_button_help_clicked) hbox.addWidget(self.btn_help) hbox.setContentsMargins(0, 0, 0, 5) # left, top, right, bottom vbl_0.addLayout(hbox) self.grp_simple = QGroupBox(_("Simpel selection: One directory")) self.grp_simple.setCheckable(True) self.grp_simple.toggled.connect(self.on_grp_simple_toggle) # simple group self.lbl_simple = QLabel(_("Location")) self.edt_simple = QLineEdit() self.edt_simple.editingFinished.connect(self.on_edt_simple_finished) vbox_simple = QVBoxLayout() vbox_simple.setSpacing(0) self.btn_simple_brws = QPushButton(_("Browse")) self.btn_simple_brws.clicked.connect(self.on_btn_simple_brws_clicked) vbox_simple.addWidget(self.btn_simple_brws) self.btn_simple_play = QPushButton(_("Play...")) self.btn_simple_play.clicked.connect(self.on_btn_simple_play_clicked) vbox_simple.addWidget(self.btn_simple_play) hbox2 = QHBoxLayout() hbox2.addWidget(self.lbl_simple) hbox2.addWidget(self.edt_simple) hbox2.addLayout(vbox_simple) self.grp_simple.setLayout(hbox2) vbl_0.addWidget(self.grp_simple) self.grp_selector = QGroupBox(_("Advanced: Create a selector")) self.grp_selector.setCheckable(True) self.grp_selector.toggled.connect(self.on_grp_selector_toggle) grid = QGridLayout() # selector group: selector file self.lbl_saved_as = QLabel(_("Selector")) self.lbl_selector_file = QLabel() self.lbl_selector_file.setTextInteractionFlags( Qt.TextSelectableByMouse) grid.addWidget(self.lbl_saved_as, 1, 1) grid.addWidget(self.lbl_selector_file, 1, 2, 1, 2) # selector group: includes self.lbl_includes = QLabel(_("Includes")) self.lbl_includes.setAlignment(Qt.AlignTop) self.txt_includes = QPlainTextEdit() self.txt_includes.installEventFilter(self) self.btn_incl_directory = QPushButton(_("Add directory")) self.btn_incl_directory.clicked.connect( self.on_btn_incl_directory_clicked) self.btn_incl_files = QPushButton(_("Add files")) self.btn_incl_files.clicked.connect(self.on_btn_incl_files_clicked) self.btn_incl_import = QPushButton(_("Import entries")) self.btn_incl_import.clicked.connect(self.on_btn_incl_import_clicked) grid.addWidget(self.lbl_includes, 2, 1) grid.addWidget(self.txt_includes, 2, 2) vbox_inc = QVBoxLayout() vbox_inc.setSpacing(0) vbox_inc.addWidget(self.btn_incl_directory) vbox_inc.addWidget(self.btn_incl_files) vbox_inc.addWidget(self.btn_incl_import) vbox_inc.addStretch(1) grid.addLayout(vbox_inc, 2, 3) # selector group: excludes self.lbl_excludes = QLabel(_("Excludes")) self.lbl_excludes.setAlignment(Qt.AlignTop) self.txt_excludes = QPlainTextEdit() self.txt_excludes.installEventFilter(self) self.btn_excl_directory = QPushButton(_("Add directory")) self.btn_excl_directory.clicked.connect( self.on_btn_excl_directory_clicked) self.btn_excl_files = QPushButton(_("Add files")) self.btn_excl_files.clicked.connect(self.on_btn_excl_files_clicked) self.btn_excl_import = QPushButton(_("Import entries")) self.btn_excl_import.clicked.connect(self.on_btn_excl_import_clicked) grid.addWidget(self.lbl_excludes, 3, 1) grid.addWidget(self.txt_excludes, 3, 2) vbox_exc = QVBoxLayout() vbox_exc.setSpacing(0) vbox_exc.addWidget(self.btn_excl_directory) vbox_exc.addWidget(self.btn_excl_files) vbox_exc.addWidget(self.btn_excl_import) vbox_exc.addStretch(1) grid.addLayout(vbox_exc, 3, 3) # selector group: bottom buttons self.btn_open_selector = QPushButton(_("Open...")) self.btn_open_selector.clicked.connect( self.on_btn_open_selector_clicked) self.btn_save_selector_as = QPushButton(_("Save as...")) self.btn_save_selector_as.clicked.connect( self.on_btn_save_selector_as_clicked) self.btn_play_selected = QPushButton(_("Play...")) self.btn_play_selected.clicked.connect( self.on_btn_play_selected_clicked) hbox3 = QHBoxLayout() hbox3.addStretch(1) hbox3.addWidget(self.btn_open_selector) hbox3.addWidget(self.btn_save_selector_as) grid.addLayout(hbox3, 4, 1, 1, 2) grid.addWidget(self.btn_play_selected, 4, 3) self.grp_selector.setLayout(grid) vbl_0.addWidget(self.grp_selector) self.setLayout(vbl_0)
def __init_ui__(self): vbox = QVBoxLayout() self.lbl_explanation = QLabel(_("Selected resources")) vbox.addWidget(self.lbl_explanation) splitter = QSplitter() splitter.setOrientation(Qt.Vertical) self.pte_output = QPlainTextEdit() self.pte_output.setReadOnly(True) self.pte_output.setMaximumBlockCount(self.max_lines) self.pte_output.setLineWrapMode(QPlainTextEdit.NoWrap) self.pte_output.setCenterOnScroll(True) splitter.addWidget(self.pte_output) self.pte_exceptions = QPlainTextEdit() self.pte_exceptions.setReadOnly(True) self.pte_exceptions.setMaximumBlockCount(5000) self.pte_exceptions.setLineWrapMode(QPlainTextEdit.NoWrap) self.pte_exceptions.setCenterOnScroll(True) self.pte_exceptions.setStyleSheet(Style.blue_text()) splitter.addWidget(self.pte_exceptions) splitter.setStretchFactor(0, 2) splitter.setStretchFactor(1, 1) vbox.addWidget(splitter) btn_box = QHBoxLayout() count_grid = QGridLayout() count_grid.setSpacing(3) self.lbl_recources_count = QLabel(_("Selected resources:")) count_grid.addWidget(self.lbl_recources_count, 1, 1) self.lbl_resources_counter = QLabel("0") self.lbl_resources_counter.setTextInteractionFlags( Qt.TextSelectableByMouse) count_grid.addWidget(self.lbl_resources_counter, 1, 2) self.lbl_excluded_recources_count = QLabel(_("Excluded resources:")) count_grid.addWidget(self.lbl_excluded_recources_count, 2, 1) self.lbl_excluded_resources_counter = QLabel("0") self.lbl_excluded_resources_counter.setTextInteractionFlags( Qt.TextSelectableByMouse) count_grid.addWidget(self.lbl_excluded_resources_counter, 2, 2) btn_box.addLayout(count_grid) btn_box.addStretch(1) self.btn_play = QPushButton(_("Play")) self.btn_play.clicked.connect(self.on_btn_play_clicked) btn_box.addWidget(self.btn_play) self.btn_stop = QPushButton(_("Stop")) self.normal_style = self.btn_stop.styleSheet() self.btn_stop.clicked.connect(self.on_btn_stop_clicked) self.btn_stop.setEnabled(False) btn_box.addWidget(self.btn_stop) self.btn_close = QPushButton(_("Close")) self.btn_close.clicked.connect(self.on_btn_close_clicked) btn_box.addWidget(self.btn_close) vbox.addLayout(btn_box) self.setLayout(vbox) self.resize(self.conf.play_widget_width(), self.conf.play_widget_height())