forked from logicalgamers/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDefault_GUI.plugin.py
More file actions
56 lines (36 loc) · 1.62 KB
/
Default_GUI.plugin.py
File metadata and controls
56 lines (36 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from PyQt4 import QtGui, QtCore
class Default_GUI():
def __init__(self):
pass
def _accept_API(self, API):
self.GUI = GUI(API)
def __call__(self):
while(True):
print "Default_GUI"
class Plugin_ListWidget(QtGui.QListWidget):
def __init__(self, API, parent=None):
super(Plugin_ListWidget, self).__init__(parent)
self.itemDoubleClicked.connect(self.plugin_double_clicked)
self.Plugins_API = API
def plugin_double_clicked(self, QListWidgetItem):
for Plugin in self.Plugins_API.get_plugins():
if(str(QListWidgetItem.text()) in str(Plugin.__dict__['plugin_name'])):
Plugin.run()
class GUI(QtGui.QWidget):
def __init__(self, API, title="Main"):
super(GUI, self).__init__()
self.API = API
self.Title = title
def run(self):
self.init_UI()
def init_UI(self):
self.setGeometry(500, 340, 500, 340)
self.setWindowTitle(self.Title)
self.Layout = QtGui.QBoxLayout(2, self)
self.Plugins_ListWidget = Plugin_ListWidget(API=self.API) # Create the custom QListWidget
self.Layout.addWidget(self.Plugins_ListWidget) # Add the Plugins_ListWidget to the Layout.
for Plugin in self.API.get_plugins():
if(Plugin is not None): # Just to make sure that the plugin was loaded
if('plugin_name' in Plugin.__dict__ and 'run' in dir(Plugin)): # correctly and all that before we add it to the ListWidget.
self.Plugins_ListWidget.addItem(Plugin.__dict__['plugin_name'])
self.show()