def initUI(self): self.cam = CamImage() self.start_button = QPushButton("Start") self.quit_button = QPushButton("Quit") controls = ControlWidget() self.combo = QComboBox(self) for it in self.MainProcess.list_of_filters: self.combo.addItem(it[0]) hbox = QHBoxLayout() hbox.addWidget(controls) hbox.addStretch(1) hbuttons = QHBoxLayout() hbuttons.addWidget(self.combo) hbuttons.addWidget(self.start_button) hbuttons.addWidget(self.quit_button) vbutton = QVBoxLayout() vbutton.addLayout(hbuttons) vbutton.addWidget(self.fps_label) hbox.addLayout(vbutton) vbox = QVBoxLayout() vbox.addWidget(self.cam) vbox.addStretch(1) vbox.addLayout(hbox) self.setLayout(vbox) self.setGeometry(300, 300, 300, 150) self.setWindowTitle('Buttons') self.show()
def __init__(self, data): global instance_id QWidget.__init__(self) self.actionHandler = UIActionHandler() self.actionHandler.setupActionHandler(self) offset_layout = QHBoxLayout() offset_layout.addWidget(QLabel("Offset: ")) self.offset = QLabel(hex(0)) offset_layout.addWidget(self.offset) offset_layout.setAlignment(QtCore.Qt.AlignCenter) datatype_layout = QHBoxLayout() datatype_layout.addWidget(QLabel("Data Type: ")) self.datatype = QLabel("") datatype_layout.addWidget(self.datatype) datatype_layout.setAlignment(QtCore.Qt.AlignCenter) layout = QVBoxLayout() title = QLabel("Hello Pane", self) title.setAlignment(QtCore.Qt.AlignCenter) instance = QLabel("Instance: " + str(instance_id), self) instance.setAlignment(QtCore.Qt.AlignCenter) layout.addStretch() layout.addWidget(title) layout.addWidget(instance) layout.addLayout(datatype_layout) layout.addLayout(offset_layout) layout.addStretch() self.setLayout(layout) instance_id += 1 self.data = data # Populate initial state self.updateState() # Set up view and address change notifications self.notifications = HelloNotifications(self)
def __init__(self, name): global instance_id GlobalAreaWidget.__init__(self, name) self.actionHandler = UIActionHandler() self.actionHandler.setupActionHandler(self) offset_layout = QHBoxLayout() offset_layout.addWidget(QLabel("Offset: ")) self.offset = QLabel(hex(0)) offset_layout.addWidget(self.offset) offset_layout.setAlignment(QtCore.Qt.AlignCenter) datatype_layout = QHBoxLayout() datatype_layout.addWidget(QLabel("Data Type: ")) self.datatype = QLabel("") datatype_layout.addWidget(self.datatype) datatype_layout.setAlignment(QtCore.Qt.AlignCenter) layout = QVBoxLayout() title = QLabel(name, self) title.setAlignment(QtCore.Qt.AlignCenter) instance = QLabel("Instance: " + str(instance_id), self) instance.setAlignment(QtCore.Qt.AlignCenter) layout.addStretch() layout.addWidget(title) layout.addWidget(instance) layout.addLayout(datatype_layout) layout.addLayout(offset_layout) layout.addStretch() self.setLayout(layout) instance_id += 1 self.data = None
def __init__(self, parent, name, data): QWidget.__init__(self, parent) DockContextHandler.__init__(self, self, name) self.actionHandler = UIActionHandler() self.actionHandler.setupActionHandler(self) status_layout = QHBoxLayout() status_layout.addWidget(QLabel('Status: ')) self.status = QLabel('idle') status_layout.addWidget(self.status) status_layout.setAlignment(QtCore.Qt.AlignCenter) client_dbg_layout = QHBoxLayout() client_dbg_layout.addWidget(QLabel('Client debugger: ')) self.client_dbg = QLabel('n/a') client_dbg_layout.addWidget(self.client_dbg) client_dbg_layout.setAlignment(QtCore.Qt.AlignCenter) client_pgm_layout = QHBoxLayout() client_pgm_layout.addWidget(QLabel('Client program: ')) self.client_pgm = QLabel('n/a') client_pgm_layout.addWidget(self.client_pgm) client_pgm_layout.setAlignment(QtCore.Qt.AlignCenter) layout = QVBoxLayout() layout.addStretch() layout.addLayout(status_layout) layout.addLayout(client_dbg_layout) layout.addLayout(client_pgm_layout) layout.addStretch() self.setLayout(layout)
def __init__(self, values=None): super().__init__() vbox = QVBoxLayout(self) self.grid = QGridLayout() self.grid.setColumnStretch(1, 1) vbox.addLayout(self.grid) vbox.addStretch(1) self.set_values(values)
def initUI(self): okBtn = QPushButton("OK") cancelBtn = QPushButton("Cancel") hbox = QHBoxLayout() hbox.addStretch(1) hbox.addWidget(okBtn) hbox.addWidget(cancelBtn) vbox = QVBoxLayout() vbox.addStretch(1) vbox.addLayout(hbox) self.setLayout(vbox) self.setGeometry(300, 300, 300, 300) self.setWindowTitle("Buttons")
def setupUi(self): self.setWindowTitle("Freezing GUI") self.resize(300, 150) self.centralWidget = QWidget() self.setCentralWidget(self.centralWidget) # Create and connect widgets self.clicksLabel = QLabel("Counting: 0 clicks", self) self.clicksLabel.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) self.stepLabel = QLabel("Long-Running Step: 0") self.stepLabel.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) self.countBtn = QPushButton("Click me!", self) self.countBtn.clicked.connect(self.countClicks) self.longRunningBtn = QPushButton("Long-Running Task!", self) self.longRunningBtn.clicked.connect(self.runLongTask) # Set the layout layout = QVBoxLayout() layout.addWidget(self.clicksLabel) layout.addWidget(self.countBtn) layout.addStretch() layout.addWidget(self.stepLabel) layout.addWidget(self.longRunningBtn) self.centralWidget.setLayout(layout)
def __init__(self, parent, name, data): if not type(data) == binaryninja.binaryview.BinaryView: raise Exception('expected widget data to be a BinaryView') self.bv = data QWidget.__init__(self, parent) DockContextHandler.__init__(self, self, name) self.actionHandler = UIActionHandler() self.actionHandler.setupActionHandler(self) layout = QVBoxLayout() self.consoleText = QTextEdit(self) self.consoleText.setReadOnly(True) self.consoleText.setFont(getMonospaceFont(self)) layout.addWidget(self.consoleText, 1) inputLayout = QHBoxLayout() inputLayout.setContentsMargins(4, 4, 4, 4) promptLayout = QVBoxLayout() promptLayout.setContentsMargins(0, 5, 0, 5) inputLayout.addLayout(promptLayout) self.consoleEntry = QLineEdit(self) inputLayout.addWidget(self.consoleEntry, 1) self.entryLabel = QLabel("dbg>>> ", self) self.entryLabel.setFont(getMonospaceFont(self)) promptLayout.addWidget(self.entryLabel) promptLayout.addStretch(1) self.consoleEntry.returnPressed.connect(lambda: self.sendLine()) layout.addLayout(inputLayout) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) self.setLayout(layout)
class ControlPanel(QFrame): def __init__(self, controller, parent=None): super().__init__(parent=parent) self.controller = controller self.setFrameStyle(QFrame.StyledPanel) # self.ch1_panel = ChannelBox("CH1") # at the moment only one channel is supported self.time_panel = TimebaseBox(self.controller) self.trigger_panel = TriggerBox(self.controller) self.acq_panel = AcquisitionBox(self.controller) self.stats_panel = StatsBox() self.dev_panel = DeviceBox(self.controller) self.layout = QVBoxLayout() # self.layout.addWidget(self.ch1_panel) self.layout.addWidget(self.time_panel) self.layout.addWidget(self.trigger_panel) self.layout.addWidget(self.acq_panel) self.layout.addWidget(self.stats_panel) self.layout.addStretch() self.layout.addWidget(self.dev_panel) self.setLayout(self.layout)
class Widget(QWidget): def __init__(self): QWidget.__init__(self) self.items = 0 # Example data self._data = { "Water": 24.5, "Electricity": 55.1, "Rent": 850.0, "Supermarket": 230.4, "Internet": 29.99, "Spätkauf": 21.85, "BVG Ticket": 60.0, "Coffee": 22.45, "Meetup": 0.0 } # Left self.table = QTableWidget() self.table.setColumnCount(2) self.table.setHorizontalHeaderLabels(["Description", "Quantity"]) self.table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) # Right self.description = QLineEdit() self.quantity = QLineEdit() self.add = QPushButton("Add") self.clear = QPushButton("Clear") self.quit = QPushButton("Quit") self.right = QVBoxLayout() self.right.setContentsMargins(10, 10, 10, 10) self.right.addWidget(QLabel("Description")) self.right.addWidget(self.description) self.right.addWidget(QLabel("Quantity")) self.right.addWidget(self.quantity) self.right.addWidget(self.add) self.right.addStretch() self.right.addWidget(self.clear) self.right.addWidget(self.quit) # QWidget Layout self.layout = QHBoxLayout() self.layout.addWidget(self.table) self.layout.addLayout(self.right) # Set the layout to the QWidget self.setLayout(self.layout) # Fill example data self.fill_table() def fill_table(self, data=None): data = self._data if not data else data for desc, price in data.items(): self.table.insertRow(self.items) self.table.setItem(self.items, 0, QTableWidgetItem(desc)) self.table.setItem(self.items, 1, QTableWidgetItem(str(price))) self.items += 1
def __init__(self, parent, data): assert type(data) == BinaryView self.bv = data QDialog.__init__(self, parent) debug_state = binjaplug.get_state(self.bv) self.setWindowTitle("Debug Adapter Settings") self.setMinimumSize(UIContext.getScaledWindowSize(400, 130)) self.setAttribute(Qt.WA_DeleteOnClose) layout = QVBoxLayout() layout.setSpacing(0) titleLabel = QLabel("Adapter Settings") titleLayout = QHBoxLayout() titleLayout.setContentsMargins(0, 0, 0, 0) titleLayout.addWidget(titleLabel) self.adapterEntry = QPushButton(self) self.adapterMenu = QMenu(self) for adapter in DebugAdapter.ADAPTER_TYPE: if not DebugAdapter.ADAPTER_TYPE.can_use(adapter): continue def select_adapter(adapter): return lambda: self.selectAdapter(adapter) self.adapterMenu.addAction(adapter.name, select_adapter(adapter)) if adapter == debug_state.adapter_type: self.adapterEntry.setText(adapter.name) self.adapterEntry.setMenu(self.adapterMenu) self.argumentsEntry = QLineEdit(self) self.addressEntry = QLineEdit(self) self.portEntry = QLineEdit(self) self.requestTerminalEmulator = QCheckBox(self) self.formLayout = QFormLayout() self.formLayout.addRow("Adapter Type", self.adapterEntry) self.formLayout.addRow("Command Line Arguments", self.argumentsEntry) self.formLayout.addRow("Address", self.addressEntry) self.formLayout.addRow("Port", self.portEntry) self.formLayout.addRow("Request Terminal Emulator", self.requestTerminalEmulator) buttonLayout = QHBoxLayout() buttonLayout.setContentsMargins(0, 0, 0, 0) self.cancelButton = QPushButton("Cancel") self.cancelButton.clicked.connect(lambda: self.reject()) self.acceptButton = QPushButton("Accept") self.acceptButton.clicked.connect(lambda: self.accept()) self.acceptButton.setDefault(True) buttonLayout.addStretch(1) buttonLayout.addWidget(self.cancelButton) buttonLayout.addWidget(self.acceptButton) layout.addLayout(titleLayout) layout.addSpacing(10) layout.addLayout(self.formLayout) layout.addStretch(1) layout.addSpacing(10) layout.addLayout(buttonLayout) self.setLayout(layout) self.addressEntry.setText(debug_state.remote_host) self.portEntry.setText(str(debug_state.remote_port)) self.addressEntry.textEdited.connect(lambda: self.apply()) self.portEntry.textEdited.connect(lambda: self.apply()) self.argumentsEntry.setText(' '.join( shlex.quote(arg) for arg in debug_state.command_line_args)) self.argumentsEntry.textEdited.connect(lambda: self.updateArguments()) self.requestTerminalEmulator.setChecked( debug_state.request_terminal_emulator) self.requestTerminalEmulator.stateChanged.connect(lambda: self.apply()) self.accepted.connect(lambda: self.apply())
class ResultsList(QScrollArea): def __init__(self, parent=None): # List View of results # Only Title Search and Playlist Search use this QScrollArea.__init__(self) self.setParent(parent) # Make QScrollArea transparent self.setStyleSheet( "QScrollArea { background-color: transparent } .QFrame { background-color: transparent }" ) self.setWidgetResizable(True) self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) # Add touch screen control to QScrollArea QScroller.grabGesture(self, QScroller.LeftMouseButtonGesture) # Set layout settings of the QScrollArea self.layout = QVBoxLayout() self.layout.setContentsMargins(0, 0, 0, 0) self.layout.setSpacing(0) # A separate QWidget is needed to properly use QScrollArea frame = QFrame() frame.setLayout(self.layout) self.setWidget(frame) def clearResults(self): # Clear the results in the list while self.layout.count(): item = self.layout.takeAt(0) if item.widget() is not None: item.widget().deleteLater() def addResults(self, results): # Add the results to the list # results (list): list of python dict representing results details (playlist or song search) self.results = results self.clearResults() if results: for i in self.results: item = self.ResultsListItem(i, self) self.layout.addWidget(item) self.layout.addStretch(1) else: # If the results are empty, display no result label = QLabel("没有结果/No Result") label.setStyleSheet("color: white") label.setAlignment(Qt.AlignCenter) font = QFont() font.setPointSize(35) label.setFont(font) self.layout.addWidget(label) class ResultsListItem(QToolButton): def __init__(self, result, parent=None): # An item of ResultsList # result: (dict) represents details (playlist or song search) QToolButton.__init__(self) self.setParent(parent) self.result = result # Button formatting self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) self.setFixedHeight(70) self.setAutoRaise(True) # TODO: change with global themes self.setStyleSheet( "QToolButton:pressed { background-color: rgba(255, 255, 255, 0.1)} QToolButton { background-color: rgba(255, 255, 255, 0.05); border: 1px solid white}" ) # Set layout self.layout = QHBoxLayout() self.layout.setContentsMargins(0, 0, 0, 0) self.layout.setSpacing(0) # Depending on result type, add action when the item is clicked if result["type"] == "songs": self.formatTitle() self.clicked.connect(self.clickedSong) elif result["type"] == "playlists": self.formatPlaylist() self.clicked.connect(self.clickedPlaylist) self.setLayout(self.layout) def formatTitle(self): # Format the title for the ResultsList # Add space to the beginning of the ResultsListItem labelQueue = self.formattedLabel(QLabel("", self)) labelQueue.setFixedWidth(70) labelQueue.setAlignment(Qt.AlignCenter) self.layout.addWidget(labelQueue) # Artist name labelArtist = self.formattedLabel( QLabel(self.result["artist_name"])) labelArtist.setFixedWidth(300) self.layout.addWidget(labelArtist) # Song title labelTitle = self.formattedLabel( QLabel(self.result["song_title"])) self.layout.addWidget(labelTitle) # Add buttons for favourites and playlists # Favourite button self.favouriteButton = QToolButton() # Toggle Favourite Icon depending on DB if self.result["favourited"] == 0: self.favouriteButton.isFavourited = False self.favouriteButton.setIcon(QIcon("icons/star.svg")) else: self.favouriteButton.isFavourited = True self.favouriteButton.setIcon( QIcon("icons/star-yellow.svg")) self.favouriteButton.setIconSize(QSize(30, 30)) self.favouriteButton.setFixedSize(70, 70) self.favouriteButton.clicked.connect(self.clickedFavourite) self.layout.addWidget(self.favouriteButton) # Playlist button playlistButton = QToolButton() playlistButton.setIcon(QIcon("icons/music-player-2.svg")) playlistButton.setIconSize(QSize(30, 30)) playlistButton.setFixedSize(70, 70) playlistButton.clicked.connect(self.addToPlaylist) self.layout.addWidget(playlistButton) def formatPlaylist(self): # Add space to beginning of LisItem labelQueue = self.formattedLabel(QLabel("", self)) labelQueue.setFixedWidth(70) labelQueue.setAlignment(Qt.AlignCenter) self.layout.addWidget(labelQueue) # Playlist name labelPlaylist = self.formattedLabel( QLabel(self.result["playlist_name"])) self.layout.addWidget(labelPlaylist) # Remove playlist button btnRemove = QToolButton() btnRemove.setText("X") btnRemove.setFixedSize(70, 70) btnRemove.setStyleSheet("color: white") btnRemove.clicked.connect(self.removePlaylist) self.layout.addWidget(btnRemove) def formattedLabel(self, label): # Format a label font = QFont() font.setPixelSize(25) # TODO: change with global themes label.setStyleSheet("color: white") label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) label.setFont(font) return label def clickedSong(self): # Called when a song is clicked on # Add to queue self.window().songQueue.addSong(self.result) if len(self.window().songQueue.getQueue()) < 2: if not self.window().mediaPlayer.currentSong: # If this is the first song to queue, signal media player to start it self.window().mediaPlayer.skipSong() # Update scrolling text marquee self.window().mediaPlayer.updateMarquee() def clickedPlaylist(self): # Called when a playlist is clicked on self.window().content.addWidget( WindowSearch( "搜索全部/Search", self, self.window().content.currentWidget().counter + 1, self.result)) self.window().content.setCurrentIndex( self.window().content.currentWidget().counter + 1) def clickedFavourite(self): # Toggle Icon and DB state of song being favourited # For songs only if self.favouriteButton.isFavourited: self.favouriteButton.isFavourited = False self.favouriteButton.setIcon(QIcon("icons/star.svg")) else: self.favouriteButton.isFavourited = True self.favouriteButton.setIcon( QIcon("icons/star-yellow.svg")) DB.setFavouriteSong(self.result["song_id"]) def addToPlaylist(self): # Opens a popup for adding songs to playlists popup = PlaylistPopup(self.result, self.window()) popup.resize(1366, 768) popup.SIGNALS.CLOSE.connect(lambda: popup.close()) popup.show() def removePlaylist(self): # Remove a playlist DB.removePlaylist(self.result["playlist_id"]) self.window().content.currentWidget().results.results.remove( self.result) self.window().content.currentWidget().results.addResults( self.window().content.currentWidget().results.results)
class Config(QWidget): def __init__(self): super().__init__() # global self.config_params self.xml_root = None # self.tab = QWidget() # self.tabs.resize(200,5) #------------------------------------------- label_width = 110 domain_value_width = 100 value_width = 60 label_height = 20 units_width = 70 self.scroll = QScrollArea() # might contain centralWidget self.config_params = QWidget() self.vbox = QVBoxLayout() self.vbox.addStretch(0) #============ Domain ================================ label = QLabel("Domain (micron)") label.setFixedHeight(label_height) label.setStyleSheet("background-color: orange") label.setAlignment(QtCore.Qt.AlignCenter) self.vbox.addWidget(label) hbox = QHBoxLayout() label = QLabel("Xmin") label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.xmin = QLineEdit() self.xmin.setFixedWidth(domain_value_width) self.xmin.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.xmin) label = QLabel("Xmax") label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.xmax = QLineEdit() self.xmax.setFixedWidth(domain_value_width) self.xmax.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.xmax) label = QLabel("dx") label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.xdel = QLineEdit() self.xdel.setFixedWidth(value_width) self.xdel.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.xdel) self.vbox.addLayout(hbox) #---------- hbox = QHBoxLayout() label = QLabel("Ymin") label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.ymin = QLineEdit() self.ymin.setFixedWidth(domain_value_width) self.ymin.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.ymin) label = QLabel("Ymax") label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.ymax = QLineEdit() self.ymax.setFixedWidth(domain_value_width) self.ymax.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.ymax) label = QLabel("dy") label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.ydel = QLineEdit() self.ydel.setFixedWidth(value_width) self.ydel.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.ydel) self.vbox.addLayout(hbox) #---------- hbox = QHBoxLayout() label = QLabel("Zmin") label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.zmin = QLineEdit() self.zmin.setFixedWidth(domain_value_width) self.zmin.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.zmin) label = QLabel("Zmax") label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.zmax = QLineEdit() self.zmax.setFixedWidth(domain_value_width) self.zmax.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.zmax) label = QLabel("dz") label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.zdel = QLineEdit() self.zdel.setFixedWidth(value_width) self.zdel.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.zdel) self.vbox.addLayout(hbox) #---------- hbox = QHBoxLayout() self.virtual_walls = QCheckBox("Virtual walls") # self.motility_enabled.setAlignment(QtCore.Qt.AlignRight) # label.setFixedWidth(label_width) hbox.addWidget(self.virtual_walls) self.vbox.addLayout(hbox) # self.vbox.addWidget(QHLine()) #============ Misc ================================ label = QLabel("Misc runtime parameters") label.setFixedHeight(label_height) label.setStyleSheet("background-color: orange") label.setAlignment(QtCore.Qt.AlignCenter) self.vbox.addWidget(label) hbox = QHBoxLayout() # hbox.setFixedHeight(label_width) label = QLabel("Max Time") # label_width = 210 label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.max_time = QLineEdit() # self.max_time.setFixedWidth(200) self.max_time.setFixedWidth(domain_value_width) self.max_time.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.max_time) label = QLabel("min") label.setFixedWidth(units_width) label.setAlignment(QtCore.Qt.AlignLeft) hbox.addWidget(label) self.vbox.addLayout(hbox) #---------- hbox = QHBoxLayout() label = QLabel("# threads") label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.num_threads = QLineEdit() # self.num_threads.setFixedWidth(value_width) self.num_threads.setFixedWidth(domain_value_width) self.num_threads.setValidator(QtGui.QIntValidator()) hbox.addWidget(self.num_threads) label = QLabel(" ") label.setFixedWidth(units_width) label.setAlignment(QtCore.Qt.AlignLeft) hbox.addWidget(label) self.vbox.addLayout(hbox) #------------------ hbox = QHBoxLayout() label = QLabel("Save data:") label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignLeft) hbox.addWidget(label) #------ self.save_svg = QCheckBox("SVG") # self.motility_2D.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(self.save_svg) label = QLabel("every") # label_width = 210 # label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.svg_interval = QLineEdit() self.svg_interval.setFixedWidth(value_width) self.svg_interval.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.svg_interval) label = QLabel("min") # label.setFixedWidth(units_width) label.setAlignment(QtCore.Qt.AlignLeft) hbox.addWidget(label) #------ self.save_full = QCheckBox("Full") # self.motility_2D.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(self.save_full) label = QLabel("every") # label_width = 210 # label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.full_interval = QLineEdit() self.full_interval.setFixedWidth(value_width) self.full_interval.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.full_interval) label = QLabel("min") # label.setFixedWidth(units_width) label.setAlignment(QtCore.Qt.AlignLeft) hbox.addWidget(label) self.vbox.addLayout(hbox) #============ Cells IC ================================ label = QLabel("Initial conditions of cells (x,y,z, type)") label.setFixedHeight(label_height) label.setStyleSheet("background-color: orange") label.setAlignment(QtCore.Qt.AlignCenter) self.vbox.addWidget(label) self.cells_csv = QCheckBox("config/cells.csv") self.vbox.addWidget(self.cells_csv) #-------------------------- # Dummy widget for filler?? # label = QLabel("") # label.setFixedHeight(1000) # # label.setStyleSheet("background-color: orange") # label.setAlignment(QtCore.Qt.AlignCenter) # self.vbox.addWidget(label) self.vbox.addStretch() #================================================================== self.config_params.setLayout(self.vbox) self.scroll.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) self.scroll.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) self.scroll.setWidgetResizable(True) self.scroll.setWidget( self.config_params) # self.config_params = QWidget() self.layout = QVBoxLayout(self) self.layout.addWidget(self.scroll) # @QtCore.Slot() # def save_xml(self): # # self.text.setText(random.choice(self.hello)) # pass def fill_gui(self): self.xmin.setText(self.xml_root.find(".//x_min").text) self.xmax.setText(self.xml_root.find(".//x_max").text) self.xdel.setText(self.xml_root.find(".//dx").text) self.ymin.setText(self.xml_root.find(".//y_min").text) self.ymax.setText(self.xml_root.find(".//y_max").text) self.ydel.setText(self.xml_root.find(".//dy").text) self.zmin.setText(self.xml_root.find(".//z_min").text) self.zmax.setText(self.xml_root.find(".//z_max").text) self.zdel.setText(self.xml_root.find(".//dz").text) self.max_time.setText(self.xml_root.find(".//max_time").text) self.num_threads.setText(self.xml_root.find(".//omp_num_threads").text) self.svg_interval.setText(self.xml_root.find(".//SVG//interval").text) # NOTE: do this *after* filling the mcds_interval, directly above, due to the callback/constraints on them?? if self.xml_root.find(".//SVG//enable").text.lower() == 'true': self.save_svg.setChecked(True) else: self.save_svg.setChecked(False) self.full_interval.setText( self.xml_root.find(".//full_data//interval").text) if self.xml_root.find(".//full_data//enable").text.lower() == 'true': self.save_full.setChecked(True) else: self.save_full.setChecked(False) # Read values from the GUI widgets and generate/write a new XML def fill_xml(self): # pass # self.xmin.setText(self.xml_root.find(".//x_min").text) print("config_tab: fill_xml: xmin=", str(self.xmin.text)) self.xml_root.find(".//x_min").text = self.xmin.text() self.xml_root.find(".//x_max").text = self.xmax.text() self.xml_root.find(".//dx").text = self.xdel.text() self.xml_root.find(".//y_min").text = self.ymin.text() self.xml_root.find(".//y_max").text = self.ymax.text() self.xml_root.find(".//dy").text = self.ydel.text() self.xml_root.find(".//z_min").text = self.zmin.text() self.xml_root.find(".//z_max").text = self.zmax.text() self.xml_root.find(".//dz").text = self.zdel.text() if not self.xml_root.find(".//virtual_wall_at_domain_edge"): # create it? print("config_tab.py: no virtual_wall_at_domain_edge tag") else: if self.virtual_walls.isChecked(): self.xml_root.find( ".//virtual_wall_at_domain_edge").text = 'true' else: self.xml_root.find( ".//virtual_wall_at_domain_edge").text = 'false' self.xml_root.find(".//max_time").text = self.max_time.text() self.xml_root.find(".//omp_num_threads").text = self.num_threads.text() if self.save_svg.isChecked(): self.xml_root.find(".//SVG//enable").text = 'true' else: self.xml_root.find(".//SVG//enable").text = 'false' self.xml_root.find(".//SVG//interval").text = self.svg_interval.text() if self.save_full.isChecked(): self.xml_root.find(".//full_data//enable").text = 'true' else: self.xml_root.find(".//full_data//enable").text = 'false' self.xml_root.find( ".//full_data//interval").text = self.full_interval.text() if self.cells_csv.isChecked(): self.xml_root.find(".//initial_conditions//cell_positions" ).attrib['enabled'] = 'true' else: self.xml_root.find(".//initial_conditions//cell_positions" ).attrib['enabled'] = 'false'
def __init__(self, parent, data): QScrollArea.__init__(self, parent) View.__init__(self) View.setBinaryDataNavigable(self, True) self.setupView(self) self.data = data self.currentOffset = 0 self.byteView = None self.fullAnalysisButton = None self.importsWidget = None container = QWidget(self) layout = QVBoxLayout() entropyGroup = QGroupBox("Entropy", container) entropyLayout = QVBoxLayout() entropyLayout.addWidget( entropy.EntropyWidget(entropyGroup, self, self.data)) entropyGroup.setLayout(entropyLayout) layout.addWidget(entropyGroup) hdr = None try: if self.data.view_type == "PE": hdr = headers.PEHeaders(self.data) elif self.data.view_type != "Raw": hdr = headers.GenericHeaders(self.data) except: log.log_error(traceback.format_exc()) if hdr is not None: headerGroup = QGroupBox("Headers", container) headerLayout = QVBoxLayout() headerWidget = headers.HeaderWidget(headerGroup, hdr) headerLayout.addWidget(headerWidget) headerGroup.setLayout(headerLayout) layout.addWidget(headerGroup) if self.data.executable: importExportSplitter = QSplitter(Qt.Horizontal) importGroup = QGroupBox("Imports", container) importLayout = QVBoxLayout() self.importsWidget = imports.ImportsWidget(importGroup, self, self.data) importLayout.addWidget(self.importsWidget) importGroup.setLayout(importLayout) importExportSplitter.addWidget(importGroup) exportGroup = QGroupBox("Exports", container) exportLayout = QVBoxLayout() exportLayout.addWidget( exports.ExportsWidget(exportGroup, self, self.data)) exportGroup.setLayout(exportLayout) importExportSplitter.addWidget(exportGroup) layout.addWidget(importExportSplitter) if self.data.view_type != "PE": segmentsGroup = QGroupBox("Segments", container) segmentsLayout = QVBoxLayout() segmentsWidget = sections.SegmentsWidget( segmentsGroup, self.data) segmentsLayout.addWidget(segmentsWidget) segmentsGroup.setLayout(segmentsLayout) layout.addWidget(segmentsGroup) if len(segmentsWidget.segments) == 0: segmentsGroup.hide() sectionsGroup = QGroupBox("Sections", container) sectionsLayout = QVBoxLayout() sectionsWidget = sections.SectionsWidget(sectionsGroup, self.data) sectionsLayout.addWidget(sectionsWidget) sectionsGroup.setLayout(sectionsLayout) layout.addWidget(sectionsGroup) if len(sectionsWidget.sections) == 0: sectionsGroup.hide() buttonLayout = QHBoxLayout() buttonLayout.addStretch(1) self.loadDynamicButton = QPushButton("Load Dynamic Imports") self.loadDynamicButton.clicked.connect( self.importsWidget.scanDynamic) buttonLayout.addWidget(self.loadDynamicButton) self.fullAnalysisButton = QPushButton("Start Full Analysis") self.fullAnalysisButton.clicked.connect(self.startFullAnalysis) buttonLayout.addWidget(self.fullAnalysisButton) layout.addLayout(buttonLayout) layout.addStretch(1) else: self.byteView = byte.ByteView(self, self.data) layout.addWidget(self.byteView, 1) container.setLayout(layout) self.setWidgetResizable(True) self.setWidget(container) if self.fullAnalysisButton is not None and Settings().get_string( "analysis.mode", data) == "full": self.fullAnalysisButton.hide()
def __init__(self, persepolis_setting): super().__init__() self.persepolis_setting = persepolis_setting icons = ':/' + \ str(self.persepolis_setting.value('settings/icons')) + '/' # add support for other languages locale = str(self.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) # set ui direction ui_direction = self.persepolis_setting.value('ui_direction') if ui_direction == 'rtl': self.setLayoutDirection(Qt.RightToLeft) elif ui_direction in 'ltr': self.setLayoutDirection(Qt.LeftToRight) self.setWindowIcon( QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg'))) window_verticalLayout = QVBoxLayout() self.setLayout(window_verticalLayout) # queue_tabWidget self.queue_tabWidget = QTabWidget(self) window_verticalLayout.addWidget(self.queue_tabWidget) # links_tab self.links_tab = QWidget() links_tab_verticalLayout = QVBoxLayout(self.links_tab) # link table self.links_table = QTableWidget(self.links_tab) links_tab_verticalLayout.addWidget(self.links_table) self.links_table.setSelectionBehavior(QAbstractItemView.SelectRows) self.links_table.setEditTriggers(QAbstractItemView.NoEditTriggers) self.links_table.verticalHeader().hide() self.links_table.setColumnCount(3) links_table_header_labels = [ 'File Name', 'Download Link', 'dictionary' ] self.links_table.setHorizontalHeaderLabels(links_table_header_labels) self.links_table.setColumnHidden(2, True) self.links_table.horizontalHeader().setSectionResizeMode( QHeaderView.ResizeMode.Stretch) self.links_table.horizontalHeader().setStretchLastSection(True) # add_queue add_queue_horizontalLayout = QHBoxLayout() self.select_all_pushButton = QPushButton(self.links_tab) add_queue_horizontalLayout.addWidget(self.select_all_pushButton) self.deselect_all_pushButton = QPushButton(self.links_tab) add_queue_horizontalLayout.addWidget(self.deselect_all_pushButton) add_queue_horizontalLayout.addStretch(1) self.add_queue_label = QLabel(self.links_tab) add_queue_horizontalLayout.addWidget(self.add_queue_label) self.add_queue_comboBox = QComboBox(self.links_tab) add_queue_horizontalLayout.addWidget(self.add_queue_comboBox) links_tab_verticalLayout.addLayout(add_queue_horizontalLayout) links_tab_verticalLayout.addStretch(1) self.queue_tabWidget.addTab(self.links_tab, "") # options_tab self.options_tab = QWidget() options_tab_verticalLayout = QVBoxLayout(self.options_tab) # proxy proxy_verticalLayout = QVBoxLayout() self.proxy_checkBox = QCheckBox(self.options_tab) proxy_verticalLayout.addWidget(self.proxy_checkBox) self.proxy_frame = QFrame(self.options_tab) self.proxy_frame.setFrameShape(QFrame.StyledPanel) self.proxy_frame.setFrameShadow(QFrame.Raised) proxy_gridLayout = QGridLayout(self.proxy_frame) self.ip_lineEdit = QLineEdit(self.proxy_frame) self.ip_lineEdit.setInputMethodHints(Qt.ImhNone) proxy_gridLayout.addWidget(self.ip_lineEdit, 0, 1, 1, 1) self.proxy_pass_label = QLabel(self.proxy_frame) proxy_gridLayout.addWidget(self.proxy_pass_label, 2, 2, 1, 1) self.proxy_pass_lineEdit = QLineEdit(self.proxy_frame) self.proxy_pass_lineEdit.setEchoMode(QLineEdit.Password) proxy_gridLayout.addWidget(self.proxy_pass_lineEdit, 2, 3, 1, 1) self.ip_label = QLabel(self.proxy_frame) proxy_gridLayout.addWidget(self.ip_label, 0, 0, 1, 1) self.proxy_user_lineEdit = QLineEdit(self.proxy_frame) proxy_gridLayout.addWidget(self.proxy_user_lineEdit, 0, 3, 1, 1) self.proxy_user_label = QLabel(self.proxy_frame) proxy_gridLayout.addWidget(self.proxy_user_label, 0, 2, 1, 1) self.port_label = QLabel(self.proxy_frame) proxy_gridLayout.addWidget(self.port_label, 2, 0, 1, 1) self.port_spinBox = QSpinBox(self.proxy_frame) self.port_spinBox.setMaximum(9999) self.port_spinBox.setSingleStep(1) proxy_gridLayout.addWidget(self.port_spinBox, 2, 1, 1, 1) proxy_verticalLayout.addWidget(self.proxy_frame) options_tab_verticalLayout.addLayout(proxy_verticalLayout) # download Username & Password download_horizontalLayout = QHBoxLayout() download_horizontalLayout.setContentsMargins(-1, 10, -1, -1) download_verticalLayout = QVBoxLayout() self.download_checkBox = QCheckBox(self.options_tab) download_verticalLayout.addWidget(self.download_checkBox) self.download_frame = QFrame(self.options_tab) self.download_frame.setFrameShape(QFrame.StyledPanel) self.download_frame.setFrameShadow(QFrame.Raised) download_gridLayout = QGridLayout(self.download_frame) self.download_user_lineEdit = QLineEdit(self.download_frame) download_gridLayout.addWidget(self.download_user_lineEdit, 0, 1, 1, 1) self.download_user_label = QLabel(self.download_frame) download_gridLayout.addWidget(self.download_user_label, 0, 0, 1, 1) self.download_pass_label = QLabel(self.download_frame) download_gridLayout.addWidget(self.download_pass_label, 1, 0, 1, 1) self.download_pass_lineEdit = QLineEdit(self.download_frame) self.download_pass_lineEdit.setEchoMode(QLineEdit.Password) download_gridLayout.addWidget(self.download_pass_lineEdit, 1, 1, 1, 1) download_verticalLayout.addWidget(self.download_frame) download_horizontalLayout.addLayout(download_verticalLayout) # select folder self.folder_frame = QFrame(self.options_tab) self.folder_frame.setFrameShape(QFrame.StyledPanel) self.folder_frame.setFrameShadow(QFrame.Raised) folder_gridLayout = QGridLayout(self.folder_frame) self.download_folder_lineEdit = QLineEdit(self.folder_frame) folder_gridLayout.addWidget(self.download_folder_lineEdit, 2, 0, 1, 1) self.folder_pushButton = QPushButton(self.folder_frame) folder_gridLayout.addWidget(self.folder_pushButton, 3, 0, 1, 1) self.folder_pushButton.setIcon(QIcon(icons + 'folder')) self.folder_checkBox = QCheckBox(self.folder_frame) folder_gridLayout.addWidget(self.folder_checkBox) self.folder_label = QLabel(self.folder_frame) self.folder_label.setAlignment(Qt.AlignCenter) folder_gridLayout.addWidget(self.folder_label, 1, 0, 1, 1) download_horizontalLayout.addWidget(self.folder_frame) options_tab_verticalLayout.addLayout(download_horizontalLayout) self.queue_tabWidget.addTab(self.options_tab, '') # limit Speed limit_verticalLayout = QVBoxLayout() self.limit_checkBox = QCheckBox(self.options_tab) limit_verticalLayout.addWidget(self.limit_checkBox) self.limit_frame = QFrame(self.options_tab) self.limit_frame.setFrameShape(QFrame.StyledPanel) self.limit_frame.setFrameShadow(QFrame.Raised) limit_horizontalLayout = QHBoxLayout(self.limit_frame) self.limit_spinBox = QSpinBox(self.limit_frame) self.limit_spinBox.setMinimum(1) self.limit_spinBox.setMaximum(1023) limit_horizontalLayout.addWidget(self.limit_spinBox) self.limit_comboBox = QComboBox(self.limit_frame) self.limit_comboBox.addItem("KiB/S") self.limit_comboBox.addItem("MiB/S") limit_horizontalLayout.addWidget(self.limit_comboBox) limit_verticalLayout.addWidget(self.limit_frame) limit_connections_horizontalLayout = QHBoxLayout() limit_connections_horizontalLayout.addLayout(limit_verticalLayout) # number of connections connections_horizontalLayout = QHBoxLayout() connections_horizontalLayout.setContentsMargins(-1, 10, -1, -1) self.connections_frame = QFrame(self.options_tab) self.connections_frame.setFrameShape(QFrame.StyledPanel) self.connections_frame.setFrameShadow(QFrame.Raised) horizontalLayout_3 = QHBoxLayout(self.connections_frame) self.connections_label = QLabel(self.connections_frame) horizontalLayout_3.addWidget(self.connections_label) self.connections_spinBox = QSpinBox(self.connections_frame) self.connections_spinBox.setMinimum(1) self.connections_spinBox.setMaximum(16) self.connections_spinBox.setProperty("value", 16) horizontalLayout_3.addWidget(self.connections_spinBox) connections_horizontalLayout.addWidget(self.connections_frame) limit_connections_horizontalLayout.addLayout( connections_horizontalLayout) options_tab_verticalLayout.addLayout( limit_connections_horizontalLayout) options_tab_verticalLayout.addStretch(1) # buttons buttons_horizontalLayout = QHBoxLayout() buttons_horizontalLayout.addStretch(1) # ok_pushButton self.ok_pushButton = QPushButton(self) self.ok_pushButton.setIcon(QIcon(icons + 'ok')) buttons_horizontalLayout.addWidget(self.ok_pushButton) # cancel_pushButton self.cancel_pushButton = QPushButton(self) self.cancel_pushButton.setIcon(QIcon(icons + 'remove')) buttons_horizontalLayout.addWidget(self.cancel_pushButton) window_verticalLayout.addLayout(buttons_horizontalLayout) # labels self.setWindowTitle( QCoreApplication.translate("text_ui_tr", "Persepolis Download Manager")) self.queue_tabWidget.setTabText( self.queue_tabWidget.indexOf(self.links_tab), QCoreApplication.translate("text_ui_tr", 'Links')) self.queue_tabWidget.setTabText( self.queue_tabWidget.indexOf(self.options_tab), QCoreApplication.translate("text_ui_tr", 'Download Options')) self.select_all_pushButton.setText( QCoreApplication.translate("text_ui_tr", 'Select All')) self.deselect_all_pushButton.setText( QCoreApplication.translate("text_ui_tr", 'Deselect All')) self.add_queue_label.setText( QCoreApplication.translate("text_ui_tr", 'Add to queue: ')) self.proxy_checkBox.setText( QCoreApplication.translate("text_ui_tr", 'Proxy')) self.proxy_pass_label.setText( QCoreApplication.translate("text_ui_tr", "Proxy password: "******"text_ui_tr", "IP:")) self.proxy_user_label.setText( QCoreApplication.translate("text_ui_tr", "Proxy username: "******"text_ui_tr", "Port:")) self.download_checkBox.setText( QCoreApplication.translate("text_ui_tr", "Download username and password")) self.download_user_label.setText( QCoreApplication.translate("text_ui_tr", "Download username: "******"text_ui_tr", "Download password: "******"text_ui_tr", "Change Download Folder")) self.folder_checkBox.setText( QCoreApplication.translate("addlink_ui_tr", "Remember this path")) self.folder_label.setText( QCoreApplication.translate("text_ui_tr", "Download folder: ")) self.limit_checkBox.setText( QCoreApplication.translate("text_ui_tr", "Limit speed")) self.connections_label.setText( QCoreApplication.translate("text_ui_tr", "Number of connections:")) self.ok_pushButton.setText( QCoreApplication.translate("text_ui_tr", 'OK')) self.cancel_pushButton.setText( QCoreApplication.translate("text_ui_tr", 'Cancel'))
def __init__(self, persepolis_setting): super().__init__() icon = QIcon() self.persepolis_setting = persepolis_setting # add support for other languages locale = str(self.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) self.setWindowIcon( QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg'))) self.setWindowTitle( QCoreApplication.translate("setting_ui_tr", 'Preferences')) # set ui direction ui_direction = self.persepolis_setting.value('ui_direction') if ui_direction == 'rtl': self.setLayoutDirection(Qt.RightToLeft) elif ui_direction in 'ltr': self.setLayoutDirection(Qt.LeftToRight) global icons icons = ':/' + str( self.persepolis_setting.value('settings/icons')) + '/' # main layout window_verticalLayout = QVBoxLayout(self) # setting_tabWidget self.setting_tabWidget = QTabWidget(self) # download_options_tab self.download_options_tab = QWidget() download_options_tab_verticalLayout = QVBoxLayout( self.download_options_tab) download_options_tab_verticalLayout.setContentsMargins(21, 21, 0, 0) # tries tries_horizontalLayout = QHBoxLayout() self.tries_label = QLabel(self.download_options_tab) tries_horizontalLayout.addWidget(self.tries_label) self.tries_spinBox = QSpinBox(self.download_options_tab) self.tries_spinBox.setMinimum(1) tries_horizontalLayout.addWidget(self.tries_spinBox) download_options_tab_verticalLayout.addLayout(tries_horizontalLayout) # wait wait_horizontalLayout = QHBoxLayout() self.wait_label = QLabel(self.download_options_tab) wait_horizontalLayout.addWidget(self.wait_label) self.wait_spinBox = QSpinBox(self.download_options_tab) wait_horizontalLayout.addWidget(self.wait_spinBox) download_options_tab_verticalLayout.addLayout(wait_horizontalLayout) # time_out time_out_horizontalLayout = QHBoxLayout() self.time_out_label = QLabel(self.download_options_tab) time_out_horizontalLayout.addWidget(self.time_out_label) self.time_out_spinBox = QSpinBox(self.download_options_tab) time_out_horizontalLayout.addWidget(self.time_out_spinBox) download_options_tab_verticalLayout.addLayout( time_out_horizontalLayout) # connections connections_horizontalLayout = QHBoxLayout() self.connections_label = QLabel(self.download_options_tab) connections_horizontalLayout.addWidget(self.connections_label) self.connections_spinBox = QSpinBox(self.download_options_tab) self.connections_spinBox.setMinimum(1) self.connections_spinBox.setMaximum(16) connections_horizontalLayout.addWidget(self.connections_spinBox) download_options_tab_verticalLayout.addLayout( connections_horizontalLayout) # rpc_port self.rpc_port_label = QLabel(self.download_options_tab) self.rpc_horizontalLayout = QHBoxLayout() self.rpc_horizontalLayout.addWidget(self.rpc_port_label) self.rpc_port_spinbox = QSpinBox(self.download_options_tab) self.rpc_port_spinbox.setMinimum(1024) self.rpc_port_spinbox.setMaximum(65535) self.rpc_horizontalLayout.addWidget(self.rpc_port_spinbox) download_options_tab_verticalLayout.addLayout( self.rpc_horizontalLayout) # wait_queue wait_queue_horizontalLayout = QHBoxLayout() self.wait_queue_label = QLabel(self.download_options_tab) wait_queue_horizontalLayout.addWidget(self.wait_queue_label) self.wait_queue_time = MyQDateTimeEdit(self.download_options_tab) self.wait_queue_time.setDisplayFormat('H:mm') wait_queue_horizontalLayout.addWidget(self.wait_queue_time) download_options_tab_verticalLayout.addLayout( wait_queue_horizontalLayout) # don't check certificate checkBox self.dont_check_certificate_checkBox = QCheckBox( self.download_options_tab) download_options_tab_verticalLayout.addWidget( self.dont_check_certificate_checkBox) # change aria2 path aria2_path_verticalLayout = QVBoxLayout() self.aria2_path_checkBox = QCheckBox(self.download_options_tab) aria2_path_verticalLayout.addWidget(self.aria2_path_checkBox) aria2_path_horizontalLayout = QHBoxLayout() self.aria2_path_lineEdit = QLineEdit(self.download_options_tab) aria2_path_horizontalLayout.addWidget(self.aria2_path_lineEdit) self.aria2_path_pushButton = QPushButton(self.download_options_tab) aria2_path_horizontalLayout.addWidget(self.aria2_path_pushButton) aria2_path_verticalLayout.addLayout(aria2_path_horizontalLayout) download_options_tab_verticalLayout.addLayout( aria2_path_verticalLayout) download_options_tab_verticalLayout.addStretch(1) self.setting_tabWidget.addTab(self.download_options_tab, "") # save_as_tab self.save_as_tab = QWidget() save_as_tab_verticalLayout = QVBoxLayout(self.save_as_tab) save_as_tab_verticalLayout.setContentsMargins(20, 30, 0, 0) # download_folder self.download_folder_horizontalLayout = QHBoxLayout() self.download_folder_label = QLabel(self.save_as_tab) self.download_folder_horizontalLayout.addWidget( self.download_folder_label) self.download_folder_lineEdit = QLineEdit(self.save_as_tab) self.download_folder_horizontalLayout.addWidget( self.download_folder_lineEdit) self.download_folder_pushButton = QPushButton(self.save_as_tab) self.download_folder_horizontalLayout.addWidget( self.download_folder_pushButton) save_as_tab_verticalLayout.addLayout( self.download_folder_horizontalLayout) # temp_download_folder self.temp_horizontalLayout = QHBoxLayout() self.temp_download_label = QLabel(self.save_as_tab) self.temp_horizontalLayout.addWidget(self.temp_download_label) self.temp_download_lineEdit = QLineEdit(self.save_as_tab) self.temp_horizontalLayout.addWidget(self.temp_download_lineEdit) self.temp_download_pushButton = QPushButton(self.save_as_tab) self.temp_horizontalLayout.addWidget(self.temp_download_pushButton) save_as_tab_verticalLayout.addLayout(self.temp_horizontalLayout) # create subfolder self.subfolder_checkBox = QCheckBox(self.save_as_tab) save_as_tab_verticalLayout.addWidget(self.subfolder_checkBox) save_as_tab_verticalLayout.addStretch(1) self.setting_tabWidget.addTab(self.save_as_tab, "") # notifications_tab self.notifications_tab = QWidget() notification_tab_verticalLayout = QVBoxLayout(self.notifications_tab) notification_tab_verticalLayout.setContentsMargins(21, 21, 0, 0) self.enable_notifications_checkBox = QCheckBox(self.notifications_tab) notification_tab_verticalLayout.addWidget( self.enable_notifications_checkBox) self.sound_frame = QFrame(self.notifications_tab) self.sound_frame.setFrameShape(QFrame.StyledPanel) self.sound_frame.setFrameShadow(QFrame.Raised) verticalLayout = QVBoxLayout(self.sound_frame) self.volume_label = QLabel(self.sound_frame) verticalLayout.addWidget(self.volume_label) self.volume_dial = QDial(self.sound_frame) self.volume_dial.setProperty("value", 100) verticalLayout.addWidget(self.volume_dial) notification_tab_verticalLayout.addWidget(self.sound_frame) # message_notification message_notification_horizontalLayout = QHBoxLayout() self.notification_label = QLabel(self.notifications_tab) message_notification_horizontalLayout.addWidget( self.notification_label) self.notification_comboBox = QComboBox(self.notifications_tab) message_notification_horizontalLayout.addWidget( self.notification_comboBox) notification_tab_verticalLayout.addLayout( message_notification_horizontalLayout) notification_tab_verticalLayout.addStretch(1) self.setting_tabWidget.addTab(self.notifications_tab, "") # style_tab self.style_tab = QWidget() style_tab_verticalLayout = QVBoxLayout(self.style_tab) style_tab_verticalLayout.setContentsMargins(21, 21, 0, 0) # style style_horizontalLayout = QHBoxLayout() self.style_label = QLabel(self.style_tab) style_horizontalLayout.addWidget(self.style_label) self.style_comboBox = QComboBox(self.style_tab) style_horizontalLayout.addWidget(self.style_comboBox) style_tab_verticalLayout.addLayout(style_horizontalLayout) # language language_horizontalLayout = QHBoxLayout() self.lang_label = QLabel(self.style_tab) language_horizontalLayout.addWidget(self.lang_label) self.lang_comboBox = QComboBox(self.style_tab) language_horizontalLayout.addWidget(self.lang_comboBox) style_tab_verticalLayout.addLayout(language_horizontalLayout) language_horizontalLayout = QHBoxLayout() self.lang_label.setText( QCoreApplication.translate("setting_ui_tr", "Language: ")) # color scheme self.color_label = QLabel(self.style_tab) language_horizontalLayout.addWidget(self.color_label) self.color_comboBox = QComboBox(self.style_tab) language_horizontalLayout.addWidget(self.color_comboBox) style_tab_verticalLayout.addLayout(language_horizontalLayout) # icons icons_horizontalLayout = QHBoxLayout() self.icon_label = QLabel(self.style_tab) icons_horizontalLayout.addWidget(self.icon_label) self.icon_comboBox = QComboBox(self.style_tab) icons_horizontalLayout.addWidget(self.icon_comboBox) style_tab_verticalLayout.addLayout(icons_horizontalLayout) self.icons_size_horizontalLayout = QHBoxLayout() self.icons_size_label = QLabel(self.style_tab) self.icons_size_horizontalLayout.addWidget(self.icons_size_label) self.icons_size_comboBox = QComboBox(self.style_tab) self.icons_size_horizontalLayout.addWidget(self.icons_size_comboBox) style_tab_verticalLayout.addLayout(self.icons_size_horizontalLayout) # font font_horizontalLayout = QHBoxLayout() self.font_checkBox = QCheckBox(self.style_tab) font_horizontalLayout.addWidget(self.font_checkBox) self.fontComboBox = QFontComboBox(self.style_tab) font_horizontalLayout.addWidget(self.fontComboBox) self.font_size_label = QLabel(self.style_tab) font_horizontalLayout.addWidget(self.font_size_label) self.font_size_spinBox = QSpinBox(self.style_tab) self.font_size_spinBox.setMinimum(1) font_horizontalLayout.addWidget(self.font_size_spinBox) style_tab_verticalLayout.addLayout(font_horizontalLayout) self.setting_tabWidget.addTab(self.style_tab, "") window_verticalLayout.addWidget(self.setting_tabWidget) # start persepolis in system tray if browser executed self.start_persepolis_if_browser_executed_checkBox = QCheckBox( self.style_tab) style_tab_verticalLayout.addWidget( self.start_persepolis_if_browser_executed_checkBox) # hide window if close button clicked self.hide_window_checkBox = QCheckBox(self.style_tab) style_tab_verticalLayout.addWidget(self.hide_window_checkBox) # Enable system tray icon self.enable_system_tray_checkBox = QCheckBox(self.style_tab) style_tab_verticalLayout.addWidget(self.enable_system_tray_checkBox) # after_download dialog self.after_download_checkBox = QCheckBox() style_tab_verticalLayout.addWidget(self.after_download_checkBox) # show_menubar_checkbox self.show_menubar_checkbox = QCheckBox() style_tab_verticalLayout.addWidget(self.show_menubar_checkbox) # show_sidepanel_checkbox self.show_sidepanel_checkbox = QCheckBox() style_tab_verticalLayout.addWidget(self.show_sidepanel_checkbox) # hide progress window self.show_progress_window_checkbox = QCheckBox() style_tab_verticalLayout.addWidget(self.show_progress_window_checkbox) # add persepolis to startup self.startup_checkbox = QCheckBox() style_tab_verticalLayout.addWidget(self.startup_checkbox) # keep system awake self.keep_awake_checkBox = QCheckBox() style_tab_verticalLayout.addWidget(self.keep_awake_checkBox) style_tab_verticalLayout.addStretch(1) # columns_tab self.columns_tab = QWidget() columns_tab_verticalLayout = QVBoxLayout(self.columns_tab) columns_tab_verticalLayout.setContentsMargins(21, 21, 0, 0) # creating checkBox for columns self.show_column_label = QLabel() self.column0_checkBox = QCheckBox() self.column1_checkBox = QCheckBox() self.column2_checkBox = QCheckBox() self.column3_checkBox = QCheckBox() self.column4_checkBox = QCheckBox() self.column5_checkBox = QCheckBox() self.column6_checkBox = QCheckBox() self.column7_checkBox = QCheckBox() self.column10_checkBox = QCheckBox() self.column11_checkBox = QCheckBox() self.column12_checkBox = QCheckBox() columns_tab_verticalLayout.addWidget(self.show_column_label) columns_tab_verticalLayout.addWidget(self.column0_checkBox) columns_tab_verticalLayout.addWidget(self.column1_checkBox) columns_tab_verticalLayout.addWidget(self.column2_checkBox) columns_tab_verticalLayout.addWidget(self.column3_checkBox) columns_tab_verticalLayout.addWidget(self.column4_checkBox) columns_tab_verticalLayout.addWidget(self.column5_checkBox) columns_tab_verticalLayout.addWidget(self.column6_checkBox) columns_tab_verticalLayout.addWidget(self.column7_checkBox) columns_tab_verticalLayout.addWidget(self.column10_checkBox) columns_tab_verticalLayout.addWidget(self.column11_checkBox) columns_tab_verticalLayout.addWidget(self.column12_checkBox) columns_tab_verticalLayout.addStretch(1) self.setting_tabWidget.addTab(self.columns_tab, '') # video_finder_tab self.video_finder_tab = QWidget() video_finder_layout = QVBoxLayout(self.video_finder_tab) video_finder_layout.setContentsMargins(21, 21, 0, 0) video_finder_tab_verticalLayout = QVBoxLayout() max_links_horizontalLayout = QHBoxLayout() # max_links_label self.max_links_label = QLabel(self.video_finder_tab) max_links_horizontalLayout.addWidget(self.max_links_label) # max_links_spinBox self.max_links_spinBox = QSpinBox(self.video_finder_tab) self.max_links_spinBox.setMinimum(1) self.max_links_spinBox.setMaximum(16) max_links_horizontalLayout.addWidget(self.max_links_spinBox) video_finder_tab_verticalLayout.addLayout(max_links_horizontalLayout) self.video_finder_dl_path_horizontalLayout = QHBoxLayout() self.video_finder_frame = QFrame(self.video_finder_tab) self.video_finder_frame.setLayout(video_finder_tab_verticalLayout) video_finder_tab_verticalLayout.addStretch(1) video_finder_layout.addWidget(self.video_finder_frame) self.setting_tabWidget.addTab(self.video_finder_tab, "") # shortcut tab self.shortcut_tab = QWidget() shortcut_tab_verticalLayout = QVBoxLayout(self.shortcut_tab) shortcut_tab_verticalLayout.setContentsMargins(21, 21, 0, 0) # shortcut_table self.shortcut_table = QTableWidget(self) self.shortcut_table.setColumnCount(2) self.shortcut_table.setSelectionBehavior(QAbstractItemView.SelectRows) self.shortcut_table.setSelectionMode(QAbstractItemView.SingleSelection) self.shortcut_table.setEditTriggers(QAbstractItemView.NoEditTriggers) self.shortcut_table.verticalHeader().hide() shortcut_table_header = [ QCoreApplication.translate("setting_ui_tr", 'Action'), QCoreApplication.translate("setting_ui_tr", 'Shortcut') ] self.shortcut_table.setHorizontalHeaderLabels(shortcut_table_header) shortcut_tab_verticalLayout.addWidget(self.shortcut_table) self.setting_tabWidget.addTab( self.shortcut_tab, QCoreApplication.translate("setting_ui_tr", "Shortcuts")) # Actions actions_list = [ QCoreApplication.translate('setting_ui_tr', 'Quit'), QCoreApplication.translate('setting_ui_tr', 'Minimize to System Tray'), QCoreApplication.translate('setting_ui_tr', 'Remove Download Items'), QCoreApplication.translate('setting_ui_tr', 'Delete Download Items'), QCoreApplication.translate('setting_ui_tr', 'Move Selected Items Up'), QCoreApplication.translate('setting_ui_tr', 'Move Selected Items Down'), QCoreApplication.translate('setting_ui_tr', 'Add New Download Link'), QCoreApplication.translate('setting_ui_tr', 'Add New Video Link'), QCoreApplication.translate('setting_ui_tr', 'Import Links from Text File') ] # add actions to the shortcut_table j = 0 for action in actions_list: item = QTableWidgetItem(str(action)) # align center item.setTextAlignment(0x0004 | 0x0080) # insert item in shortcut_table self.shortcut_table.insertRow(j) self.shortcut_table.setItem(j, 0, item) j = j + 1 self.shortcut_table.resizeColumnsToContents() # window buttons buttons_horizontalLayout = QHBoxLayout() buttons_horizontalLayout.addStretch(1) self.defaults_pushButton = QPushButton(self) buttons_horizontalLayout.addWidget(self.defaults_pushButton) self.cancel_pushButton = QPushButton(self) self.cancel_pushButton.setIcon(QIcon(icons + 'remove')) buttons_horizontalLayout.addWidget(self.cancel_pushButton) self.ok_pushButton = QPushButton(self) self.ok_pushButton.setIcon(QIcon(icons + 'ok')) buttons_horizontalLayout.addWidget(self.ok_pushButton) window_verticalLayout.addLayout(buttons_horizontalLayout) # set style_tab for default self.setting_tabWidget.setCurrentIndex(3) # labels and translations self.setWindowTitle( QCoreApplication.translate("setting_ui_tr", "Preferences")) self.tries_label.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Set number of tries if download failed.</p></body></html>" )) self.tries_label.setText( QCoreApplication.translate("setting_ui_tr", "Number of tries: ")) self.tries_spinBox.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Set number of tries if download failed.</p></body></html>" )) self.wait_label.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Set the seconds to wait between retries. Download manager will retry downloads when the HTTP server returns a 503 response.</p></body></html>" )) self.wait_label.setText( QCoreApplication.translate( "setting_ui_tr", "Wait period between retries (seconds): ")) self.wait_spinBox.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Set the seconds to wait between retries. Download manager will retry downloads when the HTTP server returns a 503 response.</p></body></html>" )) self.time_out_label.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Set timeout in seconds. </p></body></html>" )) self.time_out_label.setText( QCoreApplication.translate("setting_ui_tr", "Timeout (seconds): ")) self.time_out_spinBox.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Set timeout in seconds. </p></body></html>" )) self.connections_label.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Using multiple connections can help speed up your download.</p></body></html>" )) self.connections_label.setText( QCoreApplication.translate("setting_ui_tr", "Number of connections: ")) self.connections_spinBox.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Using multiple connections can help speed up your download.</p></body></html>" )) self.rpc_port_label.setText( QCoreApplication.translate("setting_ui_tr", "RPC port number: ")) self.rpc_port_spinbox.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p> Specify a port number for JSON-RPC/XML-RPC server to listen to. Possible Values: 1024 - 65535 Default: 6801 </p></body></html>" )) self.wait_queue_label.setText( QCoreApplication.translate( "setting_ui_tr", 'Wait period between each download in queue:')) self.dont_check_certificate_checkBox.setText( QCoreApplication.translate( "setting_ui_tr", "Don't use certificate to verify the peers")) self.dont_check_certificate_checkBox.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>This option avoids SSL/TLS handshake failure. But use it at your own risk!</p></body></html>" )) self.aria2_path_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Change Aria2 default path')) self.aria2_path_pushButton.setText( QCoreApplication.translate("setting_ui_tr", 'Change')) aria2_path_tooltip = QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Attention: Wrong path may cause problems! Do it carefully or don't change default setting!</p></body></html>" ) self.aria2_path_checkBox.setToolTip(aria2_path_tooltip) self.aria2_path_lineEdit.setToolTip(aria2_path_tooltip) self.aria2_path_pushButton.setToolTip(aria2_path_tooltip) self.setting_tabWidget.setTabText( self.setting_tabWidget.indexOf(self.download_options_tab), QCoreApplication.translate("setting_ui_tr", "Download Options")) self.download_folder_label.setText( QCoreApplication.translate("setting_ui_tr", "Download folder: ")) self.download_folder_pushButton.setText( QCoreApplication.translate("setting_ui_tr", "Change")) self.temp_download_label.setText( QCoreApplication.translate("setting_ui_tr", "Temporary download folder: ")) self.temp_download_pushButton.setText( QCoreApplication.translate("setting_ui_tr", "Change")) self.subfolder_checkBox.setText( QCoreApplication.translate( "setting_ui_tr", "Create subfolders for Music,Videos, ... in default download folder" )) self.setting_tabWidget.setTabText( self.setting_tabWidget.indexOf(self.save_as_tab), QCoreApplication.translate("setting_ui_tr", "Save As")) self.enable_notifications_checkBox.setText( QCoreApplication.translate("setting_ui_tr", "Enable Notification Sounds")) self.volume_label.setText( QCoreApplication.translate("setting_ui_tr", "Volume: ")) self.setting_tabWidget.setTabText( self.setting_tabWidget.indexOf(self.notifications_tab), QCoreApplication.translate("setting_ui_tr", "Notifications")) self.style_label.setText( QCoreApplication.translate("setting_ui_tr", "Style: ")) self.color_label.setText( QCoreApplication.translate("setting_ui_tr", "Color scheme: ")) self.icon_label.setText( QCoreApplication.translate("setting_ui_tr", "Icons: ")) self.icons_size_label.setText( QCoreApplication.translate("setting_ui_tr", "Toolbar icons size: ")) self.notification_label.setText( QCoreApplication.translate("setting_ui_tr", "Notification type: ")) self.font_checkBox.setText( QCoreApplication.translate("setting_ui_tr", "Font: ")) self.font_size_label.setText( QCoreApplication.translate("setting_ui_tr", "Size: ")) self.hide_window_checkBox.setText( QCoreApplication.translate( "setting_ui_tr", "Hide main window if close button clicked.")) self.hide_window_checkBox.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>This feature may not work in your operating system.</p></body></html>" )) self.start_persepolis_if_browser_executed_checkBox.setText( QCoreApplication.translate( 'setting_ui_tr', 'If browser is opened, start Persepolis in system tray')) self.enable_system_tray_checkBox.setText( QCoreApplication.translate("setting_ui_tr", "Enable system tray icon")) self.after_download_checkBox.setText( QCoreApplication.translate( "setting_ui_tr", "Show download complete dialog when download is finished")) self.show_menubar_checkbox.setText( QCoreApplication.translate("setting_ui_tr", "Show menubar")) self.show_sidepanel_checkbox.setText( QCoreApplication.translate("setting_ui_tr", "Show side panel")) self.show_progress_window_checkbox.setText( QCoreApplication.translate("setting_ui_tr", "Show download progress window")) self.startup_checkbox.setText( QCoreApplication.translate("setting_ui_tr", "Run Persepolis at startup")) self.keep_awake_checkBox.setText( QCoreApplication.translate("setting_ui_tr", "Keep system awake!")) self.keep_awake_checkBox.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>This option will prevent the system from going to sleep.\ It is necessary if your power manager is suspending the system automatically. </p></body></html>" )) self.wait_queue_time.setToolTip( QCoreApplication.translate( "setting_ui_tr", "<html><head/><body><p>Format HH:MM</p></body></html>")) self.setting_tabWidget.setTabText( self.setting_tabWidget.indexOf(self.style_tab), QCoreApplication.translate("setting_ui_tr", "Preferences")) # columns_tab self.show_column_label.setText( QCoreApplication.translate("setting_ui_tr", 'Show these columns:')) self.column0_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'File Name')) self.column1_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Status')) self.column2_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Size')) self.column3_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Downloaded')) self.column4_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Percentage')) self.column5_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Connections')) self.column6_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Transfer Rate')) self.column7_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Estimated Time Left')) self.column10_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'First Try Date')) self.column11_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Last Try Date')) self.column12_checkBox.setText( QCoreApplication.translate("setting_ui_tr", 'Category')) self.setting_tabWidget.setTabText( self.setting_tabWidget.indexOf(self.columns_tab), QCoreApplication.translate("setting_ui_tr", "Columns Customization")) # Video Finder options tab self.setting_tabWidget.setTabText( self.setting_tabWidget.indexOf(self.video_finder_tab), QCoreApplication.translate("setting_ui_tr", "Video Finder Options")) self.max_links_label.setText( QCoreApplication.translate( "setting_ui_tr", 'Maximum number of links to capture:<br/>' '<small>(If browser sends multiple video links at a time)</small>' )) # window buttons self.defaults_pushButton.setText( QCoreApplication.translate("setting_ui_tr", "Defaults")) self.cancel_pushButton.setText( QCoreApplication.translate("setting_ui_tr", "Cancel")) self.ok_pushButton.setText( QCoreApplication.translate("setting_ui_tr", "OK"))
class UIDeleteROIWindow(): def setup_ui(self, delete_roi_window_instance, regions_of_interest, dataset_rtss, deleting_rois_structure_tuple): # Initialise the 2 lists for containing the ROI(s) that we are going to keep and delete respectively self.regions_of_interest_to_keep = [] self.regions_of_interest_to_delete = [] # This is for holding the original list of ROI(s) self.regions_of_interest_list = regions_of_interest # This is for holding the DICOM dataset of that specific patient self.dataset_rtss = dataset_rtss # Assigning new tuple for holding the deleting ROI(s) self.deleting_rois_structure_tuple = deleting_rois_structure_tuple # Initialise a DeleteROIWindow if platform.system() == 'Darwin': self.stylesheet_path = "res/stylesheet.qss" else: self.stylesheet_path = "res/stylesheet-win-linux.qss" stylesheet = open(resource_path(self.stylesheet_path)).read() window_icon = QIcon() window_icon.addPixmap(QPixmap(resource_path("res/images/icon.ico")), QIcon.Normal, QIcon.Off) delete_roi_window_instance.setObjectName("DeleteRoiWindowInstance") delete_roi_window_instance.setWindowIcon(window_icon) delete_roi_window_instance.resize(800, 606) # Create a vertical box to hold all widgets self.delete_roi_window_instance_vertical_box = QVBoxLayout() self.delete_roi_window_instance_vertical_box.setObjectName( "DeleteRoiWindowInstanceVerticalBox") # Create a label for holding the window's title self.delete_roi_window_title = QLabel() self.delete_roi_window_title.setObjectName("DeleteRoiWindowTitle") self.delete_roi_window_title.setProperty("QLabelClass", "window-title") self.delete_roi_window_title.setAlignment(Qt.AlignLeft) self.delete_roi_window_instance_vertical_box.addWidget( self.delete_roi_window_title) # Create a label for holding the instruction of how to delete the ROIs self.delete_roi_window_instruction = QLabel() self.delete_roi_window_instruction.setObjectName( "DeleteRoiWindowInstruction") self.delete_roi_window_instruction.setAlignment(Qt.AlignCenter) self.delete_roi_window_instance_vertical_box.addWidget( self.delete_roi_window_instruction) # Create a horizontal box for holding the 2 lists and the move left, move right buttons self.delete_roi_window_keep_and_delete_box = QHBoxLayout() self.delete_roi_window_keep_and_delete_box.setObjectName( "DeleteRoiWindowKeepAndDeleteBox") # ================================= KEEP BOX ================================= # Create a vertical box for holding the label and the tree view for holding the ROIs that we are keeping self.delete_roi_window_keep_vertical_box = QVBoxLayout() self.delete_roi_window_keep_vertical_box.setObjectName( "DeleteRoiWindowKeepVerticalBox") # Create a label for the tree view with the list of ROIs to keep self.delete_roi_window_keep_tree_view_label = QLabel() self.delete_roi_window_keep_tree_view_label.setObjectName( "DeleteRoiWindowKeepTreeViewLabel") self.delete_roi_window_keep_tree_view_label.setProperty( "QLabelClass", ["tree-view-label", "tree-view-label-keep-delete"]) self.delete_roi_window_keep_tree_view_label.setAlignment( Qt.AlignCenter) self.delete_roi_window_keep_tree_view_label.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) self.delete_roi_window_keep_tree_view_label.resize( self.delete_roi_window_keep_tree_view_label.sizeHint().width(), self.delete_roi_window_keep_tree_view_label.sizeHint().height()) self.delete_roi_window_keep_vertical_box.addWidget( self.delete_roi_window_keep_tree_view_label) # Create a tree view for containing the list of ROIs to keep self.delete_roi_window_keep_tree_view = QTreeWidget() self.delete_roi_window_keep_tree_view.setObjectName( "DeleteRoiWindowKeepTreeView") self.delete_roi_window_keep_tree_view.setHeaderHidden(True) self.delete_roi_window_keep_tree_view.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) self.delete_roi_window_keep_tree_view.resize( self.delete_roi_window_keep_tree_view.sizeHint().width(), self.delete_roi_window_keep_tree_view.sizeHint().height()) self.delete_roi_window_keep_vertical_box.addWidget( self.delete_roi_window_keep_tree_view) self.delete_roi_window_keep_vertical_box.setStretch(1, 4) # Create a widget to hold the keep vertical box self.delete_roi_window_keep_widget = QWidget() self.delete_roi_window_keep_widget.setObjectName( "DeleteRoiWindowKeepWidget") self.delete_roi_window_keep_widget.setLayout( self.delete_roi_window_keep_vertical_box) self.delete_roi_window_keep_and_delete_box.addStretch(1) self.delete_roi_window_keep_and_delete_box.addWidget( self.delete_roi_window_keep_widget) # ================================= KEEP BOX ================================= # ================================= MOVE LEFT/RIGHT BOX ================================= # Create a vertical box for holding the 2 buttons for moving left and right self.delete_roi_window_move_left_right_vertical_box = QVBoxLayout() self.delete_roi_window_move_left_right_vertical_box.setObjectName( "DeleteRoiWindowMoveLeftRightVerticalBox") # Create Move Right Button / Delete Button self.move_right_button = QPushButton() self.move_right_button.setObjectName("MoveRightButton") self.move_right_button.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) self.move_right_button.resize( self.move_right_button.sizeHint().width(), self.move_right_button.sizeHint().height()) self.move_right_button.setCursor( QtGui.QCursor(QtCore.Qt.PointingHandCursor)) self.move_right_button.clicked.connect( self.move_right_button_onClicked) self.move_right_button.setProperty("QPushButtonClass", "fail-button") self.delete_roi_window_move_left_right_vertical_box.addStretch(1) self.delete_roi_window_move_left_right_vertical_box.addWidget( self.move_right_button) # Create Move Left Button / Keep Button self.move_left_button = QPushButton() self.move_left_button.setObjectName("MoveLeftButton") self.move_left_button.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) self.move_left_button.resize(self.move_left_button.sizeHint().width(), self.move_left_button.sizeHint().height()) self.move_left_button.setCursor( QtGui.QCursor(QtCore.Qt.PointingHandCursor)) self.move_left_button.clicked.connect(self.move_left_button_onClicked) self.move_left_button.setProperty("QPushButtonClass", "success-button") self.delete_roi_window_move_left_right_vertical_box.addWidget( self.move_left_button) self.delete_roi_window_move_left_right_vertical_box.addStretch(1) # Create a widget for holding the 2 buttons self.delete_roi_window_move_left_right_widget = QWidget() self.delete_roi_window_move_left_right_widget.setObjectName( "DeleteRoiWindowMoveLeftRightWidget") self.delete_roi_window_move_left_right_widget.setLayout( self.delete_roi_window_move_left_right_vertical_box) self.delete_roi_window_keep_and_delete_box.addWidget( self.delete_roi_window_move_left_right_widget) # ================================= MOVE LEFT/RIGHT BOX ================================= # ================================= DELETE BOX ================================= # Create a vertical box for holding the label and the tree view for holding the ROIs that we are deleting self.delete_roi_window_delete_vertical_box = QVBoxLayout() self.delete_roi_window_delete_vertical_box.setObjectName( "DeleteRoiWindowDeleteVerticalBox") # Create a label for the tree view with the list of ROIs to delete self.delete_roi_window_delete_tree_view_label = QLabel() self.delete_roi_window_delete_tree_view_label.setObjectName( "DeleteRoiWindowDeleteTreeViewLabel") self.delete_roi_window_delete_tree_view_label.setProperty( "QLabelClass", ["tree-view-label", "tree-view-label-keep-delete"]) self.delete_roi_window_delete_tree_view_label.setAlignment( Qt.AlignCenter) self.delete_roi_window_delete_tree_view_label.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) self.delete_roi_window_delete_tree_view_label.resize( self.delete_roi_window_delete_tree_view_label.sizeHint().width(), self.delete_roi_window_delete_tree_view_label.sizeHint().height()) self.delete_roi_window_delete_vertical_box.addWidget( self.delete_roi_window_delete_tree_view_label) # Create a tree view for containing the list of ROIs to delete self.delete_roi_window_delete_tree_view = QTreeWidget() self.delete_roi_window_delete_tree_view.setObjectName( "DeleteRoiWindowDeleteTreeView") self.delete_roi_window_delete_tree_view.setHeaderHidden(True) self.delete_roi_window_delete_tree_view.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) self.delete_roi_window_delete_tree_view.resize( self.delete_roi_window_delete_tree_view.sizeHint().width(), self.delete_roi_window_delete_tree_view.sizeHint().height()) self.delete_roi_window_delete_vertical_box.addWidget( self.delete_roi_window_delete_tree_view) self.delete_roi_window_delete_vertical_box.setStretch(1, 4) # Create a widget to hold the delete vertical box self.delete_roi_window_delete_widget = QWidget() self.delete_roi_window_delete_widget.setObjectName( "DeleteRoiWindowDeleteWidget") self.delete_roi_window_delete_widget.setLayout( self.delete_roi_window_delete_vertical_box) self.delete_roi_window_keep_and_delete_box.addWidget( self.delete_roi_window_delete_widget) self.delete_roi_window_keep_and_delete_box.addStretch(1) self.delete_roi_window_keep_and_delete_box.setStretch(1, 4) self.delete_roi_window_keep_and_delete_box.setStretch(3, 4) # ================================= DELETE BOX ================================= # Create a widget to hold the keep and delete box self.delete_roi_window_keep_and_delete_widget = QWidget() self.delete_roi_window_keep_and_delete_widget.setObjectName( "DeleteRoiWindowKeepAndDeleteWidget") self.delete_roi_window_keep_and_delete_widget.setLayout( self.delete_roi_window_keep_and_delete_box) self.delete_roi_window_instance_vertical_box.addWidget( self.delete_roi_window_keep_and_delete_widget) # Create a horizontal box to hold 2 action buttons for this window self.delete_roi_window_action_buttons_box = QHBoxLayout() self.delete_roi_window_action_buttons_box.setObjectName( "DeleteRoiWindowActionButtonsBox") # Create the cancel button self.delete_roi_window_cancel_button = QPushButton() self.delete_roi_window_cancel_button.setObjectName( "DeleteRoiWindowCancelButton") self.delete_roi_window_cancel_button.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) self.delete_roi_window_cancel_button.resize( self.delete_roi_window_cancel_button.sizeHint().width(), self.delete_roi_window_cancel_button.sizeHint().height()) self.delete_roi_window_cancel_button.setCursor( QtGui.QCursor(QtCore.Qt.PointingHandCursor)) self.delete_roi_window_cancel_button.clicked.connect( self.on_cancel_button_clicked) self.delete_roi_window_cancel_button.setProperty( "QPushButtonClass", "fail-button") self.delete_roi_window_action_buttons_box.addStretch(1) self.delete_roi_window_action_buttons_box.addWidget( self.delete_roi_window_cancel_button) # Create the confirm button self.delete_roi_window_confirm_button = QPushButton() self.delete_roi_window_confirm_button.setObjectName( "DeleteRoiWindowConfirmButton") self.delete_roi_window_confirm_button.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) self.delete_roi_window_confirm_button.resize( self.delete_roi_window_confirm_button.sizeHint().width(), self.delete_roi_window_confirm_button.sizeHint().height()) self.delete_roi_window_confirm_button.setCursor( QtGui.QCursor(QtCore.Qt.PointingHandCursor)) self.delete_roi_window_confirm_button.clicked.connect( self.confirm_button_onClicked) self.delete_roi_window_confirm_button.setEnabled(False) self.delete_roi_window_confirm_button.setProperty( "QPushButtonClass", "success-button") self.delete_roi_window_action_buttons_box.addWidget( self.delete_roi_window_confirm_button) # Create a widget to hold the action buttons self.delete_roi_window_action_buttons_widget = QWidget() self.delete_roi_window_action_buttons_widget.setObjectName( "DeleteRoiWindowActionButtonsWidget") self.delete_roi_window_action_buttons_widget.setLayout( self.delete_roi_window_action_buttons_box) self.delete_roi_window_instance_vertical_box.addWidget( self.delete_roi_window_action_buttons_widget) # Set text for all attributes self.retranslate_ui(delete_roi_window_instance) # Create a central widget to hold the vertical layout box self.delete_roi_window_instance_central_widget = QWidget() self.delete_roi_window_instance_central_widget.setObjectName( "DeleteRoiWindowInstanceCentralWidget") self.delete_roi_window_instance_central_widget.setLayout( self.delete_roi_window_instance_vertical_box) self.delete_roi_window_instance_vertical_box.setStretch(2, 4) # Set the central widget for the main window and style the window delete_roi_window_instance.setCentralWidget( self.delete_roi_window_instance_central_widget) delete_roi_window_instance.setStyleSheet(stylesheet) # Load the ROIs in self.display_rois_in_listViewKeep() # Set the selection mode to multi so that we can select multiple ROIs to delete self.delete_roi_window_keep_tree_view.setSelectionMode( QAbstractItemView.MultiSelection) self.delete_roi_window_delete_tree_view.setSelectionMode( QAbstractItemView.MultiSelection) QtCore.QMetaObject.connectSlotsByName(delete_roi_window_instance) def retranslate_ui(self, delete_roi_window_instance): _translate = QtCore.QCoreApplication.translate delete_roi_window_instance.setWindowTitle( _translate("DeleteRoiWindowInstance", "OnkoDICOM - Delete ROI(s)")) self.delete_roi_window_title.setText( _translate("DeleteRoiWindowTitle", "Delete ROI(s)")) self.delete_roi_window_instruction.setText( _translate( "DeleteRoiWindowInstruction", "Move the Regions of Interest to be deleted to the right-hand side or vice versa" )) self.delete_roi_window_keep_tree_view_label.setText( _translate("DeleteRoiWindowKeepTreeViewLabel", "To Keep")) self.delete_roi_window_delete_tree_view_label.setText( _translate("DeleteRoiWindowDeleteTreeViewLabel", "To Delete")) self.move_right_button.setText( _translate("MoveRightButton", "Move Right ->>>")) self.move_left_button.setText( _translate("MoveLeftButton", "<<<- Move Left")) self.delete_roi_window_cancel_button.setText( _translate("DeleteRoiWindowCancelButton", "Cancel")) self.delete_roi_window_confirm_button.setText( _translate("DeleteRoiWindowConfirmButton", "Confirm")) def on_cancel_button_clicked(self): self.close() def display_rois_in_listViewKeep(self): self.regions_of_interest_to_keep.clear() for roi_id, roi_dict in self.regions_of_interest_list.items(): self.regions_of_interest_to_keep.append(roi_dict['name']) self.delete_roi_window_keep_tree_view.clear() self.delete_roi_window_keep_tree_view.setIndentation(0) self.item = QTreeWidgetItem(["item"]) for index in self.regions_of_interest_to_keep: item = QTreeWidgetItem([index]) self.delete_roi_window_keep_tree_view.addTopLevelItem(item) def move_right_button_onClicked(self): root_item = self.delete_roi_window_keep_tree_view.invisibleRootItem() for index in range(root_item.childCount()): item = root_item.child(index) if item in self.delete_roi_window_keep_tree_view.selectedItems(): # This will get ROI name self.regions_of_interest_to_delete.append(item.text(0)) # Move to the right column list self.delete_roi_window_delete_tree_view.clear() self.delete_roi_window_delete_tree_view.setIndentation(0) for roi in self.regions_of_interest_to_delete: item = QTreeWidgetItem([roi]) self.delete_roi_window_delete_tree_view.addTopLevelItem(item) self.delete_roi_window_confirm_button.setEnabled(True) # Delete moved items from the left column list self.regions_of_interest_to_keep = [ x for x in self.regions_of_interest_to_keep if x not in self.regions_of_interest_to_delete ] self.delete_roi_window_keep_tree_view.clear() for index in self.regions_of_interest_to_keep: item = QTreeWidgetItem([index]) self.delete_roi_window_keep_tree_view.addTopLevelItem(item) def move_left_button_onClicked(self): root_item = self.delete_roi_window_delete_tree_view.invisibleRootItem() for index in range(root_item.childCount()): item = root_item.child(index) if item in self.delete_roi_window_delete_tree_view.selectedItems(): # This will get ROI name self.regions_of_interest_to_keep.append(item.text(0)) # Move to the left column list self.delete_roi_window_keep_tree_view.clear() self.delete_roi_window_keep_tree_view.setIndentation(0) for roi in self.regions_of_interest_to_keep: item = QTreeWidgetItem([roi]) self.delete_roi_window_keep_tree_view.addTopLevelItem(item) # Delete moved items from the right column list self.regions_of_interest_to_delete = [ x for x in self.regions_of_interest_to_delete if x not in self.regions_of_interest_to_keep ] self.delete_roi_window_delete_tree_view.clear() for index in self.regions_of_interest_to_delete: item = QTreeWidgetItem([index]) self.delete_roi_window_delete_tree_view.addTopLevelItem(item) if len(self.regions_of_interest_to_delete) == 0: self.delete_roi_window_confirm_button.setEnabled(False) def confirm_button_onClicked(self): confirmation_dialog = QMessageBox.information( self, 'Delete ROI(s)?', 'Region(s) of Interest in the To Delete table will be deleted. ' 'Would you like to continue?', QMessageBox.Yes | QMessageBox.No) if confirmation_dialog == QMessageBox.Yes: progress_window = DeleteROIProgressWindow( self, QtCore.Qt.WindowTitleHint) progress_window.signal_roi_deleted.connect(self.on_rois_deleted) progress_window.start_deleting(self.dataset_rtss, self.regions_of_interest_to_delete) progress_window.show() def on_rois_deleted(self, new_rtss): self.deleting_rois_structure_tuple.emit((new_rtss, { "delete": self.regions_of_interest_to_delete })) QMessageBox.about(self, "Saved", "Regions of interest successfully deleted!") self.close()
def __init__(self, persepolis_setting): super().__init__() self.persepolis_setting = persepolis_setting # add support for other languages locale = str(self.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) # set ui direction ui_direction = self.persepolis_setting.value('ui_direction') if ui_direction == 'rtl': self.setLayoutDirection(Qt.RightToLeft) elif ui_direction in 'ltr': self.setLayoutDirection(Qt.LeftToRight) icons = ':/' + \ str(self.persepolis_setting.value('settings/icons')) + '/' self.setMinimumSize(QSize(545, 375)) self.setWindowIcon(QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg'))) verticalLayout = QVBoxLayout(self) self.about_tabWidget = QTabWidget(self) # about tab self.about_tab = QWidget(self) about_tab_horizontalLayout = QHBoxLayout(self.about_tab) about_tab_verticalLayout = QVBoxLayout() # persepolis icon if qtsvg_available: persepolis_icon_verticalLayout = QVBoxLayout() self.persepolis_icon = QtSvgWidget.QSvgWidget(':/persepolis.svg') self.persepolis_icon.setFixedSize(QSize(64, 64)) persepolis_icon_verticalLayout.addWidget(self.persepolis_icon) persepolis_icon_verticalLayout.addStretch(1) about_tab_horizontalLayout.addLayout(persepolis_icon_verticalLayout) self.title_label = QLabel(self.about_tab) font = QFont() font.setBold(True) font.setWeight(QFont.Weight.Bold) self.title_label.setFont(font) self.title_label.setAlignment(Qt.AlignCenter) about_tab_verticalLayout.addWidget(self.title_label) self.version_label = QLabel(self.about_tab) self.version_label.setAlignment(Qt.AlignCenter) about_tab_verticalLayout.addWidget(self.version_label) self.site2_label = QLabel(self.about_tab) self.site2_label.setTextFormat(Qt.RichText) self.site2_label.setAlignment(Qt.AlignCenter) self.site2_label.setOpenExternalLinks(True) self.site2_label.setTextInteractionFlags( Qt.TextBrowserInteraction) about_tab_verticalLayout.addWidget(self.site2_label) self.telegram_label = QLabel(self.about_tab) self.telegram_label.setTextFormat(Qt.RichText) self.telegram_label.setAlignment(Qt.AlignCenter) self.telegram_label.setOpenExternalLinks(True) self.telegram_label.setTextInteractionFlags( Qt.TextBrowserInteraction) about_tab_verticalLayout.addWidget(self.telegram_label) self.twitter_label = QLabel(self.about_tab) self.twitter_label.setTextFormat(Qt.RichText) self.twitter_label.setAlignment(Qt.AlignCenter) self.twitter_label.setOpenExternalLinks(True) self.twitter_label.setTextInteractionFlags( Qt.TextBrowserInteraction) about_tab_verticalLayout.addWidget(self.twitter_label) about_tab_verticalLayout.addStretch(1) about_tab_horizontalLayout.addLayout(about_tab_verticalLayout) # developers_tab # developers self.developers_tab = QWidget(self) developers_verticalLayout = QVBoxLayout(self.developers_tab) self.developers_title_label = QLabel(self.developers_tab) font.setBold(True) font.setWeight(QFont.Weight.Bold) self.developers_title_label.setFont(font) self.developers_title_label.setAlignment(Qt.AlignCenter) developers_verticalLayout.addWidget(self.developers_title_label) self.name_label = QLabel(self.developers_tab) self.name_label.setAlignment(Qt.AlignCenter) developers_verticalLayout.addWidget(self.name_label) # contributors self.contributors_thank_label = QLabel(self.developers_tab) self.contributors_thank_label.setFont(font) self.contributors_thank_label.setAlignment(Qt.AlignCenter) developers_verticalLayout.addWidget(self.contributors_thank_label) self.contributors_link_label = QLabel(self.developers_tab) self.contributors_link_label.setTextFormat(Qt.RichText) self.contributors_link_label.setAlignment(Qt.AlignCenter) self.contributors_link_label.setOpenExternalLinks(True) self.contributors_link_label.setTextInteractionFlags( Qt.TextBrowserInteraction) developers_verticalLayout.addWidget(self.contributors_link_label) developers_verticalLayout.addStretch(1) # translators tab self.translators_tab = QWidget(self) translators_tab_verticalLayout = QVBoxLayout(self.translators_tab) # translators self.translators_textEdit = QTextEdit(self.translators_tab) self.translators_textEdit.setReadOnly(True) translators_tab_verticalLayout.addWidget(self.translators_textEdit) # License tab self.license_tab = QWidget(self) license_tab_verticalLayout = QVBoxLayout(self.license_tab) self.license_text = QTextEdit(self.license_tab) self.license_text.setReadOnly(True) license_tab_verticalLayout.addWidget(self.license_text) verticalLayout.addWidget(self.about_tabWidget) # buttons button_horizontalLayout = QHBoxLayout() button_horizontalLayout.addStretch(1) self.pushButton = QPushButton(self) self.pushButton.setIcon(QIcon(icons + 'ok')) self.pushButton.clicked.connect(self.close) button_horizontalLayout.addWidget(self.pushButton) verticalLayout.addLayout(button_horizontalLayout) self.setWindowTitle(QCoreApplication.translate("about_ui_tr", "About Persepolis")) # about_tab self.title_label.setText(QCoreApplication.translate("about_ui_tr", "Persepolis Download Manager")) self.version_label.setText(QCoreApplication.translate("about_ui_tr", "Version 3.2.0")) self.site2_label.setText(QCoreApplication.translate("about_ui_tr", "<a href=https://persepolisdm.github.io>https://persepolisdm.github.io</a>", "TRANSLATORS NOTE: YOU REALLY DON'T NEED TO TRANSLATE THIS PART!")) self.telegram_label.setText(QCoreApplication.translate("about_ui_tr", "<a href=https://telegram.me/persepolisdm>https://telegram.me/persepolisdm</a>", "TRANSLATORS NOTE: YOU REALLY DON'T NEED TO TRANSLATE THIS PART!")) self.twitter_label.setText(QCoreApplication.translate("about_ui_tr", "<a href=https://twitter.com/persepolisdm>https://twitter.com/persepolisdm</a>", "TRANSLATORS NOTE: YOU REALLY DON'T NEED TO TRANSLATE THIS PART!")) # developers_tab self.developers_title_label.setText(QCoreApplication.translate('about_ui_tr', 'Developers:')) self.name_label.setText(QCoreApplication.translate("about_ui_tr", "\nAliReza AmirSamimi\nMohammadreza Abdollahzadeh\nSadegh Alirezaie\nMostafa Asadi\nMohammadAmin Vahedinia\nJafar Akhondali\nH.Rostami\nEhsan Titish", "TRANSLATORS NOTE: YOU REALLY DON'T NEED TO TRANSLATE THIS PART!")) self.contributors_thank_label.setText(QCoreApplication.translate('about_ui_tr', 'Special thanks to:')) self.contributors_link_label.setText( "<a href=https://github.com/persepolisdm/persepolis/graphs/contributors>our contributors</a>") # License self.license_text.setPlainText(""" This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. """) # tabs self.about_tabWidget.addTab(self.about_tab, QCoreApplication.translate("about_ui_tr", "About Persepolis")) self.about_tabWidget.addTab(self.developers_tab, QCoreApplication.translate("about_ui_tr", "Developers")) self.about_tabWidget.addTab(self.translators_tab, QCoreApplication.translate("about_ui_tr", "Translators")) self.about_tabWidget.addTab(self.license_tab, QCoreApplication.translate("about_ui_tr", "License")) # button self.pushButton.setText(QCoreApplication.translate("about_ui_tr", "OK"))
class Config(QWidget): def __init__(self): super().__init__() # global self.params_cell_def self.tab = QWidget() # self.tabs.resize(200,5) #------------------------------------------- label_width = 110 domain_value_width = 100 value_width = 60 label_height = 20 units_width = 70 self.scroll = QScrollArea() # might contain centralWidget self.params_cell_def = QWidget() self.vbox = QVBoxLayout() self.vbox.addStretch(0) #============ Domain ================================ label = QLabel("Domain (micron)") label.setFixedHeight(label_height) label.setStyleSheet("background-color: orange") label.setAlignment(QtCore.Qt.AlignCenter) self.vbox.addWidget(label) hbox = QHBoxLayout() label = QLabel("Xmin") label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.xmin = QLineEdit() self.xmin.setFixedWidth(domain_value_width) self.xmin.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.xmin) label = QLabel("Xmax") label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.xmax = QLineEdit() self.xmax.setFixedWidth(domain_value_width) self.xmax.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.xmax) self.vbox.addLayout(hbox) #---------- hbox = QHBoxLayout() label = QLabel("Ymin") label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.ymin = QLineEdit() self.ymin.setFixedWidth(domain_value_width) self.ymin.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.ymin) label = QLabel("Ymax") label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.ymax = QLineEdit() self.ymax.setFixedWidth(domain_value_width) self.ymax.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.ymax) self.vbox.addLayout(hbox) #---------- hbox = QHBoxLayout() self.virtual_walls = QCheckBox("Virtual walls") # self.motility_enabled.setAlignment(QtCore.Qt.AlignRight) # label.setFixedWidth(label_width) hbox.addWidget(self.virtual_walls) self.vbox.addLayout(hbox) self.vbox.addWidget(QHLine()) #---------- hbox = QHBoxLayout() # hbox.setFixedHeight(label_width) label = QLabel("Max Time") # label_width = 210 label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.max_time = QLineEdit() self.max_time.setFixedWidth(200) self.max_time.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.max_time) label = QLabel("min") label.setFixedWidth(units_width) label.setAlignment(QtCore.Qt.AlignLeft) hbox.addWidget(label) self.vbox.addLayout(hbox) #---------- hbox = QHBoxLayout() label = QLabel("# threads") label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.num_threads = QLineEdit() self.num_threads.setFixedWidth(value_width) self.num_threads.setValidator(QtGui.QIntValidator()) hbox.addWidget(self.num_threads) self.vbox.addLayout(hbox) #------------------ hbox = QHBoxLayout() label = QLabel("Save data:") label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignLeft) hbox.addWidget(label) #------ self.save_svg = QCheckBox("SVG") # self.motility_2D.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(self.save_svg) label = QLabel("every") # label_width = 210 # label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.svg_interval = QLineEdit() self.svg_interval.setFixedWidth(value_width) self.svg_interval.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.svg_interval) label = QLabel("min") # label.setFixedWidth(units_width) label.setAlignment(QtCore.Qt.AlignLeft) hbox.addWidget(label) #------ self.save_svg = QCheckBox("Full") # self.motility_2D.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(self.save_svg) label = QLabel("every") # label_width = 210 # label.setFixedWidth(label_width) label.setAlignment(QtCore.Qt.AlignRight) hbox.addWidget(label) self.full_interval = QLineEdit() self.full_interval.setFixedWidth(value_width) self.full_interval.setValidator(QtGui.QDoubleValidator()) hbox.addWidget(self.full_interval) label = QLabel("min") # label.setFixedWidth(units_width) label.setAlignment(QtCore.Qt.AlignLeft) hbox.addWidget(label) self.vbox.addLayout(hbox) #-------------- self.cells_csv = QCheckBox("cells.csv") self.vbox.addWidget(self.cells_csv) #-------------------------- # Dummy widget for filler?? label = QLabel("") label.setFixedHeight(300) # label.setStyleSheet("background-color: orange") label.setAlignment(QtCore.Qt.AlignCenter) self.vbox.addWidget(label) #================================================================== self.params_cell_def.setLayout(self.vbox) self.scroll.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) self.scroll.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) self.scroll.setWidgetResizable(True) self.scroll.setWidget(self.params_cell_def) self.layout = QVBoxLayout(self) self.layout.addWidget(self.scroll)
class QueueList(QScrollArea): def __init__(self, parent=None): QScrollArea.__init__(self) self.setParent(parent) # Make QScrollArea transparent self.setStyleSheet( "QScrollArea { background-color: transparent } .QFrame { background-color: transparent }" ) self.setWidgetResizable(True) self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) # Add Touch Gestures to menu. QScroller.grabGesture(self, QScroller.LeftMouseButtonGesture) # Set layout settings self.layout = QVBoxLayout() self.layout.setContentsMargins(0, 0, 0, 0) self.layout.setSpacing(0) # A singular widget frame is needed to set the scroll area properly. frame = QFrame() frame.setLayout(self.layout) self.setWidget(frame) self.updateQueue() class QueueListItem(QToolButton): def __init__(self, song, parent=None): QToolButton.__init__(self) self.setParent(parent) self.song = song # Button formatting self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) self.setFixedHeight(70) self.setAutoRaise(True) # TODO: change with global themes self.setStyleSheet( "QToolButton:pressed { background-color: rgba(255, 255, 255, 0.1)} QToolButton { background-color: rgba(255, 255, 255, 0.05); border: 1px solid white}" ) # Set layout self.layout = QHBoxLayout() self.layout.setContentsMargins(0, 0, 0, 0) self.layout.setSpacing(0) self.createItem() self.setLayout(self.layout) def createItem(self): # Create a song item # Add Space to the beginning of the item labelQueue = self.formattedLabel(QLabel("", self)) labelQueue.setFixedWidth(70) labelQueue.setAlignment(Qt.AlignCenter) self.layout.addWidget(labelQueue) # Artist name labelArtist = self.formattedLabel( QLabel(self.song["artist_name"])) labelArtist.setFixedWidth(300) self.layout.addWidget(labelArtist) # Song Title labelTitle = self.formattedLabel( QLabel(self.song["song_title"])) self.layout.addWidget(labelTitle) # Set font (icon) size font = QFont() font.setPointSize(48) # Add buttons for queue-specific actions # Move the song up the queue btnMoveUp = QToolButton() btnMoveUp.setText("▲") btnMoveUp.setFixedSize(70, 70) btnMoveUp.setStyleSheet("color: white") btnMoveUp.setFont(font) btnMoveUp.clicked.connect(self.moveUp) self.layout.addWidget(btnMoveUp) # Move the song down the queue btnMoveDown = QToolButton() btnMoveDown.setText("▼") btnMoveDown.setFixedSize(70, 70) btnMoveDown.setStyleSheet("color: white") btnMoveDown.setFont(font) btnMoveDown.clicked.connect(self.moveDown) self.layout.addWidget(btnMoveDown) # Move the song to the top of the queue btnMoveTop = QToolButton() btnMoveTop.setText("⍏") btnMoveTop.setFixedSize(70, 70) btnMoveTop.setStyleSheet("color: white") btnMoveTop.setFont(font) btnMoveTop.clicked.connect(self.moveTop) self.layout.addWidget(btnMoveTop) # Play the song immediately btnPlay = QToolButton() btnPlay.setText("➤") btnPlay.setFixedSize(70, 70) btnPlay.setStyleSheet("color: white") btnPlay.setFont(font) btnPlay.clicked.connect(self.playSong) self.layout.addWidget(btnPlay) # Remove the song from the queue btnRemove = QToolButton() btnRemove.setText("X") btnRemove.setFixedSize(70, 70) btnRemove.setStyleSheet("color: white") btnRemove.setFont(font) btnRemove.clicked.connect(self.removeSong) self.layout.addWidget(btnRemove) def formattedLabel(self, label): font = QFont() font.setPixelSize(25) # TODO: change with global themes label.setStyleSheet("color: white") label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) label.setFont(font) return label def moveUp(self): # Move the song up the queue self.window().songQueue.moveUp(self.song) self.window().content.queueList.updateQueue() def moveDown(self): # Move the song down the queue self.window().songQueue.moveDown(self.song) self.window().content.queueList.updateQueue() def moveTop(self): # Move the song to the top of the queue self.window().songQueue.moveTop(self.song) self.window().content.queueList.updateQueue() def playSong(self): # Play the song immediately self.window().songQueue.moveTop(self.song) self.window().overlayBottom.buttonAction("next") self.window().content.queueList.updateQueue() def removeSong(self): # Remove the song from the queue self.window().songQueue.removeSong(self.song) self.window().content.queueList.updateQueue() if len(self.window().mediaPlayer.songQueue.getQueue()) == 0: self.window().mediaPlayer.updateMarquee() def updateQueue(self): # "Refresh" the queue visually while self.layout.count(): item = self.layout.takeAt(0) if item.widget() is not None: item.widget().deleteLater() for i in self.window().songQueue.getQueue(): item = self.QueueListItem(i, self) self.layout.addWidget(item) if self.window().songQueue.getQueue(): self.layout.addStretch(1) else: label = QLabel("没有结果/No Result") label.setStyleSheet("color: white") label.setAlignment(Qt.AlignCenter) font = QFont() font.setPointSize(35) label.setFont(font) self.layout.addWidget(label)
class NovoCliente(QWidget): status_signal = Signal(str) def __init__(self): self.db = ClientesDB() QWidget.__init__(self) font = QFont() font.setBold(True) # Labels em Negrito # Labels: self.label_title = QLabel("Novo Cliente") self.label_title.setFont(font) self.label_nome = QLabel("Nome Completo:") self.label_nome.setFont(font) self.label_endereco = QLabel("Endereço:") self.label_endereco.setFont(font) self.label_numero = QLabel("Número:") self.label_numero.setFont(font) self.label_cpf = QLabel("CPF:") self.label_cpf.setFont(font) # Entries: self.entry_nome = QLineEdit() self.entry_endereco = QTextEdit() self.entry_numero = QLineEdit() self.entry_cpf = QLineEdit() # Botões; self.button_salvar = QPushButton("&Salvar") self.button_salvar.clicked.connect(self.salvar_cliente) self.button_salvar.setShortcut("Ctrl+S") self.button_cancelar = QPushButton("Cancelar") self.button_cancelar.clicked.connect(self.limpar) self.button_cancelar.setShortcut("ESC") # Linha self.line = QFrame() self.line.setFrameShape(QFrame.HLine) self.line.setFrameShadow(QFrame.Sunken) self.line.setLineWidth(0) self.line.setMidLineWidth(1) # Leiaute: self.layout = QVBoxLayout() self.layout_buttons = QHBoxLayout() self.layout.addWidget(self.label_title) self.layout.addWidget(self.line) self.layout.addWidget(self.label_nome) self.layout.addWidget(self.entry_nome) self.layout.addWidget(self.label_numero) self.layout.addWidget(self.entry_numero) self.layout.addWidget(self.label_cpf) self.layout.addWidget(self.entry_cpf) self.layout.addWidget(self.label_endereco) self.layout.addWidget(self.entry_endereco) self.layout_buttons.addWidget(self.button_salvar) self.layout_buttons.addWidget(self.button_cancelar) self.layout.addStretch(2) self.layout.addLayout(self.layout_buttons) self.setLayout(self.layout) @Slot() def salvar_cliente(self): nome = self.entry_nome.text() cpf = self.entry_cpf.text() numero = self.entry_numero.text() endereco = self.entry_endereco.toPlainText() data = { 'nome': nome, 'cpf': cpf, 'numero': numero, 'endereco': endereco } try: self.db.novo_cliente(data) self.status_signal.emit("Salvo") self.limpar() except ValueError as e: popup = QMessageBox(QMessageBox.Critical, "Erro", "Campo Inválido") popup.setInformativeText(str(e)) popup.addButton(QMessageBox.Ok) popup.exec() @Slot() def limpar(self): self.entry_nome.setText('') self.entry_endereco.setText('') self.entry_numero.setText('') self.entry_cpf.setText('')
class Widget(QWidget): def __init__(self): QWidget.__init__(self) self.items = 0 # Example data self._data = { "Water": 24.5, "Electricity": 55.1, "Rent": 850.0, "Supermarket": 230.4, "Internet": 29.99, "Spätkauf": 21.85, "BVG Ticket": 60.0, "Coffee": 22.45, "Meetup": 0.0 } # Left self.table = QTableWidget() self.table.setColumnCount(2) self.table.setHorizontalHeaderLabels(["Description", "Quantity"]) self.table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) # Right self.description = QLineEdit() self.quantity = QLineEdit() self.add = QPushButton("Add") self.clear = QPushButton("Clear") self.quit = QPushButton("Quit") # Disabling 'Add' button self.add.setEnabled(False) self.right = QVBoxLayout() self.right.setContentsMargins(10, 10, 10, 10) self.right.addWidget(QLabel("Description")) self.right.addWidget(self.description) self.right.addWidget(QLabel("Quantity")) self.right.addWidget(self.quantity) self.right.addWidget(self.add) self.right.addStretch() self.right.addWidget(self.clear) self.right.addWidget(self.quit) # QWidget Layout self.layout = QHBoxLayout() self.layout.addWidget(self.table) self.layout.addLayout(self.right) # Set the layout to the QWidget self.setLayout(self.layout) # Signals and Slots self.add.clicked.connect(self.add_element) self.quit.clicked.connect(self.quit_application) self.clear.clicked.connect(self.clear_table) self.description.textChanged[str].connect(self.check_disable) self.quantity.textChanged[str].connect(self.check_disable) # Fill example data self.fill_table() @Slot() def add_element(self): des = self.description.text() qty = self.quantity.text() self.table.insertRow(self.items) self.table.setItem(self.items, 0, QTableWidgetItem(des)) self.table.setItem(self.items, 1, QTableWidgetItem(qty)) self.description.setText("") self.quantity.setText("") self.items += 1 @Slot() def check_disable(self, s): if not self.description.text() or not self.quantity.text(): self.add.setEnabled(False) else: self.add.setEnabled(True) @Slot() def quit_application(self): QApplication.quit() def fill_table(self, data=None): data = self._data if not data else data for desc, price in data.items(): self.table.insertRow(self.items) self.table.setItem(self.items, 0, QTableWidgetItem(desc)) self.table.setItem(self.items, 1, QTableWidgetItem(str(price))) self.items += 1 @Slot() def clear_table(self): self.table.setRowCount(0) self.items = 0
class UIFirstTimeWelcomeWindow(object): configured = QtCore.Signal(str) # the ui constructor function def setup_ui(self, first_time_welcome_window_instance): self.filepath = "" if platform.system() == 'Darwin': self.stylesheet_path = "res/stylesheet.qss" else: self.stylesheet_path = "res/stylesheet-win-linux.qss" window_icon = QtGui.QIcon() window_icon.addPixmap( QtGui.QPixmap(resource_path("res/images/icon.ico")), QtGui.QIcon.Normal, QtGui.QIcon.Off) # adding icon first_time_welcome_window_instance.setObjectName( "FirstTimeWelcomeWindowInstance") first_time_welcome_window_instance.setWindowIcon(window_icon) first_time_welcome_window_instance.setFixedSize(840, 530) # Create a vertical layout to manage layout in a vertical manner self.window_vertical_layout_box = QVBoxLayout() self.window_vertical_layout_box.setObjectName( "FirstTimeWelcomeWindowInstanceVerticalLayoutBox") # Create a horizontal box to hold the Onko logo & welcome message self.first_time_welcome_logo_message_horizontal_box = QHBoxLayout() self.first_time_welcome_logo_message_horizontal_box.setObjectName( "FirstTimeWelcomeLogoMessageBox") # Set up the Logo Holder self.logo_holder = QtWidgets.QHBoxLayout() self.first_time_welcome_logo = QtWidgets.QLabel() self.first_time_welcome_logo.setPixmap( QtGui.QPixmap(resource_path("res/images/image.png"))) self.first_time_welcome_logo.setScaledContents(True) self.first_time_welcome_logo.setObjectName( "FirstTimeWelcomeWindowLogo") self.first_time_welcome_logo.setFixedSize(240, 130) self.logo_holder.addWidget(self.first_time_welcome_logo) self.first_time_welcome_logo_message_horizontal_box.addLayout( self.logo_holder) # Create a vertical box to hold the welcome message self.first_time_welcome_message_vertical_box = QVBoxLayout() self.first_time_welcome_message_vertical_box.setObjectName( "FirstTimeWelcomeWindowWelcomeMessage") # Set up the Label self.first_time_welcome_message_label = QtWidgets.QLabel() self.first_time_welcome_message_label.setObjectName( "FirstTimeWelcomeWindowLabel") self.first_time_welcome_message_label.setAlignment(Qt.AlignLeft) self.first_time_welcome_message_vertical_box.addWidget( self.first_time_welcome_message_label) # Set up the Slogan self.first_time_welcome_message_slogan = QtWidgets.QLabel() self.first_time_welcome_message_slogan.setObjectName( "FirstTimeWelcomeWindowSlogan") self.first_time_welcome_message_slogan.setAlignment(Qt.AlignLeft) self.first_time_welcome_message_slogan.setWordWrap(True) self.first_time_welcome_message_vertical_box.addWidget( self.first_time_welcome_message_slogan) self.first_time_welcome_message_slogan_widget = QWidget() self.first_time_welcome_message_slogan_widget.setLayout( self.first_time_welcome_message_vertical_box) self.first_time_welcome_logo_message_horizontal_box.addWidget( self.first_time_welcome_message_slogan_widget) self.first_time_welcome_logo_message_widget = QWidget() self.first_time_welcome_logo_message_widget.setLayout( self.first_time_welcome_logo_message_horizontal_box) self.window_vertical_layout_box.addWidget( self.first_time_welcome_logo_message_widget) # Create a label to prompt the user to enter the path to the default directory self.first_time_welcome_default_dir_prompt = QtWidgets.QLabel() self.first_time_welcome_default_dir_prompt.setObjectName( "FirstTimeWelcomeWindowPrompt") self.first_time_welcome_default_dir_prompt.setAlignment(Qt.AlignLeft) self.window_vertical_layout_box.addWidget( self.first_time_welcome_default_dir_prompt) # Create a horizontal box to hold the input box for the directory and the choose button self.first_time_welcome_input_horizontal_box = QHBoxLayout() self.first_time_welcome_input_horizontal_box.setObjectName( "FirstTimeWelcomeWindowInputHorizontalBox") # Create a textbox to contain the path to the default directory self.first_time_welcome_input_box = UIFirstTimeUserDragAndDropEvent( self) self.first_time_welcome_input_box.setObjectName( "FirstTimeWelcomeWindowInputBox") self.first_time_welcome_input_box.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) self.first_time_welcome_input_horizontal_box.addWidget( self.first_time_welcome_input_box) # Create a choose button to open the file dialog self.first_time_welcome_choose_button = QPushButton() self.first_time_welcome_choose_button.setObjectName( "FirstTimeWelcomeWindowChooseButton") self.first_time_welcome_choose_button.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) self.first_time_welcome_choose_button.resize( self.first_time_welcome_choose_button.sizeHint().width(), self.first_time_welcome_input_box.height()) self.first_time_welcome_choose_button.setCursor( QtGui.QCursor(QtCore.Qt.PointingHandCursor)) self.first_time_welcome_input_horizontal_box.addWidget( self.first_time_welcome_choose_button) self.first_time_welcome_choose_button.clicked.connect( self.choose_button_clicked) # Create a widget to hold the input field self.first_time_welcome_input_widget = QWidget() self.first_time_welcome_input_horizontal_box.setStretch(0, 4) self.first_time_welcome_input_widget.setLayout( self.first_time_welcome_input_horizontal_box) self.window_vertical_layout_box.addWidget( self.first_time_welcome_input_widget) self.window_vertical_layout_box.addStretch(1) # Create widgets for the clinical data CSV file path self.clinical_data_csv_dir_label = QtWidgets.QLabel() self.clinical_data_csv_dir_label.setObjectName("ClinicalDataCSVPrompt") self.clinical_data_csv_dir_label.setAlignment(Qt.AlignLeft) self.window_vertical_layout_box.addWidget( self.clinical_data_csv_dir_label) # Create a horizontal box to hold the input box for the # directory and the choose button self.clinical_data_csv_horizontal_box = QHBoxLayout() self.clinical_data_csv_horizontal_box.setObjectName( "ClinicalDataCSVHorizontalBox") # Create a textbox to contain the path to the default directory self.clinical_data_csv_input_box = \ UIFirstTimeUserDragAndDropEvent(self) self.clinical_data_csv_input_box.setObjectName( "ClinicalDataCSVInputBox") self.clinical_data_csv_input_box.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) self.clinical_data_csv_horizontal_box.addWidget( self.clinical_data_csv_input_box) # Create a choose button to open the file dialog self.clinical_data_csv_choose_button = QPushButton() self.clinical_data_csv_choose_button.setObjectName( "ClinicalDataCSVChooseButton") self.clinical_data_csv_choose_button.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) self.clinical_data_csv_choose_button.resize( self.clinical_data_csv_choose_button.sizeHint().width(), self.clinical_data_csv_input_box.height()) self.clinical_data_csv_choose_button.setCursor( QtGui.QCursor(QtCore.Qt.PointingHandCursor)) self.clinical_data_csv_horizontal_box.addWidget( self.clinical_data_csv_choose_button) self.clinical_data_csv_choose_button.clicked.connect( self.change_clinical_data_csv_button_clicked) # Create a widget to hold the input field self.clinical_data_input_widget = QWidget() self.clinical_data_csv_horizontal_box.setStretch(0, 4) self.clinical_data_input_widget.setLayout( self.clinical_data_csv_horizontal_box) self.window_vertical_layout_box.addWidget( self.clinical_data_input_widget) self.window_vertical_layout_box.addStretch(1) # Create a horizontal box to hold the Skip and Confirm button self.first_time_window_configure_actions_horizontal_box = QHBoxLayout() self.first_time_window_configure_actions_horizontal_box.setObjectName( "FirstTimeWelcomeWindowConfigureActionsHorizontalBox") self.first_time_window_configure_actions_horizontal_box.addStretch(1) # Add a button to skip the configuration setting self.skip_button = QPushButton() self.skip_button.setObjectName("SkipButton") self.skip_button.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) self.skip_button.resize(self.skip_button.sizeHint().width(), self.skip_button.sizeHint().height()) self.skip_button.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor)) self.skip_button.setProperty("QPushButtonClass", "fail-button") self.first_time_window_configure_actions_horizontal_box.addWidget( self.skip_button) # Add a button to save the default directory self.save_dir_button = QPushButton() self.save_dir_button.setObjectName("SaveDirButton") self.save_dir_button.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) self.save_dir_button.resize(self.save_dir_button.sizeHint().width(), self.save_dir_button.sizeHint().height()) self.save_dir_button.setCursor( QtGui.QCursor(QtCore.Qt.PointingHandCursor)) self.save_dir_button.clicked.connect(self.save_options) self.save_dir_button.setProperty("QPushButtonClass", "success-button") self.first_time_window_configure_actions_horizontal_box.addWidget( self.save_dir_button) # Create a widget to house all of the actions button for first-time window self.first_time_window_configure_actions_widget = QWidget() self.first_time_window_configure_actions_widget.setLayout( self.first_time_window_configure_actions_horizontal_box) self.window_vertical_layout_box.addWidget( self.first_time_window_configure_actions_widget) self.first_time_window_instance_central_widget = QWidget() self.first_time_window_instance_central_widget.setLayout( self.window_vertical_layout_box) first_time_welcome_window_instance.setCentralWidget( self.first_time_window_instance_central_widget) # Set the current stylesheet to the instance and connect it back to the caller through slot _stylesheet = open(resource_path(self.stylesheet_path)).read() first_time_welcome_window_instance.setStyleSheet(_stylesheet) self.retranslate_ui(first_time_welcome_window_instance) QtCore.QMetaObject.connectSlotsByName( first_time_welcome_window_instance) # this function inserts all the text in the first time page def retranslate_ui(self, first_time_welcome_window_instance): _translate = QtCore.QCoreApplication.translate first_time_welcome_window_instance.setWindowTitle( _translate("FirstTimeWelcomeWindowInstance", "OnkoDICOM - First-time User Setting")) self.first_time_welcome_message_label.setText( _translate("FirstTimeWelcomeWindowInstance", "Welcome to OnkoDICOM!")) self.first_time_welcome_message_slogan.setText( _translate( "FirstTimeWelcomeWindowInstance", "OnkoDICOM - the solution for producing data for analysis from your oncology plans and scans." )) self.first_time_welcome_default_dir_prompt.setText( _translate( "FirstTimeWelcomeWindowInstance", "Choose the path of the default directory containing all DICOM files:" )) self.first_time_welcome_input_box.setPlaceholderText( _translate( "FirstTimeWelcomeWindowInstance", "Enter DICOM Files Path (For example, C:\path\\to\your\DICOM\Files)" )) self.first_time_welcome_choose_button.setText( _translate("FirstTimeWelcomeWindowInstance", "Choose")) # Clinical data CSV widgets self.clinical_data_csv_dir_label.setText( _translate( "FirstTimeWelcomeWindowInstance", "Choose the CSV file containing patient clinical data:")) self.clinical_data_csv_input_box.setPlaceholderText( _translate("FirstTimeWelcomeWindowInstance", "Enter CSV File Path (for example, C:\CSV\\file.csv)")) self.clinical_data_csv_choose_button.setText( _translate("FirstTimeWelcomeWindowInstance", "Choose")) self.save_dir_button.setText( _translate("FirstTimeWelcomeWindowInstance", "Confirm")) self.skip_button.setText( _translate("FirstTimeWelcomeWindowInstance", "Skip")) def save_options(self): """ Saves options selected in the first time welcome window. """ self.filepath = self.first_time_welcome_input_box.text() self.csv_path = self.clinical_data_csv_input_box.text() if self.filepath == "" and self.csv_path == "": QMessageBox.about(self, "Unable to proceed", "No directories selected.") elif not os.path.exists(self.filepath) or not \ os.path.exists(self.csv_path): QMessageBox.about(self, "Unable to proceed", "Directories do not exist") else: config = Configuration() try: config.update_default_directory(self.filepath) # Update CSV path if it exists if self.csv_path != "" and os.path.exists(self.csv_path): config.update_clinical_data_csv_dir(self.csv_path) except SqlError: config.set_up_config_db() QMessageBox.critical( self, "Config file error", "Failed to access configuration file.\nPlease try again.") else: self.configured.emit(self.filepath) def choose_button_clicked(self): """ Executes when the choose button is clicked. Gets filepath from the user and loads all files and subdirectories. """ # Get folder path from pop up dialog box self.filepath = QtWidgets.QFileDialog.getExistingDirectory( None, 'Select default directory...', '') self.first_time_welcome_input_box.setText(self.filepath) def change_clinical_data_csv_button_clicked(self): """ Executes when the choose button is clicked. Gets filepath from the user. """ # Get folder path from pop up dialog box self.csv_path = QtWidgets.QFileDialog.getOpenFileName( None, "Open Clinical Data File", "", "CSV data files (*.csv)")[0] if len(self.csv_path) > 0: self.clinical_data_csv_input_box.setText(self.csv_path)
def __init__(self, persepolis_setting): super().__init__() self.persepolis_setting = persepolis_setting # add support for other languages locale = str(self.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) # set ui direction ui_direction = self.persepolis_setting.value('ui_direction') if ui_direction == 'rtl': self.setLayoutDirection(Qt.RightToLeft) elif ui_direction in 'ltr': self.setLayoutDirection(Qt.LeftToRight) icons = ':/' + str( self.persepolis_setting.value('settings/icons')) + '/' self.setWindowIcon( QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg'))) self.setWindowTitle( QCoreApplication.translate("after_download_ui_tr", "Persepolis Download Manager")) # complete_label window_verticalLayout = QVBoxLayout() window_verticalLayout.setContentsMargins(21, 21, 21, 21) self.complete_label = QLabel() window_verticalLayout.addWidget(self.complete_label) # file_name_label self.file_name_label = QLabel() window_verticalLayout.addWidget(self.file_name_label) # size_label self.size_label = QLabel() window_verticalLayout.addWidget(self.size_label) # link self.link_label = QLabel() window_verticalLayout.addWidget(self.link_label) self.link_lineEdit = QLineEdit() window_verticalLayout.addWidget(self.link_lineEdit) # save_as self.save_as_label = QLabel() window_verticalLayout.addWidget(self.save_as_label) self.save_as_lineEdit = QLineEdit() window_verticalLayout.addWidget(self.save_as_lineEdit) # open_pushButtun button_horizontalLayout = QHBoxLayout() button_horizontalLayout.setContentsMargins(10, 10, 10, 10) button_horizontalLayout.addStretch(1) self.open_pushButtun = QPushButton() self.open_pushButtun.setIcon(QIcon(icons + 'file')) button_horizontalLayout.addWidget(self.open_pushButtun) # open_folder_pushButtun self.open_folder_pushButtun = QPushButton() self.open_folder_pushButtun.setIcon(QIcon(icons + 'folder')) button_horizontalLayout.addWidget(self.open_folder_pushButtun) # ok_pushButton self.ok_pushButton = QPushButton() self.ok_pushButton.setIcon(QIcon(icons + 'ok')) button_horizontalLayout.addWidget(self.ok_pushButton) window_verticalLayout.addLayout(button_horizontalLayout) # dont_show_checkBox self.dont_show_checkBox = QCheckBox() window_verticalLayout.addWidget(self.dont_show_checkBox) window_verticalLayout.addStretch(1) self.setLayout(window_verticalLayout) # labels self.open_pushButtun.setText( QCoreApplication.translate("after_download_ui_tr", " Open File ")) self.open_folder_pushButtun.setText( QCoreApplication.translate("after_download_ui_tr", "Open Download Folder")) self.ok_pushButton.setText( QCoreApplication.translate("after_download_ui_tr", " OK ")) self.dont_show_checkBox.setText( QCoreApplication.translate("after_download_ui_tr", "Don't show this message again.")) self.complete_label.setText( QCoreApplication.translate("after_download_ui_tr", "<b>Download Completed!</b>")) self.save_as_label.setText( QCoreApplication.translate("after_download_ui_tr", "<b>Save as</b>: ")) self.link_label.setText( QCoreApplication.translate("after_download_ui_tr", "<b>Link</b>: "))
class ConfigTab(QWidget): show_all_updated = Signal(bool) def __init__(self, parent, root_config_path, force_all_fields=False): super().__init__(parent=parent) self.root_config_path = root_config_path self.force_all_fields = force_all_fields self.show_all_fields = force_all_fields self.main_window = parent self.layout = QVBoxLayout(self) # setup mapping config self.layout.addWidget(MappingGroupBox(self, root_config_path)) # setup extractor config self.layout.addWidget( DynamicClassFormBlock( self, "Extractor", f"{root_config_path}.extractor", CONNECTOR_CLASSES, ) ) # setup loader config self.layout.addWidget( DynamicClassFormBlock( self, "Loader", f"{root_config_path}.loader", CONNECTOR_CLASSES ) ) # add runner config self.layout.addWidget( DynamicClassFormBlock( self, "Runner", f"{root_config_path}.runner", RUNNER_CLASSES, default_class=PandasRunner, ) ) # if we dont force all the fields to be shown and a template is set, # add a toggle button to show/hide if not force_all_fields: self.toggle_all_fields_button = QPushButton("Show all fields") self.toggle_all_fields_button.clicked.connect( self.toggle_all_fields ) self.update_show_field_toggle_button_visibility( self.main_window.config ) self.main_window.config_changed.connect( self.update_show_field_toggle_button_visibility ) self.layout.addWidget(self.toggle_all_fields_button) else: self.toggle_all_fields_button = None # Add a spacer to push all the fields up when fields are hidden self.layout.addStretch() self.main_window.running_changed.connect( lambda b: self.setEnabled(not b) ) def toggle_all_fields(self): self.show_all_fields = not self.show_all_fields self.toggle_all_fields_button.text = ( "Show all fields" if not self.show_all_fields else "Hide template fields" ) self.show_all_updated.emit(self.show_all_fields) def update_show_field_toggle_button_visibility(self, config): if self.main_window.config.has_template: self.toggle_all_fields_button.show() else: self.toggle_all_fields_button.hide()
def __init__(self, persepolis_setting): super().__init__() self.persepolis_setting = persepolis_setting icons = ':/' + str(persepolis_setting.value('settings/icons')) + '/' # add support for other languages locale = str(self.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) # set ui direction ui_direction = self.persepolis_setting.value('ui_direction') if ui_direction == 'rtl': self.setLayoutDirection(Qt.RightToLeft) elif ui_direction in 'ltr': self.setLayoutDirection(Qt.LeftToRight) # window self.setMinimumSize(QSize(595, 284)) self.setWindowIcon( QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg'))) self.setWindowTitle( QCoreApplication.translate("progress_ui_tr", "Persepolis Download Manager")) verticalLayout = QVBoxLayout(self) # progress_tabWidget self.progress_tabWidget = QTabWidget(self) # information_tab self.information_tab = QWidget() information_verticalLayout = QVBoxLayout(self.information_tab) # link_label self.link_label = QLabel(self.information_tab) information_verticalLayout.addWidget(self.link_label) # status_label self.status_label = QLabel(self.information_tab) information_verticalLayout.addWidget(self.status_label) # downloaded_label self.downloaded_label = QLabel(self.information_tab) information_verticalLayout.addWidget(self.downloaded_label) # rate_label self.rate_label = QLabel(self.information_tab) information_verticalLayout.addWidget(self.rate_label) # time_label self.time_label = QLabel(self.information_tab) information_verticalLayout.addWidget(self.time_label) # connections_label self.connections_label = QLabel(self.information_tab) information_verticalLayout.addWidget(self.connections_label) information_verticalLayout.addStretch(1) # add information_tab to progress_tabWidget self.progress_tabWidget.addTab(self.information_tab, "") # options_tab self.options_tab = QWidget() options_tab_verticalLayout = QVBoxLayout(self.options_tab) options_tab_horizontalLayout = QHBoxLayout() # options_tab_horizontalLayout.setContentsMargins(11, 11, 11, 11) # limit_checkBox self.limit_checkBox = QCheckBox(self.options_tab) limit_verticalLayout = QVBoxLayout() limit_verticalLayout.addWidget(self.limit_checkBox) # limit_frame self.limit_frame = QFrame(self.options_tab) self.limit_frame.setFrameShape(QFrame.StyledPanel) self.limit_frame.setFrameShadow(QFrame.Raised) limit_frame_verticalLayout = QVBoxLayout(self.limit_frame) limit_frame_horizontalLayout = QHBoxLayout() # limit_spinBox self.limit_spinBox = QDoubleSpinBox(self.options_tab) self.limit_spinBox.setMinimum(1) self.limit_spinBox.setMaximum(1023) limit_frame_horizontalLayout.addWidget(self.limit_spinBox) # limit_comboBox self.limit_comboBox = QComboBox(self.options_tab) self.limit_comboBox.addItem("") self.limit_comboBox.addItem("") limit_frame_horizontalLayout.addWidget(self.limit_comboBox) # limit_pushButton self.limit_pushButton = QPushButton(self.options_tab) limit_frame_verticalLayout.addLayout(limit_frame_horizontalLayout) limit_frame_verticalLayout.addWidget(self.limit_pushButton) limit_verticalLayout.addWidget(self.limit_frame) limit_verticalLayout.setContentsMargins(11, 11, 11, 11) options_tab_horizontalLayout.addLayout(limit_verticalLayout) options_tab_verticalLayout.addLayout(options_tab_horizontalLayout) options_tab_verticalLayout.addStretch(1) # after_checkBox self.after_checkBox = QCheckBox(self.options_tab) after_verticalLayout = QVBoxLayout() after_verticalLayout.addWidget(self.after_checkBox) # after_frame self.after_frame = QFrame(self.options_tab) self.after_frame.setFrameShape(QFrame.StyledPanel) self.after_frame.setFrameShadow(QFrame.Raised) after_frame_verticalLayout = QVBoxLayout(self.after_frame) # after_comboBox self.after_comboBox = QComboBox(self.options_tab) self.after_comboBox.addItem("") after_frame_verticalLayout.addWidget(self.after_comboBox) # after_pushButton self.after_pushButton = QPushButton(self.options_tab) after_frame_verticalLayout.addWidget(self.after_pushButton) after_verticalLayout.addWidget(self.after_frame) after_verticalLayout.setContentsMargins(11, 11, 11, 11) options_tab_horizontalLayout.addLayout(after_verticalLayout) self.progress_tabWidget.addTab(self.options_tab, "") verticalLayout.addWidget(self.progress_tabWidget) # download_progressBar self.download_progressBar = QProgressBar(self) verticalLayout.addWidget(self.download_progressBar) self.download_progressBar.setTextVisible(False) # buttons button_horizontalLayout = QHBoxLayout() button_horizontalLayout.addStretch(1) # resume_pushButton self.resume_pushButton = QPushButton(self) self.resume_pushButton.setIcon(QIcon(icons + 'play')) button_horizontalLayout.addWidget(self.resume_pushButton) # pause_pushButton self.pause_pushButton = QPushButton(self) self.pause_pushButton.setIcon(QIcon(icons + 'pause')) button_horizontalLayout.addWidget(self.pause_pushButton) # stop_pushButton self.stop_pushButton = QPushButton(self) self.stop_pushButton.setIcon(QIcon(icons + 'stop')) button_horizontalLayout.addWidget(self.stop_pushButton) verticalLayout.addLayout(button_horizontalLayout) self.progress_tabWidget.setCurrentIndex(0) # labels self.link_label.setText( QCoreApplication.translate("progress_ui_tr", "Link: ")) self.status_label.setText( QCoreApplication.translate("progress_ui_tr", "Status: ")) self.downloaded_label.setText( QCoreApplication.translate("progress_ui_tr", "Downloaded:")) self.rate_label.setText( QCoreApplication.translate("progress_ui_tr", "Transfer rate: ")) self.time_label.setText( QCoreApplication.translate("progress_ui_tr", "Estimated time left:")) self.connections_label.setText( QCoreApplication.translate("progress_ui_tr", "Number of connections: ")) self.progress_tabWidget.setTabText( self.progress_tabWidget.indexOf(self.information_tab), QCoreApplication.translate("progress_ui_tr", "Download Information")) self.limit_checkBox.setText( QCoreApplication.translate("progress_ui_tr", "Limit speed")) self.after_checkBox.setText( QCoreApplication.translate("progress_ui_tr", "After download")) self.limit_comboBox.setItemText(0, "KiB/s") self.limit_comboBox.setItemText(1, "MiB/s") self.limit_pushButton.setText( QCoreApplication.translate("progress_ui_tr", "Apply")) self.after_comboBox.setItemText( 0, QCoreApplication.translate("progress_ui_tr", "Shut Down")) self.progress_tabWidget.setTabText( self.progress_tabWidget.indexOf(self.options_tab), QCoreApplication.translate("progress_ui_tr", "Download Options")) self.resume_pushButton.setText( QCoreApplication.translate("progress_ui_tr", "Resume")) self.pause_pushButton.setText( QCoreApplication.translate("progress_ui_tr", "Pause")) self.stop_pushButton.setText( QCoreApplication.translate("progress_ui_tr", "Stop")) self.after_pushButton.setText( QCoreApplication.translate("progress_ui_tr", "Apply"))