parent
b750ae8bae
commit
c41dd80143
|
|
@ -27,20 +27,24 @@ class WatchPipe(QThread):
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
while True:
|
while True:
|
||||||
while True:
|
while not os.path.exists(pipe_path): time.sleep(0.1)
|
||||||
if os.path.exists(pipe_path): break
|
|
||||||
else: time.sleep(0.1)
|
|
||||||
pipe = open(pipe_path, 'r')
|
pipe = open(pipe_path, 'r')
|
||||||
pipe.flush()
|
pipe.flush()
|
||||||
|
|
||||||
while True:
|
was_nonzero = False
|
||||||
if not os.path.exists(pipe_path):
|
|
||||||
break # Handle game quitting cleanup
|
while os.path.exists(pipe_path): # Make sure the file still exists and wasn't cleaned up by SyngleChance
|
||||||
message = os.read(pipe.fileno(), 256)
|
message = os.read(pipe.fileno(), 256)
|
||||||
if len(message) > 0:
|
if len(message) > 0:
|
||||||
|
was_nonzero = True
|
||||||
self.change_image.emit(message.decode())
|
self.change_image.emit(message.decode())
|
||||||
|
else:
|
||||||
|
st = os.stat(pipe_path)
|
||||||
|
if st.st_size == 0 and was_nonzero:
|
||||||
|
self.change_image.emit("CLOSE")
|
||||||
|
|
||||||
time.sleep(0.05)
|
time.sleep(0.05)
|
||||||
|
|
||||||
class AnimationTimer(QThread):
|
class AnimationTimer(QThread):
|
||||||
next_frame = pyqtSignal()
|
next_frame = pyqtSignal()
|
||||||
|
|
@ -95,12 +99,16 @@ class Journal(QWidget):
|
||||||
self.setGeometry(frameGm.x() + pos.x() - self.mousedownpos.x(), frameGm.y() + pos.y() - self.mousedownpos.y(), 800, 600)
|
self.setGeometry(frameGm.x() + pos.x() - self.mousedownpos.x(), frameGm.y() + pos.y() - self.mousedownpos.y(), 800, 600)
|
||||||
|
|
||||||
def change_image(self, image):
|
def change_image(self, image):
|
||||||
|
if image == "CLOSE":
|
||||||
|
self.app.quit()
|
||||||
|
return
|
||||||
|
if not "_" in image: return
|
||||||
|
|
||||||
name, lang = image.split('_', 1)
|
name, lang = image.split('_', 1)
|
||||||
if lang == 'en':
|
if lang == 'en': img = os.path.join(base_path, 'images', '{}.png'.format(name))
|
||||||
img = os.path.join(base_path, 'images', '{}.png'.format(name))
|
else: img = os.path.join(base_path, 'images', lang.upper(), '{}.png'.format(name))
|
||||||
else:
|
|
||||||
img = os.path.join(base_path, 'images', lang.upper(), '{}.png'.format(name))
|
|
||||||
if not os.path.exists(img): return
|
if not os.path.exists(img): return
|
||||||
|
|
||||||
self.pixmap = QPixmap(img)
|
self.pixmap = QPixmap(img)
|
||||||
self.label.setPixmap(self.pixmap)
|
self.label.setPixmap(self.pixmap)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue