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


Python QWidget.setContentsMargins方法代码示例

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


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

示例1: createDialogCenterWidget

# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setContentsMargins [as 别名]
 def createDialogCenterWidget(self, formation):
   '''
   Scrolling list of editor widgets for editing StyleProperty.
   List comprises labels, and labeled editing widgets.
   But labels are indented as a tree.
   
   Canonical way: nest widget, layout, scrollarea
   '''
   formationLayout = formation.getLayout(top=True)
   viewport = QWidget()
   viewport.setLayout(formationLayout)
   
   # A hack so scroll bars not obscure buttons?
   # !!! left, top, right, bottom (not top, left... as usual.)
   viewport.setContentsMargins(10, 10, 10, 10)
   
   scrollArea = QScrollArea()
   scrollArea.setWidget(viewport)
   
   '''
   Assert width of contents is less than screen width (even mobile screens.)
   Can't assert height of contents less than screen height,
   e.g. a stylesheet has large height that must be vertically scrolled.
   Note this is statically determined, at design time,
   by ensuring that all rows are narrow.
   TODO dynamically enable horizontal and vertical scroll bar policy
   by calculations based on screen size and size of dialog needs?
   
   At one time, this not work: it obscured contents.
   Before I shortened many labels and model names???
   '''
   scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
   return scrollArea
开发者ID:bootchk,项目名称:documentStyle,代码行数:35,代码来源:styleDialogWidget.py

示例2: iWindow

# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setContentsMargins [as 别名]
class iWindow(iWidget):
    def __init__(self, 
                 parent=None, 
                 buttons=('min', 'max', 'close')
                 ):
        super(iWindow, self).__init__(parent)
        self.borderMargin = 5

        self.setBackgroundColor(QColor(107, 173, 246))
        
        self.__mainLayout = QVBoxLayout()
        self.__mainLayout.setSpacing(0)
        self.__mainLayout.setContentsMargins(0, 0, 0, 0)
        self.__contentLayout = QVBoxLayout()
        self.__contentLayout.setSpacing(0)
        
        self.__titleBar = iTitleBar(self, buttons=buttons)
        self.__content = QWidget()
        self.__content.setMouseTracking(True)
        self.__content.setAutoFillBackground(True)
        self.__contentLayout.addWidget(self.__content)
        
        self.__mainLayout.addWidget(self.__titleBar)
        self.__mainLayout.addLayout(self.__contentLayout)
        
        self.setBorderWidth(self.borderMargin, 0, 
                            self.borderMargin, self.borderMargin)
        self.setContentBackgroundColor(QColor(242, 242, 242))
        QWidget.setLayout(self, self.__mainLayout)
    
    ''' Overrides APIs. ''' 
    def setLayout(self, layout):
        self.__content.setLayout(layout)
        
    def setContentsMargins(self, left=0, top=0, right=0, bottom=0):
        self.__content.setContentsMargins(left, top, right, bottom)
    
    ''' Extends APIs. '''    
    def setBorderWidth(self, left=0, top=0, right=0, bottom=0):
        self.__contentLayout.setContentsMargins(left, top, right, bottom)
        
    def titleBar(self):
        return self.__titleBar
        
    def setIcon(self, icon=''):
        self._titleBar.setIcon(icon)
    
    def setTitle(self, title=''):
        self._titleBar.setTitle(title)
    
    def setTitleBarColor(self, color):    
        p = self._titleBar.palette()
        p.setColor(QPalette.WindowText, color)
        self._titleBar.setPalette(p)
        
    def setContentBackgroundColor(self, color):
        palette = QPalette(self.__content.palette())
        palette.setBrush(QPalette.Background, color)
        self.__content.setPalette(palette)
开发者ID:yuanjq,项目名称:idoui,代码行数:61,代码来源:iwindow.py

示例3: make_vbox

# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setContentsMargins [as 别名]
 def make_vbox(*widgets, stretch_index=None):
     box = QVBoxLayout(self)
     for idx, w in enumerate(widgets):
         box.addWidget(w, 1 if idx == stretch_index else 0)
     container = QWidget(self)
     container.setLayout(box)
     container.setContentsMargins(0, 0, 0, 0)
     return container
