<commit_before>﻿#! /usr/bin/python3 

import sys
from PyQt5.QtWidgets import (QWidget, QHBoxLayout, 
    QLabel, QApplication, QPushButton)
from PyQt5.QtGui import QPixmap
from PyQt5.QtCore import QObject


class FreakingQtImageViewer(QWidget):
    
    def __init__(self, function):
        super().__init__()
        self.function = function
        
        self.initUI(function)
        
    def refresh(self):
        self.function()
        
        pixmap = QPixmap("tmp.png")
        pixmap = pixmap.scaledToWidth(800)
        self.lbl.setPixmap(pixmap)
        
    def initUI(self, function):      

        hbox = QHBoxLayout(self)
        
        self.lbl = QLabel(self)
        self.refresh()
        
        btn = QPushButton(self)
        btn.setText('Drück mich')
        btn.clicked.connect(self.refresh)
        
        hbox.addWidget(self.lbl)
        hbox.addWidget(btn)
        self.setLayout(hbox)
        
        self.move(300, 200)
        self.setWindowTitle('Freaking Qt Image Viewer')
        self.show()


        
        

<commit_msg>Update image every 0.5s till button gets pressed again<commit_after>﻿#! /usr/bin/python3 

import sys
import time
from PyQt5.QtWidgets import (QWidget, QHBoxLayout, 
    QLabel, QApplication, QPushButton)
from PyQt5.QtGui import QPixmap
from PyQt5.QtCore import QObject


class FreakingQtImageViewer(QWidget):
    
    def __init__(self, function):
        super().__init__()
        self.function = function
        self.initUI(function)
        self.refresh = False
    
      
    def refresh(self):
        if !self.refresh:
            self.refresh = True
            while self.refresh:
                self.function()
                
                pixmap = QPixmap("tmp.png")
                pixmap = pixmap.scaledToWidth(800)
                self.lbl.setPixmap(pixmap)
                time.sleep(0.5)
        else: 
            self.refresh = False
        
    def initUI(self, function):      

        hbox = QHBoxLayout(self)
        
        self.lbl = QLabel(self)
        self.refresh()
        
        btn = QPushButton(self)
        btn.setText('Drück mich')
        btn.clicked.connect(self.refresh)
        
        hbox.addWidget(self.lbl)
        hbox.addWidget(btn)
        self.setLayout(hbox)
        
        self.move(300, 200)
        self.setWindowTitle('Freaking Qt Image Viewer')
        self.show()


        
        


{'fraction_non_alphanumeric': 0.09282178217821782, 'fraction_numerical': 0.012376237623762377, 'mean_word_length': 1.7339346110484781, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3641264', 'n_tokens_mistral': 788, 'n_tokens_neox': 733, 'n_words': 142}