Created
October 29, 2019 02:13
-
-
Save alexrockhill/5b64cc0d283a760c059af5bbc75b9aac to your computer and use it in GitHub Desktop.
fbs PyQt5 unable to write file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fbs_runtime.application_context.PyQt5 import ApplicationContext | |
from PyQt5.QtWidgets import (QMainWindow, QLabel, QPushButton, | |
QWidget, QStackedWidget) | |
import sys | |
import os | |
import os.path as op | |
class AppContext(ApplicationContext): | |
def run(self, path): | |
exp = Test(500, 500, path) | |
exp.show() | |
return self.app.exec_() | |
class Test(QMainWindow): | |
def __init__(self, width, height, path): | |
super().__init__() | |
self.path = path | |
self.setGeometry(0, 0, width, height) | |
self.stack = QStackedWidget(self) | |
self.setCentralWidget(self.stack) | |
self.stack.addWidget(self.screen1()) # 0 | |
self.stack.addWidget(self.screen2()) # 1 | |
# SCREENS | |
def screen1(self): | |
screen1 = QWidget() | |
button = QPushButton('start', screen1) | |
button.pressed.connect(self.test) | |
return screen1 | |
def screen2(self): | |
screen2 = QWidget() | |
screen2.label = QLabel(self.path, screen2) | |
return screen2 | |
def test(self): | |
self.stack.setCurrentIndex(1) | |
with open(op.join('/Applications', 'test.txt', 'w')) as f: | |
f.write('test') | |
if __name__ == '__main__': | |
path = os.getcwd() | |
appctxt = AppContext() | |
exit_code = appctxt.run(path) | |
sys.exit(exit_code) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment