QWidget: Must construct a QApplication before a QWidget

2021.10.23 16:53 Turboflopper QWidget: Must construct a QApplication before a QWidget

I got three files (GUI.py, encrypt.py, filebrowser.py). Via GUI, the user clicks a "search" button that opens a filebrowser. He Chooses a file and hits "encrypt" to encrypt it. As long as I got the encrypt.py imported inside the GUI.py I get the error "QWidget: Must construct a QApplication before a QWidget" so I guess the mistake lies inside the encrypt.py. But within the encrypt.py I dont use any PyQt, I just get the filename off a variable from the filebrowser.py which indeed uses PyQt. Anybody got some advice?
filebrowser.py:

import sys from PyQt5.QtWidgets import QApplication, QWidget, QInputDialog, QLineEdit, QFileDialog from PyQt5.QtGui import QIcon class App(QWidget): #unencrypted def __init__(self): super().__init__() self.title = 'PyQt5 file dialog' self.left = 10 self.top = 10 self.width = 640 self.height = 480 self.initUI() def initUI(self): self.setWindowTitle(self.title) self.setGeometry(self.left, self.top, self.width, self.height) self.openFileNameDialog() #self.openFileNamesDialog() #self.saveFileDialog() self.show() def openFileNameDialog(self): global fileName options = QFileDialog.Options() options |= QFileDialog.DontUseNativeDialog fileName = QFileDialog.getOpenFileName(self,"Choose file to encrypt", "./","All Files (*);;Python Files (*.py)", options=options) if fileName: return(fileName) if __name__ == '__main__': 
app = QApplication(sys.argv) ex = App() sys.exit(app.exec_())
encrypt.py:
import os 
from filebrowser import App import filebrowser as FB
class App1(object): 
def encrypt(filename:str = None): if filename is None: filename = FB.App().openFileNameDialog() to_encrypt = open(filename, "rb").read() size = len(to_encrypt) key = os.urandom(size) with open(filename + ".key", "wb") as key_out: key_out.write(key) encrypted = bytes(ab for (a,b) in zip(filename, key)) with open(filename, "wb") as encrypted_out: encrypted_out.write(encrypted) encrypt(filename=FB.App().openFileNameDialog())
class App2(object): 
def decrypt(filename, key): file = open(filename, "rb").read() key = open(key, "rb").read() decrypted = bytes(ab for (a,b) in zip(file, key)) with open("de_" + filename, "wb") as decrypted_out: decrypted_out.write(decrypted)
Even if I add
from PyQt5.QtWidgets import QApplication, QWidget 
at the top of the encrypt.py and
if __name__ == '__main__': 
import sys from PyQt5.QtWidgets import QApplication app = QApplication(sys.argv) sys.exit(app.exec_())
at it's bottom I get the same error. Im a newbie so please don't be too harsh.

Thanks alot<3
submitted by Turboflopper to learnpython [link] [comments]


2021.10.23 16:53 Effective_Albatros Requesting help to ID these.

Requesting help to ID these. submitted by Effective_Albatros to ShroomID [link] [comments]


2021.10.23 16:53 alkaliphiles A Wilmington double rainbow, y'all!

A Wilmington double rainbow, y'all! submitted by alkaliphiles to WilmingtonDE [link] [comments]


2021.10.23 16:53 hiddenproblem12 Post open surgery

Hello everyone it’s been 17 weeks since I had open surgery to remove my appendix and I’ve started light weights in the gym. I’ve realised when I lay down on a flat bench or try do pull ups. When my stomach is in a stretch position I can feel the incisions. Has anybody experienced this and how long will it take until it’s gone.
submitted by hiddenproblem12 to Hernia [link] [comments]


2021.10.23 16:53 crazy_ex_boyfriend What are your thoughts about the viral song Island boy by Flyysoulja and Kodiyakredd?

For the uninitiated this is the viral song https://youtu.be/YIWSEa5U9_U
submitted by crazy_ex_boyfriend to NoStupidQuestions [link] [comments]


2021.10.23 16:53 MrsLaceyBones The lucky peepkin has come to visit, hope you are doing well today.

The lucky peepkin has come to visit, hope you are doing well today. submitted by MrsLaceyBones to Memes_Of_The_Dank [link] [comments]


2021.10.23 16:53 rabotatrecords IT'S ALIVE! The newest episode of Rabotat Radio - Halloween 2021 Watched or Wasted Special!

IT'S ALIVE! The newest episode of Rabotat Radio - Halloween 2021 Watched or Wasted Special! submitted by rabotatrecords to SelfPromotionYouTube [link] [comments]


