Python Forum
Closing the Programm after stuck in while loop
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Closing the Programm after stuck in while loop
#4
This is my code so far. Any suggestions?

# -*- coding: utf-8 -*-
"""
Created on Mon Dec 03 11:12:09 2018

@author: Matthias Hochholzer
"""

import sys
import os
import subprocess
import time
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.uic import *

class HexChecker():
    
   # def getLines():            different approche
   #     global filePath, toolPath, gotPath
   #     filePath = w.hexLine.text()
   #     toolPath = w.consolLine.text()
   #     gotPath = 1
    #    print filePath
    
    
    def checkHex(self):
        global filePath, toolPath
        filePath = w.hexLine.text()
        toolPath = w.consolLine.text()
        while go:
            global oldDate
            newDate = time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(os.path.getmtime(filePath)))
            if newDate != oldDate:
                subprocess.Popen([toolPath, "-c", "SWD", "-P", filePath, "-v", "-Rst"], shell = True)
                oldDate = newDate
            time.sleep(1)
            
       
       
    def cancelFlashing(self):
        global go
        go = 0
     
     
filePath = "start"
toolPath = "start"
oldDate = "0000-00-00 00:00:00"
go = 1
hexChecker = HexChecker()

app = QApplication(sys.argv)
w = loadUi("Autoflash.ui")

w.startButton.clicked.connect(hexChecker.checkHex)
w.closeButton.clicked.connect(hexChecker.cancelFlashing)

w.show()
sys.exit(app.exec_())
Reply


Messages In This Thread
RE: Closing the Programm after stuck in while loop - by Rigunas - Dec-17-2018, 10:57 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Tried to programm a parking lot Croshihw 0 2,232 Sep-19-2018, 09:08 AM
Last Post: Croshihw

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020