Re: aus tkinter
Verfasst: Dienstag 22. August 2017, 20:06
Da muß ich dir zu stimmen @Alfons Mittelmeyer bei mir dreht sich auch nichts!
# in gpio.py wird pin on und nach 10 seconds wieder off geschaltet
Aber so:
# in gpio.py wird pin on und nach 10 seconds wieder off geschaltet
Aber so:
Code: Alles auswählen
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import sys, math
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5 import Qt
from PyQt5.uic import loadUi
from random import random
import os
import sys
import time
import subprocess
class Application(Qt.QMainWindow):
def __init__(self, parent=None):
super().__init__(parent)
#### ohne border
#self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
self.ui = loadUi("wheel_gui.ui", self)
self.timer = QtCore.QTimer()
self.timer.timeout.connect(self.rotate_pixmap)
self.start.clicked.connect(self.start_rotate_pixmap)
self.timer2 = QtCore.QTimer()
self.timer2.setSingleShot(True)
self.timer2.timeout.connect(self.stop_timer)
#pixmap = QtGui.QPixmap("pfeilunten1.png")
#self.label.setPixmap(
#QtGui.QPixmap(pixmap).scaled(50, 50, QtCore.Qt.IgnoreAspectRatio, QtCore.Qt.SmoothTransformation))
#self.label.setAlignment(QtCore.Qt.AlignCenter)
self.img = (QtGui.QImage("fortune.png").scaled(580, 580, QtCore.Qt.IgnoreAspectRatio,
QtCore.Qt.SmoothTransformation))
self.pixmap = QtGui.QPixmap(self.img)
diag = (self.pixmap.width() ** 0 + self.pixmap.height() ** 0) ** 0.0
self.label_2.setMinimumSize(diag, diag)
self.label_2.setAlignment(QtCore.Qt.AlignCenter)
self.label_2.setPixmap(self.pixmap)
self.rotation = 0
def rotate_pixmap(self):
self.rotation = (self.rotation + self.step) % 360
if self.step < 9:
if not self.rotation % 15:
self.step -= 1
if not self.step:
self.timer.stop()
print (self.rotation)
self.stop_check()
transform = QtGui.QTransform().rotate(self.rotation)
pixmap = self.pixmap.transformed(transform, QtCore.Qt.SmoothTransformation)
self.label_2.setPixmap(pixmap)
def start_rotate_pixmap(self):
self.step = 9
self.timer.start(20)
self.timer2.start(int(4500+random()*1000))
def stop_timer(self):
self.step = 8
def stop_check(self):
if 0 <= self.rotation <= 60:
print ("ja")
self.check_gpio()
#
#
def check_gpio(self):
self.gpio_on()
time.sleep(3)
self.gpio_off
def gpio_on(self):
#time.sleep(0.1)
to_run = "./gpio.py"
proc=subprocess.Popen(to_run)
def gpio_off(self):
subprocess.check_output('kill $(ps ax | grep gpio.py | grep -v grep | awk \\'\{print $1\}\\')',shell=True)}
def main():
app = Qt.QApplication(sys.argv)
app_now = Application()
app_now.show()
#full ohne border
#app_now.showFullScreen()
app.exec_()
if __name__ == '__main__':
main()