-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add queues to gui and bj3wc but also
realise that you cant fucking use multiprocessing with tkinter objects
- Loading branch information
1 parent
e578678
commit 52196e5
Showing
4 changed files
with
110 additions
and
54 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
from dataclasses import * | ||
|
||
@dataclass | ||
class QueueItem: | ||
function: str | ||
arguments: tuple | list | ||
|
||
def __post_init__(self): | ||
if type(self.arguments) not in [tuple, list]: | ||
def __init__(self, function: str, *arguments): | ||
self.function = function | ||
if type(arguments) not in [tuple, list]: | ||
try: | ||
self.arguments = tuple(self.arguments,) | ||
except: | ||
self.arguments = (self.arguments,) | ||
self.arguments = (self.arguments,) | ||
else: | ||
self.arguments = arguments |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from bj3wc import * | ||
from gui import * | ||
|
||
import multiprocessing | ||
|
||
def main(): | ||
world_championships = Bejeweled3WorldChampionships() | ||
gui = GraphicalUserInterface() | ||
|
||
with multiprocessing.Manager() as manager: | ||
gui_queue = manager.Queue() | ||
action_queue = manager.Queue() | ||
|
||
world_championships.gui_queue = gui_queue | ||
world_championships.action_queue = action_queue | ||
gui.gui_queue = gui_queue | ||
gui.action_queue = action_queue | ||
|
||
wc = multiprocessing.Process(target = world_championships.check_queue, name = "championships") | ||
g = multiprocessing.Process(target = gui.start, name = "gui") | ||
|
||
wc.start() | ||
g.start() | ||
|
||
g.join() | ||
print("GUI stopped") | ||
wc.join() | ||
print("World Championships stopped") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |