当前位置: 首页>>代码示例>>Python>>正文


Python QPushButton.setFlat方法代码示例

本文整理汇总了Python中python_qt_binding.QtGui.QPushButton.setFlat方法的典型用法代码示例。如果您正苦于以下问题:Python QPushButton.setFlat方法的具体用法?Python QPushButton.setFlat怎么用?Python QPushButton.setFlat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在python_qt_binding.QtGui.QPushButton的用法示例。


在下文中一共展示了QPushButton.setFlat方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _create_tag_button

# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setFlat [as 别名]
 def _create_tag_button(self, parent=None):
     btn = QPushButton(parent)
     btn.setObjectName("tagButton")
     btn.setText(self._translate("Add &tag"))
     btn.setShortcut("Ctrl+T")
     btn.setToolTip('Adds a ROS launch tag to launch file (Ctrl+T)')
     btn.setMenu(self._create_tag_menu(btn))
     btn.setFlat(True)
     return btn
开发者ID:fkie,项目名称:multimaster_fkie,代码行数:11,代码来源:editor.py

示例2: Editor

# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setFlat [as 别名]
class Editor(QMainWindow):
    '''
    Creates a dialog to edit a launch file.
    '''
    finished_signal = Signal(list)
    '''
    finished_signal has as parameter the filenames of the initialization and is emitted, if this
    dialog was closed.
    '''

    def __init__(self, filenames, search_text='', parent=None):
        '''
        @param filenames: a list with filenames. The last one will be activated.
        @type filenames: C{[str, ...]}
        @param search_text: if not empty, searches in new document for first occurrence of the given text
        @type search_text: C{str} (Default: C{Empty String})
        '''
        QMainWindow.__init__(self, parent)
        self.setObjectName(' - '.join(['Editor', str(filenames)]))
        self.setAttribute(Qt.WA_DeleteOnClose, True)
        self.setWindowFlags(Qt.Window)
        self.mIcon = QIcon(":/icons/crystal_clear_edit_launch.png")
        self._error_icon = QIcon(":/icons/crystal_clear_warning.png")
        self._empty_icon = QIcon()
        self.setWindowIcon(self.mIcon)
        window_title = "ROSLaunch Editor"
        if filenames:
            window_title = self.__getTabName(filenames[0])
        self.setWindowTitle(window_title)
        self.init_filenames = list(filenames)
        self._search_thread = None
        # list with all open files
        self.files = []
        # create tabs for files
        self.main_widget = QWidget(self)
        self.verticalLayout = QVBoxLayout(self.main_widget)
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout.setSpacing(1)
        self.verticalLayout.setObjectName("verticalLayout")

        self.tabWidget = EditorTabWidget(self)
        self.tabWidget.setTabPosition(QTabWidget.North)
        self.tabWidget.setDocumentMode(True)
        self.tabWidget.setTabsClosable(True)
        self.tabWidget.setMovable(False)
        self.tabWidget.setObjectName("tabWidget")
        self.tabWidget.tabCloseRequested.connect(self.on_close_tab)

        self.verticalLayout.addWidget(self.tabWidget)
        self.buttons = self._create_buttons()
        self.verticalLayout.addWidget(self.buttons)
        self.setCentralWidget(self.main_widget)

        self.find_dialog = TextSearchFrame(self.tabWidget, self)
        self.find_dialog.search_result_signal.connect(self.on_search_result)
        self.find_dialog.replace_signal.connect(self.on_replace)
        self.addDockWidget(Qt.RightDockWidgetArea, self.find_dialog)
        # open the files
        for f in filenames:
            if f:
                self.on_load_request(os.path.normpath(f), search_text)
        self.readSettings()
        self.find_dialog.setVisible(False)

#  def __del__(self):
#    print "******** destroy", self.objectName()

    def _create_buttons(self):
        # create the buttons line
        self.buttons = QWidget(self)
        self.horizontalLayout = QHBoxLayout(self.buttons)
        self.horizontalLayout.setContentsMargins(4, 0, 4, 0)
        self.horizontalLayout.setObjectName("horizontalLayout")
        # add the search button
        self.searchButton = QPushButton(self)
        self.searchButton.setObjectName("searchButton")
#        self.searchButton.clicked.connect(self.on_shortcut_find)
        self.searchButton.toggled.connect(self.on_toggled_find)
        self.searchButton.setText(self._translate("&Find"))
        self.searchButton.setToolTip('Open a search dialog (Ctrl+F)')
        self.searchButton.setFlat(True)
        self.searchButton.setCheckable(True)
        self.horizontalLayout.addWidget(self.searchButton)
        # add the replace button
        self.replaceButton = QPushButton(self)
        self.replaceButton.setObjectName("replaceButton")
