def __init__(self, targetImage=None, axeSize=500, layer=None, parent=None): super().__init__(layer=layer, targetImage=targetImage, parent=parent) # positioning window self.widgetImg = QLabel(parent=parent) # stay on top and center self.widgetImg.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.Dialog) # source pixmap self.sourcePixmap = None self.sourcePixmapThumb = None # flag indicating where source pixmap come from self.sourceFromFile = False # opencv flags cv2Flag_dict = { 'Normal Clone': cv2.NORMAL_CLONE, 'Mixed Clone': cv2.MIXED_CLONE, 'Monochrome Transfer': cv2.MONOCHROME_TRANSFER } cv2Flags = list(cv2Flag_dict.keys()) self.layer.cloningMethod = cv2Flag_dict['Normal Clone'] self.layer.maskIsEnabled = True self.layer.maskIsSelected = True # mask all pixels, use a semi transparent mask self.layer.resetMask(maskAll=True, alpha=128) self.layer.autoclone = True self.listWidget1 = optionsWidget(options=cv2Flags, exclusive=True, changed=self.dataChanged) # init flags for i in range(self.listWidget1.count()): item = self.listWidget1.item(i) item.setData(Qt.UserRole, cv2Flag_dict[item.text()]) self.options = self.listWidget1.options self.listWidget1.checkOption(self.listWidget1.intNames[0]) optionList2, optionListNames2 = ['opencv', 'blue' ], ['OpenCV Cloning', 'bLUe Cloning'] self.listWidget2 = optionsWidget(options=optionList2, optionNames=optionListNames2, exclusive=True, changed=self.dataChanged) self.listWidget2.checkOption(self.listWidget2.intNames[1]) self.options = UDict((self.options, self.listWidget2.options)) pushButton1 = QPushButton('Load Image From File') # Load Image button clicked slot def f(): from bLUeTop.QtGui1 import window lastDir = str(window.settings.value('paths/dlgdir', '.')) dlg = QFileDialog(window, "select", lastDir, " *".join(IMAGE_FILE_EXTENSIONS)) if dlg.exec_(): filenames = dlg.selectedFiles() newDir = dlg.directory().absolutePath() window.settings.setValue('paths/dlgdir', newDir) img = QImage(filenames[0]) # scale img while keeping its aspect ratio # into a QPixmap having the same size as self layer sourcePixmap = QPixmap.fromImage(img).scaled( self.layer.size(), Qt.KeepAspectRatio) self.sourcePixmap = QPixmap(self.layer.size()) self.sourcePixmap.fill(Qt.black) qp = QPainter(self.sourcePixmap) qp.drawPixmap( QRect(0, 0, sourcePixmap.width(), sourcePixmap.height()), sourcePixmap) qp.end() self.sourcePixmapThumb = self.sourcePixmap.scaled( self.pwSize, self.pwSize, aspectMode=Qt.KeepAspectRatio) self.widgetImg.setPixmap(self.sourcePixmapThumb) self.widgetImg.setFixedSize(self.sourcePixmapThumb.size()) self.sourceFromFile = True self.widgetImg.show() pushButton1.clicked.connect(f) pushButton2 = QPushButton('Reset') # reset button clicked slot def g(): layer = self.layer # mask all pixels layer.resetMask(maskAll=True, alpha=128) layer.setMaskEnabled(color=True) # reset clone layer layer.xAltOffset, layer.yAltOffset = 0.0, 0.0 layer.AltZoom_coeff = 1.0 layer.applyCloning(seamless=False, showTranslated=True) layer.parentImage.onImageChanged() pushButton2.clicked.connect(g) # layout layout = QVBoxLayout() layout.setContentsMargins(20, 0, 20, 25) # left, top, right, bottom self.setLayout(layout) layout.addWidget(self.listWidget2) layout.addWidget(self.listWidget1) hl = QHBoxLayout() hl.addWidget(pushButton1) hl.addWidget(pushButton2) layout.addLayout(hl) self.setDefaults() self.setWhatsThis(""" <b>Cloning</b> : Seamless replacement of a region of the image by another region from the same image or by another image (e.g. to erase an object):<br> 1) <b> make sure that the cloning layer is the topmost visible layer</b><br> 2) Select the Unmask/FG tool and paint the pixels to erase (use the Mask/BG tool to adjust the mask if needed); <br> 3) Select the drag tool and while pressing <b>Ctrl-Alt</b> use the mouse to drag or zoom the image shown in the painted region;<br> Eventually use <b>Mask Erode</b> from the layer context menu to smooth mask edges.<br> """) # end of setWhatsthis
def __init__(self): QWidget.__init__(self) """ PROCESSING ATTRIBUTES """ self.loop_simulation = False self.parameters_window = None self.term = Terminal() self.stl_model = None self.stl_model_pressure = None self.stl_model_display = None self.object_mass = DEFAULT_OBJECT_MASS self.dichotomy_precision = DEFAULT_DICHOTOMY_PRECISION self.fluid_density = DEFAULT_FLUID_DENSITY self.show_draught = DEFAULT_SHOW_DRAUGHT self.setWindowTitle("G5 SIMULATION OBJECT FLOTABILITY") self.setFixedSize(1280, 1024) self.main_layout = QVBoxLayout() self.main_layout.setMargin(0) self.main_layout.setSpacing(0) self.setLayout(self.main_layout) """ TOPBAR WIDGETS """ self.topbar_layout = QGridLayout() self.topbar_layout.setAlignment(Qt.AlignTop) self.topbar_layout.setSpacing(32) buttons_icons = [ 'stl_file', 'parameters', 'prepare_simulation', 'start_simulation', 'loop_simulation', 'stop_simulation', 'generate_animation_gif' ] group_buttons_labels = ['LOAD 3D MODEL', 'PARAMETERS', 'SIMULATION'] buttons_slots = [ self.loadSTLModel, self.displayParametersWindow, self.prepareSimulation, self.startSimulation, self.loopSimulation, self.stopSimulation, self.generateAnimationsGIF ] buttons_tooltips = [ 'Load 3d model', 'Set parameters', 'Prepare the simulation', 'Start the simulation', 'Loop the simulation', 'Stop the simulation', 'Generate animations GIF' ] self.buttons = [QPushButton() for i in range(7)] for i, button in enumerate(self.buttons): button.setIcon(QIcon(ICONS_FOLDER + buttons_icons[i] + '_icon.png')) button.setIconSize(QSize(50, 50)) button.setStyleSheet('border:none; margin-top : 24px;') button.clicked.connect(buttons_slots[i]) button.setToolTip(buttons_tooltips[i]) if i > 0: button.setDisabled(True) self.topbar_layout.addWidget(button, 0, i, 1, 1) for i, group_buttons_label in enumerate(group_buttons_labels): label = QLabel(group_buttons_label) label.setFixedHeight(32) label.setAlignment(Qt.AlignCenter) label.setStyleSheet( 'border-top : 2px solid #dfdfdf; font-family: Calibri; font-size : 10pt; color: #2C3E50;' ) self.topbar_layout.addWidget(label, 1, i, 1, 1 if i != 2 else 5) self.main_layout.addLayout(self.topbar_layout) """ BODY_WIDGETS """ self.body_layout = QGridLayout() self.body_layout.setSpacing(0) self.stl_model_graph = QLabel() self.stl_model_graph.setPixmap(QPixmap(DEFAULT_STL_MODEL_GRAPH_FOLDER)) self.stl_model_graph.setFixedSize(640, 480) self.draught_graph = QLabel() self.draught_graph.setPixmap(QPixmap(DEFAULT_DRAUGHT_GRAPH_FOLDER)) self.draught_graph.setFixedSize(640, 480) self.body_layout.addWidget(self.stl_model_graph, 0, 0, 1, 1) self.body_layout.addWidget(self.draught_graph, 0, 1, 1, 1) self.colored_parts_legend = QLabel() self.colored_parts_legend.setPixmap( QPixmap(LEGEND_FOLDER + 'colored_parts_legend.png')) self.colored_parts_legend.setStyleSheet( 'padding : 0 0 13px 24px; background : #fff') self.body_layout.addWidget(self.colored_parts_legend, 1, 0, 1, 2) self.draught_legend = QLabel() self.draught_legend.setPixmap( QPixmap(LEGEND_FOLDER + 'draught_legend.png')) self.draught_legend.setStyleSheet( 'padding : 0 0 13px 24px; background : #fff') self.draught_legend.hide() self.body_layout.addWidget(self.draught_legend, 2, 0, 1, 2) self.term.setFixedWidth(1280) self.main_layout.addLayout(self.body_layout) self.main_layout.addWidget(self.term) self.show()
def doLayout(self): self.update_total_value() self.intelBox = QGroupBox("Units :") self.intelLayout = QGridLayout() i = 0 for g in self.ground_object.groups: if not hasattr(g, "units_losts"): g.units_losts = [] for u in g.units: unit_display_name = u.type unit_type = vehicles.vehicle_map.get(u.type) if unit_type is not None: unit_display_name = db.unit_get_expanded_info( self.game.enemy_country, unit_type, 'name') self.intelLayout.addWidget( QLabel("<b>Unit #" + str(u.id) + " - " + str(unit_display_name) + "</b>"), i, 0) i = i + 1 for u in g.units_losts: utype = unit_type_of(u) if utype in PRICES: price = PRICES[utype] else: price = 6 self.intelLayout.addWidget( QLabel("<b>Unit #" + str(u.id) + " - " + str(u.type) + "</b> [DEAD]"), i, 0) if self.cp.captured: repair = QPushButton("Repair [" + str(price) + "M]") repair.setProperty("style", "btn-success") repair.clicked.connect( lambda u=u, g=g, p=price: self.repair_unit(g, u, p)) self.intelLayout.addWidget(repair, i, 1) i = i + 1 stretch = QVBoxLayout() stretch.addStretch() self.intelLayout.addLayout(stretch, i, 0) self.buildingBox = QGroupBox("Buildings :") self.buildingsLayout = QGridLayout() j = 0 total_income = 0 received_income = 0 for i, building in enumerate(self.buildings): if building.dcs_identifier not in FORTIFICATION_BUILDINGS: self.buildingsLayout.addWidget( QBuildingInfo(building, self.ground_object), j / 3, j % 3) j = j + 1 if building.category in REWARDS.keys(): total_income = total_income + REWARDS[building.category] if not building.is_dead: received_income = received_income + REWARDS[ building.category] else: logging.warning(building.category + " not in REWARDS") self.financesBox = QGroupBox("Finances: ") self.financesBoxLayout = QGridLayout() self.financesBoxLayout.addWidget( QLabel("Available: " + str(total_income) + "M"), 2, 1) self.financesBoxLayout.addWidget( QLabel("Receiving: " + str(received_income) + "M"), 2, 2) self.financesBox.setLayout(self.financesBoxLayout) self.buildingBox.setLayout(self.buildingsLayout) self.intelBox.setLayout(self.intelLayout)
def __init__(self, game_model: GameModel, sim_controller: SimController) -> None: super(QTopPanel, self).__init__() self.game_model = game_model self.sim_controller = sim_controller self.dialog: Optional[QDialog] = None self.setMaximumHeight(70) self.conditionsWidget = QConditionsWidget(sim_controller) self.budgetBox = QBudgetBox(self.game) pass_turn_text = "Pass Turn" if not self.game or self.game.turn == 0: pass_turn_text = "Begin Campaign" self.passTurnButton = QPushButton(pass_turn_text) self.passTurnButton.setIcon(CONST.ICONS["PassTurn"]) self.passTurnButton.setProperty("style", "btn-primary") self.passTurnButton.clicked.connect(self.passTurn) if not self.game: self.passTurnButton.setEnabled(False) self.proceedButton = QPushButton("Take off") self.proceedButton.setIcon(CONST.ICONS["Proceed"]) self.proceedButton.setProperty("style", "start-button") self.proceedButton.clicked.connect(self.launch_mission) if not self.game or self.game.turn == 0: self.proceedButton.setEnabled(False) self.factionsInfos = QFactionsInfos(self.game) self.air_wing = QPushButton("Air Wing") self.air_wing.setDisabled(True) self.air_wing.setProperty("style", "btn-primary") self.air_wing.clicked.connect(self.open_air_wing) self.transfers = QPushButton("Transfers") self.transfers.setDisabled(True) self.transfers.setProperty("style", "btn-primary") self.transfers.clicked.connect(self.open_transfers) self.intel_box = QIntelBox(self.game) self.buttonBox = QGroupBox("Misc") self.buttonBoxLayout = QHBoxLayout() self.buttonBoxLayout.addWidget(self.air_wing) self.buttonBoxLayout.addWidget(self.transfers) self.buttonBox.setLayout(self.buttonBoxLayout) self.proceedBox = QGroupBox("Proceed") self.proceedBoxLayout = QHBoxLayout() self.proceedBoxLayout.addLayout(SimSpeedControls(sim_controller)) self.proceedBoxLayout.addLayout( MaxPlayerCount(self.game_model.ato_model)) self.proceedBoxLayout.addWidget(self.passTurnButton) self.proceedBoxLayout.addWidget(self.proceedButton) self.proceedBox.setLayout(self.proceedBoxLayout) self.layout = QHBoxLayout() self.layout.addWidget(self.factionsInfos) self.layout.addWidget(self.conditionsWidget) self.layout.addWidget(self.budgetBox) self.layout.addWidget(self.intel_box) self.layout.addWidget(self.buttonBox) self.layout.addStretch(1) self.layout.addWidget(self.proceedBox) self.layout.setContentsMargins(0, 0, 0, 0) self.setLayout(self.layout) GameUpdateSignal.get_instance().gameupdated.connect(self.setGame) GameUpdateSignal.get_instance().budgetupdated.connect( self.budget_update)
def __init__(self): super().__init__() self.button = QPushButton("Push for Window") self.button.clicked.connect(self.show_new_window) self.setCentralWidget(self.button)
def create_filter_widget(self, name): button = QPushButton(name) menu = FilterMenu(button) menu.filterChanged.connect(self.change_filter) button.setMenu(menu) return button, menu
def account_dialog(self, new_account=False): self.account_dialog_window = QDialog(self) self.account_dialog_window.setMinimumSize(300, 125) if self.account_dialog_window.isVisible(): self.account_dialog_window.hide() # Main layout dialog_layout = QVBoxLayout() self.account_dialog_window.setLayout(dialog_layout) account_name_edit = QLineEdit() comment_edit = QLineEdit() comment_edit.setPlaceholderText(_("Comment")) steam_skin_select = QComboBox() steam_skin_select.addItems(self.switcher.steam_skins) if new_account: user = {} self.account_dialog_window.setWindowTitle(_("Add account")) self.submit_button = QPushButton(_("Add")) self.submit_button.setDisabled(True) else: login_name_selected = self.accounts_list.currentItem().data(5) user = self.switcher.settings["users"].get(login_name_selected, {}) self.account_dialog_window.setWindowTitle( _("Edit account {0}").format(login_name_selected)) self.submit_button = QPushButton(_("Edit")) account_name_edit.setText(login_name_selected) comment_edit.setText(user.get("comment")) steam_skin_select_index = steam_skin_select.findText( user.get("steam_skin", _("default"))) if steam_skin_select_index != -1: steam_skin_select.setCurrentIndex(steam_skin_select_index) else: steam_skin_select.setCurrentIndex(1) def submit_enabled(item): if 3 < len(item) < 32: self.submit_button.setEnabled(True) else: self.submit_button.setEnabled(False) account_name_edit.setPlaceholderText(_("Login name")) account_name_edit.textChanged.connect(submit_enabled) close_button = QPushButton(_("Close")) dialog_layout.addWidget(account_name_edit) dialog_layout.addWidget(comment_edit) dialog_layout.addWidget(steam_skin_select) def update_user(u: dict) -> dict: u["comment"] = comment_edit.text() u["steam_skin"] = steam_skin_select.currentText() return u self.submit_button.clicked.connect(lambda: self.save_account( account_name_edit.text(), update_user(user), login_name_selected if not new_account else None)) close_button.clicked.connect(self.account_dialog_window.close) buttons = QHBoxLayout() buttons.addWidget(self.submit_button) buttons.addWidget(close_button) dialog_layout.addLayout(buttons) self.account_dialog_window.show()
def __init__(self, *args, **kwargs): super(TestingWindow, self).__init__(*args, **kwargs) # Loading Fonts QFontDatabase.addApplicationFont("fonts/BebasNeue-Light.ttf") # Window Settings self.setFixedSize(1280, 720) self.setWindowTitle("TestingWindow") background = QPixmap("images/testing") palette = QPalette() palette.setBrush(QPalette.Background, background) self.setAttribute(Qt.WA_StyledBackground, True) self.setPalette(palette) self.setAutoFillBackground(True) # Stylesheet Settings styleFile = QFile("stylesheets/testing.qss") styleFile.open(QFile.ReadOnly) style = str(styleFile.readAll()) self.setStyleSheet(style) # Title Settings self.__title = QLabel("Testing", self) self.__title.setFont(QFont("BebasNeue", 45, QFont.Bold)) self.__title.setAlignment(Qt.AlignCenter) self.__title.setGeometry(0, 30, 1280, 100) # Button Settings self.buttons = [] for x in range(4): self.buttons.append(x) self.buttons[x] = QPushButton(self) self.buttons[x].setCursor(Qt.PointingHandCursor) self.buttons[x].setObjectName("select") self.buttons[x].setFont(QFont("BebasNeue", 10, QFont.Bold)) self.buttons[x].setGeometry(80, 100 + x * 120, 80, 80) # Connecting buttons self.buttons[0].clicked.connect(self.loadNetwork) self.buttons[1].clicked.connect(self.loadTestFile) self.buttons[2].clicked.connect(self.startTest) # Buttons Icons self.buttons[0].setIcon(QIcon("images/brain_icon")) self.buttons[0].setIconSize(QSize(35, 35)) self.buttons[1].setIcon(QIcon("images/upload_icon")) self.buttons[1].setIconSize(QSize(35, 35)) self.buttons[2].setIcon(QIcon("images/test_icon")) self.buttons[2].setIconSize(QSize(35, 35)) self.buttons[3].setIcon(QIcon("images/goback_icon")) self.buttons[3].setIconSize(QSize(35, 35)) # Return Button self.buttons[3].setText("Back") self.buttons[3].setObjectName("retour") self.buttons[3].setGeometry(1100, 620, 120, 120) self.buttons[3].setIcon(QIcon("images/goback_icon")) self.buttons[3].setIconSize(QSize(35, 35)) # Labels Settings self.__labels = [] for x in range(3): self.__labels.append(x) self.__labels[x] = QLabel(self) self.__labels[x].setGeometry(200, 110 + x * 120, 300, 80) self.__labels[x].setFont(QFont("BebasNeue", 20, QFont.Bold)) self.__labels[0].setText("Load a neural network") self.__labels[1].setText("Load the test file") self.__labels[2].setText("Start the test") # Main #app = QApplication(sys.argv) #window = TestingWindow() #window.show() #app.exec_()
import sys from PySide2.QtWidgets import QApplication, QWidget, QPushButton from PySide2.QtCore import Slot #@slot()是一个装饰器,标志这这个函数是一个slot(槽) @Slot() def output(): print("Button clicked!") app = QApplication(sys.argv) button = QPushButton("clicked me") #将信号与槽进行绑定 button.clicked.connect(output) button.show() app.exec_()
def add_surface(self): """Validate the selection and create a surface object Parameters ---------- self : DXF_Hole a DXF_Hole object """ # Get all the selected lines line_list = list() for ii, line in enumerate(self.line_list): if self.selected_list[ii]: line_list.append(line.copy()) # Sort the lines (begin = end) curve_list = list() curve_list.append(line_list.pop()) while len(line_list) > 0: end = curve_list[-1].get_end() for ii in range(len(line_list)): if abs(line_list[ii].get_begin() - end) < 1e-9: break if abs(line_list[ii].get_end() - end) < 1e-9: line_list[ii].reverse() break curve_list.append(line_list.pop(ii)) # Create the Surface object self.surf_list.append(SurfLine(line_list=curve_list)) self.surf_list[-1].comp_point_ref(is_set=True) # Update the GUI nrows = self.w_surface_list.rowCount() # Adding Surface Type combobox self.w_surface_list.setRowCount(nrows + 1) combobox = QComboBox() combobox.addItems(["Hole", "Magnet"]) self.w_surface_list.setCellWidget( nrows, TYPE_COL, combobox, ) # Adding Delete button del_button = QPushButton("Delete") del_button.setIcon(QIcon(self.delete_icon)) del_button.pressed.connect(self.delete_surface) self.w_surface_list.setCellWidget( nrows, DEL_COL, del_button, ) # Adding Highlight button HL_button = QPushButton("Highlight") HL_button.setIcon(QIcon(self.highlight_icon)) HL_button.pressed.connect(self.highlight_surface) self.w_surface_list.setCellWidget( nrows, HL_COL, HL_button, ) # Remove selection self.selected_list = [False for line in self.line_list] self.update_graph()
from PySide2.QtWidgets import QLabel, QWidget, QPushButton, QApplication, QVBoxLayout app = QApplication([]) mainWidget = QWidget() layout = QVBoxLayout() label = QLabel("Ceci est un QLabel") button = QPushButton("Ceci est un QPushButton") layout.addWidget(label) layout.addWidget(button) mainWidget.setLayout(layout) mainWidget.show() app.exec_()
def Layout(self): #LAYOUT self.select_video = QLabel(self) self.select_video.setText("Folder Selected:") self.select_video.setVisible(False) self.browse_btn = QPushButton("Browse", self) self.browse_btn.setStatusTip(" Browse Folder") # self.browse_btn.setStyleSheet("background-color: rgb(186, 186, 186); border-radius: 15px;border-style: solid;border-width: 2px;border-color: black;"); self.browse_btn.clicked.connect(self.browse) self.VideoName = QLabel(self) self.todo = QLabel(self) self.todo.setText("What do you want to do?") self.todo.setVisible(False) ## Various checkboxes for activities to perform within MARS. self.doPose = False self.pose_chbox = QCheckBox('[Pose]', self) self.pose_chbox.stateChanged.connect(self.checkDoPose) self.pose_chbox.setVisible(False) self.doFeats = False self.feat_chbox = QCheckBox('[Features]', self) self.feat_chbox.stateChanged.connect(self.checkDoFeat) self.feat_chbox.setVisible(False) self.doActions = False self.actions_chbox = QCheckBox('[Classify Actions]', self) self.actions_chbox.stateChanged.connect(self.checkDoActions) self.actions_chbox.setVisible(False) # self.ddlist_label = QLabel(self) # self.ddlist_label.setText("Classifier:") # self.ddlist_label.move(200, 150) # self.ddlist_label.resize(150, 30) # self.ddlist_label.setVisible(False) # # self.ddlist = QComboBox(self) # self.ddlist.setVisible(False) # self.ddlist.setStatusTip('Choose the classifier you\'d like to use.') # self.ddlist.move(220, 120) # self.ddlist.resize(150, 50) # self.ddlist.setSizeAdjustPolicy(QComboBox.AdjustToContents) self.doVideo = False self.video_chbox = QCheckBox('[Produce Video]', self) self.video_chbox.stateChanged.connect(self.checkDoVideo) self.video_chbox.setVisible(False) self.doOverwrite = False self.overwrite_chbox = QCheckBox('[Overwrite]', self) self.overwrite_chbox.setStyleSheet("background-color: #ff7a7a") self.overwrite_chbox.stateChanged.connect(self.checkDoOverwrite) self.overwrite_chbox.setVisible(False) ## Checkboxes that pick which view(s) to use, as well as the internal values they represent. self.doTop = False self.top_chbox = QCheckBox('[Top]', self) self.top_chbox.stateChanged.connect(self.checkDoTop) self.top_chbox.setVisible(False) self.doToppcf = False # self.toppcf_chbox = QCheckBox('[Top (w/ Front pixel features)]', self) # self.toppcf_chbox.stateChanged.connect(self.checkDoToppcf) # self.toppcf_chbox.setVisible(False) self.doFront = False self.front_chbox = QCheckBox('[Front]', self) self.front_chbox.stateChanged.connect(self.checkDoFront) self.front_chbox.setVisible(False) # Button to run MARS. self.run_mars = QPushButton("[Run MARS]", self) self.run_mars.setVisible(False) self.run_mars.setStatusTip('Run detection and actions classification') self.run_mars.setStyleSheet( "background-color: rgb(142, 229, 171); border-radius: 15px;") self.run_mars.clicked.connect(self.run_event) # Button to reset the form for MARS. self.reset_btn = QPushButton("[Reset]", self) self.reset_btn.setVisible(False) self.reset_btn.setStatusTip('Reset buttons') self.reset_btn.setStyleSheet( "background-color: rgb(229, 200, 142);border-radius: 15px") self.reset_btn.clicked.connect(self.reset) # Button for adding things to queue. self.add2queue_btn = QPushButton("[Enqueue]", self) self.add2queue_btn.setVisible(False) self.add2queue_btn.setStyleSheet( "background-color: rgb(216,191,216);border-radius: 50px") self.add2queue_btn.clicked.connect(self.addToQueue) self.progress = QLabel(self) self.progress.setVisible(True) # Progress bar above the global progress, shows the progress on the current task. self.progbar = QProgressBar(self) self.progbar.setStyleSheet( "background-color: #FFA07A; border: 3px solid #000000;") self.progbar.setVisible(True) self.progbar.setAlignment(QtCore.Qt.AlignCenter) # Label for progress bar. self.progbar_label = QLabel(self) self.progbar_label.setText("Current Task Progress:") # Big progress bar at the bottom. Global progress. self.big_progbar = QProgressBar(self) self.big_progbar.setVisible(True) self.big_progbar.setStyleSheet( "background-color: #add8e6; border: 3px solid #FFFFFF;") self.big_progbar.setAlignment(QtCore.Qt.AlignCenter) # Label for big progress bar. self.big_progbar_label = QLabel(self) self.big_progbar_label.setText("Global Video Progress:") # Layout for the browsing span. self.button_layout = QHBoxLayout() self.button_layout.addWidget(self.browse_btn) self.button_layout.addWidget(self.select_video) self.button_layout.addWidget(self.VideoName) self.button_layout.addWidget(self.add2queue_btn) self.button_layout.addStretch(0.5) # Layout for the menu at the top. self.menu_layout = QHBoxLayout() self.menu_layout.addWidget(self.toolbar) self.menu_layout.addStretch() self.menu_layout.addWidget(self.toolbar2) # Layout for the view selection (Top, Toppcf, Front) self.view_layout = QHBoxLayout() self.view_layout.addWidget(self.top_chbox) # self.view_layout.addWidget(self.toppcf_chbox) self.view_layout.addWidget(self.front_chbox) self.view_layout.addStretch() # Layout for the checkboxes. self.chbox_layout = QHBoxLayout() self.chbox_layout.setSpacing(10) self.chbox_layout.addWidget(self.pose_chbox) self.chbox_layout.addWidget(self.feat_chbox) self.chbox_layout.addWidget(self.actions_chbox) self.chbox_layout.addWidget(self.video_chbox) self.chbox_layout.addWidget(self.overwrite_chbox) self.chbox_layout.addStretch(1) # Layout for the activity buttons, RUN and RESET. self.active_layout = QHBoxLayout() self.active_layout.addWidget(self.run_mars, stretch=2) self.active_layout.addWidget(self.reset_btn, stretch=1) # # Layout for the task progress bar. # self.task_progbar_layout = QtGui.QHBoxLayout() # self.task_progbar_layout.addWidget(self.progbar_label) # self.task_progbar_layout.addWidget(self.progbar, stretch=1) # # # Layout for the global progress bar. # self.global_progbar_layout = QtGui.QHBoxLayout() # self.global_progbar_layout.addWidget(self.big_progbar_label) # self.global_progbar_layout.addWidget(self.big_progbar) # Layout for the labels, to get ther vertically-aligned. self.progbar_label_layout = QVBoxLayout() self.progbar_label_layout.addWidget(self.progbar_label) self.progbar_label_layout.addWidget(self.big_progbar_label) # Layout for the progress bars themselves, to get them vertically-aligned. self.progbar_bar_layout = QVBoxLayout() self.progbar_bar_layout.addWidget(self.progbar) self.progbar_bar_layout.addWidget(self.big_progbar) # Layout for the combined progress bars and labels. self.progbar_layout = QHBoxLayout() self.progbar_layout.addLayout(self.progbar_label_layout) self.progbar_layout.addLayout(self.progbar_bar_layout, stretch=1) # This layout puts everything on the screen. self.main_layout = QVBoxLayout() self.main_layout.addLayout(self.menu_layout) self.main_layout.addWidget(self.toto) self.main_layout.addLayout(self.button_layout) self.main_layout.addWidget(self.todo) self.main_layout.addLayout(self.view_layout) self.main_layout.addLayout(self.chbox_layout) self.main_layout.addLayout(self.active_layout) self.main_layout.addWidget(self.progress) self.main_layout.addStretch() self.main_layout.addLayout(self.progbar_layout)
def __init__(self, crossword_index, grid_data, grid_cell_length, clue_across_data, clue_down_data): QWidget.__init__(self) self.grid_model = CrosswordGridModel(crossword_index, grid_data) self.grid_table_view = QTableView(self) self.grid_table_view.setModel(self.grid_model) self.grid_horizontal_header = self.grid_table_view.horizontalHeader() self.grid_horizontal_header.setSectionResizeMode(QHeaderView.Fixed) self.grid_horizontal_header.setDefaultSectionSize(grid_cell_length) self.grid_horizontal_header.hide() self.grid_vertical_header = self.grid_table_view.verticalHeader() self.grid_vertical_header.setSectionResizeMode(QHeaderView.Fixed) self.grid_vertical_header.setDefaultSectionSize(grid_cell_length * 1.3) self.grid_vertical_header.hide() self.clue_across_model = CrosswordClueModel(clue_across_data, 'পাশাপাশি') self.clue_across_table_view = QTableView(self) self.clue_across_table_view.setModel(self.clue_across_model) self.clue_across_horizontal_header = self.clue_across_table_view.horizontalHeader( ) self.clue_across_horizontal_header.setSectionResizeMode( QHeaderView.ResizeToContents) self.clue_across_vertical_header = self.clue_across_table_view.verticalHeader( ) self.clue_across_vertical_header.setSectionResizeMode( QHeaderView.Fixed) self.clue_across_vertical_header.setDefaultSectionSize( grid_cell_length) self.clue_down_model = CrosswordClueModel(clue_down_data, 'উপর নীচে') self.clue_down_table_view = QTableView(self) self.clue_down_table_view.setModel(self.clue_down_model) self.clue_down_horizontal_header = self.clue_down_table_view.horizontalHeader( ) self.clue_down_horizontal_header.setSectionResizeMode( QHeaderView.ResizeToContents) self.clue_down_vertical_header = self.clue_down_table_view.verticalHeader( ) self.clue_down_vertical_header.setSectionResizeMode(QHeaderView.Fixed) self.clue_down_vertical_header.setDefaultSectionSize(grid_cell_length) self.clue_layout = QHBoxLayout(self) self.clue_layout.addWidget(self.clue_across_table_view) self.clue_layout.addWidget(self.clue_down_table_view) self.clue_widget = QWidget(self) self.clue_widget.setLayout(self.clue_layout) self.buttons_layout = QHBoxLayout(self) self.save_button = QPushButton("Save") self.load_button = QPushButton("Load") self.clear_button = QPushButton("Clear") self.save_button.clicked.connect(self.save_solution) self.load_button.clicked.connect(self.grid_model.load_solution) self.clear_button.clicked.connect(self.grid_model.clear_solution) self.buttons_layout.addWidget(self.save_button) self.buttons_layout.addWidget(self.load_button) self.buttons_layout.addWidget(self.clear_button) self.buttons_widget = QWidget(self) self.buttons_widget.setLayout(self.buttons_layout) self.grid_layout = QVBoxLayout(self) self.grid_layout.addWidget(self.grid_table_view) self.grid_layout.addWidget(self.buttons_widget) self.grid_widget = QWidget(self) self.grid_widget.setLayout(self.grid_layout) self.main_layout = QHBoxLayout(self) self.main_layout.addWidget(self.grid_widget) self.main_layout.addWidget(self.clue_widget) self.setLayout(self.main_layout)
def createWidgets(self): self._tm = TableModel(self) self._tm.inputsToSkip = self.inputsToSkip self._tm.data_types_to_skip = self.data_types_to_skip self._tv = TableView(self) # selectionModel = QItemSelectionModel(self._tm) # self._tv.setSelectionMode(QAbstractItemView.ExtendedSelection) # self._tv.setSelectionBehavior(QAbstractItemView.MultiSelection) self.alwaysOnTop = QCheckBox("Always on top") self.alwaysOnTop.setChecked(True) self.drawInputInfoColors = QToolButton() self.drawInputInfoColors.setCheckable(True) self.drawInputInfoColors.setChecked(True) self.drawInputInfoColors.setText("Draw Color Info") # self.drawInputInfoColors.setFixedSize(QSize(20,20)) self.pushButton = QPushButton() self.pushButton.setText("Refresh") self.pushButton.setFixedSize(QSize(128, 20)) self.lineEdit = QLineEdit(self) # self.lineEdit.setFixedSize(QSize(256, 20)) self.lineEdit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) self.statusBar().showMessage("System Status | Normal") self.cacheButton = QToolButton() self.cacheButton.setCheckable(True) self.cacheButton.setChecked(False) self.cacheButton.setText("use cache") v_box = QVBoxLayout() h_box = QHBoxLayout() h_box.setAlignment(Qt.AlignRight) h_box.addWidget(self.alwaysOnTop) h_box.addWidget(self.lineEdit) h_box.addWidget(self.pushButton) h_box.addWidget(self.drawInputInfoColors) h_box.addWidget(self.cacheButton) h_box.setContentsMargins(0, 0, 0, 0) v_box.addLayout(h_box) v_box.addWidget(self._tv) sizeGrip = QSizeGrip(self) # sizeGrip.setParent(self) # v_box.addWidget(sizeGrip) # v_box.setAlignment(sizeGrip, Qt.AlignBottom | Qt.AlignRight) v_box.setContentsMargins(2, 2, 2, 2) # v_box.setSpacing(0) sizeGrip.setWindowFlags(Qt.WindowStaysOnTopHint) sizeGrip.move(0, 200) central_widget = QWidget() central_widget.setLayout(v_box) self.setCentralWidget(central_widget) self.statusBar() self.proxyModel = TableSortFilterProxyModel() self.proxyModel.setFilterCaseSensitivity(Qt.CaseInsensitive) self.proxyModel.setSortCaseSensitivity(Qt.CaseInsensitive) self.proxyModel.setDynamicSortFilter(True) self.drawInputInfoColors.setChecked(True) # self.lineEdit.textChanged.connect(self._tv.updateColumns) # self.proxyModel.setSourceModel(self._tm) # self.proxyModel.filteredKeys = self._tm.attributeNameKeys self._tv.setModel(self.proxyModel) self.progressBar = QProgressBar() self.statusBar().addPermanentWidget(self.progressBar) # This is simply to show the bar # self.progressBar.setGeometry(30, 40, 200, 25) self.progressBar.setValue(0) # Connections self.alwaysOnTop.stateChanged.connect(self.changeAlwaysOnTop) self.lineEdit.textChanged.connect(self.filterRegExpChanged) self.drawInputInfoColors.clicked.connect( self.changeTableModelBackgroundRoleMethod) self.cacheButton.clicked.connect(self.changeCacheMode) self.pushButton.pressed.connect(self.reloadFusionData) self._tm.communicate.broadcast.connect(self.communication)
def add_purchase_row( self, unit_type: Type[UnitType], layout: QLayout, row: int, disabled: bool = False, ) -> int: exist = QGroupBox() exist.setProperty("style", "buy-box") exist.setMaximumHeight(36) exist.setMinimumHeight(36) existLayout = QHBoxLayout() exist.setLayout(existLayout) existing_units = self.cp.base.total_units_of_type(unit_type) scheduled_units = self.pending_deliveries.units.get(unit_type, 0) unitName = QLabel("<b>" + db.unit_get_expanded_info( self.game_model.game.player_country, unit_type, "name") + "</b>") unitName.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) existing_units = QLabel(str(existing_units)) existing_units.setSizePolicy( QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) amount_bought = QLabel("<b>{}</b>".format(str(scheduled_units))) amount_bought.setSizePolicy( QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) self.existing_units_labels[unit_type] = existing_units self.bought_amount_labels[unit_type] = amount_bought price = QLabel("<b>$ {:02d}</b> m".format(db.PRICES[unit_type])) price.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) buysell = QGroupBox() buysell.setProperty("style", "buy-box") buysell.setMaximumHeight(36) buysell.setMinimumHeight(36) buysellayout = QHBoxLayout() buysell.setLayout(buysellayout) buy = QPushButton("+") buy.setProperty("style", "btn-buy") buy.setDisabled(disabled) buy.setMinimumSize(16, 16) buy.setMaximumSize(16, 16) buy.clicked.connect(lambda: self.buy(unit_type)) buy.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) sell = QPushButton("-") sell.setProperty("style", "btn-sell") sell.setDisabled(disabled) sell.setMinimumSize(16, 16) sell.setMaximumSize(16, 16) sell.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) sell.clicked.connect(lambda: self.sell(unit_type)) info = QGroupBox() info.setProperty("style", "buy-box") info.setMaximumHeight(36) info.setMinimumHeight(36) infolayout = QHBoxLayout() info.setLayout(infolayout) unitInfo = QPushButton("i") unitInfo.setProperty("style", "btn-info") unitInfo.setDisabled(disabled) unitInfo.setMinimumSize(16, 16) unitInfo.setMaximumSize(16, 16) unitInfo.clicked.connect(lambda: self.info(unit_type)) unitInfo.setSizePolicy( QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) existLayout.addWidget(unitName) existLayout.addItem( QSpacerItem(20, 0, QSizePolicy.Minimum, QSizePolicy.Minimum)) existLayout.addWidget(existing_units) existLayout.addItem( QSpacerItem(20, 0, QSizePolicy.Minimum, QSizePolicy.Minimum)) existLayout.addWidget(price) buysellayout.addWidget(sell) buysellayout.addWidget(amount_bought) buysellayout.addWidget(buy) infolayout.addWidget(unitInfo) layout.addWidget(exist, row, 1) layout.addWidget(buysell, row, 2) layout.addWidget(info, row, 3) return row + 1
#!/usr/bin/env python import sys from PySide2.QtWidgets import QApplication, QPushButton from PySide2.QtCore import Slot @Slot() def toggle(): print('Toggling play') app = QApplication(sys.argv) button = QPushButton("Toggle play") button.clicked.connect(toggle) button.show() app.exec_()
def initUI(self): self.layout = QVBoxLayout() # Result if self.gameEvent.is_successfull(self.debriefing): title = QLabel("<b>Operation Succesfull !</b>") title.setProperty("style", "title-success") else: title = QLabel("<b>Operation failed !</b>") title.setProperty("style", "title-danger") self.layout.addWidget(title) # Player lost units lostUnits = QGroupBox(self.game.player_country + "'s lost units :") lostUnitsLayout = QGridLayout() lostUnits.setLayout(lostUnitsLayout) row = 0 for unit_type, count in self.debriefing.player_dead_aircraft_dict.items( ): try: lostUnitsLayout.addWidget(QLabel(db.unit_type_name(unit_type)), row, 0) lostUnitsLayout.addWidget(QLabel("{}".format(count)), row, 1) row += 1 except: print("Issue adding " + str(unit_type) + " to debriefing information") for unit_type, count in self.debriefing.player_dead_units_dict.items(): try: lostUnitsLayout.addWidget(QLabel(db.unit_type_name(unit_type)), row, 0) lostUnitsLayout.addWidget(QLabel("{}".format(count)), row, 1) row += 1 except: print("Issue adding " + str(unit_type) + " to debriefing information") for building, count in self.debriefing.player_dead_buildings_dict.items( ): try: lostUnitsLayout.addWidget(QLabel(building, row, 0)) lostUnitsLayout.addWidget(QLabel("{}".format(count)), row, 1) row += 1 except: print("Issue adding " + str(building) + " to debriefing information") self.layout.addWidget(lostUnits) # Enemy lost units enemylostUnits = QGroupBox(self.game.enemy_country + "'s lost units :") enemylostUnitsLayout = QGridLayout() enemylostUnits.setLayout(enemylostUnitsLayout) #row = 0 #if self.debriefing.destroyed_objects: # enemylostUnitsLayout.addWidget(QLabel("Ground assets"), row, 0) # enemylostUnitsLayout.addWidget(QLabel("{}".format(len(self.debriefing.destroyed_objects))), row, 1) # row += 1 for unit_type, count in self.debriefing.enemy_dead_aircraft_dict.items( ): if count == 0: continue try: enemylostUnitsLayout.addWidget( QLabel(db.unit_type_name(unit_type)), row, 0) enemylostUnitsLayout.addWidget(QLabel("{}".format(count)), row, 1) row += 1 except: print("Issue adding " + str(unit_type) + " to debriefing information") for unit_type, count in self.debriefing.enemy_dead_units_dict.items(): if count == 0: continue enemylostUnitsLayout.addWidget( QLabel(db.unit_type_name(unit_type)), row, 0) enemylostUnitsLayout.addWidget(QLabel("{}".format(count)), row, 1) row += 1 for building, count in self.debriefing.enemy_dead_buildings_dict.items( ): try: enemylostUnitsLayout.addWidget(QLabel(building), row, 0) enemylostUnitsLayout.addWidget(QLabel("{}".format(count)), row, 1) row += 1 except: print("Issue adding " + str(building) + " to debriefing information") self.layout.addWidget(enemylostUnits) # confirm button okay = QPushButton("Okay") okay.clicked.connect(self.close) self.layout.addWidget(okay) self.setLayout(self.layout)
def testButtonClick(self): """Multiple connections to QPushButton.clicked()""" sender = QPushButton('button') receivers = [BasicPySlotCase() for x in range(30)] self.run_many(sender, 'clicked()', sender.click, receivers)
def __init__(self, m1m3): super().__init__() self.m1m3 = m1m3 self._hpData = None self._imsData = None self.layout = QVBoxLayout() dataLayout = QGridLayout() self.layout.addLayout(dataLayout) self.setLayout(self.layout) directions = ["X", "Y", "Z", "Rotation X", "Rotation Y", "Rotation Z"] row = 0 for d in range(6): dataLayout.addWidget(QLabel(f"<b>{directions[d]}</b>"), row, d + 1) def createXYZR(): return { "xPosition": Mm(), "yPosition": Mm(), "zPosition": Mm(), "xRotation": Arcsec(), "yRotation": Arcsec(), "zRotation": Arcsec(), } def createXYZRWarning(): return { "xPosition": MmWarning(), "yPosition": MmWarning(), "zPosition": MmWarning(), "xRotation": ArcsecWarning(), "yRotation": ArcsecWarning(), "zRotation": ArcsecWarning(), } self.hpVariables = createXYZR() self.imsVariables = createXYZR() self.diffs = createXYZRWarning() def addDataRow(variables, row, col=1): for k, v in variables.items(): dataLayout.addWidget(v, row, col) col += 1 row += 1 dataLayout.addWidget(QLabel("<b>HP</b>"), row, 0) addDataRow(self.hpVariables, row) row += 1 dataLayout.addWidget(QLabel("<b>IMS</b>"), row, 0) addDataRow(self.imsVariables, row) row += 1 dataLayout.addWidget(QLabel("<b>Diff</b>"), row, 0) addDataRow(self.diffs, row) row += 1 dataLayout.addWidget(QLabel("<b>Target</b>"), row, 0) col = 1 for p in self.POSITIONS: sb = QDoubleSpinBox() if p[1:] == "Position": sb.setRange(-10, 10) sb.setDecimals(3) sb.setSingleStep(0.001) else: sb.setRange(-300, 300) sb.setDecimals(2) sb.setSingleStep(0.01) dataLayout.addWidget(sb, row, col) setattr(self, "target_" + p, sb) col += 1 row += 1 self.moveMirrorButton = QPushButton("Move Mirror") self.moveMirrorButton.setEnabled(False) self.moveMirrorButton.clicked.connect(self._moveMirror) self.moveMirrorButton.setDefault(True) dataLayout.addWidget(self.moveMirrorButton, row, 1, 1, 3) self.copyCurrentButton = QPushButton("Copy Current") self.copyCurrentButton.setEnabled(False) self.copyCurrentButton.clicked.connect(self._copyCurrent) dataLayout.addWidget(self.copyCurrentButton, row, 4, 1, 3) row += 1 self.dirPad = DirectionPadWidget() self.dirPad.setEnabled(False) self.dirPad.positionChanged.connect(self._positionChanged) dataLayout.addWidget(self.dirPad, row, 1, 3, 6) def createForces(): return { "fx": Force(), "fy": Force(), "fz": Force(), "mx": Moment(), "my": Moment(), "mz": Moment(), } self.preclipped = createForces() self.applied = createForces() self.measured = createForces() row += 3 dataLayout.addWidget(QLabel("<b>Preclipped</b>"), row, 0) addDataRow(self.preclipped, row) row += 1 dataLayout.addWidget(QLabel("<b>Applied</b>"), row, 0) addDataRow(self.applied, row) row += 1 dataLayout.addWidget(QLabel("<b>Measured</b>"), row, 0) addDataRow(self.measured, row) row += 1 dataLayout.addWidget(QLabel("<b>Offset</b>"), row, 0) col = 1 for p in self.FORCES: sb = QDoubleSpinBox() sb.setRange(-10000, 10000) sb.setDecimals(1) sb.setSingleStep(1) dataLayout.addWidget(sb, row, col) setattr(self, "forceOffsets_" + p, sb) col += 1 row += 1 self.offsetForces = QPushButton("Apply offset forces") self.offsetForces.setEnabled(False) self.offsetForces.clicked.connect(self._applyOffsetForces) dataLayout.addWidget(self.offsetForces, row, 1, 1, 3) self.clearOffsetForcesButton = QPushButton("Reset forces") self.clearOffsetForcesButton.setEnabled(False) self.clearOffsetForcesButton.clicked.connect(self._clearOffsetForces) dataLayout.addWidget(self.clearOffsetForcesButton, row, 4, 1, 3) self.layout.addStretch() self.m1m3.hardpointActuatorData.connect( self._hardpointActuatorDataCallback) self.m1m3.imsData.connect(self._imsDataCallback) self.m1m3.preclippedOffsetForces.connect(self._preclippedOffsetForces) self.m1m3.appliedOffsetForces.connect(self._appliedOffsetForces) self.m1m3.forceActuatorData.connect(self._forceActuatorCallback) self.m1m3.detailedState.connect(self._detailedStateCallback)
def __init__(self, parent=None): super(VideoWindow, self).__init__(parent) self.setWindowTitle( "PyQt Video Player Widget Example - pythonprogramminglanguage.com") self.mediaPlayer = QMediaPlayer(None, QMediaPlayer.VideoSurface) videoWidget = QVideoWidget() self.playButton = QPushButton() self.playButton.setEnabled(False) self.playButton.setIcon(self.style().standardIcon(QStyle.SP_MediaPlay)) self.playButton.clicked.connect(self.play) self.positionSlider = QSlider(Qt.Horizontal) self.positionSlider.setRange(0, 0) self.positionSlider.sliderMoved.connect(self.setPosition) self.errorLabel = QLabel() self.errorLabel.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum) # Create new action openAction = QAction(QIcon('open.png'), '&Open', self) openAction.setShortcut('Ctrl+O') openAction.setStatusTip('Open movie') openAction.triggered.connect(self.openFile) # Create exit action exitAction = QAction(QIcon('exit.png'), '&Exit', self) exitAction.setShortcut('Ctrl+Q') exitAction.setStatusTip('Exit application') exitAction.triggered.connect(self.exitCall) # Create menu bar and add action menuBar = self.menuBar() fileMenu = menuBar.addMenu('&File') #fileMenu.addAction(newAction) fileMenu.addAction(openAction) fileMenu.addAction(exitAction) # Create a widget for window contents wid = QWidget(self) self.setCentralWidget(wid) # Create layouts to place inside widget controlLayout = QHBoxLayout() controlLayout.setContentsMargins(0, 0, 0, 0) controlLayout.addWidget(self.playButton) controlLayout.addWidget(self.positionSlider) layout = QVBoxLayout() layout.addWidget(videoWidget) layout.addLayout(controlLayout) layout.addWidget(self.errorLabel) # Set widget to contain window contents wid.setLayout(layout) self.mediaPlayer.setVideoOutput(videoWidget) self.mediaPlayer.stateChanged.connect(self.mediaStateChanged) self.mediaPlayer.positionChanged.connect(self.positionChanged) self.mediaPlayer.durationChanged.connect(self.durationChanged) self.mediaPlayer.error.connect(self.handleError)
def init_ui(self): self.setWindowTitle('Trace Event Window') self.setGeometry(100, 100, 800, 600) bar = self.menuBar() file_ = bar.addMenu('File') export_log = QAction('Save to File', self, triggered=lambda: self.save_log()) options = bar.addMenu('Options') auto_refresh = QAction( 'Auto Refresh', self, checkable=True, triggered=lambda: self.timer.start(100) if auto_refresh.isChecked() else self.timer.stop()) auto_refresh.setChecked(True) options.addAction(auto_refresh) file_.addAction(export_log) vgrid = QVBoxLayout() grid = QHBoxLayout() self.tree = QTreeWidget() self.tree.setHeaderLabels(['Name']) self.top = [] self.lst = [] for n, event in enumerate(self.trace_events): word = event.split('_')[0] if word not in self.top: self.top.append(word) item = QTreeWidgetItem(self.tree) self.lst.append(item) item.setText(0, word) subitem = QTreeWidgetItem(item) subitem.setText(0, ' ' + event.split(' : ')[0]) # subitem.setCheckState(0, Qt.Unchecked) cbox = QCheckBox() cbox.stateChanged.connect(lambda state, text=subitem.text(0): self. handle_checked(state, text)) self.tree.setItemWidget(subitem, 0, cbox) # self.tree.setColumnWidth(0, 25) self.tracelist = QLabel() self.disp_output() self.traceview = QScrollArea() self.traceview.setWidget(self.tracelist) self.traceview.setWidgetResizable(True) search = QHBoxLayout() self.search_bar = QLineEdit(self) self.completer = QCompleter(self.top, self) self.completer.setCaseSensitivity(Qt.CaseInsensitive) self.search_bar.setCompleter(self.completer) search_button = QPushButton('Search') search_button.clicked.connect(lambda: self.tree.setCurrentItem( self.lst[self.top.index(self.search_bar.text())])) expand = QPushButton('▼') expand.setFixedSize(QSize(25, 25)) expand.clicked.connect(lambda: self.tree.expandAll()) collapse = QPushButton('▲') collapse.setFixedSize(QSize(25, 25)) collapse.clicked.connect(lambda: self.tree.collapseAll()) self.search_bar.returnPressed.connect(lambda: search_button.click()) search.addWidget(self.search_bar) search.addWidget(search_button) search.addWidget(expand) search.addWidget(collapse) self.digest = QLabel() vgrid.addLayout(search) vgrid.addWidget(self.tree) vgridwid = QWidget() vgridwid.setLayout(vgrid) split = QSplitter(Qt.Horizontal) split.addWidget(vgridwid) split.addWidget(self.traceview) split.setStretchFactor(1, 1) # grid.addLayout(vgrid) grid.addWidget(split) # grid.addWidget(self.tracelist) self.disp_output() center = QWidget() center.setLayout(grid) self.setCentralWidget(center) self.show()
def __init__(self, parent=None, caption="", width=600, height=600): super(BrowserDialog, self).__init__(parent) self.setAttribute(Qt.WA_DeleteOnClose) self.resize(width, height) self.setWindowTitle(caption) self.url = None self.domain = None self.headers = {} self.stopped = False self.cookie = '' self.ready = False central = QWidget() self.setCentralWidget(central) self.mainLayout = QVBoxLayout(central) self.topLayout = QHBoxLayout() self.mainLayout.addLayout(self.topLayout) # Status bar self.statusBar = self.statusBar() self.cookieLabel = QScrollLabel() self.cookieLabel.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Ignored) self.statusBar.addWidget(self.cookieLabel) self.cookieLabel.textVisible(False) self.loadingLabel = QLabel() self.statusBar.addPermanentWidget(self.loadingLabel) # Adress bar self.addressBar = QLineEdit() self.addressBar.returnPressed.connect(self.addressChanged) self.topLayout.addWidget(self.addressBar) self.addressBar.setVisible(False) # Create WebView self.webview = QWebEngineView(self) QWebEngineSettings.globalSettings().setAttribute( QWebEngineSettings.PluginsEnabled, True) QWebEngineSettings.globalSettings().setAttribute( QWebEngineSettings.ScreenCaptureEnabled, True) self.webpage = WebPageCustom(self.webview) self.webview.setPage(self.webpage) self.mainLayout.addWidget(self.webview) self.webview.show() # Signals self.webpage.logMessage.connect(self.logMessage) self.webpage.cookieChanged.connect(self.cookieChanged) self.webview.urlChanged.connect(self.urlChanged) self.webpage.loadFinished.connect(self.loadFinished) self.webpage.loadStarted.connect(self.loadStarted) #self.webpage.urlNotFound.connect(self.urlNotFound) #self.browserWebview.loadFinished.connect(self.loadFinished) #self.browserWebview.loadStarted.connect(self.loadStarted) # Button layout self.buttonLayout = QHBoxLayout() self.topLayout.addLayout(self.buttonLayout) # Buttons buttonDismiss = QPushButton(self) buttonDismiss.setText("Close") buttonDismiss.setDefault(True) buttonDismiss.clicked.connect(self.close) self.buttonLayout.addWidget(buttonDismiss)
def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.setWindowTitle('Commander V 0.1') self.resize(1600, 1200) #Functions self.commands = { # GUI commands 'CLEARALL': self.clear_all_results, # Basic Text Commands 'transform': TextFunctions().transform, '-tf': TextFunctions().transform, # Translation Commands 'translate': TextFunctions().translate, '-tr': TextFunctions().translate, # Information Commands 'extract': ExtractFunctions().extract, '-ext': ExtractFunctions().extract, 'regex': ExtractFunctions().regex, '-re': ExtractFunctions().regex, # Image Functions 'grayscale': ImageFunctions().grayscale, 'bw': ImageFunctions().bw, 'flip': ImageFunctions().flip, 'invert': ImageFunctions().invert } # Fonts self.text_font = QFont('monospace', 16) self.button_font = QFont('monospace', 18) self.console_font = QFont('monospace', 14) # Create widgets self.input_area = QTabWidget() self.input_area.setFont(self.text_font) self.text_area = QTextEdit() self.text_area.setFont(self.text_font) self.file_area = FileArea() self.image_area = ImageArea() self.result_scroll_area = QScrollArea() self.result_area = QWidget() self.result_area.layout = QVBoxLayout() self.result_area.setLayout(self.result_area.layout) self.result_scroll_area.setWidget(self.result_area) self.result_scroll_area.setWidgetResizable(True) self.console = QTextEdit() self.console.setMaximumHeight(300) self.console.setReadOnly(True) self.console.setStyleSheet( 'background-color: #0F0E0D; color: white; border: 0;') self.console.setFont(self.console_font) def set_command_line_focus(event): self.command_line.setFocus() self.console.mousePressEvent = set_command_line_focus self.command_line = QLineEdit() # self.command_line.setStyleSheet('background-color: #0F0E0D; color: white; border: 0;') self.command_line.setFont(self.console_font) self.command_line.setPlaceholderText('Enter command') self.command_line.setTextMargins(5, 0, 0, 0) self.execute_button = QPushButton("Execute") self.execute_button.setFont(self.button_font) self.execute_button.setStyleSheet( 'background-color: red; color: white;') self.command_line.returnPressed.connect(self.execute_button.click) self.execute_button.setVisible(False) # Create layout and add widgets self.layout = QGridLayout() self.top_layout = QGridLayout() # Tabbed input area self.top_layout.addWidget(self.input_area, 0, 0) self.input_area.insertTab(0, self.text_area, 'Text') self.input_area.insertTab(1, self.file_area, 'File') self.input_area.insertTab(2, self.image_area, 'Image') self.top_layout.addWidget(self.result_scroll_area, 0, 2) self.bottom_layout = QGridLayout() self.bottom_layout.setSpacing(0) self.bottom_layout.addWidget(self.console, 0, 0) self.bottom_layout.addWidget(self.command_line, 1, 0) self.bottom_layout.addWidget(self.execute_button, 2, 0) # Set layout self.setLayout(self.layout) self.layout.addLayout(self.top_layout, 0, 0) self.layout.addLayout(self.bottom_layout, 1, 0) # Add button signal to execution function self.execute_button.clicked.connect(self.execute_command) # Set focus to command line self.command_line.setFocus()
def __init__(self, targetImage=None, axeSize=500, layer=None, parent=None, colorModel='HSV'): super().__init__(targetImage=targetImage, axeSize=axeSize, layer=layer, parent=parent) graphicsScene = self.scene() graphicsScene.colorModel = colorModel # hue curve init. cubic = activeCubicSpline(axeSize) graphicsScene.addItem(cubic) graphicsScene.cubicR = cubic cubic.channel = channelValues.Hue cubic.initFixedPoints() # sat curve init. cubic = activeCubicSpline(axeSize) graphicsScene.addItem(cubic) graphicsScene.cubicG = cubic cubic.channel = channelValues.Sat cubic.initFixedPoints() # brightness curve init. cubic = activeCubicSpline(axeSize) graphicsScene.addItem(cubic) graphicsScene.cubicB = cubic cubic.channel = channelValues.Br cubic.initFixedPoints() # init histograms self.updateHists() # set current curve to sat graphicsScene.cubicItem = graphicsScene.cubicG graphicsScene.cubicItem.setVisible(True) # buttons pushButton1 = QPushButton("Reset Current") pushButton1.clicked.connect(self.resetCurve) pushButton2 = QPushButton("Reset All") pushButton2.clicked.connect(self.resetAllCurves) # options options = ['H', 'S', 'B'] self.listWidget1 = optionsWidget(options=options, exclusive=True) self.listWidget1.setGeometry(0, 0, self.listWidget1.sizeHintForColumn(0) + 5, self.listWidget1.sizeHintForRow(0) * len(options) + 5) # selection changed handler curves = [graphicsScene.cubicR, graphicsScene.cubicG, graphicsScene.cubicB] curveDict = dict(zip(options, curves)) def onSelect1(item): self.scene().cubicItem.setVisible(False) self.scene().cubicItem = curveDict[item.text()] self.scene().cubicItem.setVisible(True) # draw histogram self.scene().invalidate(QRectF(0.0, -self.scene().axeSize, self.scene().axeSize, self.scene().axeSize), QGraphicsScene.BackgroundLayer) self.listWidget1.onSelect = onSelect1 # set initial selection to Saturation item = self.listWidget1.items[options[1]] item.setCheckState(Qt.Checked) self.listWidget1.select(item) # layout gl = QGridLayout() gl.addWidget(self.listWidget1, 0, 0, 2, 1) for i, button in enumerate([pushButton1, pushButton2]): gl.addWidget(button, i, 1) self.addCommandLayout(gl) self.setWhatsThis("""<b>HSV curves</b><br>""" + self.whatsThis()) def f(): layer = graphicsScene.layer layer.applyToStack() layer.parentImage.onImageChanged() self.scene().cubicR.curveChanged.sig.connect(f) self.scene().cubicG.curveChanged.sig.connect(f) self.scene().cubicB.curveChanged.sig.connect(f)
import sys from PySide2.QtWidgets import QApplication, QPushButton, QMessageBox from PySide2.QtCore import Slot from ENtoANKI import makefolder, recursive, move_images @Slot() def convert_evernote(): makefolder() recursive() dial = QMessageBox() dial.setText("Finished Converting!") dial.setWindowTitle("Success!") dial.addButton(QMessageBox.Ok) dial.exec_() # move_images() # Create the Qt Application app = QApplication(sys.argv) # Create a button, connect it and show it button = QPushButton("Convert") button.clicked.connect(convert_evernote) button.show() # Run the main Qt loop app.exec_()
def __init__(self, parent: Optional[QWindow], level_ref: LevelRef): super(HeaderEditor, self).__init__(parent, "Level Header Editor") self.level: Level = level_ref.level # enables undo self.header_change.connect(level_ref.save_level_state) main_layout = QVBoxLayout(self) self.tab_widget = QTabWidget(self) main_layout.addWidget(self.tab_widget) # level settings self.length_dropdown = QComboBox() self.length_dropdown.addItems(STR_LEVEL_LENGTHS) self.length_dropdown.activated.connect(self.on_combo) self.music_dropdown = QComboBox() self.music_dropdown.addItems(MUSIC_ITEMS) self.music_dropdown.activated.connect(self.on_combo) self.time_dropdown = QComboBox() self.time_dropdown.addItems(TIMES) self.time_dropdown.activated.connect(self.on_combo) self.v_scroll_direction_dropdown = QComboBox() self.v_scroll_direction_dropdown.addItems(SCROLL_DIRECTIONS) self.v_scroll_direction_dropdown.activated.connect(self.on_combo) self.level_is_vertical_cb = QCheckBox("Level is Vertical") self.level_is_vertical_cb.clicked.connect(self.on_check_box) self.pipe_ends_level_cb = QCheckBox("Pipe ends Level") self.pipe_ends_level_cb.clicked.connect(self.on_check_box) check_box_layout = QHBoxLayout() check_box_layout.setContentsMargins(0, 0, 0, 0) check_box_layout.addWidget(self.level_is_vertical_cb) check_box_layout.addWidget(self.pipe_ends_level_cb) check_box_widget = QWidget() check_box_widget.setLayout(check_box_layout) form = QFormLayout() form.setFormAlignment(Qt.AlignCenter) form.addRow("Level length: ", self.length_dropdown) form.addRow("Music: ", self.music_dropdown) form.addRow("Time: ", self.time_dropdown) form.addRow("Scroll direction: ", self.v_scroll_direction_dropdown) form.addWidget(check_box_widget) widget = QWidget() widget.setLayout(form) self.tab_widget.addTab(widget, "Level") # player settings self.x_position_dropdown = QComboBox() self.x_position_dropdown.addItems(STR_X_POSITIONS) self.x_position_dropdown.activated.connect(self.on_combo) self.y_position_dropdown = QComboBox() self.y_position_dropdown.addItems(STR_Y_POSITIONS) self.y_position_dropdown.activated.connect(self.on_combo) self.action_dropdown = QComboBox() self.action_dropdown.addItems(ACTIONS) self.action_dropdown.activated.connect(self.on_combo) form = QFormLayout() form.setFormAlignment(Qt.AlignCenter) form.addRow("Starting X: ", self.x_position_dropdown) form.addRow("Starting Y: ", self.y_position_dropdown) form.addRow("Action: ", self.action_dropdown) widget = QWidget() widget.setLayout(form) self.tab_widget.addTab(widget, "Mario") # graphic settings self.object_palette_spinner = Spinner(self, maximum=7) self.object_palette_spinner.valueChanged.connect(self.on_spin) self.enemy_palette_spinner = Spinner(self, maximum=3) self.enemy_palette_spinner.valueChanged.connect(self.on_spin) self.graphic_set_dropdown = QComboBox() self.graphic_set_dropdown.addItems(GRAPHIC_SET_NAMES) self.graphic_set_dropdown.activated.connect(self.on_combo) form = QFormLayout() form.setFormAlignment(Qt.AlignCenter) form.addRow("Object Palette: ", self.object_palette_spinner) form.addRow("Enemy Palette: ", self.enemy_palette_spinner) form.addRow("Graphic Set: ", self.graphic_set_dropdown) widget = QWidget() widget.setLayout(form) self.tab_widget.addTab(widget, "Graphics") # next area settings self.level_pointer_spinner = Spinner(self, maximum=SPINNER_MAX_VALUE) self.level_pointer_spinner.valueChanged.connect(self.on_spin) self.enemy_pointer_spinner = Spinner(self, maximum=SPINNER_MAX_VALUE) self.enemy_pointer_spinner.valueChanged.connect(self.on_spin) self.next_area_object_set_dropdown = QComboBox() self.next_area_object_set_dropdown.addItems(OBJECT_SET_ITEMS) self.next_area_object_set_dropdown.activated.connect(self.on_combo) level_select_button = QPushButton("Set from Level") level_select_button.pressed.connect(self._set_jump_destination) form = QFormLayout() form.setFormAlignment(Qt.AlignCenter) form.addRow("Address of Objects: ", self.level_pointer_spinner) form.addRow("Address of Enemies: ", self.enemy_pointer_spinner) form.addRow("Object Set: ", self.next_area_object_set_dropdown) form.addRow(QLabel("")) form.addRow(level_select_button) widget = QWidget() widget.setLayout(form) self.tab_widget.addTab(widget, "Jump Destination") self.header_bytes_label = QLabel() main_layout.addWidget(self.header_bytes_label, alignment=Qt.AlignCenter) self.update()
def __init__(self): QWidget.__init__(self) m = QMenu(self) b = QPushButton("Hello", self) b.setMenu(m)
def setupUi(self, qAuthClass): qAuthClass.setObjectName("qAuthClass") qAuthClass.resize(700, 365) self.centralwidget = QtWidgets.QWidget(qAuthClass) self.centralwidget.setObjectName("centralwidget") self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget) self.verticalLayout.setObjectName("verticalLayout") self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setContentsMargins(5, 5, -1, 5) self.horizontalLayout.setObjectName("horizontalLayout") # ************** TABLE ************** self.tblKeys = QtWidgets.QTableWidget(self.centralwidget) self.tblKeys.setMaximumSize(QtCore.QSize(540, 16777215)) self.tblKeys.viewport().setProperty("cursor", QtGui.QCursor(QtCore.Qt.UpArrowCursor)) self.tblKeys.setColumnCount(4) self.tblKeys.setObjectName("tblKeys") self.tblKeys.setRowCount(0) self.tblKeys.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) self.tblKeys.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection) self.tblKeys.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) # Column Definition: Service item = QtWidgets.QTableWidgetItem() item.setTextAlignment(QtCore.Qt.AlignLeft) self.tblKeys.setHorizontalHeaderItem(0, item) self.tblKeys.setColumnWidth(0,150) # Column Definition: OTP item = QtWidgets.QTableWidgetItem() item.setTextAlignment(QtCore.Qt.AlignLeft) self.tblKeys.setHorizontalHeaderItem(1, item) self.tblKeys.setColumnWidth(1,240) # Column Definition: 2FA item = QtWidgets.QTableWidgetItem() item.setTextAlignment(QtCore.Qt.AlignCenter) self.tblKeys.setHorizontalHeaderItem(2, item) self.tblKeys.setColumnWidth(2,70) # Column Definition: OTP 2 (hidden) item = QtWidgets.QTableWidgetItem() item.setTextAlignment(QtCore.Qt.AlignLeft) self.tblKeys.setHorizontalHeaderItem(3, item) self.tblKeys.setColumnWidth(3,10) # Hide OTP 2 self.tblKeys.hideColumn(3) self.horizontalLayout.addWidget(self.tblKeys) # spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) # self.horizontalLayout.addItem(spacerItem) self.verticalGroupBox = QtWidgets.QGroupBox(self.centralwidget) self.verticalGroupBox.setMaximumSize(QtCore.QSize(120, 16777215)) self.verticalGroupBox.setObjectName("verticalGroupBox") self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.verticalGroupBox) self.verticalLayout_3.setContentsMargins(5, -1, -1, -1) self.verticalLayout_3.setObjectName("verticalLayout_3") # Remaining time self.timeLayout = QtWidgets.QHBoxLayout() self.timeLayout.setObjectName("timeLayout") self.timeLayout.setAlignment(QtCore.Qt.AlignCenter) self.remainingTime = QtWidgets.QProgressBar(self.verticalGroupBox) self.remainingTime.setMaximumSize(QtCore.QSize(16777215, 16777215)) self.remainingTime.setProperty("value", 0) self.remainingTime.setAlignment(QtCore.Qt.AlignCenter) self.remainingTime.setTextDirection(QtWidgets.QProgressBar.TopToBottom) self.remainingTime.setObjectName("remainingTime") self.timeLayout.addWidget(self.remainingTime,0) self.verticalLayout_3.addLayout(self.timeLayout) # Buttons Layout self.buttonsLayout = QtWidgets.QHBoxLayout() self.buttonsLayout.setObjectName("buttonsLayout") # Add OTP Pushbutton self.addButton = QPushButton(self.verticalGroupBox) self.addButton.setObjectName("addButton") #self.addButton.setMaximumWidth(34) iconButton = QIcon() pixmapRefresh = QPixmap(os.path.join(dirname, "icons/document-new-symbolic.svg")) iconButton.addPixmap(pixmapRefresh, QIcon.Normal, QIcon.Off) self.addButton.setIcon(iconButton) #self.addButton.clicked.connect(self.addService) self.addButton.setToolTip("Add Authentication") self.buttonsLayout.addWidget(self.addButton) # Remove OTP button self.removeButton = QPushButton(self.verticalGroupBox) self.removeButton.setObjectName("removeButton") self.removeButton.setMaximumWidth(34) iconButton = QIcon() pixmapRefresh = QPixmap(os.path.join(dirname, "icons/edit-delete-symbolic.svg")) iconButton.addPixmap(pixmapRefresh, QIcon.Normal, QIcon.Off) self.removeButton.setIcon(iconButton) #self.removeButton.clicked.connect(self.removeOTP) self.removeButton.setToolTip("Remove Authentication") self.buttonsLayout.addWidget(self.removeButton) # Show Pushbutton self.showButton = QtWidgets.QPushButton(self.verticalGroupBox) self.showButton.setObjectName("showButton") self.showButton.setMaximumWidth(34) iconButton = QIcon() pixmapRefresh = QPixmap(os.path.join(dirname, "icons/document-properties-symbolic.svg")) iconButton.addPixmap(pixmapRefresh, QIcon.Normal, QIcon.Off) self.showButton.setIcon(iconButton) #self.showButton.clicked.connect(self.showOTP) self.showButton.setToolTip("Show OTP") self.buttonsLayout.addWidget(self.showButton) # Clipboard Pushbutton self.clipboardButton = QtWidgets.QPushButton(self.verticalGroupBox) self.clipboardButton.setObjectName("clipboardButton") self.clipboardButton.setMaximumWidth(34) iconButton = QIcon() pixmapRefresh = QPixmap(os.path.join(dirname, "icons/edit-copy-symbolic.svg")) iconButton.addPixmap(pixmapRefresh, QIcon.Normal, QIcon.Off) self.clipboardButton.setIcon(iconButton) #self.clipboardButton.clicked.connect(self.copyOTP) self.clipboardButton.setToolTip("Copy 2FA") self.buttonsLayout.addWidget(self.clipboardButton) self.verticalLayout_3.addLayout(self.buttonsLayout) spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.verticalLayout_3.addItem(spacerItem1) self.horizontalLayout.addWidget(self.verticalGroupBox) self.verticalLayout.addLayout(self.horizontalLayout) qAuthClass.setCentralWidget(self.centralwidget) # ************** MENU ************** self.menubar = QtWidgets.QMenuBar(qAuthClass) self.menubar.setGeometry(QtCore.QRect(0, 0, 535, 26)) self.menubar.setObjectName("menubar") self.menuFile = QtWidgets.QMenu(self.menubar) self.menuFile.setObjectName("menuFile") qAuthClass.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(qAuthClass) self.statusbar.setObjectName("statusbar") qAuthClass.setStatusBar(self.statusbar) # Create database self.createDB = QtWidgets.QAction(qAuthClass) self.createDB.setObjectName("createDB") self.createDB.setShortcut("Ctrl+N") self.createDB.setStatusTip('New Database') self.createDB.triggered.connect(self.createDBFile) self.menuFile.addAction(self.createDB) # Open database self.openDB = QtWidgets.QAction(qAuthClass) self.openDB.setObjectName("openDB") self.openDB.setShortcut("Ctrl+O") self.openDB.triggered.connect(self.openDatabase) self.menuFile.addAction(self.openDB) # About self.aboutAction = QtWidgets.QAction(qAuthClass) self.aboutAction.setObjectName("aboutAction") self.aboutAction.triggered.connect(self.showAbout) self.menuFile.addAction(self.aboutAction) # Quit self.actionQuit = QtWidgets.QAction(qAuthClass) self.actionQuit.setObjectName("actionQuit") self.actionQuit.setShortcut("Ctrl+Q") self.menuFile.addAction(self.actionQuit) self.menubar.addAction(self.menuFile.menuAction()) self.retranslateUi(qAuthClass) # self.actionQuit.triggered.connect(qAuthClass.close) self.actionQuit.triggered.connect(self.quitApp) QtCore.QMetaObject.connectSlotsByName(qAuthClass)
def __init__(self): super(WidgetConfig, self).__init__() HEIGHT = 30 grid = QGridLayout() # 使用默认摄像头复选框 self.check_camera = QCheckBox('Use default camera') self.check_camera.setChecked(False) self.check_camera.stateChanged.connect(self.slot_check_camera) grid.addWidget(self.check_camera, 0, 0, 1, 3) # 一行三列 # 选择视频文件 label_video = QLabel('Detect File') self.line_video = QLineEdit() if 'video' in GLOBAL.config: self.line_video.setText(GLOBAL.config['video']) self.line_video.setFixedHeight(HEIGHT) self.line_video.setEnabled(False) self.line_video.editingFinished.connect( lambda: GLOBAL.record_config({'video': self.line_video.text()})) self.btn_video = QPushButton('Choose') self.btn_video.setFixedHeight(HEIGHT) self.btn_video.setEnabled(False) self.btn_video.clicked.connect(self.choose_video_file) self.slot_check_camera() grid.addWidget(label_video, 1, 0) grid.addWidget(self.line_video, 1, 1) grid.addWidget(self.btn_video, 1, 2) # 选择权重文件 label_weights = QLabel('Weights File') self.line_weights = QLineEdit() if 'weights' in GLOBAL.config: self.line_weights.setText(GLOBAL.config['weights']) self.line_weights.setFixedHeight(HEIGHT) self.line_weights.editingFinished.connect(lambda: GLOBAL.record_config( {'weights': self.line_weights.text()})) self.btn_weights = QPushButton('Choose') self.btn_weights.setFixedHeight(HEIGHT) self.btn_weights.clicked.connect(self.choose_weights_file) grid.addWidget(label_weights, 2, 0) grid.addWidget(self.line_weights, 2, 1) grid.addWidget(self.btn_weights, 2, 2) # 是否使用GPU label_device = QLabel('CUDA device') self.line_device = QLineEdit('cpu') if 'device' in GLOBAL.config: self.line_device.setText(GLOBAL.config['device']) else: self.line_device.setText('cpu') self.line_device.setPlaceholderText('cpu or 0 or 0,1,2,3') self.line_device.setFixedHeight(HEIGHT) self.line_device.editingFinished.connect( lambda: GLOBAL.record_config({'device': self.line_device.text()})) grid.addWidget(label_device, 3, 0) grid.addWidget(self.line_device, 3, 1, 1, 2) # 设置图像大小 label_size = QLabel('Img Size') self.combo_size = QComboBox() self.combo_size.setFixedHeight(HEIGHT) self.combo_size.setStyleSheet( 'QAbstractItemView::item {height: 40px;}') self.combo_size.setView(QListView()) self.combo_size.addItem('320', 320) self.combo_size.addItem('416', 416) self.combo_size.addItem('480', 480) self.combo_size.addItem('544', 544) self.combo_size.addItem('640', 640) self.combo_size.setCurrentIndex(2) self.combo_size.currentIndexChanged.connect( lambda: GLOBAL.record_config( {'img_size': self.combo_size.currentData()})) grid.addWidget(label_size, 4, 0) grid.addWidget(self.combo_size, 4, 1, 1, 2) # 设置置信度阈值 label_conf = QLabel('Confidence') self.spin_conf = QDoubleSpinBox() self.spin_conf.setFixedHeight(HEIGHT) self.spin_conf.setDecimals(1) self.spin_conf.setRange(0.1, 0.9) self.spin_conf.setSingleStep(0.1) if 'conf_thresh' in GLOBAL.config: self.spin_conf.setValue(GLOBAL.config['conf_thresh']) else: self.spin_conf.setValue(0.4) # 默认值 GLOBAL.record_config({'conf_thresh': 0.4}) self.spin_conf.valueChanged.connect(lambda: GLOBAL.record_config( {'conf_thresh': round(self.spin_conf.value(), 1)})) grid.addWidget(label_conf, 5, 0) grid.addWidget(self.spin_conf, 5, 1, 1, 2) # 设置IOU阈值 label_iou = QLabel('IOU') self.spin_iou = QDoubleSpinBox() self.spin_iou.setFixedHeight(HEIGHT) self.spin_iou.setDecimals(1) self.spin_iou.setRange(0.1, 0.9) self.spin_iou.setSingleStep(0.1) if 'iou_thresh' in GLOBAL.config: self.spin_iou.setValue(GLOBAL.config['iou_thresh']) else: self.spin_iou.setValue(0.5) # 默认值 GLOBAL.record_config({'iou_thresh': 0.5}) self.spin_iou.valueChanged.connect(lambda: GLOBAL.record_config( {'iou_thresh': round(self.spin_iou.value(), 1)})) grid.addWidget(label_iou, 6, 0) grid.addWidget(self.spin_iou, 6, 1, 1, 2) # class-agnostic NMS self.check_agnostic = QCheckBox('Agnostic') if 'agnostic' in GLOBAL.config: self.check_agnostic.setChecked(GLOBAL.config['agnostic']) else: self.check_agnostic.setChecked(True) self.check_agnostic.stateChanged.connect(lambda: GLOBAL.record_config( {'agnostic': self.check_agnostic.isChecked()})) grid.addWidget(self.check_agnostic, 7, 0, 1, 3) # 一行三列 # augmented inference self.check_augment = QCheckBox('Augment') if 'augment' in GLOBAL.config: self.check_augment.setChecked(GLOBAL.config['augment']) else: self.check_augment.setChecked(True) self.check_augment.stateChanged.connect(lambda: GLOBAL.record_config( {'augment': self.check_augment.isChecked()})) grid.addWidget(self.check_augment, 8, 0, 1, 3) # 一行三列 self.setLayout(grid) # 设置布局
def __init__(self, available_colors: list): """ Widget allowing the user to create between 2 and 6 colors for the Colors typed attributes :param available_colors: existing colors to initialize """ QWidget.__init__(self) # Widgets self.__add_btn = QPushButton() self.__add_btn.setIcon(get_icon("add")) self.__add_btn.setIconSize(QSize(35, 35)) self.__add_btn.setToolTip(tr("crs_create_btn_tooltip")) self.__add_btn.clicked.connect(self.__add_color) self.__add_btn.setStyleSheet("border: none;") self.__delete_btn = QPushButton() self.__delete_btn.setIcon(get_icon("del")) self.__delete_btn.setIconSize(QSize(35, 35)) self.__delete_btn.setToolTip(tr("btn_suppr")) self.__delete_btn.clicked.connect(self.__remove_color) self.__delete_btn.setStyleSheet("border: none;") self.__btns = [] for c in available_colors: # Fill in existing colors self.__btns.append(ColorChooser(c, False)) for i in range(AttrColorsChooser.MAX_COLORS - len(available_colors)): # Complete with 'empty' colors self.__btns.append( ColorChooser(AttrColorsChooser.DEFAULT_COLOR, False)) # Use white as default color self.__btns[-1].setVisible(False) if len(available_colors) <= AttrColorsChooser.MIN_COLORS: self.__delete_btn.setEnabled(False) # Displays at least the minimum of buttons for i in range(AttrColorsChooser.MIN_COLORS): self.__btns[i].setVisible(True) elif len(available_colors) >= AttrColorsChooser.MAX_COLORS: self.__add_btn.setEnabled(False) # Layout layout = QGridLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.__delete_btn, 0, 0, 2, 1) r, c = 0, 1 for b in self.__btns: layout.addWidget(b, r, c) c += 1 if c == 4: r, c = 1, 1 layout.addWidget(self.__add_btn, 0, 4, 2, 1) self.setLayout(layout)