#点击自动更新按钮事件
def OnButtonAutoFrush( self ):
try:
#创建desktop文件放在启动文件夹下
file = open("/home/%s/.config/autostart/autobing.desktop" % (getpass.getuser()) , 'w')
desktop = """[Desktop Entry]
Version=1.0
Encoding=UTF-8
Name=AutoBing
Type=Application
Exec=python "%s/%s" one
Terminal=false
Comment=auto change systembackground from bingimage
NoDisplay=false
Categories=Utility; """ % (os.getcwd() , os.path.basename(__file__))
file.write(desktop)
file.close()
QtGui.QMessageBox.information( self, u'提示', u'自动更新设置成功\n如果移动了程序路径请重新设置')
except Exception, e:
QtGui.QMessageBox.information( self, u'提示', u'''设置自动更新失败''')
raise e
#点击刷新桌面壁纸
def OnButtonFrush(self):
try:
updateBack()
QtGui.QMessageBox.information( self, u'提示', u'''BING壁纸更新成功''')
pass
except Exception, e:
QtGui.QMessageBox.information( self, u'提示', u'''更新失败''')
raise
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(_translate("MainWindow", "BING壁纸自动更换", None))
self.pushButton.setText(_translate("MainWindow", "手动刷新", 'pushButton'))
self.pushButton2.setText(_translate("MainWindow", "登陆自动刷新", 'pushButton2'))
class BingWindow(QtGui.QMainWindow):
#初始化界面
def __init__(self,parent=None):
QtGui.QWidget.__init__(self,parent)
self.madWindow()
def madWindow(self):
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
import sys
app = QtGui.QApplication(sys.argv)
myqq = BingWindow()
myqq.show()
sys.exit(app.exec_())