def __init__(self, option, value=None, directory=False): super().__init__(option) self.layout.setContentsMargins(0, 0, 0, 0) self.browser = FileBrowser(directory=directory) self.layout.addWidget(self.browser) if value: self.browser.set_filenames(value)
class FileBrowserOption(GeneralOption): """ A file browser dialog""" def __init__(self, option, value=None, directory=False): super().__init__(option) self.layout.setContentsMargins(0, 0, 0, 0) self.browser = FileBrowser(directory=directory) self.layout.addWidget(self.browser) if value: self.browser.set_filenames(value) def get_value(self): if not self.browser.get_filenames(): return "''" return self.browser.get_filenames() def set_enable(self, switch_bool): self.browser.set_enable(switch_bool) def connect(self, task): self.browser.clicked_connect(task)
def __init__(self, parent=None): super().__init__(parent=parent) self.ui = Ui_Snakemake() self.ui.setupUi(self) # This is for the --cluster-config case # Note the double underscore that is used later to be replaced by a dash self.ui.snakemake_options_cluster_cluster__config_value = FileBrowser() self.ui.horizontalLayout_4.addWidget( self.ui.snakemake_options_cluster_cluster__config_value) self._application = "sequana_gui" self._section = "snakemake_dialog" self.read_settings() # Set maximum of local cores to be used cpu = multiprocessing.cpu_count() self.ui.snakemake_options_local_cores_value.setMaximum(cpu)
def test_others(qtbot): widget = FileBrowser(paired=True) qtbot.addWidget(widget) widget.set_enable(True) widget.set_enable(False) widget.clicked_connect(widget.close)
def test_setfilenames(qtbot, tmpdir): #tmpdir.join('AA_R1_.fastq.gz').ensure() widget = FileBrowser(paired=True) qtbot.addWidget(widget) widget.set_filenames("AA_R1_.fastq.gz") widget.set_filenames("AA_R2_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.fastq.gz")
def test_directory_dialog_3(qtbot, tmpdir): widget = FileBrowser(paired=True) qtbot.addWidget(widget)
def test_directory_dialog(qtbot, mock): widget = FileBrowser(paired=False, directory=False, file_filter=None) qtbot.addWidget(widget) widget.show() assert widget.isVisible() widget.setup_color() widget.set_empty_path() assert widget.get_filenames() == "" assert widget.path_is_setup() == False # Now, we open the dialog, which pops up. We need to close it... widget = FileBrowser(paired=True, directory=False, file_filter=None) qtbot.addWidget(widget) #qtbot.mouseClick(widget.btn, QtCore.Qt.LeftButton) widget.Nmax = 10 widget._set_paired_filenames(["test1.fastq.gz"]) qtbot.addWidget(widget) widget.Nmax = 30 widget._set_paired_filenames(["test1.fastq.gz", "test2.fastq.gz"]) qtbot.addWidget(widget)
def test_directory_dialog(qtbot, mock): widget = FileBrowser(paired=False, directory=False, file_filter=None) qtbot.addWidget(widget) widget.show() assert widget.isVisible() widget.setup_color() widget.set_empty_path() assert widget.get_filenames() == "" assert widget.path_is_setup() == False # Now, we open the dialog, which pops up. We need to close it... widget = FileBrowser(paired=True, directory=False, file_filter=None) qtbot.addWidget(widget) #qtbot.mouseClick(widget.btn, QtCore.Qt.LeftButton) widget.Nmax = 10 widget._set_paired_filenames([ "test1.fastq.gz"]) qtbot.addWidget(widget) widget.Nmax = 30 widget._set_paired_filenames(["test1.fastq.gz", "test2.fastq.gz"]) qtbot.addWidget(widget)