class MyTimer(QWidget): def __init__(self): QWidget.__init__(self) self.setWindowTitle(u"Цифровые часы") timer = QTimer(self) self.connect(timer, SIGNAL("timeout()"), self.updtTime) self.myTimeDisplay = QLCDNumber(self) self.myTimeDisplay.setSegmentStyle(QLCDNumber.Filled) self.myTimeDisplay.setDigitCount(8) self.myTimeDisplay.resize(500, 150) timer.start(1000) def updtTime(self): currentTime = QDateTime.currentDateTime().toString("hh:mm:ss") self.myTimeDisplay.display(currentTime)
class MyTimer(QWidget): def __init__(self): QWidget.__init__(self) self.setWindowTitle(u'Цифровые часы') timer = QTimer(self) self.connect(timer, SIGNAL("timeout()"), self.updtTime) self.myTimeDisplay = QLCDNumber(self) self.myTimeDisplay.setSegmentStyle(QLCDNumber.Filled) self.myTimeDisplay.setDigitCount(8) self.myTimeDisplay.resize(500, 150) timer.start(1000) def updtTime(self): currentTime = QDateTime.currentDateTime().toString('hh:mm:ss') self.myTimeDisplay.display(currentTime)
# Create and show the forms if sys.platform.startswith('win'): # Make sure the program is running w/ administrative privileges. import win32api from win32com.shell import shell, shellcon if not shell.IsUserAnAdmin(): alertBox = QMessageBox() alertBox.setText("You may need to run this program as an Administrator. If it doesn't work please close this program, and run it by right clicking and choose 'Run As Administrator' ") alertBox.show() #get the MS AppData directory to store data in homedir = "{}\\".format(shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0)) if not os.path.isdir("{0}{1}".format(homedir, "SelfRestraint")): os.mkdir("{0}{1}".format(homedir, "SelfRestraint")) homedir = homedir + "\\SelfRestraint\\" # updater = checkForUpdates() # updater.check() donate = checkDonation() form = MainForm() form.show() list = ListEditor() list.loadBlockFile() # Run the main Qt loop counter = QLCDNumber() counter.setSegmentStyle(QLCDNumber.Filled) counter.setNumDigits(8) counter.resize(150, 60) sys.exit(app.exec_())
# the next line replaces the currently-running process with the sudo os.execlpe('gksudo', *args) sys.exit(1) # Create the Qt Application app = QApplication(sys.argv) backend = Backend() # Create and show the forms if os.name == "nt": # Make sure the program is running w/ administrative privileges. from win32com.shell import shell if not shell.IsUserAnAdmin(): alertBox = QMessageBox() alertBox.setText ("You may need to run this program as an Administrator. If it doesn't work please close this program, and run it by right clicking and choose 'Run As Administrator' ") alertBox.show() updater = checkForUpdates() updater.check() form = MainForm() form.show() list = ListEditor() # Run the main Qt loop counter = QLCDNumber() counter.setSegmentStyle(QLCDNumber.Filled) counter.setNumDigits(8) counter.resize(150, 60) sys.exit(app.exec_())