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


Python QGridLayout.setSpacing方法代码示例

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


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

示例1: __init__

# 需要导入模块: from PyQt4.Qt import QGridLayout [as 别名]
# 或者: from PyQt4.Qt.QGridLayout import setSpacing [as 别名]
    def __init__(self, show_strength=True, parent=None):
        super(PinMatrixWidget, self).__init__(parent)
        
        self.password = QLineEdit()
        self.password.setValidator(QRegExpValidator(QRegExp('[1-9]+'), None))
        self.password.setEchoMode(QLineEdit.Password)
        QObject.connect(self.password, SIGNAL('textChanged(QString)'), self._password_changed)

        self.strength = QLabel()
        self.strength.setMinimumWidth(75)
        self.strength.setAlignment(Qt.AlignCenter)
        self._set_strength(0)

        grid = QGridLayout()
        grid.setSpacing(0)
        for y in range(3)[::-1]:
            for x in range(3):
                button = PinButton(self.password, x + y * 3 + 1)
                button.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
                button.setFocusPolicy(Qt.NoFocus)
                grid.addWidget(button, 3 - y, x)

        hbox = QHBoxLayout()
        hbox.addWidget(self.password)
        if show_strength:
            hbox.addWidget(self.strength)

        vbox = QVBoxLayout()
        vbox.addLayout(grid)
        vbox.addLayout(hbox)
        self.setLayout(vbox)
开发者ID:adballar,项目名称:python-trezor,代码行数:33,代码来源:pinmatrix.py

示例2: ConfigWidget

# 需要导入模块: from PyQt4.Qt import QGridLayout [as 别名]
# 或者: from PyQt4.Qt.QGridLayout import setSpacing [as 别名]
class ConfigWidget(QWidget):
  'Configuration widget'
  def __init__(self):
    QWidget.__init__(self)
    self.layout = QGridLayout()
    self.layout.setSpacing(10)
    self.setLayout(self.layout)

    self.key_label = QLabel('&api key:')
    self.key_msg = QLineEdit(self)
    self.key_msg.setText(PREFS['api_key'])
    self.layout.addWidget(self.key_label, 1, 0)
    self.layout.addWidget(self.key_msg, 1, 1)
    self.key_label.setBuddy(self.key_msg)

    self.threads_label = QLabel('&worker_threads:')
    self.threads_msg = QLineEdit(self)
    self.threads_msg.setText(unicode(PREFS['worker_threads']))
    self.layout.addWidget(self.threads_label, 2, 0)
    self.layout.addWidget(self.threads_msg, 2, 1)
    self.threads_label.setBuddy(self.threads_msg)

  def save_settings(self):
    'Apply new settings value'
    PREFS['api_key'] = unicode(self.key_msg.text())
    PREFS['worker_threads'] = int(self.threads_msg.text())
    pycomicvine.api_key = PREFS['api_key']
开发者ID:0tertra,项目名称:calibre-comicvine,代码行数:29,代码来源:config.py

示例3: __init__

# 需要导入模块: from PyQt4.Qt import QGridLayout [as 别名]
# 或者: from PyQt4.Qt.QGridLayout import setSpacing [as 别名]
    def __init__(self, win):
        self.xmlfile = os.path.join(_sponsordir, 'sponsors.xml')
        self.win = win

        self.needToAsk = False
        self.downloadSponsors = False
        threading.Thread.__init__(self)

        if not self.refreshWanted():
            return
        if env.prefs[sponsor_permanent_permission_prefs_key]:
            # We have a permanent answer so no need for a dialog
            if env.prefs[sponsor_download_permission_prefs_key]:
                self.downloadSponsors = True
            return

        self.needToAsk = True
        QDialog.__init__(self, None)
        self.setObjectName("Permission")
        self.setModal(True) #This fixes bug 2296. Mitigates bug 2297
        layout = QGridLayout()
        self.setLayout(layout)
        layout.setMargin(0)
        layout.setSpacing(0)
        layout.setObjectName("PermissionLayout")
        self.text_browser = QTextBrowser(self)
        self.text_browser.setObjectName("text_browser")
        layout.addWidget(self.text_browser,0,0,1,4)
        self.text_browser.setMinimumSize(400, 80)
        self.setWindowTitle('May we use your network connection?')
        self.setWindowIcon(geticon('ui/border/MainWindow.png'))
        self.text_browser.setPlainText(self.text)
        self.accept_button = QPushButton(self)
        self.accept_button.setObjectName("accept_button")
        self.accept_button.setText("Always OK")
        self.accept_once_button = QPushButton(self)
        self.accept_once_button.setObjectName("accept_once_button")
        self.accept_once_button.setText("OK now")
        self.decline_once_button = QPushButton(self)
        self.decline_once_button.setObjectName("decline_once_button")
        self.decline_once_button.setText("Not now")
        self.decline_always_button = QPushButton(self)
        self.decline_always_button.setObjectName("decline_always_button")
        self.decline_always_button.setText("Never")
        layout.addWidget(self.accept_button,1,0)
        layout.addWidget(self.accept_once_button,1,1)
        layout.addWidget(self.decline_once_button,1,2)
        layout.addWidget(self.decline_always_button,1,3)
        self.connect(self.accept_button,SIGNAL("clicked()"),self.acceptAlways)
        self.connect(self.accept_once_button,SIGNAL("clicked()"),self.acceptJustOnce)
        self.connect(self.decline_once_button,SIGNAL("clicked()"),self.declineJustOnce)
        self.connect(self.decline_always_button,SIGNAL("clicked()"),self.declineAlways)
开发者ID:alaindomissy,项目名称:nanoengineer,代码行数:54,代码来源:Sponsors.py

示例4: _createSponsorButton

# 需要导入模块: from PyQt4.Qt import QGridLayout [as 别名]
# 或者: from PyQt4.Qt.QGridLayout import setSpacing [as 别名]
    def _createSponsorButton(self):
        """
        Creates the Property Manager sponsor button, which contains
        a QPushButton inside of a QGridLayout inside of a QFrame.
        The sponsor logo image is not loaded here.
        """
        
        # Sponsor button (inside a frame)
        self.sponsor_frame = QFrame(self)
        self.sponsor_frame.setFrameShape(QFrame.NoFrame)
        self.sponsor_frame.setFrameShadow(QFrame.Plain)

        SponsorFrameGrid = QGridLayout(self.sponsor_frame)
        SponsorFrameGrid.setMargin(PM_SPONSOR_FRAME_MARGIN)
        SponsorFrameGrid.setSpacing(PM_SPONSOR_FRAME_SPACING) # Has no effect.

        self.sponsor_btn = QPushButton(self.sponsor_frame)
        self.sponsor_btn.setAutoDefault(False)
        self.sponsor_btn.setFlat(True)
        self.connect(self.sponsor_btn,
                     SIGNAL("clicked()"),
                     self.open_sponsor_homepage)
        
        SponsorFrameGrid.addWidget(self.sponsor_btn, 0, 0, 1, 1)
        
        self.vBoxLayout.addWidget(self.sponsor_frame)

        button_whatsthis_widget = self.sponsor_btn
        #bruce 070615 bugfix -- put tooltip & whatsthis on self.sponsor_btn, 
        # not self.
        # [self.sponsor_frame might be another possible place to put them.]
        
        button_whatsthis_widget.setWhatsThis("""<b>Sponsor Button</b>
            <p>When clicked, this sponsor logo will display a short 
            description about a NanoEngineer-1 sponsor. This can 
            be an official sponsor or credit given to a contributor 
            that has helped code part or all of this command. 
            A link is provided in the description to learn more 
            about this sponsor.</p>""")
        
        button_whatsthis_widget.setToolTip("NanoEngineer-1 Sponsor Button")
        
        return
开发者ID:ematvey,项目名称:NanoEngineer-1,代码行数:45,代码来源:PM_Dialog.py

示例5: PM_GroupBox

# 需要导入模块: from PyQt4.Qt import QGridLayout [as 别名]
# 或者: from PyQt4.Qt.QGridLayout import setSpacing [as 别名]

