summaryrefslogtreecommitdiff
path: root/9kwpyqt.py
diff options
context:
space:
mode:
Diffstat (limited to '9kwpyqt.py')
-rwxr-xr-x9kwpyqt.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/9kwpyqt.py b/9kwpyqt.py
index cbc84be..aceff68 100755
--- a/9kwpyqt.py
+++ b/9kwpyqt.py
@@ -180,8 +180,10 @@ class CaptchaGUI(QWidget):
def removeCaptchaImage(self):
self.captchaImage.removeImage()
- def toggleRunning(self):
- self.running = not self.running
+ def toggleRunning(self, force_start=False, force_stop=False):
+ if force_start: self.running = True
+ elif force_stop: self.running = False
+ else: self.running = not self.running
self.captchaImage.setText("")
self.offlinemessage = "Click \"Start\" to fetch next captcha."
self.startstopButton.setText(self.running and "Stop" or "Start")
@@ -325,11 +327,14 @@ class CaptchaGUI(QWidget):
# Handle logic
##################################################
def readConfig(self):
+ if self.config is not None:
+ return False
defaultconfig = {}
defaultconfig['API_URL'] = 'http://www.9kw.eu/index.cgi'
defaultconfig['API_KEY'] = ''
defaultconfig['Sound'] = 'yes'
defaultconfig['Soundfile'] = 'notify.wav'
+ defaultconfig['Autostart'] = 'no'
self.config = configparser.ConfigParser(defaultconfig)
try:
self.config.read_file(open('9kwpyqt.ini'))
@@ -344,6 +349,8 @@ class CaptchaGUI(QWidget):
self.apiurl = self.config['DEFAULT']['API_URL']+"?source=pythonapi&apikey="+self.config['DEFAULT']['API_KEY']+"&"
self.sound = QSound(self.config['DEFAULT']['Soundfile'])
self.soundCheckbox.setChecked( self.config.getboolean('DEFAULT', 'Sound') )
+ if self.config.getboolean('DEFAULT', 'Autostart'):
+ self.toggleRunning(force_start=True)
return True
def writeConfig(self):
@@ -371,11 +378,9 @@ class CaptchaGUI(QWidget):
timing = self.timeleft - time.time()
self.captchaTimer.setText(str(round(timing, 1))+"s")
if timing <= 0:
- self.timeleft = None
- self.running = False
+ self.toggleRunning(force_stop=True)
self.offlinemessage = "30 seconds passed without input."
- self.startstopButton.setText(self.running and "Stop" or "Start")
- self.startstopButton.setChecked(self.running)
+ self.timeleft = None
self.skipCaptcha()
def onQuit(self):