开发者ID:UAVCAN,项目名称:gui_tool,代码行数:10,代码来源:main.py

示例4: create_panel

# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setContentsMargins [as 别名]
    def create_panel(self):
        """Returns a tuple QGridLayout, ToolbarRibbonPanel for a new block of
        controls.
        """
        panel = QWidget()
        panel.setContentsMargins(0, 0, 0, 0)

        layout = QGridLayout(panel)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)

        # layout.setRowMinimumHeight(2, 1)

        return layout, panel
开发者ID:NaturalHistoryMuseum,项目名称:inselect,代码行数:16,代码来源:toolbar_ribbon.py

示例5: __init__

# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setContentsMargins [as 别名]
    def __init__(self, pluginEntry, parent):
        """PluginEntry QWidget -> Void
        Consumes a PluginEntry and the parent widget of the titlecard
        sets up the titlecard to the pluginEntry"""
        super().__init__()
        self.__parent = parent
        self._pluginEntry = pluginEntry
        # Should be set to 150, when there a some kind of info link / button.
        self.setMaximumHeight(300)

        bottom = QWidget()
        hbox = QHBoxLayout()
        bottom_label = QLabel(pluginEntry["author"])
        bottom_label.setMargin(0)
        bottom_label.setIndent(0)
        hbox.addWidget(bottom_label)

        moreInfoLabel = QLabel("<a href='%s'>Details</a>"
                               % pluginEntry["details"])
        moreInfoLabel.setOpenExternalLinks(True)
        hbox.addWidget(moreInfoLabel)

        button_box = QDialogButtonBox(self)
        self.installButton = button_box.addButton(
            'Install', QDialogButtonBox.DestructiveRole
        )
        self.installButton.setCheckable(True)
        self.installButton.clicked.connect(self._onInstallButtonClicked)
        self.installButton.setIcon(QIcon.fromTheme("run-install",
                                                   QIcon(DOWNLOAD_ICON_PATH)))

        hbox.addWidget(button_box)
        bottom.setLayout(hbox)
        bottom.setContentsMargins(0, 0, 0, 0)

        pluginInfoLabel = QLabel(
            """
            <h2>%s <small>%s</small></h2>
            <p>%s</p>
            <p></p>"""
            % (pluginEntry["name"],
               pluginEntry["version"],
               pluginEntry["description"]))
        pluginInfoLabel.setWordWrap(True)
        vbox = QVBoxLayout()
        vbox.addWidget(pluginInfoLabel)
        vbox.addWidget(bottom)

        self.setLayout(vbox)
开发者ID:bjones1,项目名称:enki,代码行数:51,代码来源:installpage.py

示例6: __init__

# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setContentsMargins [as 别名]
    def __init__(self, pluginEntry):
        super().__init__()
        self._pluginEntry = pluginEntry
        # Should be set to 150, when there a some kind of info link / button.
        self.setMaximumHeight(300)

        bottom = QWidget()
        hbox = QHBoxLayout()
        bottom_label = QLabel(pluginEntry["author"])
        bottom_label.setMargin(0)
        bottom_label.setIndent(0)
        hbox.addWidget(bottom_label)
        button_box = QDialogButtonBox(self)

        self.startStopButton = button_box.addButton(
            'Enable', QDialogButtonBox.DestructiveRole
        )
        self.startStopButton.setCheckable(True)
        self._setStartStopButton()
        self.startStopButton.clicked.connect(self._onStartStopButtonClicked)

        uninstallButton = button_box.addButton(
            'Uninstall', QDialogButtonBox.ActionRole
        )
        uninstallButton.setIcon(
            self.style().standardIcon(getattr(QStyle, 'SP_TrashIcon'))
        )
        uninstallButton.clicked.connect(self._onUninstallButtonClicked)

        hbox.addWidget(button_box)
        bottom.setLayout(hbox)
        bottom.setContentsMargins(0, 0, 0, 0)

        pluginInfoLabel = QLabel(
            """
            <h2>%s <small>%s</small></h2>
            <p>%s</p>
            <p></p>"""
            % (pluginEntry["pluginname"],
               pluginEntry["version"],
               pluginEntry["doc"]))
        pluginInfoLabel.setWordWrap(True)
        vbox = QVBoxLayout()
        vbox.addWidget(pluginInfoLabel)
        vbox.addWidget(bottom)

        self.setLayout(vbox)
开发者ID:hlamer,项目名称:enki,代码行数:49,代码来源:pluginspage.py

示例7: __init__

# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setContentsMargins [as 别名]
    def __init__(self, parent=None, nav_toolbar=None):
        # This view is not visible
        super(NavigatorView, self).__init__(None)

        self.navigator = Navigator()
        self.navigator.setFixedWidth(self.SIZE)
        self.navigator.setFixedHeight(self.SIZE)
        self.navigator.setContentsMargins(0, 0, 0, 0)

        # Widget containing nav toolbar and thumbnail
        layout = QVBoxLayout()
        if nav_toolbar:
            layout.addWidget(nav_toolbar)
        layout.addWidget(self.navigator)
        layout.setAlignment(self.navigator, Qt.AlignHCenter)
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)
        container = QWidget()
        container.setContentsMargins(0, 0, 0, 0)
        container.setLayout(layout)

        # Widget containing toggle label and container
        self.widget = PopupPanel('Navigator', container, parent=parent)
        self.widget.setContentsMargins(0, 0, 0, 0)
开发者ID:NaturalHistoryMuseum,项目名称:inselect,代码行数:26,代码来源:navigator.py

示例8: AppWindow

# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setContentsMargins [as 别名]
class AppWindow(QMainWindow):
	"The application's main window"
	def __init__(self):
		super().__init__()
		self.center = QWidget()
		self.display = QStackedLayout()
		self.center.setLayout(self.display)
		# init the manga view variables
		self.manga_display()
		# init the chapter view variables
		self.chapter_display()
		# init toolbar
		self.init_toolbar()
		# init status bar
		self.init_stat_bar()

		self.display.addWidget(self.manga_main)
		self.display.addWidget(self.chapter_main)

		self.setCentralWidget(self.center)
		self.setWindowTitle("Happypanda")
		self.resize(1029, 650)
		self.show()
	
	def init_stat_bar(self):
		self.status_bar = self.statusBar()
		self.status_bar.setMaximumHeight(20)
		self.status_bar.setSizeGripEnabled(False)
		self.stat_info = QLabel()
		self.stat_info.setIndent(5)
		self.sort_main = QAction("Asc", self)
		sort_menu = QMenu()
		self.sort_main.setMenu(sort_menu)
		s_by_title = QAction("Title", sort_menu)
		s_by_artist = QAction("Artist", sort_menu)
		sort_menu.addAction(s_by_title)
		sort_menu.addAction(s_by_artist)
		self.status_bar.addPermanentWidget(self.stat_info)
		#self.status_bar.addAction(self.sort_main)
		self.temp_msg = QLabel()
		self.temp_timer = QTimer()
		self.manga_list_view.series_model.ROWCOUNT_CHANGE.connect(self.stat_row_info)
		self.manga_list_view.series_model.STATUSBAR_MSG.connect(self.stat_temp_msg)

	def stat_temp_msg(self, msg):
		self.temp_timer.stop()
		self.temp_msg.setText(msg)
		self.status_bar.addWidget(self.temp_msg)
		self.temp_timer.timeout.connect(self.temp_msg.clear)
		self.temp_timer.setSingleShot(True)
		self.temp_timer.start(5000)

	def stat_row_info(self):
		r = self.manga_list_view.series_model.rowCount()
		t = len(self.manga_list_view.series_model._data)
		self.stat_info.setText("<b>Showing {} of {} </b>".format(r, t))

	def manga_display(self):
		"initiates the manga view"
		self.manga_main = QWidget()
		self.manga_main.setContentsMargins(-10, -12, -10, -10)
		self.manga_view = QHBoxLayout()
		self.manga_main.setLayout(self.manga_view)

		manga_delegate = series.CustomDelegate()
		manga_delegate.BUTTON_CLICKED.connect(self.setCurrentIndex)
		self.manga_list_view = series.MangaView()
		self.manga_list_view.setItemDelegate(manga_delegate)
		self.manga_view.addWidget(self.manga_list_view)

	def favourite_display(self):
		"initiates favourite display"
		pass

	def chapter_display(self):
		"Initiates chapter view"
		self.chapter_main = QWidget()
		self.chapter_main.setObjectName("chapter_main") # to allow styling this object
		self.chapter_layout = QHBoxLayout()
		self.chapter_main.setLayout(self.chapter_layout)

		#self.chapter_info.setContentsMargins(-8,-7,-7,-7)
		#self.chapter_info.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
		self.chapter_info_view = series.ChapterInfo()
		self.chapter_layout.addWidget(self.chapter_info_view)

		chapter_list_view = series.ChapterView()
		self.chapter_layout.addWidget(chapter_list_view)
		#self.chapter.setCollapsible(0, True)
		#self.chapter.setCollapsible(1, False)

	def init_toolbar(self):
		self.toolbar = QToolBar()
		self.toolbar.setFixedHeight(30)
		self.toolbar.setWindowTitle("Show") # text for the contextmenu
		#self.toolbar.setStyleSheet("QToolBar {border:0px}") # make it user defined?
		self.toolbar.setMovable(False)
		self.toolbar.setFloatable(False)
		#self.toolbar.setIconSize(QSize(20,20))
		self.toolbar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
#.........这里部分代码省略.........
开发者ID:gitter-badger,项目名称:happypanda,代码行数:103,代码来源:app.py

示例9: __init__

# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setContentsMargins [as 别名]
    def __init__(self, start_server=False):
        super(IDE, self).__init__()
        self.setWindowTitle('NINJA-IDE {Ninja-IDE Is Not Just Another IDE}')
        self.setMinimumSize(750, 500)
        QToolTip.setFont(QFont(settings.FONT.family(), 10))
        #Load the size and the position of the main window
        self.load_window_geometry()
        self.__project_to_open = 0

        IDE.__instance = self

        wid = QWidget()#adjustSize
        wid.setContentsMargins(0, 0, 0, 0)
        box = QHBoxLayout(wid)
        box.setContentsMargins(0, 0, 0, 0)
        # l1 = QLabel("Info Here")
        # l1.setObjectName("Info")
        # l1.setStyleSheet("background-color: rgb(88, 255, 85);")
        # box.addWidget(l1)
        space = QSpacerItem(10,10, QSizePolicy.Expanding)#, QSizePolicy.Maximum)
        box.addSpacerItem(space)
        l2 = QLabel("Tab Size: "+str(settings.INDENT))#int(qsettings.value('preferences/editor/indent', 4, type=int))))
        l2.setObjectName("Det1")

        font = l2.font()
        font.setPointSize(8)
        l2.setFont(font)
        box.addWidget(l2)

        box.addSpacing(50)

        l3 = QLabel("Python")
        l3.setObjectName("Det2")
        font.setPointSize(9)
        l3.setFont(font)
        box.addWidget(l3)

        box.addSpacing(30)

        status = self.statusBar()
        status.setMaximumHeight(20)
        status.addPermanentWidget(wid)
        # wid.show()
        # self.__wid = wid
        status.reformat()
        status.showMessage("Info Here")
        status.setStyleSheet("background-color: rgb(85, 85, 85);")

        #Editables
        self.__neditables = {}
        #Filesystem
        self.filesystem = nfilesystem.NVirtualFileSystem()

        #Sessions handler
        self._session = None
        #Opacity
        self.opacity = settings.MAX_OPACITY

        #ToolBar
        self.toolbar = QToolBar(self)
        if settings.IS_MAC_OS:
            self.toolbar.setIconSize(QSize(36, 36))
        else:
            self.toolbar.setIconSize(QSize(24, 24))
        self.toolbar.setToolTip(translations.TR_IDE_TOOLBAR_TOOLTIP)
        self.toolbar.setToolButtonStyle(Qt.ToolButtonIconOnly)
        # Set toggleViewAction text and tooltip
        self.toggleView = self.toolbar.toggleViewAction()
        self.toggleView.setText(translations.TR_TOOLBAR_VISIBILITY)
        self.toggleView.setToolTip(translations.TR_TOOLBAR_VISIBILITY)
        self.addToolBar(settings.TOOLBAR_AREA, self.toolbar)
        if settings.HIDE_TOOLBAR:
            self.toolbar.hide()
        #Notificator
        self.notification = notification.Notification(self)

        self.statusBar().messageChanged[str].connect(self.MessageStatusChanged.emit)

        #Plugin Manager
        # CHECK ACTIVATE PLUGINS SETTING
        #services = {
            #'editor': plugin_services.MainService(),
            #'toolbar': plugin_services.ToolbarService(self.toolbar),
            ##'menuApp': plugin_services.MenuAppService(self.pluginsMenu),
            #'menuApp': plugin_services.MenuAppService(None),
            #'explorer': plugin_services.ExplorerService(),
            #'misc': plugin_services.MiscContainerService(self.misc)}
        #serviceLocator = plugin_manager.ServiceLocator(services)
        serviceLocator = plugin_manager.ServiceLocator(None)
        self.plugin_manager = plugin_manager.PluginManager(resources.PLUGINS,
                                                           serviceLocator)
        self.plugin_manager.discover()
        #load all plugins!
        self.plugin_manager.load_all()

        #Tray Icon
        self.trayIcon = updates.TrayIconUpdates(self)
        self.trayIcon.closeTrayIcon.connect(self._close_tray_icon)
        self.trayIcon.show()