#.........这里部分代码省略.........
                             Defaults} button is clicked, regardless thier own 
                             I{setAsDefault} value.
        @type  setAsDefault: bool
        
        @see: U{B{QGroupBox}<http://doc.trolltech.com/4/qgroupbox.html>}
        """
      
        QGroupBox.__init__(self)
        
        self.parentWidget = parentWidget
        
        # Calling addWidget() here is important. If done at the end,
        # the title button does not get assigned its palette for some 
        # unknown reason. Mark 2007-05-20.
        # Add self to PropMgr's vBoxLayout
        if parentWidget:
            parentWidget._groupBoxCount += 1
            parentWidget.vBoxLayout.addWidget(self)
            parentWidget._widgetList.append(self)
            
        _groupBoxCount = 0
        self._widgetList = []
        self._title = title
        self.setAsDefault = setAsDefault
        
        self.setAutoFillBackground(True)
        self.setStyleSheet(self._getStyleSheet())
        
        # Create vertical box layout which will contain two widgets:
        # - the group box title button (or title) on row 0.
        # - the container widget for all PM widgets on row 1.
        self._vBoxLayout = QVBoxLayout(self)
        self._vBoxLayout.setMargin(0)
        self._vBoxLayout.setSpacing(0)
        
        # _containerWidget contains all PM widgets in this group box.
        # Its sole purpose is to easily support the collapsing and
        # expanding of a group box by calling this widget's hide()
        # and show() methods.
        self._containerWidget = QWidget()
        
        self._vBoxLayout.insertWidget(0, self._containerWidget)
        
        # Create vertical box layout
        self.vBoxLayout = QVBoxLayout(self._containerWidget)
        self.vBoxLayout.setMargin(PM_GROUPBOX_VBOXLAYOUT_MARGIN)
        self.vBoxLayout.setSpacing(PM_GROUPBOX_VBOXLAYOUT_SPACING)
        
        # Create grid layout
        self.gridLayout = QGridLayout()
        self.gridLayout.setMargin(PM_GRIDLAYOUT_MARGIN)
        self.gridLayout.setSpacing(PM_GRIDLAYOUT_SPACING)
        
        # Insert grid layout in its own vBoxLayout
        self.vBoxLayout.addLayout(self.gridLayout)
        
        # Add title button (or just a title if the parent is not a PM_Dialog).
        if not parentWidget or isinstance(parentWidget, PM_GroupBox):
            self.setTitle(title)
        else: # Parent is a PM_Dialog, so add a title button.
            if not self.titleButtonRequested:
                self.setTitle(title)
            else:
                self.titleButton = self._getTitleButton(self, title)
                self._vBoxLayout.insertWidget(0, self.titleButton)
                if connectTitleButton:
开发者ID:ematvey,项目名称:NanoEngineer-1,代码行数:70,代码来源:PM_GroupBox.py

示例6: PM_DockWidget

# 需要导入模块: from PyQt4.Qt import QGridLayout [as 别名]
# 或者: from PyQt4.Qt.QGridLayout import setSpacing [as 别名]
class PM_DockWidget(QDockWidget):
    """
    PM_DockWidget class provides a dockable widget that can either be docked
    inside a PropertyManager OR can be docked in the MainWindow depending
    on the <parentWidget> . see DnaSequenceEditor.py for an example.
    The dockWidget has its own layout and containerwidget which makes it easy
    to add various children widgets  similar to how its done in PM_GroupBox
    """


    def __init__(self, parentWidget, title = "", showWidget = True):
        """
        Constructor for PM_dockWidget

        @param showWidget: If true, this class will show the widget
        immediately in the __init__ method itself. This is the default behavior
        and subclasses may pass appropriate value to this flag
        @type showWidget: bool
        """
        self.labelWidget  = None
        self._title         = ""
        self._widgetList    = []
        self._rowCount      = 0

        QDockWidget.__init__(self, parentWidget)

        self.parentWidget = parentWidget

        self._title = title

        self.label = ''
        self.labelColumn = 0
        self.spanWidth = True
        self.labelWidget = None

        if self.label: # Create this widget's QLabel.
            self.labelWidget = QLabel()
            self.labelWidget.setText(self.label)

        self.setEnabled(True)
        self.setFloating(False)
        self.setVisible(showWidget)
        self.setWindowTitle(self._title)
        self.setAutoFillBackground(True)
        self.setPalette(getPalette( None,
                                    QPalette.Window,
                                    pmGrpBoxColor))

        self.parentWidget.addDockWidget(Qt.BottomDockWidgetArea, self)

        #Define layout
        self._containerWidget = QWidget()
        self.setWidget(self._containerWidget)

        # Create vertical box layout
        self.vBoxLayout = QVBoxLayout(self._containerWidget)
        self.vBoxLayout.setMargin(1)
        self.vBoxLayout.setSpacing(0)

        # Create grid layout
        self.gridLayout = QGridLayout()
        self.gridLayout.setMargin(1)
        self.gridLayout.setSpacing(1)

        # Insert grid layout in its own vBoxLayout
        self.vBoxLayout.addLayout(self.gridLayout)

        #self.parentWidget.addPmWidget(self)
        self._loadWidgets()

        try:
            self._addWhatsThisText()
        except:
            print_compact_traceback("Error loading whatsthis text for this " \
                                    "property manager dock widget.")

        try:
            self._addToolTipText()
        except:
            print_compact_traceback("Error loading tool tip text for this " \
                                    "property manager dock widget.")

    def _loadWidgets(self):
        """
        Subclasses should override this method. Default implementation does
        nothing.
        @see: DnaSequenceEditor._loadWidgets
        """
        pass

    def _addWhatsThisText(self):
        """
        Add 'What's This' help text for self and child widgets.
        Subclasses should override this method.
        """
        pass

    def _addToolTipText(self):
        """
        Add 'Tool tip' help text for self and child widgets.
#.........这里部分代码省略.........
开发者ID:alaindomissy,项目名称:nanoengineer,代码行数:103,代码来源:PM_DockWidget.py

示例7: __init__

# 需要导入模块: from PyQt4.Qt import QGridLayout [as 别名]
# 或者: from PyQt4.Qt.QGridLayout import setSpacing [as 别名]
 def __init__(self, win = None):
     import string
     QDialog.__init__(self, win)
     self.setWindowTitle('Manually edit sim parameters')
     layout = QGridLayout(self)
     layout.setMargin(1)
     layout.setSpacing(-1)
     layout.setObjectName("SimParameterDialog")
     for i in range(len(_sim_param_table)):
         attr, paramtype = _sim_param_table[i]
         current = sim_param_values[attr]
         currentStr = str(current)
         label = QLabel(attr + ' (' + paramtype + ')', self)
         layout.addWidget(label, i, 0)
         if paramtype == BOOLEAN:
             label = QLabel(currentStr, self)
             layout.addWidget(label, i, 1)
             def falseFunc(attr = attr, label = label):
                 sim_param_values[attr] = False
                 label.setText('False')
             def trueFunc(attr = attr, label = label):
                 sim_param_values[attr] = True
                 label.setText('True')
             btn = QPushButton(self)
             btn.setText('True')
             layout.addWidget(btn, i, 2)
             self.connect(btn,SIGNAL("clicked()"), trueFunc)
             btn = QPushButton(self)
             btn.setText('False')
             layout.addWidget(btn, i, 3)
             self.connect(btn,SIGNAL("clicked()"), falseFunc)
         else:
             label = QLabel(self)
             label.setText(currentStr)
             layout.addWidget(label, i, 1)
             linedit = QLineEdit(self)
             linedit.setText(currentStr)
             layout.addWidget(linedit, i, 2)
             def change(attr = attr, linedit = linedit,
                        paramtype = paramtype, label = label):
                 txt = str(linedit.text())
                 label.setText(txt)
                 if paramtype == STRING:
                     sim_param_values[attr] = txt
                 elif paramtype == INT:
                     if txt.startswith('0x') or txt.startswith('0X'):
                         n = string.atoi(txt[2:], 16)
                     else:
                         n = string.atoi(txt)
                     sim_param_values[attr] = n
                 elif paramtype == FLOAT:
                     sim_param_values[attr] = string.atof(txt)
             btn = QPushButton(self)
             btn.setText('OK')
             layout.addWidget(btn, i, 3)
             self.connect(btn, SIGNAL("clicked()"), change)
     btn = QPushButton(self)
     btn.setText('Done')
     layout.addWidget(btn, len(_sim_param_table), 0, len(_sim_param_table), 4)
     def done(self = self):
         global sim_params_set
         sim_params_set = True
         #import pprint
         #pprint.pprint(sim_param_values)
         self.close()
     self.connect(btn, SIGNAL("clicked()"), done)
开发者ID:ematvey,项目名称:NanoEngineer-1,代码行数:68,代码来源:DebugMenuMixin.py

示例8: MainWindow

# 需要导入模块: from PyQt4.Qt import QGridLayout [as 别名]
# 或者: from PyQt4.Qt.QGridLayout import setSpacing [as 别名]
class MainWindow(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)
        self.setWindowTitle("My Main Window")
        self.setMinimumWidth(MAIN_WINDOW_SIZE[0])
        self.setMinimumHeight(MAIN_WINDOW_SIZE[1])

        self.statusbar = QtGui.QStatusBar(self)
        self.statusbar.showMessage("Status message")
        self.setStatusBar(self.statusbar)

        ################################################

        self.menubar = self.menuBar()
        # Any menu action makes the status bar message disappear

        fileMenu = QtGui.QMenu(self.menubar)
        fileMenu.setTitle("File")
        self.menubar.addAction(fileMenu.menuAction())

        newAction = QtGui.QAction("New", self)
        newAction.setIcon(QtGui.QtIcon(icons + '/GroupPropDialog_image0.png'))
        fileMenu.addAction(newAction)
        openAction = QtGui.QAction("Open", self)
        openAction.setIcon(QtGui.QtIcon(icons + "/MainWindowUI_image1"))
        fileMenu.addAction(openAction)
        saveAction = QtGui.QAction("Save", self)
        saveAction.setIcon(QtGui.QtIcon(icons + "/MainWindowUI_image2"))
        fileMenu.addAction(saveAction)

        self.connect(newAction,SIGNAL("activated()"),self.fileNew)
        self.connect(openAction,SIGNAL("activated()"),self.fileOpen)
        self.connect(saveAction,SIGNAL("activated()"),self.fileSave)

        for otherMenuName in ('Edit', 'View', 'Display', 'Select', 'Modify', 'NanoHive-1'):
            otherMenu = QtGui.QMenu(self.menubar)
            otherMenu.setTitle(otherMenuName)
            self.menubar.addAction(otherMenu.menuAction())

        helpMenu = QtGui.QMenu(self.menubar)
        helpMenu.setTitle("Help")
        self.menubar.addAction(helpMenu.menuAction())

        aboutAction = QtGui.QAction("About", self)
        aboutAction.setIcon(QtGui.QtIcon(icons + '/MainWindowUI_image0.png'))
        helpMenu.addAction(aboutAction)

        self.connect(aboutAction,SIGNAL("activated()"),self.helpAbout)

        ##############################################

        self.setMenuBar(self.menubar)

        centralwidget = QWidget()
        self.setCentralWidget(centralwidget)
        layout = QVBoxLayout(centralwidget)
        layout.setMargin(0)
        layout.setSpacing(0)
        middlewidget = QWidget()

        self.bigButtons = QWidget()
        bblo = QHBoxLayout(self.bigButtons)
        bblo.setMargin(0)
        bblo.setSpacing(0)
        self.bigButtons.setMinimumHeight(50)
        self.bigButtons.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        for name in ('Features', 'Sketch', 'Build', 'Dimension', 'Simulator'):
            btn = QPushButton(self.bigButtons)
            btn.setMaximumWidth(80)
            btn.setMinimumHeight(50)
            btn.setText(name)
            self.bigButtons.layout().addWidget(btn)
        self.bigButtons.hide()
        layout.addWidget(self.bigButtons)

        self.littleIcons = QWidget()
        self.littleIcons.setMinimumHeight(30)
        self.littleIcons.setMaximumHeight(30)
        lilo = QHBoxLayout(self.littleIcons)
        lilo.setMargin(0)
        lilo.setSpacing(0)
        pb = QPushButton(self.littleIcons)
        pb.setIcon(QIcon(icons + '/GroupPropDialog_image0.png'))
        self.connect(pb,SIGNAL("clicked()"),self.fileNew)
        lilo.addWidget(pb)
        for x in "1 2 4 5 6 7 8 18 42 10 43 150 93 94 97 137".split():
            pb = QPushButton(self.littleIcons)
            pb.setIcon(QIcon(icons + '/MainWindowUI_image' + x + '.png'))
            lilo.addWidget(pb)
        layout.addWidget(self.littleIcons)

        layout.addWidget(middlewidget)

        self.layout = QGridLayout(middlewidget)
        self.layout.setMargin(0)
        self.layout.setSpacing(2)
        self.gridPosition = GridPosition()
        self.numParts = 0

        self.show()
#.........这里部分代码省略.........
开发者ID:alaindomissy,项目名称:nanoengineer,代码行数:103,代码来源:uiPrototype.py


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