def __init__(self, parent, option, index): """Initialize class.""" super().__init__(parent) layout = QVBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) self.model = MinimalTableModel(self) self.model.flags = self.model_flags self.view = QTableView(self) self.view.setModel(self.model) self.view.verticalHeader().hide() self.view.horizontalHeader().hide() self.view.setShowGrid(False) check_box_delegate = CheckBoxDelegate(self) self.view.setItemDelegateForColumn(0, check_box_delegate) check_box_delegate.data_committed.connect( self._handle_check_box_data_committed) self.button = QPushButton("Ok", self) self.button.setFlat(True) self.view.verticalHeader().setDefaultSectionSize(option.rect.height()) self.button.setFixedHeight(option.rect.height()) layout.addWidget(self.view) layout.addWidget(self.button) self.button.clicked.connect(self._handle_ok_button_clicked) self.setWindowFlags(Qt.FramelessWindowHint | Qt.Popup) x_offset = parent.parent().columnViewportPosition(index.column()) y_offset = parent.parent().rowViewportPosition(index.row()) self.position = parent.mapToGlobal(QPoint(0, 0)) + QPoint( x_offset, y_offset)
def __init__(self, parent=None): super(Controller, self).__init__(parent) self.resourcePath = os.path.normpath(os.path.join(fileDir, "resource")).replace( "\\", "/") self.setWindowFlags(Qt.Window | Qt.FramelessWindowHint) self.setAttribute(Qt.WA_TranslucentBackground) self.setAttribute(Qt.WA_Hover) self.setMouseTracking(True) self.setAcceptDrops(True) layout = QVBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) self.fillColor = QColor(127, 127, 127, 2) self.penColor = QColor(127, 127, 127, 2) self.onTop = False self.visible = False self.drawDrag = False self.isPaused = False self.lastMove = datetime.now() self.lastButton = Qt.MouseButton.NoButton self.setupWidget() self.setupRightClick() if parent: self.player = parent self.setupSignal() self.toggleVisibility(False)
def __init__(self): super(MainWindow, self).__init__() self.window3d = Window() mainLayout = QVBoxLayout() mainLayout.addWidget(QWidget.createWindowContainer( self.window3d, self)) mainLayout.setContentsMargins(0, 0, 0, 0) bottomLayout = QHBoxLayout() bottomLayout.setContentsMargins(20, 0, 20, 20) bottomLayout.addStretch() openHoodCB = QCheckBox("Open Hood", self) openHoodCB.toggled.connect(self.window3d.toggleHood) bottomLayout.addWidget(openHoodCB) bottomLayout.addStretch() openLeftDoorCB = QCheckBox("Open Left Door", self) openLeftDoorCB.toggled.connect(self.window3d.toggleLeftDoor) bottomLayout.addWidget(openLeftDoorCB) bottomLayout.addStretch() openRightDoorCB = QCheckBox("Open Right Door", self) openRightDoorCB.toggled.connect(self.window3d.toggleRightDoor) bottomLayout.addWidget(openRightDoorCB) bottomLayout.addStretch() self.toggleCameraAnimationPB = QPushButton("Play", self) self.toggleCameraAnimationPB.setCheckable(True) self.toggleCameraAnimationPB.toggled.connect( self.toggleCameraAnimation) bottomLayout.addWidget(self.toggleCameraAnimationPB) bottomLayout.addStretch() mainLayout.addLayout(bottomLayout) self.setLayout(mainLayout) self.resize(1024, 768)
def __init__(self, parent=None): super().__init__(parent) layout = QVBoxLayout() self.setLayout(layout) self.setContentsMargins(0, 0, 0, 0) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) self.setAutoFillBackground(True) self.setFocusPolicy(Qt.StrongFocus) self.setFrameStyle(QFrame.Panel | QFrame.Plain) self._fallback_text = None self._experiment = None self.line_edit = QLineEdit() self.line_edit.setFrame(False) self.message_label = QLabel() self.message_label.hide() # Divider line self.divider_line = QFrame() self.divider_line.setFrameShape(QFrame.HLine) self.divider_line.setFrameShadow(QFrame.Plain) self.divider_line.setLineWidth(1) layout.addWidget(self.line_edit) layout.addWidget(self.divider_line) layout.addWidget(self.message_label) self.line_edit.textChanged.connect(self._updateMessage)
def setup_location_pool_elements(self): self.randomization_mode_combo.setItemData(0, RandomizationMode.FULL) self.randomization_mode_combo.setItemData( 1, RandomizationMode.MAJOR_MINOR_SPLIT) self.randomization_mode_combo.currentIndexChanged.connect( self._on_update_randomization_mode) game_description = default_prime2_game_description() world_to_group = {} self._location_pool_for_node = {} for world in game_description.world_list.worlds: for is_dark_world in [False, True]: group_box = QGroupBox(self.excluded_locations_area_contents) group_box.setTitle(world.correct_name(is_dark_world)) vertical_layout = QVBoxLayout(group_box) vertical_layout.setContentsMargins(8, 4, 8, 4) vertical_layout.setSpacing(2) group_box.vertical_layout = vertical_layout world_to_group[world.correct_name(is_dark_world)] = group_box self.excluded_locations_area_layout.addWidget(group_box) for world, area, node in game_description.world_list.all_worlds_areas_nodes: if not isinstance(node, PickupNode): continue group_box = world_to_group[world.correct_name(area.in_dark_aether)] check = QtWidgets.QCheckBox(group_box) check.setText(game_description.world_list.node_name(node)) check.node = node check.stateChanged.connect( functools.partial(self._on_check_location, check)) group_box.vertical_layout.addWidget(check) self._location_pool_for_node[node] = check
def initUI(self): self.setStyleSheet( 'ExpanderWidget{ ' ' padding:2px -1px -1px 0px; margin-left:-1px; ' f'{" margin-top: -19px; padding-top:19px; " if sys.platform.startswith("darwin") else ""}' '}' 'ExpanderWidget::title{ ' ' color: transparent; ' # ' height: 0px; ' '}' 'ExpanderWidget>#expanderToggle{ ' ' background: transparent;' ' border: 1px solid transparent;' ' border-bottom: 1px solid #B0B0B0;' ' border-radius:0;' f' font-size: {QApplication.font().pointSizeF()}pt; ' '}' 'ExpanderWidget>#expanderToggle:hover,' 'ExpanderWidget>#expanderToggle:checked:hover{ ' ' background: qlineargradient( x1:0 y1:-0.1, x2:0 y2:1, ' ' stop:0 white, stop:1 palette(button));' ' border: 1px solid #B0B0B0; border-radius:2px;' '}' 'ExpanderWidget>#expanderToggle:checked,' 'ExpanderWidget>#expanderToggle:checked:pressed,' 'ExpanderWidget>#expanderToggle:pressed{' ' background: palette(background);' ' border: 1px solid #B0B0B0; border-radius:2px;' '}' 'ExpanderWidget:disabled{' ' border: 1px solid transparent; border-radius:2px;' '}' 'ExpanderWidget>#expanderToggle:focus{' ' border: 1px solid palette(highlight); border-radius:2px;' '}') layout = QVBoxLayout() layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout) self._toggle.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self._toggle.setObjectName('expanderToggle') self._toggle.setText(self._title) self._toggle.setAutoRaise(True) self._toggle.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed) self._toggle.setMinimumHeight(self._toggle.height()) self._toggle.setArrowType(Qt.ArrowType.DownArrow) self._toggle.setCheckable(True) self._toggle.setChecked(True) self._toggle.clicked.connect(self._toggle_closed) self._content.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) self._content.setMinimumHeight(0) self._content.setMaximumHeight(0) self._content layout.addWidget(self._toggle) layout.addWidget(self._content)
def _init_widgets(self): self._function_list = QFunctionComboBox( show_all_functions=True, selection_callback=self._on_function_selected, parent=self) self._filter_string = QLineEdit(self) self._regex_checkbox = QCheckBox("Regex?", self) self._filter_string.textChanged.connect(self.on_filter_change) self._regex_checkbox.stateChanged.connect(self.on_filter_change) function_layout = QHBoxLayout() function_layout.addWidget(QLabel("Function:", self)) function_layout.addWidget(self._function_list, 10) function_layout.addWidget(QLabel("Filter:", self)) function_layout.addWidget(self._filter_string, 10) function_layout.addWidget(self._regex_checkbox) self._string_table = QStringTable( self, selection_callback=self._on_string_selected) layout = QVBoxLayout() layout.addLayout(function_layout) layout.addWidget(self._string_table) layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout)
class Downloads(QWidget): def __init__(self): super(Downloads, self).__init__() self.history = get_download_history() self.history.reverse() self.layout = QStackedLayout() self.layout.setMargin(0) self.page_widget = QScrollArea() self.page_widget.setWidgetResizable(True) widget = QWidget(self.page_widget) widget.setMinimumWidth(350) self.page_widget.setWidget(widget) self.page_layout = QVBoxLayout(widget, alignment=Qt.AlignTop) self.page_layout.setMargin(0) self.page_layout.setContentsMargins(25, 25, 25, 25) self.layout.addWidget(self.page_widget) self.layout.setCurrentWidget(self.page_widget) if len(self.history) == 0: self.history_empty_label = QLabel('No downloads', alignment=Qt.AlignCenter) self.layout.addWidget(self.history_empty_label) self.layout.setCurrentWidget(self.history_empty_label) for item in self.history: self.page_layout.addWidget(DownloadItem(item=item)) self.setLayout(self.layout)
def __init__(self, parent=None): super().__init__(parent) self.setWindowTitle(self.tr("VQL Editor")) # Top toolbar self.top_bar = QToolBar() self.top_bar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self.run_action = self.top_bar.addAction(FIcon(0xF040A), self.tr("Run"), self.run_vql) self.run_action.setShortcuts( [Qt.CTRL + Qt.Key_R, QKeySequence.Refresh]) self.run_action.setToolTip( self.tr("Run VQL query (%s)" % self.run_action.shortcut().toString())) # Syntax highlighter and autocompletion self.text_edit = CodeEdit() # Error handling self.log_edit = QLabel() self.log_edit.setMinimumHeight(40) self.log_edit.setStyleSheet( "QWidget{{background-color:'{}'; color:'{}'}}".format( style.WARNING_BACKGROUND_COLOR, style.WARNING_TEXT_COLOR)) self.log_edit.hide() self.log_edit.setFrameStyle(QFrame.StyledPanel | QFrame.Raised) main_layout = QVBoxLayout() main_layout.addWidget(self.top_bar) main_layout.addWidget(self.text_edit) main_layout.addWidget(self.log_edit) main_layout.setContentsMargins(0, 0, 0, 0) main_layout.setSpacing(0) self.setLayout(main_layout)
def setup_starting_area_elements(self): game_description = default_prime2_game_description() world_to_group = {} self._starting_location_for_area = {} for row, world in enumerate(game_description.world_list.worlds): for column, is_dark_world in enumerate([False, True]): group_box = QGroupBox(self.starting_locations_contents) group_box.setTitle(world.correct_name(is_dark_world)) vertical_layout = QVBoxLayout(group_box) vertical_layout.setContentsMargins(8, 4, 8, 4) vertical_layout.setSpacing(2) vertical_layout.setAlignment(QtCore.Qt.AlignTop) group_box.vertical_layout = vertical_layout world_to_group[world.correct_name(is_dark_world)] = group_box self.starting_locations_layout.addWidget(group_box, row, column) for world in game_description.world_list.worlds: for area in sorted(world.areas, key=lambda a: a.name): group_box = world_to_group[world.correct_name(area.in_dark_aether)] check = QtWidgets.QCheckBox(group_box) check.setText(area.name) check.area_location = AreaLocation(world.world_asset_id, area.area_asset_id) check.stateChanged.connect(functools.partial(self._on_check_starting_area, check)) group_box.vertical_layout.addWidget(check) self._starting_location_for_area[area.area_asset_id] = check self.starting_area_quick_fill_ship.clicked.connect(self._starting_location_on_select_ship) self.starting_area_quick_fill_save_station.clicked.connect(self._starting_location_on_select_save_station)
def _createWidget(self, a, inputW: QWidget, vertical=True): """ Creates widget for given attribute and input. :param a: The attribute. :type a: PluginAttribute :param inputW: Input that is used for value manipulation. :type inputW: QWidget :param vertical: True means QVBoxLayout and Fale means QHBoxLayout. :type vertical: bool :return: Widget for attribute. :rtype: QWidget """ w = QWidget(self._widget) inputW.setParent(w) if vertical: layout = QVBoxLayout(w) layout.setContentsMargins(0, 5, 5, 0) else: layout = QHBoxLayout(w) layout.setMargin(0) w.setLayout(layout) label = QLabel(a.name + ":", self._widget) label.setTextInteractionFlags(Qt.TextSelectableByMouse | Qt.TextSelectableByKeyboard) label.setBuddy(inputW) layout.addWidget(label) layout.addWidget(inputW) return w
def __init__(self, parent, database): """Initialize class""" super().__init__(parent) self.commit_msg = None self.setWindowTitle('Commit changes to {}'.format(database)) form = QVBoxLayout(self) form.setContentsMargins(0, 0, 0, 0) inner_layout = QVBoxLayout() inner_layout.setContentsMargins(4, 4, 4, 4) self.actionAccept = QAction(self) self.actionAccept.setShortcut( QApplication.translate("Dialog", "Ctrl+Return", None, -1)) self.actionAccept.triggered.connect(self.accept) self.actionAccept.setEnabled(False) self.commit_msg_edit = QPlainTextEdit(self) self.commit_msg_edit.setPlaceholderText( 'Commit message \t(press Ctrl+Enter to commit)') self.commit_msg_edit.addAction(self.actionAccept) button_box = QDialogButtonBox() button_box.addButton(QDialogButtonBox.Cancel) self.commit_button = button_box.addButton('Commit', QDialogButtonBox.AcceptRole) button_box.accepted.connect(self.accept) button_box.rejected.connect(self.reject) inner_layout.addWidget(self.commit_msg_edit) inner_layout.addWidget(button_box) # Add status bar to form form.addLayout(inner_layout) self.setAttribute(Qt.WA_DeleteOnClose) self.commit_msg_edit.textChanged.connect(self.receive_text_changed) self.receive_text_changed()
def __init__(self): super(LevelCountWidget, self).__init__() centralWidget = QWidget() mainLayout = QVBoxLayout(centralWidget) self.setLayout(mainLayout) self.setMaximumHeight(150) mainLayout.setContentsMargins(10, 10, 10, 10) buttonsLayout = QHBoxLayout() mainLayout.addLayout(buttonsLayout) bonusLayout = QVBoxLayout() buttonsLayout.addLayout(bonusLayout) levelLayout = QVBoxLayout() buttonsLayout.addLayout(levelLayout) self.btnLevelInc = CustomButton("images/icon_plus.png") levelLayout.addWidget(self.btnLevelInc, 0, Qt.AlignHCenter) lblLevel = QLabel("<Level>") lblLevel.setAlignment(Qt.AlignHCenter) lblLevel.setObjectName("bonusLabel") levelLayout.addWidget(lblLevel) self.btnLevelDec = CustomButton("images/icon_minus.png") levelLayout.addWidget(self.btnLevelDec, 0, Qt.AlignHCenter)
def __init__(self, menus=None, *args, **kwargs): super().__init__(*args, **kwargs) self.setAttribute(Qt.WA_StyledBackground, True) self.menus = menus if menus is not None else [ 'Devices', 'Control', 'Setpoints', 'PID', 'Plotting', 'Logging' ] self.menu_buttons = { key: QPushButton(parent=self, objectName=key) for key in self.menus } self.buttongroup = QButtonGroup() elchicon = QLabel() elchicon.setPixmap(QPixmap('Icons/ElchiHead.png')) vbox = QVBoxLayout() vbox.addWidget(elchicon, alignment=Qt.AlignHCenter) for key in self.menus: vbox.addWidget(self.menu_buttons[key]) self.buttongroup.addButton(self.menu_buttons[key]) self.menu_buttons[key].setCheckable(True) self.menu_buttons[key].setFixedSize(150, 100) vbox.addStretch() vbox.setContentsMargins(0, 0, 0, 0) vbox.setSpacing(0) self.setMinimumWidth(150) self.setLayout(vbox)
def __init__(self, config, resource): """Setup each channel widget and place in QVBoxlayout""" QWidget.__init__(self) self.config = config self.resource = resource area = QScrollArea() contents = QWidget() rows = QVBoxLayout(contents) layout = QVBoxLayout(self) layout.addWidget(area) area.setWidget(contents) area.setWidgetResizable(True) layout.setContentsMargins(0, 0, 0, 0) rows.setContentsMargins(0, 0, 0, 0) rows.setSpacing(0) self.channels = [] for channel in config["channels"]: self.channels.append( ChannelWidget(channel["channel"], config, resource)) rows.addWidget(self.channels[-1]) # Set initial status and set status timer self.update_status() self.timer = QTimer() self.timer.timeout.connect(self.update_status) self.timer.start(UPDATE_INTERVAL)
def __init__(self, x, y, w, h, inputs_queue, update_position_queue, update_position_lock): QWidget.__init__(self) self.setWindowTitle('ReLuu FaceReader') self.x = x self.y = y self.w = w self.h = h self.inputs_queue = inputs_queue self.update_position_queue = update_position_queue self.update_position_lock = update_position_lock self.setGeometry(self.x, self.y, self.w, self.h) self.acceptDrops() # Window stays on top, and the other 2 combine to remove the min/close/expand buttons self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.CustomizeWindowHint | Qt.WindowTitleHint) layout = QVBoxLayout() self.setLayout(layout) # limit widget AND layout margins layout.setContentsMargins(0, 0, 0, 0) self.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) # create a "placeholder" widget for the screen grab geometry self.grabWidget = QWidget() self.grabWidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) layout.addWidget(self.grabWidget) self.show()
def _initLabels(self): self.backendName = QLabel(self.track.template.backend_name) self.backendName.setFont(Theme.track.header.backendNameFont) self.backendName.setStyleSheet(Theme.track.header.backendNameStyle) self.nameLabel.setFont(Theme.track.header.userNameFont) self.nameLabel.setStyleSheet(Theme.track.header.userNameStyle) self.nameLabel.setMaxLength(15) vlayout = QVBoxLayout() vlayout.setSpacing(0) vlayout.setContentsMargins(0, 0, 0, 0) vlayout.addWidget(self.backendName) vlayout.addWidget(self.nameLabel) vlayout.setAlignment(Qt.AlignLeft) layout = QHBoxLayout() layout.setSpacing(18) layout.setContentsMargins(18, 9, 18, 18) self.icon = QSvgWidget(self.track.template.icon_path()) self.icon.setFixedSize(36, 36) layout.addWidget(self.icon) layout.addLayout(vlayout) self.setLayout(layout)
def _init_widgets(self): if self._state.am_none(): return layout = QVBoxLayout() area = QScrollArea() area.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) area.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) area.setWidgetResizable(True) table = QTableWidget(0, 0) table.setColumnCount(len(self.COLUMNS)) table.setHorizontalHeaderLabels(self.COLUMNS) self.table = table layout.addWidget(table) # common ones layout.setSpacing(0) layout.addStretch(0) layout.setContentsMargins(2, 2, 2, 2) # the container container = QFrame() container.setAutoFillBackground(True) palette = container.palette() palette.setColor(container.backgroundRole(), Qt.white) container.setPalette(palette) container.setLayout(layout) area.setWidget(container) base_layout = QVBoxLayout() base_layout.addWidget(area) self.setLayout(base_layout)
def __init__(self, track, subject, index): self.track = track self._code = "" super().__init__(subject, index) self.setAttribute(Qt.WA_StyledBackground) self.setStyleSheet(Theme.track.cell.style) self.setFixedHeight(Theme.track.cell.height) layout = QVBoxLayout() layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) layout.setAlignment(Qt.AlignTop) self.setLayout(layout) self.layout().addWidget(self.nameLabel) self._initContentPreview() self.updateStyle() self.add_responder(events.view.main.CellEditName, self.editNameResponder) self.add_responder(events.view.track.Select, self.trackSelectResponder)
class PreferencesDocumentsPage(QWidget): preferencesChanged = Signal() def __init__(self, parent=None): super().__init__(parent) # Title title = QLabel( self.tr("<strong style=\"font-size:large;\">{0}</strong>").format( self.title())) # # Content # Main layout self._layout = QVBoxLayout(self) self._layout.addWidget(title) self._layout.addStretch(1) def setZeroMargins(self): self._layout.setContentsMargins(0, 0, 0, 0) def title(self): return self.tr("Documents") def _onPreferencesChanged(self): self.preferencesChanged.emit()
def __init__(self, item, parent): super(Override, self).__init__(parent=parent) self.path = None self.attributeUI = None self.item = weakref.ref(item) layout = QVBoxLayout() layout.setObjectName('override_vertical_box_layout') layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(utils.dpiScale(2)) self._setupMainOverrideGroupBox(layout) self.setLayout(layout) # Unwrap the layout into a pointer to be able to get the UI name. # We use fullName() to ensure a unique name is used layoutName = mui.MQtUtil.fullName(long(getCppPointer(layout)[0])) cmds.setParent(layoutName) self._uiLayout = cmds.columnLayout(adjustableColumn=True) self._dropBoxInit() if item.isUniqueOverride(): self.target = QLabel(kAppliedToUnique % item.targetNodeName()) self.target.setAlignment(Qt.AlignBottom | Qt.AlignCenter) layout.addWidget(self.target)
def _layout(self): layout = QVBoxLayout() self.setLayout(layout) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) top_row = QHBoxLayout() layout.addLayout(top_row) top_row.setContentsMargins(0, 0, 0, 0) top_row.setSpacing(0) top_row.addWidget(self.build_image("borderTL", Qt.TopEdge | Qt.LeftEdge)) top_row.addWidget(self.build_image("borderT", Qt.TopEdge, h_fix=False)) top_row.addWidget(self.build_image("borderTR", Qt.TopEdge | Qt.RightEdge)) mid_row = QHBoxLayout() layout.addLayout(mid_row) mid_row.setContentsMargins(0, 0, 0, 0) mid_row.setSpacing(0) mid_row.addWidget(self.build_image("borderL", Qt.LeftEdge, v_fix=False)) self.content = QWidget(self) mid_row.addWidget(self.content, 1) mid_row.addWidget(self.build_image("borderR", Qt.RightEdge, v_fix=False)) bot_row = QHBoxLayout() layout.addLayout(bot_row) bot_row.setContentsMargins(0, 0, 0, 0) bot_row.setSpacing(0) bot_row.addWidget( self.build_image( "borderBL", Qt.BottomEdge | Qt.LeftEdge, ) ) bot_row.addWidget(self.build_image("borderB", Qt.BottomEdge, h_fix=False)) bot_row.addWidget(self.build_image("borderBR", Qt.BottomEdge | Qt.RightEdge))
class LabelConfigurator(QFrame): def __init__(self, boxManager): super().__init__() # Objects self.boxManager = boxManager self.layout = QVBoxLayout(self) self.isOccludedButton = Check('Occluded', False) self.isTruncatedButton = Check('Truncated', False) self.isGroupOfButton = Check('Group Of', False) self.isDepictionButton = Check('Depiction', False) self.isInsideButton = Check('Inside', False) # Layout self.layout.setAlignment(Qt.AlignTop | Qt.AlignCenter) self.layout.addWidget(self.isOccludedButton) self.layout.addWidget(self.isTruncatedButton) self.layout.addWidget(self.isGroupOfButton) self.layout.addWidget(self.isDepictionButton) self.layout.addWidget(self.isInsideButton) # Styling self.layout.setContentsMargins(5, 10, 5, 10) self.layout.setSpacing(15) # Connections self.isOccludedButton.stateChanged.connect( boxManager.setNewBoxIsOccluded) self.isTruncatedButton.stateChanged.connect( boxManager.setNewBoxIsTruncated) self.isGroupOfButton.stateChanged.connect( boxManager.setNewBoxIsGroupOf) self.isDepictionButton.stateChanged.connect( boxManager.setNewBoxIsDepiction) self.isInsideButton.stateChanged.connect(boxManager.setNewBoxIsInside)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.setFixedWidth(255) self.setAttribute(Qt.WA_StyledBackground, True) self.menus = { 'Devices': ElchDeviceMenu(), 'Control': ElchControlMenu(), 'Plotting': ElchPlotMenu(), 'PID': ElchPidMenu() } vbox = QVBoxLayout() for menu in self.menus: self.menus[menu].setVisible(False) vbox.addWidget(self.menus[menu]) vbox.setSpacing(0) vbox.setContentsMargins(0, 0, 0, 0) self.setLayout(vbox) for key, button in self.menus['Devices'].unitbuttons.items(): button.clicked.connect( functools.partial(self.menus['Control'].change_units, key)) button.clicked.connect( functools.partial(self.menus['PID'].set_unit, key))
def __init__(self): # 从文件中加载定义的ui qfile_stats = QFile("ui/rz_end_test.ui") qfile_stats.open(QFile.ReadOnly) qfile_stats.close() # 从定义的Ui动态的创建相应的窗口对象 # 注意: 控件的返回值是一个窗体的对象 # 例如 self.ui.button self.ui.textEdit self.ui = QUiLoader().load(qfile_stats) # 图标显示区域 self.fig = plt.Figure() self.canvas = FC(self.fig) # self.ui.show_lable.to(self.ui) layout = QVBoxLayout(self.ui.show_lable) layout.addWidget(self.canvas) layout.setContentsMargins(0, 0, 0, 0) # 腾讯网数据显示按钮绑定事件 self.ui.province.clicked.connect(self.tencent_province_data) self.ui.data_all.clicked.connect(self.tencent_all_data) self.ui.city.clicked.connect(self.tencent_city) # 微博数据显示按钮绑定事件 self.ui.weibo_cloud.clicked.connect(self.weibo_cloud) self.ui.data_emotion.clicked.connect(self.weibo_emotion) self.ui.word_rank.clicked.connect(self.weibo_keyword) # 中国社会组织公共服务平台 self.ui.tfidf.clicked.connect(self.news_tfidf) self.ui.news_cloud.clicked.connect(self.news_wordcloud) self.ui.LDA.clicked.connect(self.news_lda)
def __init__(self, targetImage=None, axeSize=500, layer=None, parent=None): super().__init__(layer=layer, targetImage=targetImage, parent=parent) # options self.options = None self.mergeButton = QPushButton('Refresh') self.mergeButton.setMaximumWidth(80) self.warn = QLabel( 'Use the layer stack context menu\nto add or remove layers to merge.' ) # self.warn.setStyleSheet("QLabel {color : yellow; }") # button slot def f(): self.dataChanged.emit() self.mergeButton.pressed.connect(f) # layout l = QVBoxLayout() l.setAlignment(Qt.AlignTop | Qt.AlignHCenter) l.addSpacing(30) l.addWidget(self.mergeButton) l.addSpacing(100) l.addWidget(self.warn) l.setContentsMargins(20, 0, 20, 25) # left, top, right, bottom self.setLayout(l) self.adjustSize() self.setWhatsThis("""<b>Exposure Fusion</b> In the layer stack use the context menu to select the layers to be merged. Next, press the <i>Refresh</i> button.<br> """) # end setWhatsThis self.setDefaults()
def _set_layout(self): """ Creates this Widget's Layout """ box = QVBoxLayout() box.setContentsMargins(0, 0, 0, 0) box.addSpacing(20) AboutLabel("Made by\nOlivier Lécluse & Thomas Lécluse", box) logo = QLabel() logo.setPixmap(QPixmap("assets/LDC-light")) logo.setFixedSize(QSize(512, 222)) # Original dimension is 2048x888, we divided by 4 logo.setScaledContents(True) box.addWidget(logo) box.setAlignment(logo, Qt.AlignCenter) AboutLabel( f'{self.links_style}<a href="https://bradsprojects.com/digirule2/">> Digirule2 project <</a>', box, True) AboutLabel( f'{self.links_style}<a href="https://github.com/wawachief/DigiQt">> GitHub project <</a>', box, True) AboutLabel( f'Contact: {self.contact_style}<a href="mailto:[email protected]">[email protected]</a>', box, True) AboutLabel(f"Version: {self.config.get('main', 'APP_VERSION')}", box) box.addSpacing(20) self.setLayout(box)
def _init_widgets(self): self._linear_viewer = QLinearDisassembly(self.workspace, self, parent=self) self._flow_graph = QDisassemblyGraph(self.workspace, self, parent=self) self._feature_map = QFeatureMap(self, parent=self) self._statusbar = QDisasmStatusBar(self, parent=self) vlayout = QVBoxLayout() vlayout.addWidget(self._feature_map) vlayout.addWidget(self._flow_graph) vlayout.addWidget(self._linear_viewer) vlayout.addWidget(self._statusbar) vlayout.setContentsMargins(0, 0, 0, 0) self._feature_map.setMaximumHeight(25) vlayout.setStretchFactor(self._feature_map, 0) vlayout.setStretchFactor(self._flow_graph, 1) vlayout.setStretchFactor(self._linear_viewer, 1) vlayout.setStretchFactor(self._statusbar, 0) hlayout = QHBoxLayout() hlayout.addLayout(vlayout) self.setLayout(hlayout) self.display_disasm_graph() # self.display_linear_viewer() self.workspace.plugins.instrument_disassembly_view(self)
def __init__(self, parent, *db_names): """Initialize class. Args: parent (QWidget): the parent widget db_names (str): database names """ super().__init__(parent) self.setWindowModality(Qt.ApplicationModal) self.commit_msg = None self.setWindowTitle('Commit changes to {}'.format(",".join(db_names))) form = QVBoxLayout(self) form.setContentsMargins(4, 4, 4, 4) self.action_accept = QAction(self) self.action_accept.setShortcut( QApplication.translate("Dialog", "Ctrl+Return", None, -1)) self.action_accept.triggered.connect(self.accept) self.action_accept.setEnabled(False) self.commit_msg_edit = QPlainTextEdit(self) self.commit_msg_edit.setPlaceholderText( 'Commit message \t(press Ctrl+Enter to commit)') self.commit_msg_edit.addAction(self.action_accept) button_box = QDialogButtonBox() button_box.addButton(QDialogButtonBox.Cancel) self.commit_button = button_box.addButton('Commit', QDialogButtonBox.AcceptRole) button_box.accepted.connect(self.accept) button_box.rejected.connect(self.reject) form.addWidget(self.commit_msg_edit) form.addWidget(button_box) self.setAttribute(Qt.WA_DeleteOnClose) self.commit_msg_edit.textChanged.connect(self.receive_text_changed) self.receive_text_changed()
def _init_widgets(self, selection_callback=None): # function table view self._table_view = QFunctionTableView(self, self.workspace, selection_callback) # filter text box self._filter_box = QFunctionTableFilterBox(self) self._filter_box.hide() self._filter_box.textChanged.connect(self._on_filter_box_text_changed) self._filter_box.returnPressed.connect( self._on_filter_box_return_pressed) # toolbar self._toolbar = FunctionTableToolbar(self) # layout layout = QVBoxLayout() layout.addWidget(self._toolbar.qtoolbar()) layout.addWidget(self._filter_box) layout.addWidget(self._table_view) layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout)
def __init__(self, app, parent=None): super(MainWindow, self).__init__(parent) self.imagesDir = app.dir + '/images/' self.setWindowIcon(QIcon(self.imagesDir + 'icon.png')) self.path = '' self.settings = QSettings() self.lastDir = self.settings.value('lastDir', '') self.setMinimumWidth(540) self.supportedFormats = [] for f in QImageReader.supportedImageFormats(): self.supportedFormats.append(str(f.data(), encoding="utf-8")) self.fileWatcher = QFileSystemWatcher() self.fileWatcher.fileChanged.connect(self.fileChanged) # widgets self.showPixmapWidget = None self.tileWidthSpinBox = QSpinBox() self.tileWidthSpinBox.setValue(16) self.tileWidthSpinBox.setFixedWidth(50) self.tileWidthSpinBox.setMinimum(1) self.tileHeightSpinBox = QSpinBox() self.tileHeightSpinBox.setValue(16) self.tileHeightSpinBox.setFixedWidth(50) self.tileHeightSpinBox.setMinimum(1) self.paddingSpinBox = QSpinBox() self.paddingSpinBox.setFixedWidth(50) self.paddingSpinBox.setMinimum(1) self.transparentCheckbox = QCheckBox("Transparent") self.transparentCheckbox.setChecked(True) self.transparentCheckbox.stateChanged.connect(self.transparentChanged) self.backgroundColorEdit = ColorEdit() self.backgroundColorEdit.setEnabled(False) self.backgroundColorLabel = QLabel("Background color:") self.backgroundColorLabel.setEnabled(False) self.forcePotCheckBox = QCheckBox("Force PoT") self.forcePotCheckBox.setChecked(True) self.forcePotCheckBox.stateChanged.connect(self.forcePotChanged) self.reorderTilesCheckBox = QCheckBox("Reorder tiles") self.generateAndExportButton = QPushButton("Generate and export") self.generateAndExportButton.setFixedHeight(32) self.generateAndExportButton.clicked.connect(self.generateAndExportClicked) self.generateAndExportButton.setEnabled(False) self.pixmapWidget = PixmapWidget() self.pixmapWidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.pixmapWidget.setPixmap(self.createDropTextPixmap()) self.pixmapWidget.dropSignal.connect(self.fileDropped) self.pixmapWidget.setMinimumHeight(300) # load settings self.tileWidthSpinBox.setValue(int(self.settings.value('tileWidth', 16))) self.tileHeightSpinBox.setValue(int(self.settings.value('tileHeight', 16))) self.paddingSpinBox.setValue(int(self.settings.value('padding', 1))) self.forcePotCheckBox.setChecked(True if self.settings.value('forcePot', 'true') == 'true' else False) self.reorderTilesCheckBox.setChecked(True if self.settings.value('reorderTiles', 'false') == 'true' else False) self.transparentCheckbox.setChecked(True if self.settings.value('transparent', 'false') == 'true' else False) self.backgroundColorEdit.setColorText(str(self.settings.value('backgroundColor', '#FF00FF'))) self.restoreGeometry(QByteArray(self.settings.value('MainWindow/geometry'))) self.restoreState(QByteArray(self.settings.value('MainWindow/windowState'))) # layout hl1 = QHBoxLayout() hl1.setContentsMargins(5, 5, 5, 5) hl1.addWidget(QLabel("Tile width:")) hl1.addSpacing(5) hl1.addWidget(self.tileWidthSpinBox) hl1.addSpacing(15) hl1.addWidget(QLabel("Tile height:")) hl1.addSpacing(5) hl1.addWidget(self.tileHeightSpinBox) hl1.addSpacing(15) hl1.addWidget(QLabel("Padding:")) hl1.addSpacing(5) hl1.addWidget(self.paddingSpinBox) hl1.addSpacing(15) hl1.addWidget(self.forcePotCheckBox) hl1.addSpacing(15) hl1.addWidget(self.reorderTilesCheckBox) hl1.addStretch() hl2 = QHBoxLayout() hl2.setContentsMargins(5, 5, 5, 5) hl2.addWidget(self.transparentCheckbox) hl2.addSpacing(15) hl2.addWidget(self.backgroundColorLabel) hl2.addSpacing(5) hl2.addWidget(self.backgroundColorEdit) hl2.addStretch() hl3 = QHBoxLayout() hl3.setContentsMargins(5, 5, 5, 5) hl3.addWidget(self.generateAndExportButton) vl = QVBoxLayout() vl.setContentsMargins(0, 0, 0, 0) vl.setSpacing(0) vl.addLayout(hl1) vl.addLayout(hl2) vl.addWidget(self.pixmapWidget) vl.addLayout(hl3) w = QWidget() w.setLayout(vl) self.setCentralWidget(w) self.setTitle()