Skip to content

Instantly share code, notes, and snippets.

@Informatic
Last active May 23, 2017 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Informatic/cd611b4b4163d02708937b5bc45b1e46 to your computer and use it in GitHub Desktop.
Save Informatic/cd611b4b4163d02708937b5bc45b1e46 to your computer and use it in GitHub Desktop.
import sys
from cx_Freeze import setup, Executable
build_exe_options = {
"packages": ["PySide", "requests"],
"optimize": 2,
}
setup(name="bugtest app",
version="0.1",
description="just a simple test",
executables=[
Executable("bugtest.py", base=None),
],
options={"build_exe": build_exe_options})
import sys
import requests
from PySide import QtCore, QtGui
class TestThread(QtCore.QThread):
progress = QtCore.Signal(str)
def run(self):
self.progress.emit('before request')
print('doing stuff...')
print(requests.get('https://google.com'))
print('done')
self.progress.emit('after request, done')
class MainWindow(QtGui.QMainWindow):
def __init__(self, parent=None, app=None):
super(MainWindow, self).__init__(parent)
self.btn = QtGui.QPushButton(self)
self.btn.setText('press me...')
self.btn.clicked.connect(self.on_btn_clicked)
self.setCentralWidget(self.btn)
self.th = TestThread(self)
self.th.progress.connect(self.on_thread_progress)
def on_btn_clicked(self):
self.th.start()
def on_thread_progress(self, text):
self.btn.setText("progress: %s" % text)
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment