示例#1
0
 def __init__(self):
     super(Dialog, self).__init__()
     self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint
                         | Qt.Popup | Qt.Tool)
     self.setAttribute(Qt.WA_TranslucentBackground, True)
     self.setWindowOpacity(app.DialogOpacity)
     self.resize(app.DialogWidth, app.DialogHeight)
     point = Utils.getDesktopCenterPoint(self)
     self.move(point["x"], point["y"])
     self.webview = QWebView(self)
     self.webview.settings().setAttribute(QWebSettings.JavascriptEnabled,
                                          True)
     self.webview.settings().setAttribute(
         QWebSettings.DeveloperExtrasEnabled, app.Debug)
     self.webview.settings().setAttribute(
         QWebSettings.LocalContentCanAccessRemoteUrls, True)
     self.webview.settings().setAttribute(QWebSettings.LocalStorageEnabled,
                                          True)
     self.webview.settings().setLocalStoragePath(app.HomeDir + "/data")
     #self.webview.setContextMenuPolicy(Qt.NoContextMenu)
     self.webview.settings().setDefaultTextEncoding("utf-8")
     self.webview.setGeometry(1, 1, self.width() - 2, self.height() - 2)
     self.webview.page().mainFrame().javaScriptWindowObjectCleared.connect(
         self.setJavaScriptObject)
     self.webview.setStyleSheet(
         "QWebView{background-color: rgba(255, 193, 245, 0%); }")
     self.webview.page().networkAccessManager().setCookieJar(app.CookieJar)
     self.webview.load(QUrl.fromLocalFile(app.ViewDir + app.DialogSrc))
示例#2
0
    def __init__(self, url, width, height, windowType=0, handleMethod=""):
        super(Window, self).__init__()
        self.resize(width, height)
        self.round()

        # window窗口设置
        point = Utils.getDesktopCenterPoint(self)
        self.move(point["x"] * (float(3) / 4) + point["x"], 80)
        self.setWindowTitle(app.AppTitle)
        self.setWindowIcon(app.AppIcon)
        self.setWindowOpacity(app.Opacity)

        # 网页窗口配置
        self.webview = QWebView(self)
        self.webview.settings().setAttribute(
            QWebSettings.DeveloperExtrasEnabled, app.Debug)
        self.webview.settings().setAttribute(
            QWebSettings.LocalContentCanAccessRemoteUrls, True)
        self.webview.settings().setAttribute(QWebSettings.LocalStorageEnabled,
                                             True)
        self.webview.settings().setAttribute(QWebSettings.PluginsEnabled, True)
        self.webview.settings().setAttribute(QWebSettings.JavascriptEnabled,
                                             True)
        self.webview.settings().setLocalStoragePath(app.HomeDir + "/data")
        self.webview.settings().setDefaultTextEncoding("utf-8")

        # 定制画布大小,一般为固定大小
        self.webview.setGeometry(1, 1, self.width() - 2, self.height() - 2)
        self.webview.setStyleSheet(
            "QWebView{background-color: rgba(123, 104, 238, 100%); }")
        self.webview.page().networkAccessManager().setCookieJar(app.CookieJar)
        self.webview.page().mainFrame().javaScriptWindowObjectCleared.connect(
            self.setJavaScriptObject)
        self.webview.page().linkClicked.connect(self.linkClicked)

        # 提醒窗口
        self.Notification.connect(self.refreshUrl)
        # 进度条
        self.Progress.connect(self.showProgress)

        # 定时器,socket失败的备选方案,定时检索打印
        # self.timer = QTimer()
        # self.connect(self.timer, SIGNAL("timeout()"), Utils.doPrint)
        # self.timer.start(120000)
        # 定时器,机器人是否自动执行
        self.robotTimer = QTimer()
        self.connect(self.timer, SIGNAL("timeout()"), self.runRobots)

        # self.webview.page().featurePermissionRequested.connect(self.permissionRequested)
        self.webview.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
        self.handleMethod = handleMethod
        self.subUrl = url
        self.windowType = windowType
        self.url = QUrl.fromLocalFile(app.ViewDir + "window.html")
        self.webview.load(self.url)