#.........这里部分代码省略.........
开发者ID:Salmista-94,项目名称:Ninja_3.0_PyQt5,代码行数:103,代码来源:ide.py

示例10: AppWindow

# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setContentsMargins [as 别名]

#.........这里部分代码省略.........
        s_by_title = QAction("Title", sort_menu)
        s_by_artist = QAction("Artist", sort_menu)
        sort_menu.addAction(s_by_title)
        sort_menu.addAction(s_by_artist)
        self.status_bar.addPermanentWidget(self.stat_info)
        # self.status_bar.addAction(self.sort_main)
        self.temp_msg = QLabel()
        self.temp_timer = QTimer()

        self.manga_list_view.gallery_model.ROWCOUNT_CHANGE.connect(self.stat_row_info)
        self.manga_list_view.gallery_model.STATUSBAR_MSG.connect(self.stat_temp_msg)
        self.manga_list_view.STATUS_BAR_MSG.connect(self.stat_temp_msg)
        self.manga_table_view.STATUS_BAR_MSG.connect(self.stat_temp_msg)
        self.stat_row_info()

    def stat_temp_msg(self, msg):
        self.temp_timer.stop()
        self.temp_msg.setText(msg)
        self.status_bar.addWidget(self.temp_msg)
        self.temp_timer.timeout.connect(self.temp_msg.clear)
        self.temp_timer.setSingleShot(True)
        self.temp_timer.start(5000)

    def stat_row_info(self):
        r = self.manga_list_view.model().rowCount()
        t = self.manga_list_view.gallery_model._data_count
        self.stat_info.setText("Loaded {} of {} ".format(r, t))

    def manga_display(self):
        "initiates the manga view"
        # list view
        self.manga_list_main = QWidget()
        # self.manga_list_main.setContentsMargins(-10, -12, -10, -10)
        self.manga_list_main.setContentsMargins(10, -9, -10, -10)  # x, y, inverted_width, inverted_height
        self.manga_list_layout = QHBoxLayout()
        self.manga_list_main.setLayout(self.manga_list_layout)

        self.manga_list_view = gallery.MangaView(self)
        self.manga_list_view.clicked.connect(self.popup)
        self.manga_list_view.manga_delegate.POPUP.connect(self.popup)
        self.popup_window = self.manga_list_view.manga_delegate.popup_window
        self.manga_list_layout.addWidget(self.manga_list_view)

        # table view
        self.manga_table_main = QWidget()
        self.manga_table_layout = QVBoxLayout()
        self.manga_table_main.setLayout(self.manga_table_layout)

        self.manga_table_view = gallery.MangaTableView(self)
        self.manga_table_view.gallery_model = self.manga_list_view.gallery_model
        self.manga_table_view.sort_model = self.manga_list_view.sort_model
        self.manga_table_view.setModel(self.manga_table_view.sort_model)
        self.manga_table_view.sort_model.change_model(self.manga_table_view.gallery_model)
        self.manga_table_view.setColumnWidth(gui_constants.FAV, 20)
        self.manga_table_view.setColumnWidth(gui_constants.ARTIST, 200)
        self.manga_table_view.setColumnWidth(gui_constants.TITLE, 400)
        self.manga_table_view.setColumnWidth(gui_constants.TAGS, 300)
        self.manga_table_view.setColumnWidth(gui_constants.TYPE, 60)
        self.manga_table_view.setColumnWidth(gui_constants.CHAPTERS, 60)
        self.manga_table_view.setColumnWidth(gui_constants.LANGUAGE, 100)
        self.manga_table_view.setColumnWidth(gui_constants.LINK, 400)
        self.manga_table_layout.addWidget(self.manga_table_view)

    def search(self, srch_string):
        case_ins = srch_string.lower()
        if not gui_constants.ALLOW_SEARCH_REGEX:
开发者ID:utterbull,项目名称:happypanda,代码行数:70,代码来源:app.py

示例11: Plot

# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setContentsMargins [as 别名]

#.........这里部分代码省略.........

        self.__colors_selected__ = int_re.findall(self.config['color']['value'])
        self.__styles_selected__ = int_re.findall(self.config['style']['value'])

        self.__buffer_size__ = int(int_re.findall(self.config['buffersize']['value'])[0])

        self.__downsampling_rate__ = int(int_re.findall(self.config['downsampling_rate']['value'])[0])
        self.__downsampling_rate_start__ = 0

        # ----------------------------
        # Set internal variables
        # ----------------------------

        self.__tbuffer__ = collections.deque([0.0] * 0, self.__buffer_size__)

        # ----------------------------
        # Set internal variables used for single timestamp plotting (stp)
        # ----------------------------

        self.__stp_min_x = 0
        self.__stp_max_x = 0

        self.__stp_min_y = 0
        self.__stp_max_y = 1

        self.__stp_active__ = False


        # --------------------------------
        # Create Layout and labels
        # --------------------------------

        self.central_widget = QWidget()
        self.central_widget.setContentsMargins(0,0,0,0)

        self.label_widget = QWidget()
        self.label_widget.setContentsMargins(0,0,0,0)

        self.verticalLayout = QVBoxLayout()
        self.verticalLayout.setContentsMargins(0,0,0,0)
        self.verticalLayout.setSpacing(0)

        self.horizontalLayout = QHBoxLayout()
        self.horizontalLayout.setContentsMargins(0,0,0,0)
        self.horizontalLayout.setSpacing(0)

        self.space_label = QLabel()
        self.space_label.setMargin(0)
        self.space_label.setAlignment(QtCore.Qt.AlignJustify)
        self.space_label.setStyleSheet("QLabel { background-color : black; color : grey;"
                                      "border : 0px solid black ; border-bottom-width : 5px }")

        self.time_label = QLabel()
        self.time_label.setMargin(0)
        self.time_label.setAlignment(QtCore.Qt.AlignJustify)
        self.time_label.setStyleSheet("QLabel { background-color : black; color : grey;"
                                      "border : 0px solid black ; border-bottom-width : 5px }")
        self.time_label.setMaximumWidth(55)


        self.unit_label = QLabel()
        self.unit_label.setMargin(0)
        self.unit_label.setAlignment(QtCore.Qt.AlignLeft)
        self.unit_label.setStyleSheet("QLabel { background-color : black; color : grey;"
                                      "border : 0px solid black ; border-bottom-width : 5px }")
开发者ID:dani-l,项目名称:PaPI,代码行数:69,代码来源:Plot.py

示例12: PyntGui

# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setContentsMargins [as 别名]
class PyntGui(object):
  pynt = None
  AVATAR_SIZE = 60
  AVATAR_DEFAULT = 'assets/example.org_user.jpg'
  WINDOW_TITLE = 'Pynt, for #pants'
  ICON_APP = 'assets/icons/pynt.png'
  ICON_USER = 'assets/icons/rainbow.png'
  ICON_TIME = 'assets/icons/time.png'
  ICON_URL = 'assets/icons/connect.png'

  def __init__(self, pynt):
    self.pynt = pynt
    self.bootstrap()

  def bootstrap(self):
    self.no_margin = QMargins(0, 0, 0, 0)
    self.app = App()
    self.app.setWindowIcon(QIcon(self.ICON_APP))
    if platform.system() == 'Windows':
      myappid = 'f5n.pynt.alpha'
      ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)

    self.scroll_area = QScrollArea()
    self.scroll_area.setContentsMargins(self.no_margin)
    self.scroll_area.setBackgroundRole(QPalette.Dark);
    self.scroll_area.setWidgetResizable(True)
    self.scroll_area.setWindowTitle(self.WINDOW_TITLE)

    self.main_layout = QVBoxLayout()
    self.main_layout.setSpacing(0)
    self.main_layout.setContentsMargins(self.no_margin)
    self.main_layout.addWidget(self.scroll_area)

    self.contents = QWidget()
    self.contents.setContentsMargins(self.no_margin)
    self.contents.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
    #self.contents.setScaledContents(True)

    self.scroll_area.setWidget(self.contents)

    self.layout = QVBoxLayout(self.contents)
    self.layout.setSizeConstraint(QLayout.SetMinimumSize)

    return self

  def addStuff(self, posts):
    for post in posts:
      # xpanel holds one post
      xpanel_layout = QHBoxLayout()
      xpanel_layout.setSpacing(5)
      xpanel_layout.setContentsMargins(self.no_margin)

      xpanel = QFrame()
      xpanel.setContentsMargins(self.no_margin)
      xpanel.setLayout(xpanel_layout)

      avatar_label = self.updated_avatar(self.AVATAR_DEFAULT)

      # panel holds controls and view
      panel_layout = QVBoxLayout()
      panel_layout.setSpacing(0)
      panel_layout.setContentsMargins(self.no_margin)

      panel = QFrame()
      panel.setLayout(panel_layout)
      panel.setContentsMargins(self.no_margin)
      panel.setStyleSheet("background-color:green;")

      # control holds the controls at the top
      control_layout = QHBoxLayout()
      control_layout.setSpacing(0)
      control_layout.setContentsMargins(self.no_margin)

      controls = QFrame()
      controls.setStyleSheet("background-color:#ffeeee;")
      controls.setContentsMargins(self.no_margin)
      controls.setLayout(control_layout)

      # ctrl_ is inside control
      ctrl_url = QPushButton()
      ctrl_url.setContentsMargins(self.no_margin)
      ctrl_url.setStyleSheet("QPushButton { color: black; }")
      ctrl_url.setFlat(True)
      ctrl_url.setIcon(QIcon(self.ICON_URL))

      ctrl_updated = QPushButton()
      ctrl_updated.setContentsMargins(self.no_margin)
      ctrl_updated.setStyleSheet("color:#000000;")
      ctrl_updated.setFlat(True)
      ctrl_updated.setIcon(QIcon(self.ICON_TIME))

      ctrl_user = QPushButton()
      ctrl_user.setContentsMargins(self.no_margin)
      ctrl_user.setStyleSheet("QPushButton { color: black; }")
      ctrl_user.setFlat(True)
      ctrl_user.setIcon(QIcon(self.ICON_USER))

      # view displays HTML
      view = WebView()
      #view.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum)
#.........这里部分代码省略.........
开发者ID:winks,项目名称:pynt,代码行数:103,代码来源:qtx.py

示例13: __init__

# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setContentsMargins [as 别名]