2021.10.23 16:53 Klams7896 Why yes I did buy a jersey just to match my car.

Why yes I did buy a jersey just to match my car. submitted by Klams7896 to hockeyjerseys [link] [comments]


2021.10.23 16:53 pminasia 715 Creeks Heron

715 Creeks Heron submitted by pminasia to boniver [link] [comments]


2021.10.23 16:53 CultureAnxious 🔥 The Narrows in Zion National Park

🔥 The Narrows in Zion National Park submitted by CultureAnxious to NatureIsFuckingLit [link] [comments]


2021.10.23 16:53 Mhind1 What should I look for that may be causing this

submitted by Mhind1 to ender3 [link] [comments]


2021.10.23 16:53 noNazis_noCommunists What actor has grown worse with time?

submitted by noNazis_noCommunists to AskReddit [link] [comments]


2021.10.23 16:53 Lis7xz Is it worth it to buy Fallout 76 in 2021 ?

Hello everyone, and I'm a potential new player in 76-th, so I saw a lot of videos about it, and as far as I understand it was horrible in the beginning, but now it seems to be more attractive and playable. So guys, could you tell me if it is worth it to buy it now when this game has a discount?
submitted by Lis7xz to Fallout [link] [comments]


2021.10.23 16:53 Varionator A structure similar to the omnipresent god statue in celestia

A structure similar to the omnipresent god statue in celestia submitted by Varionator to Genshin_Lore [link] [comments]


2021.10.23 16:53 ZhiRou2003 Luna's big brother Osauh

Luna's big brother Osauh submitted by ZhiRou2003 to lookatmydog [link] [comments]


2021.10.23 16:53 HolcBuster I drew Oryx! Please be gentle…

https://www.instagram.com/p/CVYRNN6LdW5/?utm_medium=copy_link
submitted by HolcBuster to DestinyTheGame [link] [comments]


2021.10.23 16:53 Bobert1823 Help

I need a Gibby gawd to help me out. I’ve been playing him for about a week and I have some great matches and then some horrible ones. I can hardly ever win really close up fights. I start to hip fire but then if I ADS it’s too close and I miss my shots. But if I don’t ADS I get melted because I’m so big. Also I never can win a 1V2. They always just both push me. I’m a good player. Have hit 20bomb before and 4K multiple times but I struggle with the big man. Someone help lol
submitted by Bobert1823 to GibraltarMains [link] [comments]


2021.10.23 16:53 ArmySash [PGA TOUR 2K21] #17 I am honest. I didn't enjoy a single minute of those 13 hours. But at least I won a bet with a co-worker... Deleted the game instantly after the trophy plopped.

[PGA TOUR 2K21] #17 I am honest. I didn't enjoy a single minute of those 13 hours. But at least I won a bet with a co-worker... Deleted the game instantly after the trophy plopped. submitted by ArmySash to Trophies [link] [comments]


2021.10.23 16:53 Free_Stick_ Hey Americans, the All Blacks are playing in Washington against The USA Eagles. Check it out. (Weekend vibes)

Hey Americans, the All Blacks are playing in Washington against The USA Eagles. Check it out. (Weekend vibes) submitted by Free_Stick_ to Superstonk [link] [comments]


2021.10.23 16:53 Rekcoret M340i. Absolutely love this car.

M340i. Absolutely love this car. submitted by Rekcoret to BMW [link] [comments]


2021.10.23 16:53 hqjl Bouncey

Bouncey submitted by hqjl to Kellzor101 [link] [comments]


2021.10.23 16:53 OskarKHL Does pine trees know that cactues exist? And if they met would they be friends or enemies?

submitted by OskarKHL to questions [link] [comments]


2021.10.23 16:53 rotted_teeth Cant claim Halloween pass

Cant claim Halloween pass submitted by rotted_teeth to RedDeadOnline [link] [comments]


2021.10.23 16:53 jaydawg999 Painting advice - Hi all keen to get some thoughts around what colour people would pain the skirt and fireplace trim??

submitted by jaydawg999 to architecture [link] [comments]


2021.10.23 16:53 rumpusrouser How is the quality of Fable 2 on Xbox game pass?

I was thinking of replaying it but my disk is pretty scratched up. I have played it on game pass before but the textures would glitch out, specifically I remember my hair and some random patches of scenery would turn blue. Has it improved in the last few years?
submitted by rumpusrouser to Fable [link] [comments]


http://carmonkey.ru