Skip to content

Commit a6ac3f2

Browse files
author
ilgarlunin
committed
cut multipldispatch. fix style sheet problem applying style to whole QApplication. Redundant api, maya launch wip, small fixes. Singletons destroy on window close
1 parent fdc1525 commit a6ac3f2

27 files changed

+134
-144
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ PyFlow/Configs/
99
docs/build/
1010
docs/source/_build/
1111
docs/build_docs_env.bat
12+
__pycache__/

.vscode/launch.json

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
{
2-
// Use IntelliSense to learn about possible attributes.
3-
// Hover to view descriptions of existing attributes.
4-
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
52
"version": "0.2.0",
63
"configurations": [
74
{
@@ -12,54 +9,19 @@
129
"console": "integratedTerminal"
1310
},
1411
{
15-
"name": "Python: Current File (Integrated Terminal)",
16-
"type": "python",
17-
"request": "launch",
18-
"program": "${file}",
19-
"console": "integratedTerminal"
20-
},
21-
{
22-
"name": "Python: Attach",
12+
"name": "Python: Attach Maya",
2313
"type": "python",
2414
"request": "attach",
25-
"port": 5678,
26-
"host": "localhost"
15+
"port": 3000,
16+
"host": "0.0.0.0"
2717
},
2818
{
29-
"name": "Python: Module",
19+
"name": "Python: Current File (Integrated Terminal)",
3020
"type": "python",
3121
"request": "launch",
32-
"module": "enter-your-module-name-here",
22+
"program": "${file}",
3323
"console": "integratedTerminal"
3424
},
35-
{
36-
"name": "Python: Django",
37-
"type": "python",
38-
"request": "launch",
39-
"program": "${workspaceFolder}/manage.py",
40-
"console": "integratedTerminal",
41-
"args": [
42-
"runserver",
43-
"--noreload",
44-
"--nothreading"
45-
],
46-
"django": true
47-
},
48-
{
49-
"name": "Python: Flask",
50-
"type": "python",
51-
"request": "launch",
52-
"module": "flask",
53-
"env": {
54-
"FLASK_APP": "app.py"
55-
},
56-
"args": [
57-
"run",
58-
"--no-debugger",
59-
"--no-reload"
60-
],
61-
"jinja": true
62-
},
6325
{
6426
"name": "Python: Current File (External Terminal)",
6527
"type": "python",

PyFlow/App.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
from PyFlow.UI.EditorHistory import EditorHistory
4848
from PyFlow.UI.Tool import GET_TOOLS
4949
from PyFlow.UI.Tool import REGISTER_TOOL
50+
from PyFlow.UI.Utils.stylesheet import editableStyleSheet
5051
from PyFlow.Wizards.PackageWizard import PackageWizard
5152
from PyFlow import INITIALIZE
5253
from PyFlow.Input import InputAction, InputActionType
@@ -90,6 +91,7 @@ class PyFlow(QMainWindow):
9091

9192
def __init__(self, parent=None):
9293
super(PyFlow, self).__init__(parent=parent)
94+
self.currentSoftware = ""
9395
self.edHistory = EditorHistory(self)
9496
self.setWindowTitle("PyFlow v{0}".format(currentVersion().__str__()))
9597
self.undoStack = QUndoStack(self)
@@ -430,6 +432,8 @@ def invokeDockToolByName(self, packageName, name, settings=None):
430432
def closeEvent(self, event):
431433
self.tick_timer.stop()
432434
self.tick_timer.timeout.disconnect()
435+
EditorHistory().shutdown()
436+
433437
self.canvasWidget.shoutDown()
434438
# save editor config
435439
settings = ConfigManager().getSettings("APP_STATE")
@@ -466,6 +470,12 @@ def closeEvent(self, event):
466470
if os.path.exists(self.currentTempDir):
467471
shutil.rmtree(self.currentTempDir)
468472

473+
# TODO: Use "Borg" pattern
474+
EditorHistory.destroy()
475+
GraphManagerSingleton.destroy()
476+
ConfigManager.destroy()
477+
PreferencesWindow.destroy()
478+
469479
QMainWindow.closeEvent(self, event)
470480

471481
def shortcuts_info(self):
@@ -493,13 +503,15 @@ def shortcuts_info(self):
493503
QMessageBox.information(self, "Shortcuts", data)
494504

495505
@staticmethod
496-
def instance(parent=None):
497-
if PyFlow.appInstance is not None:
498-
return PyFlow.appInstance
499-
506+
def instance(parent=None, software=""):
500507
settings = ConfigManager().getSettings("APP_STATE")
501508

502509
instance = PyFlow(parent)
510+
instance.currentSoftware = software
511+
512+
if software == "standalone":
513+
editableStyleSheet(instance)
514+
503515
REGISTER_TOOL("PyFlowBase", LoggerTool)
504516
a = GET_TOOLS()["PyFlowBase"][0]()
505517
a.setAppInstance(instance)

PyFlow/ConfigManager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515

1616
import os
1717
import json
18-
from enum import Enum
18+
1919
from Qt import QtCore, QtGui
2020

21-
from PyFlow.Core.Common import SingletonDecorator
21+
from PyFlow.Core.Common import *
2222
from PyFlow.Input import InputAction, InputManager, InputActionType
2323

2424

PyFlow/Core/Common.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535

3636
from nine import IS_PYTHON2, str
3737
if IS_PYTHON2:
38-
from aenum import IntEnum, Flag, auto
38+
from aenum import IntEnum, Flag, auto, Enum
3939
else:
40-
from enum import IntEnum, Flag, auto
40+
from enum import IntEnum, Flag, auto, Enum
4141

4242
from PyFlow import findPinClassByType
4343
from PyFlow.Core.version import Version
@@ -619,6 +619,10 @@ def __init__(self, cls):
619619
self.cls = cls
620620
self.instance = None
621621

622+
def destroy(self):
623+
del self.instance
624+
self.instance = None
625+
622626
def __call__(self, *args, **kwds):
623627
if self.instance is None:
624628
self.instance = self.cls(*args, **kwds)

PyFlow/Core/GraphBase.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
import weakref
1717
from blinker import Signal
18-
from multipledispatch import dispatch
1918
from collections import Counter
2019

2120
from PyFlow.Core.Common import *

PyFlow/Core/GraphManager.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515

1616
from nine import str
17-
from multipledispatch import dispatch
1817
from blinker import Signal
1918

2019
from PyFlow.Core.GraphBase import GraphBase

PyFlow/Core/NodeBase.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
except:
2626
from inspect import getargspec
2727
from types import MethodType
28-
from multipledispatch import dispatch
2928
import collections
3029

3130
from PyFlow import getPinDefaultValueByType

PyFlow/Input.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from collections import Counter
1717
from collections import defaultdict
18-
from enum import Enum
18+
1919
from Qt import QtCore, QtGui
2020

2121
from PyFlow.Core.Common import *

PyFlow/Packages/PyFlowBase/FunctionLibraries/PathLib.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
# Copyright 2015-2019 Ilgar Lunin, Pedro Cabrera
23

34
# Licensed under the Apache License, Version 2.0 (the "License");

PyFlow/Packages/PyFlowBase/Nodes/consoleOutput.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@
1313
## limitations under the License.
1414

1515

16+
from nine import *
17+
import logging
18+
1619
from PyFlow.Core import NodeBase
1720
from PyFlow.Core.NodeBase import NodePinsSuggestionsHelper
21+
from PyFlow.ConfigManager import ConfigManager
1822
from PyFlow.Core.Common import *
19-
from nine import *
20-
import logging
23+
2124

2225
class consoleOutput(NodeBase):
2326
def __init__(self, name):
@@ -51,7 +54,8 @@ def description():
5154
return "Python's 'print' function wrapper"
5255

5356
def compute(self, *args, **kwargs):
54-
if self.getWrapper() is not None:
57+
redirectionEnabled = ConfigManager().getPrefsValue("PREFS", "General/RedirectOutput") == "true"
58+
if self.getWrapper() is not None and redirectionEnabled:
5559
data = str(self.entity.getData())
5660
if self.entity.dataType != "StringPin":
5761
data = data.encode('unicode-escape')
@@ -60,5 +64,5 @@ def compute(self, *args, **kwargs):
6064
errorLink = """<a href=%s><span style=" text-decoration: underline; color:green;">%s</span></a></p>""" % (self.name, "<br/>%s" % data)
6165
logging.getLogger(None).consoleoutput(errorLink)
6266
else:
63-
print("{0}: {1}".format(self.name, self.entity.getData()))
67+
print(self.entity.getData())
6468
self.outExec.call()

PyFlow/Packages/PyFlowBase/Nodes/constant.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@
1919
from PyFlow import findPinClassByType, getAllPinClasses
2020
from PyFlow import CreateRawPin
2121
from copy import copy
22-
from multipledispatch import dispatch
2322

2423
class constant(NodeBase):
2524
def __init__(self, name):
2625
super(constant, self).__init__(name)
2726
self.input = self.createInputPin("in", 'AnyPin', defaultValue=0.0, structure=PinStructure.Multi, constraint="1", structConstraint="1")
2827
self.output = self.createOutputPin("out", 'AnyPin', defaultValue=0.0, structure=PinStructure.Multi, constraint="1", structConstraint="1")
2928
self.input.disableOptions(PinOptions.ChangeTypeOnConnection)
30-
self.output.disableOptions(PinOptions.ChangeTypeOnConnection)
29+
self.output.disableOptions(PinOptions.ChangeTypeOnConnection)
3130
pinAffects(self.input, self.output)
3231
self.input.call = self.output.call
3332
self.pinTypes = []

PyFlow/Packages/PyFlowBase/Nodes/convertTo.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from PyFlow import findPinClassByType, getAllPinClasses
2020
from PyFlow import CreateRawPin
2121
from copy import copy
22-
from multipledispatch import dispatch
2322

2423

2524
class convertTo(NodeBase):

PyFlow/UI/Canvas/Canvas.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from inspect import getfullargspec as getargspec
2525
except:
2626
from inspect import getargspec
27-
from multipledispatch import dispatch
2827

2928
from Qt import QtCore
3029
from Qt import QtGui
@@ -665,22 +664,6 @@ def disableSortcuts(self):
665664
def enableSortcuts(self):
666665
self._sortcuts_enabled = True
667666

668-
@dispatch(uuid.UUID)
669-
def findPin(self, uid):
670-
uiPin = None
671-
if uid in self.pins:
672-
return self.pins[uid]
673-
return uiPin
674-
675-
@dispatch(str)
676-
def findPin(self, pinName):
677-
uiPin = None
678-
for pin in self.pins.values():
679-
if pinName == pin.getFullName():
680-
uiPin = pin
681-
break
682-
return uiPin
683-
684667
def onNewFile(self, keepRoot=True):
685668
self.getApp().undoStack.clear()
686669
self.shoutDown()
@@ -1028,7 +1011,6 @@ def pasteNodes(self, move=True, data=None):
10281011
if newNode.isCommentNode:
10291012
newNode.collapsed = data["wrapper"]["collapsed"]
10301013

1031-
@dispatch(str)
10321014
def findNode(self, name):
10331015
for node in self.nodes.values():
10341016
if name == node.name:

0 commit comments

Comments
 (0)