#.........这里部分代码省略.........
                               'If automatic mounting is configured on your system,\n'
                               'explicitly setting a mountpoint is not required\n\n'
                               'For more information, visit\n'
                               '<a href="{project_url}">{project_url}</a>'
                               ).format(executable=os.path.basename(sys.argv[0]),
                                        project_url=PROJECT_URL), critical=True)

        # spawn worker process with root privileges
        try:
            self.worker = utils.WorkerMonitor(self)
            # start communication thread
            self.worker.start()
        except utils.SudoException as se:
            show_alert(self, format_exception(se), critical=True)
            return

        # if no arguments supplied, display dialog to gather this information
        if self.encrypted_container is None and self.luks_device_name is None:

            from luckyLUKS.setupUI import SetupDialog
            sd = SetupDialog(self)

            if sd.exec_() == QDialog.Accepted:
                self.luks_device_name = sd.get_luks_device_name()
                self.encrypted_container = sd.get_encrypted_container()
                self.mount_point = sd.get_mount_point()
                self.key_file = sd.get_keyfile()

                self.is_unlocked = True  # all checks in setup dialog -> skip initializing state
            else:
                # user closed dialog -> quit program
                # and check if a keyfile create thread has to be stopped
                # the worker process terminates itself when its parent dies
                if hasattr(sd, 'create_thread') and sd.create_thread.isRunning():
                    sd.create_thread.terminate()
                QApplication.instance().quit()
                return

        # center window on desktop
        qr = self.frameGeometry()
        cp = QDesktopWidget().availableGeometry().center()
        qr.moveCenter(cp)
        self.move(qr.topLeft())

        # widget content
        main_grid = QGridLayout()
        main_grid.setSpacing(10)
        icon = QLabel()
        icon.setPixmap(QIcon.fromTheme('dialog-password', QApplication.style().standardIcon(QStyle.SP_DriveHDIcon)).pixmap(32))
        main_grid.addWidget(icon, 0, 0)
        main_grid.addWidget(QLabel('<b>' + _('Handle encrypted container') + '</b>\n'), 0, 1, alignment=Qt.AlignCenter)

        main_grid.addWidget(QLabel(_('Name:')), 1, 0)
        main_grid.addWidget(QLabel('<b>{dev_name}</b>'.format(dev_name=self.luks_device_name)), 1, 1, alignment=Qt.AlignCenter)

        main_grid.addWidget(QLabel(_('File:')), 2, 0)
        main_grid.addWidget(QLabel(self.encrypted_container), 2, 1, alignment=Qt.AlignCenter)

        if self.key_file is not None:
            main_grid.addWidget(QLabel(_('Key:')), 3, 0)
            main_grid.addWidget(QLabel(self.key_file), 3, 1, alignment=Qt.AlignCenter)

        if self.mount_point is not None:
            main_grid.addWidget(QLabel(_('Mount:')), 4, 0)
            main_grid.addWidget(QLabel(self.mount_point), 4, 1, alignment=Qt.AlignCenter)

        main_grid.addWidget(QLabel(_('Status:')), 5, 0)
        self.label_status = QLabel('')
        main_grid.addWidget(self.label_status, 5, 1, alignment=Qt.AlignCenter)

        self.button_toggle_status = QPushButton('')
        self.button_toggle_status.setMinimumHeight(34)
        self.button_toggle_status.clicked.connect(self.toggle_container_status)
        main_grid.setRowMinimumHeight(6, 10)
        main_grid.addWidget(self.button_toggle_status, 7, 1)

        widget = QWidget()
        widget.setLayout(main_grid)
        widget.setContentsMargins(10, 10, 10, 10)
        self.setCentralWidget(widget)

        # tray popup menu
        if self.has_tray:
            tray_popup = QMenu(self)
            tray_popup.addAction(QIcon.fromTheme('dialog-password', QApplication.style().standardIcon(QStyle.SP_DriveHDIcon)), self.luks_device_name).setEnabled(False)
            tray_popup.addSeparator()
            self.tray_toggle_action = QAction(QApplication.style().standardIcon(QStyle. SP_DesktopIcon), _('Hide'), self)
            self.tray_toggle_action.triggered.connect(self.toggle_main_window)
            tray_popup.addAction(self.tray_toggle_action)
            quit_action = QAction(QApplication.style().standardIcon(QStyle.SP_MessageBoxCritical), _('Quit'), self)
            quit_action.triggered.connect(self.tray_quit)
            tray_popup.addAction(quit_action)
            # systray
            self.tray = QSystemTrayIcon(self)
            self.tray.setIcon(QIcon.fromTheme('dialog-password', QApplication.style().standardIcon(QStyle.SP_DriveHDIcon)))
            self.tray.setContextMenu(tray_popup)
            self.tray.activated.connect(self.toggle_main_window)
            self.tray.show()

        self.init_status()
开发者ID:jas-per,项目名称:luckyLUKS,代码行数:104,代码来源:mainUI.py


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