1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時間:8:30-17:00
      你可能遇到了下面的問題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      python+PyQT怎么實現(xiàn)系統(tǒng)桌面時鐘?-創(chuàng)新互聯(lián)

      這篇文章將為大家詳細(xì)講解有關(guān)python+PyQT怎么實現(xiàn)系統(tǒng)桌面時鐘?,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

      創(chuàng)新互聯(lián)始終堅持【策劃先行,效果至上】的經(jīng)營理念,通過多達(dá)10年累計超上千家客戶的網(wǎng)站建設(shè)總結(jié)了一套系統(tǒng)有效的網(wǎng)絡(luò)營銷推廣解決方案,現(xiàn)已廣泛運用于各行各業(yè)的客戶,其中包括:成都茶樓設(shè)計等企業(yè),備受客戶稱贊。

      用Python + PyQT寫的一個系統(tǒng)桌面時鐘,剛學(xué)習(xí)Python,寫的比較簡陋,但是基本的功能還可以。

      功能:

      ①窗體在應(yīng)用程序最上層,不用但是打開其他應(yīng)用后看不到時間

      ②左鍵雙擊全屏,可以做小屏保使用,再次雙擊退出全屏。

      ③系統(tǒng)托盤圖標(biāo),主要參考PyQt4源碼目錄中的PyQt4\examples\desktop\systray下的程序

      ④鼠標(biāo)右鍵,將程序最小化

      使用時需要heart.svg放在源代碼同級目錄下,[文件可在PyQt4示例代碼目錄下PyQt4\examples\desktop\systray\images找到

      運行需要Python2.7 + PyQt4.

      __metaclass__ = type 
      #!coding= utf-8 
      #http://blog.csdn.net/gatieme/article/details/17659259 
      #gatieme 
       
       
      import sys 
      from PyQt4.QtCore import * 
      from PyQt4.QtGui import * 
       
       
      #-------------------------------------------------------------------------------- 
      class SystemTrayIcon(QSystemTrayIcon): 
       """ 
       The systemTrayIcon which uesd to connect the clock 
       """ 
       #---------------------------------------------------------------------------- 
       def __init__(self, mainWindow, parent = None): 
        """ 
        mainWindow : the main window that the system tray icon serves to 
        """  
        super(SystemTrayIcon, self).__init__(parent) 
        self.window = mainWindow 
        self.setIcon(QIcon("heart.svg")) # set the icon of the systemTrayIcon 
         
        self.createActions( ) 
        self.createTrayMenu( ) 
         
        self.connect(self, SIGNAL("doubleClicked"), self.window, SLOT("showNormal")) 
        #self.connect(self, SIGNAL("activated( )"), self, SLOT("slot_iconActivated")) 
         
       
       def createActions(self): 
        """ 
        create some action to Max Min Normal show the window 
        """ 
        self.minimizeAction = QAction("Mi&nimize", self.window, triggered = self.window.hide) 
        self.maximizeAction = QAction("Ma&ximize", self.window, triggered = self.window.showMaximized) 
        self.restoreAction = QAction("&Restore", self.window, triggered = self.window.showNormal) 
        self.quitAction = QAction("&Quit", self.window, triggered = qApp.quit) 
           
       
       def createTrayMenu(self): 
         self.trayIconMenu = QMenu(self.window) 
         self.trayIconMenu.addAction(self.minimizeAction) 
         self.trayIconMenu.addAction(self.maximizeAction) 
         self.trayIconMenu.addAction(self.restoreAction) 
         self.trayIconMenu.addSeparator( ) 
         self.trayIconMenu.addAction(self.quitAction) 
       
         self.setContextMenu(self.trayIconMenu) 
        
       def setVisible(self, visible): 
        self.minimizeAction.setEnabled(not visible) 
        self.maximizeAction.setEnabled(not self.window.isMaximized()) 
        self.restoreAction.setEnabled(self.window.isMaximized() or not visible) 
        super(Window, self).setVisible(visible) 
       
       
       
       def closeEvent(self, event): 
        #if event.button( ) == Qt.RightButton: 
        self.showMessage("Message", 
          "The program will keep running in the system tray. To " 
          "terminate the program, choose Quit in the " 
          "context menu of the system tray entry.", 
          QSystemTrayIcon.Information, 5000) 
        self.window.hide( ) 
        event.ignore( ) 
       
       def slot_iconActivated(self, reason): 
        if reason == QSystemTrayIcon.DoubleClick: 
         self.wiondow.showNormal( ) 
       
       
       
      #-------------------------------------------------------------------------------- 
      class DigitClock(QLCDNumber): 
       """ 
       the DigitClock show a digit clock int the printer 
       """ 
        
       #---------------------------------------------------------------------------- 
       def __init__(self, parent = None): 
        """ 
        the constructor function of the DigitClock 
        """ 
        super(DigitClock, self).__init__(parent) 
        pale = self.palette( ) 
       
        pale.setColor(QPalette.Window, QColor(100, 180, 100)) 
        self.setPalette(pale) 
         
        self.setNumDigits(19) 
        self.systemTrayIcon = SystemTrayIcon(mainWindow = self) 
       
         
        self.dragPosition = None; 
        self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.Popup | Qt.Tool) 
        self.setWindowOpacity(1) 
         
        self.showTime( )   # print the time when the clock show 
        self.systemTrayIcon.show( ) # show the SystemTaryIcon when the clock show 
       
        self.timer = QTimer( ) 
        self.connect(self.timer, SIGNAL("timeout( )"), self.showTime) 
        self.timer.start(1000) 
         
        self.resize(500, 60) 
         
        
       #---------------------------------------------------------------------------- 
       def showTime(self): 
        """ 
        show the current time 
        """ 
        self.date = QDate.currentDate( ) 
        self.time = QTime.currentTime( ) 
        text = self.date.toString("yyyy-MM-dd") + " " + self.time.toString("hh:mm:ss") 
        self.display(text) 
       
         
       
       #---------------------------------------------------------------------------- 
       def mousePressEvent(self, event): 
        """ 
        clicked the left mouse to move the clock 
        clicked the right mouse to hide the clock 
        """ 
        if event.button( ) == Qt.LeftButton: 
         self.dragPosition = event.globalPos( ) - self.frameGeometry( ).topLeft( ) 
         event.accept( ) 
        elif event.button( ) == Qt.RightButton: 
         self.systemTrayIcon.closeEvent(event) 
       
         #self.systemTrayIcon.hide( ) 
         #self.close( ) 
       
       def mouseMoveEvent(self, event): 
        """ 
        """ 
        if event.buttons( ) & Qt.LeftButton: 
         self.move(event.globalPos( ) - self.dragPosition) 
         event.accept( ) 
        
       def keyPressEvent(self, event): 
        """ 
        you can enter "ESC" to normal show the window, when the clock is Maxmize 
        """ 
        if event.key() == Qt.Key_Escape and self.isMaximized( ): 
         self.showNormal( ) 
       
       def mouseDoubleClickEvent(self, event): 
        """ 
        """ 
        if event.buttons() == Qt.LeftButton: 
         if self.isMaximized( ): 
          self.showNormal( ) 
         else: 
          self.showMaximized( ) 
        
      if __name__ == "__main__": 
       app = QApplication(sys.argv) 
        
       digitClock = DigitClock( ) 
       digitClock.show( )  
        
       sys.exit(app.exec_( )) 
      

      網(wǎng)頁標(biāo)題:python+PyQT怎么實現(xiàn)系統(tǒng)桌面時鐘?-創(chuàng)新互聯(lián)
      網(wǎng)站網(wǎng)址:http://ef60e0e.cn/article/dgegos.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        敖汉旗| 班玛县| 固安县| 镇江市| 寻甸| 阿尔山市| 威海市| 渭源县| 泗洪县| 鹿邑县| 政和县| 思南县| 保亭| 枝江市| 柯坪县| 承德市| 遂宁市| 工布江达县| 娱乐| 通海县| 姜堰市| 云和县| 万宁市| 千阳县| 灵寿县| 腾冲县| 西和县| 务川| 克什克腾旗| 榆树市| 靖远县| 揭阳市| 平湖市| 治县。| 白山市| 闽清县| 新兴县| 石景山区| 福泉市| 横峰县| 油尖旺区|