Example #1
0
    def __init__(self, styleoptions, parent=None):
        super(LoginDialog, self).__init__(styleoptions, parent)

        self.login_np = QtGui.QWidget()
        login_np_mainlayout = QtGui.QGridLayout()
        login_nameLabel = QtGui.QLabel(u'用户名')
        self.login_name = QtGui.QLineEdit(self)
        self.login_name.setPlaceholderText(u'用户名')

        login_passwordLabel = QtGui.QLabel(u'密码')
        self.login_password = QtGui.QLineEdit(self)
        self.login_password.setEchoMode(QtGui.QLineEdit.Password)
        self.login_password.setPlaceholderText(u'密码')

        login_np_mainlayout.addWidget(login_nameLabel, 0, 0)
        login_np_mainlayout.addWidget(self.login_name, 0, 1)
        login_np_mainlayout.addWidget(login_passwordLabel, 1, 0)
        login_np_mainlayout.addWidget(self.login_password, 1, 1)
        self.login_np.setLayout(login_np_mainlayout)

        #确认按钮布局
        self.enterwidget = QtGui.QWidget()
        self.pbLogin = QtGui.QPushButton(u'登录', self)
        self.pbCancel = QtGui.QPushButton(u'取消', self)
        self.pbLogin.clicked.connect(self.login)
        self.pbCancel.clicked.connect(self.reject)

        enterwidget_mainlayout = QtGui.QGridLayout()
        enterwidget_mainlayout.addWidget(self.pbLogin, 0, 0)
        enterwidget_mainlayout.addWidget(self.pbCancel, 0, 1)
        self.enterwidget.setLayout(enterwidget_mainlayout)

        self.layout().addWidget(self.login_np)
        self.layout().addWidget(self.enterwidget)
        self.resize(self.width(), self.height())
Example #2
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)
Example #3
0
 def initSize(self):
     desktopWidth = QtGui.QDesktopWidget().availableGeometry().width()
     desktopHeight = QtGui.QDesktopWidget().availableGeometry().height()
     self.resize(
         desktopWidth * 0.6,
         desktopHeight * 0.8)
     self.moveCenter()
Example #4
0
    def initFrame(self):
        title = windowsoptions['mainwindow']['title']
        postion = windowsoptions['mainwindow']['postion']
        minsize = windowsoptions['mainwindow']['minsize']
        size = windowsoptions['mainwindow']['size']
        windowicon = windowsoptions['mainwindow']['windowicon']
        fullscreenflag = windowsoptions['mainwindow']['fullscreenflag']
        navigationvisual = windowsoptions['mainwindow']['navigationvisual']

        self.setWindowTitle(title)
        self.setWindowIcon(QtGui.QIcon(windowicon))  # 设置程序图标
        self.setMinimumSize(minsize[0], minsize[1])
        width = QtGui.QDesktopWidget().availableGeometry().width() * 5 / 6
        height = QtGui.QDesktopWidget().availableGeometry().height() * 7 / 8
        self.setGeometry(postion[0], postion[1], width, height)  # 初始化窗口位置和大小
        self.center()  # 将窗口固定在屏幕中间
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

        self.fullscreenflag = fullscreenflag  # 初始化时非窗口最大话标志
        if self.fullscreenflag:
            self.showFullScreen()
        else:
            self.showNormal()

        self.navigationvisual = navigationvisual   # 导航标志,初始化时显示导航
        self.layout().setContentsMargins(0, 0, 0, 0)

        # self.setWindowFlags(QtCore.Qt.CustomizeWindowHint)  # 隐藏标题栏, 可以拖动边框改变大小
        # self.setWindowFlags(QtCore.Qt.FramelessWindowHint)  # 隐藏标题栏, 无法改变大小
        self.setWindowFlags(QtCore.Qt.FramelessWindowHint)  # 无边框, 带系统菜单, 可以最小化
    def __init__(self, styleoptions, parent=None):
        super(IPaddressDialog, self).__init__(styleoptions, parent)

        # url内容输入
        self.urlwidget = QtGui.QWidget()
        ip_mainlayout = QtGui.QGridLayout()
        self.ipLabel = QtGui.QLabel(u'输入主机ip:')
        self.ipLineEdit = QtGui.QLineEdit(u'192.168.100.100')
        self.ipLineEdit.setInputMask('000.000.000.000')
        self.portLabel = QtGui.QLabel(u'输入主机port:')
        self.portLineEdit = QtGui.QLineEdit(u'8000')
        ip_mainlayout.addWidget(self.ipLabel, 0, 0)
        ip_mainlayout.addWidget(self.ipLineEdit, 0, 1)
        ip_mainlayout.addWidget(self.portLabel, 1, 0)
        ip_mainlayout.addWidget(self.portLineEdit, 1, 1)

        self.urlwidget.setLayout(ip_mainlayout)

        #确认按钮布局
        self.enterwidget = QtGui.QWidget()
        self.pbEnter = QtGui.QPushButton(u'确定', self)
        self.pbCancel = QtGui.QPushButton(u'取消', self)
        self.pbEnter.clicked.connect(self.enter)
        self.pbCancel.clicked.connect(self.reject)
        enterwidget_mainlayout = QtGui.QGridLayout()
        enterwidget_mainlayout.addWidget(self.pbEnter, 0, 0)
        enterwidget_mainlayout.addWidget(self.pbCancel, 0, 1)
        self.enterwidget.setLayout(enterwidget_mainlayout)

        self.layout().addWidget(self.urlwidget)
        self.layout().addWidget(self.enterwidget)
        self.resize(self.width(), self.height())
Example #6
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')
                 )
Example #7
0
    def __init__(self, styleoptions, parent=None):
        super(numinputDialog, self).__init__(styleoptions, parent)

        # url内容输入
        self.numwidget = QtGui.QWidget()
        num_mainlayout = QtGui.QGridLayout()
        self.numLabel = QtGui.QLabel(u'Q的防区个数:')
        self.numspinbox = QtGui.QSpinBox(self.numwidget)

        self.ipLabel = QtGui.QLabel(u'Q的下位机IP:')
        self.ipIn = QtGui.QLineEdit()

        num_mainlayout.addWidget(self.numLabel, 0, 0)
        num_mainlayout.addWidget(self.numspinbox, 0, 1)
        #num_mainlayout.addWidget(self.ipLabel, 1, 0)
        #num_mainlayout.addWidget(self.ipIn, 1, 1)
        self.numwidget.setLayout(num_mainlayout)

        #确认按钮布局
        self.enterwidget = QtGui.QWidget()
        self.pbEnter = QtGui.QPushButton(u'确定', self)
        self.pbCancel = QtGui.QPushButton(u'取消', self)
        self.pbEnter.clicked.connect(self.enter)
        self.pbCancel.clicked.connect(self.reject)
        enterwidget_mainlayout = QtGui.QGridLayout()
        enterwidget_mainlayout.addWidget(self.pbEnter, 0, 0)
        enterwidget_mainlayout.addWidget(self.pbCancel, 0, 1)
        self.enterwidget.setLayout(enterwidget_mainlayout)

        self.layout().addWidget(self.numwidget)
        self.layout().addWidget(self.enterwidget)
        self.resize(self.width(), self.height())
Example #8
0
    def __init__(self, styleoptions, parent=None):
        super(BaseDialog2, self).__init__(parent)
        title = styleoptions['title']
        windowicon = styleoptions['windowicon']
        minsize = styleoptions['minsize']
        size = styleoptions['size']
        logo_title = styleoptions['logo_title']
        logo_img_url = styleoptions['logo_img_url']

        self.setWindowTitle(title)
        self.setWindowIcon(QtGui.QIcon(windowicon))  # 设置程序图标
        self.setMinimumSize(minsize[0], minsize[1])
        self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowMinimizeButtonHint)  # 无边框, 带系统菜单, 可以最小化

        # logo显示
        self.logowidget = QtGui.QWidget()
        logo_mainlayout = QtGui.QGridLayout()
        bg = QtGui.QLabel(logo_title)
        bg.setAlignment(QtCore.Qt.AlignCenter)
        logo_mainlayout.addWidget(bg)
        self.logowidget.setLayout(logo_mainlayout)
        self.bg = logo_img_url
        setbg(self.logowidget, self.bg)

        # 主布局
        mainlayout = QtGui.QVBoxLayout()
        mainlayout.addWidget(self.logowidget)
        self.setLayout(mainlayout)
        # setskin(self, os.sep.join([__file__.split('utildialog')[0], 'utildialogskin', 'qss', 'dialog.qss']))  # 设置主窗口样式
        setskin(self, 'D:\GitHub\QSoftKeyer\utildialogskin\qss\dialog.qss')
        self.resize(size[0], size[1])
Example #9
0
    def __init__(self, styleoptions, parent=None):
        super(BaseDialog, self).__init__(parent)
        title = styleoptions['title']
        windowicon = styleoptions['windowicon']
        minsize = styleoptions['minsize']
        size = styleoptions['size']
        logo_title = styleoptions['logo_title']
        logo_img_url = styleoptions['logo_img_url']

        self.setWindowTitle(title)
        self.setWindowIcon(QtGui.QIcon(windowicon))  # 设置程序图标
        self.setMinimumSize(minsize[0], minsize[1])
        self.setWindowFlags(QtCore.Qt.FramelessWindowHint)  # 无边框, 带系统菜单, 可以最小化

        self.logowidget = DynamicTextWidget(logo_title, logo_img_url)

        # 主布局
        mainlayout = QtGui.QVBoxLayout()
        mainlayout.addWidget(self.logowidget)
        self.setLayout(mainlayout)
        # logger.info(os.sep.join([os.getcwd(), 'utildialogskin', 'qss', 'dialog.qss']))
        if os.path.isdir(os.sep.join([os.getcwd(), 'utildialogskin'])):
            setskin(self, os.sep.join([os.getcwd(), 'utildialogskin', 'qss', 'dialog.qss']))  # 设置主窗口样式
        elif  os.path.isdir(os.sep.join([os.getcwd(), 'utildialog', 'utildialogskin'])):
            setskin(self, os.sep.join([os.getcwd(), 'utildialog', 'utildialogskin', 'qss', 'dialog.qss']))  # 设置主窗口样式

        # self.setStyleSheet(style) # 设置主窗口样式
        self.resize(size[0], size[1])
Example #10
0
    def createNavigationByPage(self):
        systembuttons = ['Min', 'Max', 'Close']
        navbutton = windowsoptions['mainwindow']['centralwindow']['pagetags'][
            0] + systembuttons
        navbutton_zh = windowsoptions['mainwindow']['centralwindow'][
            'pagetags_zh']
        self.navigation = QtGui.QWidget()
        navigationLayout = QtGui.QHBoxLayout()

        for item in navbutton:
            button = item + 'Button'
            if item not in systembuttons:
                setattr(self, button, QtGui.QPushButton(navbutton_zh[item]))
                getattr(self,
                        button).clicked.connect(self.parent.childpageChange)
            else:
                setattr(self, button, QtGui.QPushButton())

            getattr(self, button).setObjectName(button)
            navigationLayout.addWidget(getattr(self, button))
        self.navigation.setLayout(navigationLayout)
        self.navigation.setMaximumHeight(60)
        self.navigation.setContentsMargins(0, 0, 0, 0)

        getattr(self, 'Min' + 'Button').clicked.connect(
            self.parent.parent().showMinimized)
        getattr(self, 'Max' + 'Button').clicked.connect(
            self.parent.parent().windowMaxNormal)
        getattr(self,
                'Close' + 'Button').clicked.connect(self.parent.parent().close)
Example #11
0
    def drawDynamicText(self, painter):
        sineTable = (0, 38, 71, 92, 100, 92, 71, 38, 0, -38, -71, -92, -100, -92, -71, -38)
        metrics = QtGui.QFontMetrics(self.font())
        x = (self.width() - metrics.width(self.text)) / 2
        y = (self.height() + metrics.ascent() - metrics.descent()) / 2
        color = QtGui.QColor()

        for i, ch in enumerate(self.text):
            index = (self.step + i) % 16
            color.setHsv((15 - index) * 16, 255, 191)
            painter.setPen(color)
            painter.drawText(x, y - ((sineTable[index] * metrics.height()) / 400), ch)
            x += metrics.width(ch)
Example #12
0
class AboutPage(WebkitBasePage):
    def __init__(self, parent=None):
        super(AboutPage, self).__init__(parent)
        self.parent = parent
        self.view.page().settings().setAttribute(
            QtWebKit.QWebSettings.PluginsEnabled, True)
        self.loadfromlocal()

    def auto_html(self, template):
        verfilepath = os.sep.join([os.getcwd(), 'options', 'ver.json'])
        try:
            with open(verfilepath, 'r') as f:
                info = json.load(f)
                sw_info = '-'.join([
                    info['sw_name'], info['sw_version'], info['svn_version'],
                    info['buildtime']
                ])
        except Exception, e:
            logger.error(e)
            info = {
                "sw_name": "QDConfiger",
                "sw_version": "v1.0",
                "svn_version": "r100",
                "buildtime": "b20130725"
            }
            sw_info = '-'.join([
                info['sw_name'], info['sw_version'], info['svn_version'],
                info['buildtime']
            ])
        nameSpace = {
            'title':
            "关于",
            'funtion_info':
            "软件基本功能",
            'soft_info':
            '软件版本说明',
            'company_info':
            '关于我们',
            'help_info':
            'MarkDown语法简介',
            'sw_info':
            sw_info,
            'imagewidth':
            QtGui.QDesktopWidget().availableGeometry().width() * 3 / 5,
            'imageheight':
            QtGui.QDesktopWidget().availableGeometry().width() * 27 / 80,
        }
        t = Template(template, searchList=[nameSpace])
        html = unicode(t)
        return html
Example #13
0
    def createcontrolbar(self):
        self.controlbar = QtGui.QWidget()
        controlbar_layout = QtGui.QGridLayout()

        self.pageLabel = QtGui.QLabel()
        exportmarkdownButton = QtGui.QPushButton(u'导出md')
        exportmarkdownButton.setObjectName('ExpmarkdownButton')
        exportmarkdownButton.setToolTip(u'导出md')
        self.exportmarkdownButton = exportmarkdownButton

        exporthtmlButton = QtGui.QPushButton(u'导出HTML')
        exporthtmlButton.setObjectName('ExphtmlButton')
        exporthtmlButton.setToolTip(u'导出')
        self.exporthtmlButton = exporthtmlButton

        exportpdfButton = QtGui.QPushButton(u'导出PDF')
        exportpdfButton.setObjectName('ExppdfButton')
        exportpdfButton.setToolTip(u'导出PDF')
        self.exportpdfButton = exportpdfButton

        n = 15
        blank1 = 3
        blank2 = 3
        for i in xrange(blank1):
            controlbar_layout.addWidget(QtGui.QLabel(), 0, i)

        themes = [
            item[5:] for item in windowsoptions['markdownthemes']['themes']
        ]
        for item in themes:
            button = 'Theme%sButton' % item
            setattr(self, button, QtGui.QPushButton(item))
            getattr(self, button).setObjectName(button)
            controlbar_layout.addWidget(getattr(self, button), 0,
                                        themes.index(item) + blank1)
            getattr(self, button).clicked.connect(self.settheme)

        for i in xrange(len(themes) + blank1, len(themes) + blank1 + blank2):
            controlbar_layout.addWidget(QtGui.QLabel(), 0, i)
        controlbar_layout.addWidget(exportmarkdownButton, 0, n - 4)
        controlbar_layout.addWidget(exporthtmlButton, 0, n - 3)
        controlbar_layout.addWidget(exportpdfButton, 0, n - 2)
        controlbar_layout.addWidget(QtGui.QLabel(), 0, n)
        self.controlbar.setLayout(controlbar_layout)
        controlbar_layout.setContentsMargins(0, 0, 0, 0)
        self.controlbar.setMaximumHeight(50)

        exportmarkdownButton.clicked.connect(self.exportmarkdown)
        exporthtmlButton.clicked.connect(self.exporthtml)
        exportpdfButton.clicked.connect(self.exportpdf)
Example #14
0
 def _setup_actions(self):
     """ Creates the main window actions.
     """
     # Show/hide callable objects
     self.toggle_callable_action = \
         QtGui.QAction("Show routine attributes", self, checkable=True, 
                       statusTip = "Shows/hides attributes that are routings (functions, methods, etc)")
     self.toggle_callable_action.toggled.connect(self.toggle_callables)
                           
     # Show/hide special attributes
     self.toggle_special_attribute_action = \
         QtGui.QAction("Show __special__ attributes", self, checkable=True, 
                       statusTip = "Shows or hides __special__ attributes")
     self.toggle_special_attribute_action.toggled.connect(self.toggle_special_attributes)