#        self.replaceButton.clicked.connect(self.on_shortcut_replace)
        self.replaceButton.toggled.connect(self.on_toggled_replace)
        self.replaceButton.setText(self._translate("&Replace"))
        self.replaceButton.setToolTip('Open a search&replace dialog (Ctrl+R)')
        self.replaceButton.setFlat(True)
        self.replaceButton.setCheckable(True)
        self.horizontalLayout.addWidget(self.replaceButton)
        # add the goto button
        self.gotoButton = QPushButton(self)
        self.gotoButton.setObjectName("gotoButton")
        self.gotoButton.clicked.connect(self.on_shortcut_goto)
        self.gotoButton.setText(self._translate("&Goto line"))
        self.gotoButton.setShortcut("Ctrl+G")
        self.gotoButton.setToolTip('Open a goto dialog (Ctrl+G)')
#.........这里部分代码省略.........
开发者ID:fkie,项目名称:multimaster_fkie,代码行数:103,代码来源:editor.py

示例3: CapabilityControlWidget

# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setFlat [as 别名]
class CapabilityControlWidget(QFrame):
    '''
    The control widget contains buttons for control a capability. Currently this
    are C{On} and C{Off} buttons. Additionally, the state of the capability is
    color coded.
    '''

    start_nodes_signal = Signal(str, str, list)
    '''@ivar: the signal is emitted to start on host(described by masteruri) the nodes described in the list, Parameter(masteruri, config, nodes).'''

    stop_nodes_signal = Signal(str, list)
    '''@ivar: the signal is emitted to stop on masteruri the nodes described in the list.'''

    def __init__(self, masteruri, cfg, ns, nodes, parent=None):
        QFrame.__init__(self, parent)
        self._masteruri = masteruri
        self._nodes = {cfg: {ns: nodes}}
        frame_layout = QVBoxLayout(self)
        frame_layout.setContentsMargins(0, 0, 0, 0)
        # create frame for warning label
        self.warning_frame = warning_frame = QFrame(self)
        warning_layout = QHBoxLayout(warning_frame)
        warning_layout.setContentsMargins(0, 0, 0, 0)
        warning_layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding))
        self.warning_label = QLabel()
        icon = QIcon(':/icons/crystal_clear_warning.png')
        self.warning_label.setPixmap(icon.pixmap(QSize(40, 40)))
        self.warning_label.setToolTip('Multiple configuration for same node found!\nA first one will be selected for the start a node!')
        warning_layout.addWidget(self.warning_label)
        warning_layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding))
        frame_layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding))
        frame_layout.addWidget(warning_frame)
        # create frame for start/stop buttons
        buttons_frame = QFrame()
        buttons_layout = QHBoxLayout(buttons_frame)
        buttons_layout.setContentsMargins(0, 0, 0, 0)
        buttons_layout.addItem(QSpacerItem(20, 20))
        self.on_button = QPushButton()
        self.on_button.setFlat(False)
        self.on_button.setText("On")
        self.on_button.clicked.connect(self.on_on_clicked)
        buttons_layout.addWidget(self.on_button)

        self.off_button = QPushButton()
        self.off_button.setFlat(True)
        self.off_button.setText("Off")
        self.off_button.clicked.connect(self.on_off_clicked)
        buttons_layout.addWidget(self.off_button)
        buttons_layout.addItem(QSpacerItem(20, 20))
        frame_layout.addWidget(buttons_frame)
        frame_layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding))
        self.warning_frame.setVisible(False)

    def hasConfigs(self):
        '''
        @return: True, if a configurations for this widget are available.
        @rtype: bool
        '''
        return len(self._nodes) > 0

    def nodes(self, cfg=''):
        '''
        @return: the list with nodes required by this capability. The nodes are
        defined by ROS full name.
        @rtype: C{[str]}
        '''
        try:
            if cfg:
                return [n for l in self._nodes[cfg].itervalues() for n in l]
            else:
                return [n for c in self._nodes.itervalues() for l in c.itervalues() for n in l]
        except:
            return []

    def setNodeState(self, running_nodes, stopped_nodes, error_nodes):
        '''
        Sets the state of this capability.
        @param running_nodes: a list with running nodes.
        @type running_nodes: C{[str]}
        @param stopped_nodes: a list with not running nodes.
        @type stopped_nodes: C{[str]}
        @param error_nodes: a list with nodes having a problem.
        @type error_nodes: C{[str]}
        '''
        self.setAutoFillBackground(True)
        self.setBackgroundRole(QPalette.Base)
        palette = QPalette()
        if error_nodes:
            brush = QBrush(QColor(255, 100, 0))
        elif running_nodes and stopped_nodes:
            brush = QBrush(QColor(140, 185, 255))  # 30, 50, 255
        elif running_nodes:
            self.on_button.setFlat(True)
            self.off_button.setFlat(False)
            brush = QBrush(QColor(59, 223, 18))  # 59, 223, 18
        else:
            brush = QBrush(QColor(255, 255, 255))
            self.on_button.setFlat(False)
            self.off_button.setFlat(True)
        palette.setBrush(QPalette.Active, QPalette.Base, brush)
#.........这里部分代码省略.........
开发者ID:zhouchengming1,项目名称:multimaster_fkie,代码行数:103,代码来源:capability_table.py


注:本文中的python_qt_binding.QtGui.QPushButton.setFlat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。