Ejemplo n.º 1
0
def setbg(widget, filename):
    widget.setAutoFillBackground(True)
    palette = QtGui.QPalette()
    pixmap = QtGui.QPixmap(filename)
    pixmap = pixmap.scaled(widget.size())
    palette.setBrush(QtGui.QPalette.Background, QtGui.QBrush(pixmap))
    widget.setPalette(palette)
Ejemplo n.º 2
0
 def createMenus(self):
     menusettings = windowsoptions['mainwindow']['menusettings']
     menubar = self.menuBar()
     menubar.setVisible(menusettings['visual'])
     for menu in menusettings['menus']:
         setattr(
             self,
             '%smenu' % menu['name'],
             menubar.addMenu(u'%s%s' % (menu['name'], menu['name_zh']))
         )
         submenu = getattr(self, '%smenu' % menu['name'])
         for menuaction in menu['actions']:
             setattr(
                 self,
                 '%sAction' % menuaction['trigger'],
                 QtGui.QAction(
                     QtGui.QIcon(QtGui.QPixmap(menuaction['icon'])),
                     '%s%s' % (menuaction['name'], menuaction['name_zh']),
                     self
                 )
             )
             if hasattr(self, 'action%s' % menuaction['trigger']):
                 action = getattr(self, '%sAction' % menuaction['trigger'])
                 action.setShortcut(QtGui.QKeySequence(menuaction['shortcut']))
                 submenu.addAction(action)
                 action.triggered.connect(
                     getattr(self, 'action%s' % menuaction['trigger'])
                 )
             else:
                 action = getattr(self, '%sAction' % menuaction['trigger'])
                 action.setShortcut(QtGui.QKeySequence(menuaction['shortcut']))
                 submenu.addAction(action)
                 action.triggered.connect(
                     getattr(self, 'actionNotImplement')
                 )
Ejemplo n.º 3
0
    def createToolbars(self):
        toolbarsettings = windowsoptions['mainwindow']['toolbarsettings']
        self.toolbar = QtGui.QToolBar(self)
        self.toolbar.setMovable(toolbarsettings['movable'])
        self.toolbar.setVisible(toolbarsettings['visual'])
        self.addToolBar(toolbarsettings['dockArea'], self.toolbar)

        for toolbar in toolbarsettings['toolbars']:
            setattr(
                self,
                '%sAction' % toolbar['trigger'],
                QtGui.QAction(
                    QtGui.QIcon(QtGui.QPixmap(toolbar['icon'])),
                    '%s%s' % (toolbar['name'], toolbar['name_zh']),
                    self
                )
            )
            if hasattr(self, 'action%s' % toolbar['trigger']):
                action = getattr(self, '%sAction' % toolbar['trigger'])
                action.setShortcut(QtGui.QKeySequence(toolbar['shortcut']))
                action.setToolTip(toolbar['tooltip'])
                self.toolbar.addAction(action)
                action.triggered.connect(
                    getattr(self, 'action%s' % toolbar['trigger'])
                )
                self.toolbar.widgetForAction(action).setObjectName(toolbar['id'])
            else:
                action = getattr(self, '%sAction' % toolbar['trigger'])
                action.setShortcut(QtGui.QKeySequence(toolbar['shortcut']))
                action.setToolTip(toolbar['tooltip'])
                self.toolbar.addAction(action)
                action.triggered.connect(
                    getattr(self, 'actionNotImplement')
                )
                self.toolbar.widgetForAction(action).setObjectName(toolbar['id'])
Ejemplo n.º 4
0
 def drawBackground(self, painter):
     painter.drawPixmap(0, 0, self.width(), self.height(), QtGui.QPixmap(self.bg))
Ejemplo n.º 5
0
        t = 0
        while t <= 50:
            newOpacity = self.windowOpacity() - 0.02   # 设置淡出
            if newOpacity < 0:
                self.close()
                break
            self.setWindowOpacity(newOpacity)
            self.show()
            t += 1
            time.sleep(0.04)


if __name__ == '__main__':
    import sys
    if sys.platform == "linux2":
        import platform
        if platform.architecture()[0] == "32bit":
            QtGui.QApplication.addLibraryPath(
                '/usr/lib/%s-linux-gnu/qt5/plugins/' % 'i386')
        else:
            QtGui.QApplication.addLibraryPath(
                '/usr/lib/%s-linux-gnu/qt5/plugins/' % platform.machine())
    app = QtGui.QApplication(sys.argv)
    splash = SplashScreen(QtGui.QPixmap(windowsoptions['splashimg']))
    splash.fadeTicker(0)
    app.processEvents()
    main = MainWindow()
    main.show()
    splash.finish(main)
    sys.exit(app.exec_())