-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathshuffler.py
More file actions
60 lines (49 loc) · 1.7 KB
/
shuffler.py
File metadata and controls
60 lines (49 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python
# -'''- coding: utf-8 -'''-
import sys
import subprocess
from PySide.QtCore import *
from PySide.QtGui import *
from PySide.QtDeclarative import *
import PIL
import PIL.Image
import sqlite3
import random
from time import sleep
class MyHandler(QObject):
def __init__(self, window, *args, **kwargs):
QObject.__init__(self, *args, **kwargs)
self.window = window
self.conn = sqlite3.connect('badges.db')
c = self.conn.cursor()
c.execute(""" SELECT ticket FROM badges WHERE ticket != ''""")
tickets = []
for t in c.fetchall():
tickets.append(t[0])
random.shuffle(tickets)
self.tickets = tickets
@Slot(QObject)
def run(self, target):
target.setProperty('text', self.tickets.pop())
# Our main window
class MainWindow(QDeclarativeView):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.setWindowTitle("Main Window")
# Renders 'view.qml'
self.setSource(QUrl.fromLocalFile('shuffler-view.qml'))
# QML resizes to main window
self.setResizeMode(QDeclarativeView.SizeRootObjectToView)
if __name__ == '__main__':
# Create the Qt Application
app = QApplication(sys.argv)
# Create and show the main window
window = MainWindow()
window.setWindowFlags(Qt.FramelessWindowHint)
handler = MyHandler(window)
window.rootContext().setContextProperty("handler", handler)
#window.rootObject().findChild(QObject, 'inputName').selectAll()
#print window.rootContext().findChild(QObject, 'winners')
window.showFullScreen()
# Run the main Qt loop
sys.exit(app.exec_())