Example #15
0
    def __init__(self, styleoptions, parent=None):
        super(UrlinputDialog, self).__init__(styleoptions, parent)

        # url内容输入
        self.urlwidget = QtGui.QWidget()
        url_mainlayout = QtGui.QGridLayout()
        self.urlLabel = QtGui.QLabel(u'请输入需要访问的url:')
        self.urlLineEdit = QtGui.QLineEdit(u'http://192.168.10.135:8000/webs/protection_areas/list')
        url_mainlayout.addWidget(self.urlLabel, 0, 0)
        url_mainlayout.addWidget(self.urlLineEdit, 1, 0)
        self.urlwidget.setLayout(url_mainlayout)

        #确认按钮布局
        self.enterwidget = QtGui.QWidget()
        self.pbEnter = QtGui.QPushButton(u'确定', self)
        self.pbCancel = QtGui.QPushButton(u'取消', self)
        self.pbEnter.clicked.connect(self.enter)
        self.pbCancel.clicked.connect(self.reject)
        enterwidget_mainlayout = QtGui.QGridLayout()
        enterwidget_mainlayout.addWidget(self.pbEnter, 0, 0)
        enterwidget_mainlayout.addWidget(self.pbCancel, 0, 1)
        self.enterwidget.setLayout(enterwidget_mainlayout)

        self.layout().addWidget(self.urlwidget)
        self.layout().addWidget(self.enterwidget)
        self.resize(self.width(), self.height())
Example #16
0
    def initUI(self):
        self.setWindowFlags(
            QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowSystemMenuHint
            | QtCore.Qt.WindowMinimizeButtonHint)  # 无边框, 带系统菜单, 可以最小化)

        self.centralWidget = QtGui.QFrame()  # QtGui.QLabel('centralWidget')
        self.centralWidget.setMouseTracking(True)

        self.setMouseTracking(True)
        mainLayout = QtGui.QVBoxLayout()
        mainLayout.addWidget(self.centralWidget)
        mainLayout.setContentsMargins(0, 0, 0, 0)
        mainLayout.setSpacing(0)
        self.setLayout(mainLayout)
        self.rectFrame = self.geometry()
Example #17
0
 def createStatusbar(self):
     statusbarsettings = windowsoptions['mainwindow']['statusbarsettings']
     self.statusbar = QtGui.QStatusBar()
     self.setStatusBar(self.statusbar)
     self.statusbar.showMessage(statusbarsettings['initmessage'])
     self.statusbar.setMinimumHeight(statusbarsettings['minimumHeight'])
     self.statusbar.setVisible(statusbarsettings['visual'])
Example #18
0
    def __init__(self, text, styleoptions, parent=None):
        super(MessageDialog, self).__init__(styleoptions, parent)
        # message内容提示
        self.msglabel = QtGui.QLabel(text)
        self.msglabel.setAlignment(QtCore.Qt.AlignCenter)
        #确认按钮布局
        self.enterwidget = QtGui.QWidget()
        self.pbEnter = QtGui.QPushButton(u'确定', self)
        self.pbEnter.clicked.connect(self.enter)
        self.enter_mainlayout = QtGui.QGridLayout()
        self.enter_mainlayout.addWidget(self.pbEnter, 0, 0)
        self.enterwidget.setLayout(self.enter_mainlayout)

        self.layout().addWidget(self.msglabel)
        self.layout().addWidget(self.enterwidget)
        self.resize(self.width(), self.height())
Example #19
0
    def initUI(self):
        self.pagecount = len(self.pagetags_zh)  # 页面个数
        # self.createNavigation()
        self.pages = QtGui.QStackedWidget()  # 创建堆控件

        # self.pages.addWidget(self.navigationPage)

        self.createChildPages()  # 创建子页面

        # self.createConnections()
        mainLayout = QtGui.QHBoxLayout()
        mainLayout.addWidget(self.pages)
        self.setLayout(mainLayout)
        self.layout().setContentsMargins(0, 0, 0, 0)

        self.faderWidget = None
        self.pages.currentChanged.connect(self.fadeInWidget)  # 页面切换时淡入淡出效果
Example #20
0
    def add_header_context_menu(self,
                                checked=None,
                                checkable=None,
                                enabled=None):
        """ Adds the context menu from using header information
        
            checked can be a header_name -> boolean dictionary. If given, headers
            with the key name will get the checked value from the dictionary. 
            The corresponding column will be hidden if checked is False.
        
            checkable can be a header_name -> boolean dictionary. If given, headers
            with the key name will get the checkable value from the dictionary.
            
            enabled can be a header_name -> boolean dictionary. If given, headers
            with the key name will get the enabled value from the dictionary.
        """
        checked = checked if checked is not None else {}
        checkable = checkable if checkable is not None else {}
        enabled = enabled if enabled is not None else {}

        horizontal_header = self._horizontal_header()
        horizontal_header.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)

        self.toggle_column_actions_group = QtGui.QActionGroup(self)
        self.toggle_column_actions_group.setExclusive(False)
        self.__toggle_functions = []  # for keeping references

        for col in range(horizontal_header.count()):
            column_label = self.model().headerData(col, Qt.Horizontal,
                                                   Qt.DisplayRole)
            logger.debug("Adding: col {}: {}".format(col, column_label))
            action = QtGui.QAction(
                "Show {} column".format(column_label),
                self.toggle_column_actions_group,
                checkable=checkable.get(column_label, True),
                enabled=enabled.get(column_label, True),
                toolTip="Shows or hides the {} column".format(column_label))
            func = self.__make_show_column_function(col)
            self.__toggle_functions.append(func)  # keep reference
            horizontal_header.addAction(action)
            is_checked = checked.get(
                column_label, not horizontal_header.isSectionHidden(col))
            horizontal_header.setSectionHidden(col, not is_checked)
            action.setChecked(is_checked)
            action.toggled.connect(func)
Example #21
0
    def paintEvent(self, event):
        semiTransparentColor = self.startColor
        semiTransparentColor.setAlpha(self.currentAlpha)
        painter = QtGui.QPainter(self)
        painter.fillRect(self.rect(), semiTransparentColor)
        self.currentAlpha -= (255 * self.timer.interval() / self.duration)

        if self.currentAlpha <= 0:
            self.timer.stop()
            self.close()
Example #22
0
def get_qapplication_instance():
    """ Returns the QApplication instance. Creates one if it doesn't exist.
    """
    app = QtGui.QApplication.instance()

    if app is None:
        app = QtGui.QApplication(sys.argv)
    check_class(app, QtGui.QApplication)

    return app
Example #23
0
    def setupInspector(self):
        page = self.view.page()
        page.settings().setAttribute(QtWebKit.QWebSettings.DeveloperExtrasEnabled, True)
        self.webInspector = QtWebKit.QWebInspector(self)
        self.webInspector.setPage(page)

        shortcut = QtGui.QShortcut(self)
        shortcut.setKey(QtCore.Qt.Key_F11)
        shortcut.activated.connect(self.toggleInspector)
        self.webInspector.setVisible(False)
Example #24
0
    def __init__(self, parent=None, child=None):
        super(ChildPage, self).__init__(parent)
        self.parent = parent
        self.child = child
        self.createNavigationByPage()

        mainLayout = QtGui.QVBoxLayout()
        mainLayout.addWidget(self.navigation)
        mainLayout.addWidget(self.child)
        self.setLayout(mainLayout)
        self.layout().setContentsMargins(0, 0, 0, 0)
Example #25
0
def main():
    import platform
    if sys.platform == "linux2":
        QtGui.QApplication.addLibraryPath(
            '/usr/lib/%s-linux-gnu/qt5/plugins/' % platform.machine())
    app = QtGui.QApplication(sys.argv)
    window = ThFrame()
    window.setGeometry(100, 100, 800, 600)
    window.setWindowTitle('ThFrame')
    window.show()
    sys.exit(app.exec_())
Example #26
0
    def __init__(self, parent=None):
        super(WebkitBasePage, self).__init__(parent)
        self.parent = parent
        QtNetwork.QNetworkProxyFactory.setUseSystemConfiguration(True)
        QtWebKit.QWebSettings.globalSettings().setAttribute(\
            QtWebKit.QWebSettings.PluginsEnabled, True)

        self.view = QtWebKit.QWebView(self)
        self.view.setFocus()

        self.setupInspector()
        self.splitter = QtGui.QSplitter(self)
        self.splitter.setOrientation(QtCore.Qt.Vertical)

        self.splitter.addWidget(self.view)
        self.splitter.addWidget(self.webInspector)

        mainlayout = QtGui.QVBoxLayout(self)
        mainlayout.addWidget(self.splitter)
        self.setLayout(mainlayout)
        self.layout().setContentsMargins(0, 0, 0, 0)
Example #27
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'])
Example #28
0
    def createNavigation(self):
        navbutton = ['Navigation', 'Back', 'Forward', 'Min', 'Max', 'Close']
        navbutton_zh = {
            'Navigation': u'导航主页(Navigation)',
            'Back': u'后退(Back)',
            'Forward': u'前进(Forward)',
            'Min': u'',
            'Max': u'',
            'Close': u''
        }
        self.navigation = QtGui.QWidget()
        navigationLayout = QtGui.QHBoxLayout()

        for item in navbutton:
            button = item + 'Button'
            if item not in ['Min', 'Max', 'Close']:
                setattr(self, button, QtGui.QPushButton(navbutton_zh[item]))
            else:
                setattr(self, button, QtGui.QPushButton())
                getattr(self, button).setMaximumWidth(50)

            getattr(self, button).setObjectName(button)
            navigationLayout.addWidget(getattr(self, button))
        self.navigation.setLayout(navigationLayout)
        self.navigation.setMaximumHeight(60)
        self.navigation.setContentsMargins(0, 0, 0, 0)

        getattr(self, 'Navigation' + 'Button').clicked.connect(
            self.parent.backnavigationPage)
        getattr(self, 'Back' + 'Button').clicked.connect(self.parent.backPage)
        getattr(self, 'Forward' + 'Button').clicked.connect(
            self.parent.forwardnextPage)
        getattr(self, 'Min' + 'Button').clicked.connect(
            self.parent.parent().showMinimized)
        getattr(self, 'Max' + 'Button').clicked.connect(
            self.parent.parent().windowMaxNormal)
        getattr(self,
                'Close' + 'Button').clicked.connect(self.parent.parent().close)
Example #29
0
    def __init__(self, styleoptions, parent=None):
        super(ExitDialog, self).__init__(styleoptions, parent)

        # 退出设置
        self.exitoptwidget = QtGui.QWidget()
        exit_mainlayout = QtGui.QGridLayout()

        self.exitradiogroup = QtGui.QButtonGroup(self.exitoptwidget)
        self.minRadio = QtGui.QRadioButton(u'最小化')
        self.exitRadio = QtGui.QRadioButton(u'退出')
        self.exitsaveRadio = QtGui.QRadioButton(u'退出并保存配置')
        self.exitradiogroup.addButton(self.minRadio)
        self.exitradiogroup.addButton(self.exitRadio)
        self.exitradiogroup.addButton(self.exitsaveRadio)

        exit_mainlayout.addWidget(self.minRadio, 0, 0)
        exit_mainlayout.addWidget(self.exitRadio, 1, 0)
        exit_mainlayout.addWidget(self.exitsaveRadio, 2, 0)
        self.exitoptwidget.setLayout(exit_mainlayout)
        self.exitsaveRadio.setChecked(True)

        #确认按钮布局
        self.enterwidget = QtGui.QWidget()
        self.pbEnter = QtGui.QPushButton(u'确定', self)
        self.pbCancel = QtGui.QPushButton(u'取消', self)
        self.pbEnter.clicked.connect(self.exit)
        self.pbCancel.clicked.connect(self.close)

        enterwidget_mainlayout = QtGui.QGridLayout()
        enterwidget_mainlayout.addWidget(self.pbEnter, 0, 0)
        enterwidget_mainlayout.addWidget(self.pbCancel, 0, 1)
        self.enterwidget.setLayout(enterwidget_mainlayout)

        self.layout().addWidget(self.exitoptwidget)
        self.layout().addWidget(self.enterwidget)
        self.resize(self.width(), self.height())

        self.exitflag = {}
Example #30
0
    def _setup_menu(self):
        """ Sets up the main menu.
        """
        # file_menu = self.menuBar().addMenu("&File")
        self.menu = QtGui.QMenu(self)
        self.menu.addAction("C&lose", self.close_window, "Ctrl+W")
        self.menu.addAction("E&xit", self.quit_application, "Ctrl+Q")
        if DEBUGGING is True:
            self.menu.addSeparator()
            self.menu.addAction("&Test", self.my_test, "Ctrl+T")

        self.show_cols_submenu = self.menu.addMenu("Table columns")
        self.menu.addAction(self.toggle_callable_action)
        self.menu.addAction(self.toggle_special_attribute_action)

        self.titleBar().settingDownButton.setMenu(self.menu)
        self.titleBar().settingMenuShowed.connect(
            self.titleBar().settingDownButton.showMenu)