92b76e5e pyros2097

13 years ago
v0.43
Widget/QsciLexerSquirrel.py DELETED
@@ -1,186 +0,0 @@
1
- from PyQt4.Qsci import QsciLexerCustom,QsciStyle
2
- from PyQt4.QtCore import QString
3
- from PyQt4.QtGui import *
4
-
5
- #class QsciLexerSquirrel(QsciLexer):
6
-
7
- # def __init__(self):
8
- # pass
9
- #prefs.declare('font.name.margin', "MS Dlg")
10
- #prefs.declare('font.size.margin', 8)
11
- #prefs.declare('font.name.code', "Courier New")
12
- #prefs.declare('font.size.code', 10)
13
- #prefs.declare('color.editline', "#d0e0ff")
14
-
15
- class QsciLexerSquirrel(QsciLexerCustom):
16
- def __init__(self, obj=None):
17
- QsciLexerCustom.__init__(self, obj)
18
- self.sci = None
19
- self.plainFont = QFont()
20
- self.plainFont.setPointSize(10)
21
- self.plainFont.setFamily("Courier New")
22
- self.marginFont = QFont()
23
- self.marginFont.setPointSize(10)
24
- self.marginFont.setFamily("MS Dlg")
25
- self.boldFont = QFont()
26
- self.boldFont.setPointSize(10)
27
- self.boldFont.setFamily("Courier New")
28
- self.boldFont.setBold(True)
29
- self.styles = [
30
- QsciStyle(0, QString("base"), QColor("#000000"), QColor("#ffffff"), self.plainFont, True),
31
- QsciStyle(1, QString("comment"), QColor("#008000"), QColor("#eeffee"), self.marginFont, True),
32
- QsciStyle(2, QString("keyword"), QColor("#000080"), QColor("#ffffff"), self.boldFont, True),
33
- QsciStyle(3, QString("string"), QColor("#800000"), QColor("#ffffff"), self.marginFont, True),
34
- QsciStyle(4, QString("atom"), QColor("#008080"), QColor("#ffffff"), self.plainFont, True),
35
- QsciStyle(5, QString("macro"), QColor("#808000"), QColor("#ffffff"), self.boldFont, True),
36
- QsciStyle(6, QString("error"), QColor("#000000"), QColor("#ffd0d0"), self.plainFont, True),
37
- ]
38
- print("LexerErlang created")
39
-
40
- def description(self, ix):
41
- for i in self.styles:
42
- if i.style() == ix:
43
- return QtCore.QString(i.description())
44
- return QtCore.QString("")
45
- def setEditor(self, sci):
46
- self.sci = sci
47
- Qsci.QsciLexerCustom.setEditor(self, sci)
48
- print("LexerErlang.setEditor()")
49
- def styleText(self, start, end):
50
- print("LexerErlang.styleText(%d,%d)" % (start, end))
51
- lines = self.getText(start, end)
52
- offset = start
53
- self.startStyling(offset, 0)
54
- print("startStyling()")
55
- for i in lines:
56
- if i == "":
57
- self.setStyling(1, self.styles[0])
58
- print("setStyling(1)")
59
- offset += 1
60
- continue
61
- if i[0] == '%':
62
- self.setStyling(len(i)+1, self.styles[1])
63
- print("setStyling(%)")
64
- offset += len(i)+1
65
- continue
66
- self.setStyling(len(i)+1, self.styles[0])
67
- print("setStyling(n)")
68
- offset += len(i)+1
69
-
70
- def getText(self, start, end):
71
- data = self.sci.text()
72
- print("LexerErlang.getText(): " + str(len(data)) + " chars")
73
- return data[start:end].split('\n')
74
-
75
-
76
- import sys
77
- from PyQt4 import QtCore, QtGui, Qsci
78
-
79
- class MainWindow(QtGui.QMainWindow):
80
- def __init__(self):
81
- QtGui.QMainWindow.__init__(self)
82
- self.setWindowTitle('Custom Lexer Example')
83
- self.setGeometry(QtCore.QRect(50,200,400,400))
84
- self.editor = Qsci.QsciScintilla(self)
85
- self.editor.setUtf8(True)
86
- self.editor.setMarginWidth(2, 15)
87
- self.editor.setFolding(True)
88
- self.setCentralWidget(self.editor)
89
- self.lexer = CustomLexer(self.editor)
90
- self.editor.setLexer(self.lexer)
91
- self.editor.setText('\n# sample source\n\nfoo = 1\nbar = 2\n')
92
-
93
- class CustomLexer(Qsci.QsciLexerCustom):
94
- def __init__(self, parent):
95
- Qsci.QsciLexerCustom.__init__(self, parent)
96
- self._styles = {
97
- 0: 'Default',
98
- 1: 'Comment',
99
- 2: 'Key',
100
- 3: 'Assignment',
101
- 4: 'Value',
102
- }
103
- for key,value in self._styles.iteritems():
104
- setattr(self, value, key)
105
-
106
- def description(self, style):
107
- return self._styles.get(style, '')
108
-
109
- def defaultColor(self, style):
110
- if style == self.Default:
111
- return QtGui.QColor('#000000')
112
- elif style == self.Comment:
113
- return QtGui.QColor('#C0C0C0')
114
- elif style == self.Key:
115
- return QtGui.QColor('#0000CC')
116
- elif style == self.Assignment:
117
- return QtGui.QColor('#CC0000')
118
- elif style == self.Value:
119
- return QtGui.QColor('#00CC00')
120
- return Qsci.QsciLexerCustom.defaultColor(self, style)
121
-
122
- def styleText(self, start, end):
123
- editor = self.editor()
124
- if editor is None:
125
- return
126
-
127
- # scintilla works with encoded bytes, not decoded characters.
128
- # this matters if the source contains non-ascii characters and
129
- # a multi-byte encoding is used (e.g. utf-8)
130
- source = ''
131
- if end > editor.length():
132
- end = editor.length()
133
- if end > start:
134
- if sys.hexversion >= 0x02060000:
135
- # faster when styling big files, but needs python 2.6
136
- source = bytearray(end - start)
137
- editor.SendScintilla(
138
- editor.SCI_GETTEXTRANGE, start, end, source)
139
- else:
140
- source = unicode(editor.text()
141
- ).encode('utf-8')[start:end]
142
- if not source:
143
- return
144
-
145
- # the line index will also be needed to implement folding
146
- index = editor.SendScintilla(editor.SCI_LINEFROMPOSITION, start)
147
- if index > 0:
148
- # the previous state may be needed for multi-line styling
149
- pos = editor.SendScintilla(
150
- editor.SCI_GETLINEENDPOSITION, index - 1)
151
- state = editor.SendScintilla(editor.SCI_GETSTYLEAT, pos)
152
- else:
153
- state = self.Default
154
-
155
- set_style = self.setStyling
156
- self.startStyling(start, 0x1f)
157
-
158
- # scintilla always asks to style whole lines
159
- for line in source.splitlines(True):
160
- length = len(line)
161
- if line.startswith('#'):
162
- state = self.Comment
163
- else:
164
- # the following will style lines like "x = 0"
165
- pos = line.find('=')
166
- if pos > 0:
167
- set_style(pos, self.Key)
168
- set_style(1, self.Assignment)
169
- length = length - pos - 1
170
- state = self.Value
171
- else:
172
- state = self.Default
173
- set_style(length, state)
174
- # folding implementation goes here
175
- levelFolder = editor.SendScintilla(editor.SCI_GETFOLDLEVEL, index-1)
176
- if line.startswith('+ '):
177
- editor.SendScintilla(editor.SCI_SETFOLDLEVEL, index, levelFolder + 1)
178
- index += 1
179
-
180
- if __name__ == "__main__":
181
- app = QtGui.QApplication(sys.argv)
182
- app.connect(app, QtCore.SIGNAL('lastWindowClosed()'),
183
- QtCore.SLOT('quit()'))
184
- win = MainWindow()
185
- win.show()
186
- sys.exit(app.exec_())
Widget/__init__.py CHANGED
@@ -1,4 +1,5 @@
1
1
  from editor import Editor
2
2
  from tab import Tab
3
3
  from tree import Tree
4
+ from adb import Adb
4
5
  from ipython import PyInterp
Widget/__init__.pyc CHANGED
Binary file
Widget/apipread.py DELETED
@@ -1,91 +0,0 @@
1
- # begin sample application #
2
- from PyQt4.QtGui import *
3
- from PyQt4.QtCore import *
4
- from PyQt4.Qsci import *
5
- import sys
6
-
7
- # Examle API
8
- TESTAPI= """
9
- Constant1
10
- Constant2
11
- unknownFunction(??)
12
- knownFunction(name, directory)
13
- knownFunction2(number,string)
14
- module.function(??)
15
- """
16
-
17
- class Main(QMainWindow):
18
- def __init__(self):
19
- QMainWindow.__init__(self, None)
20
- self.start()
21
-
22
- def start(self):
23
- lexer = self.lexer = QsciLexerPython()
24
- api = QsciAPIs(lexer)
25
- # write the API to a file
26
- self.api = api
27
- # load the api into
28
- assert api.load("test.api")
29
- api.connect(api, SIGNAL("apiPreparationStarted()"),self.started)
30
- api.connect(api, SIGNAL("apiPreparationFinished()"),self.finished)
31
- # prepare the binary version of the API, suitable for loading
32
- api.prepare()
33
-
34
- def started(self):
35
- print "api is starting"
36
-
37
- def finished(self):
38
- # save the api to a binary file
39
- self.api.savePrepared("test.prepared")
40
- # Shows how to use the prepared API inside Scintilla with a prettier
41
- # Python Mode
42
- editor = self.editor = QsciScintilla(self.centralWidget())
43
- #editor.show()
44
- lexer = QsciLexerPython()
45
- api = QsciAPIs(lexer)
46
- # load the api into the lexer so code-completion should
47
- # work
48
- assert api.loadPrepared("test.prepared")
49
- lexer.setAPIs(api)
50
- editor.setAutoCompletionSource(editor.AcsAPIs)
51
- editor.setAutoCompletionThreshold(1)
52
- editor.setLexer(lexer)
53
- # set up the editor the prettier Python editing
54
- editor.setIndentationsUseTabs(False)
55
- font = QFont()
56
- fm = QFontMetrics(font)
57
- editor.setIndentationWidth(4)
58
- editor.setTabWidth(4)
59
- editor.show()
60
- if sys.platform != "win32":
61
- editor.zoomIn(3)
62
- editor.setIndentationsUseTabs(False)
63
- editor.setIndentationWidth(4)
64
- editor.setTabWidth(4)
65
- # conventionnaly, margin 0 is for line numbers
66
- editor.setMarginWidth(0, fm.width( "00000" ) + 5)
67
- editor.setMarginLineNumbers(0, True)
68
- ## Edge Mode shows a red vetical bar at 80 chars
69
- editor.setEdgeMode(QsciScintilla.EdgeLine)
70
- editor.setEdgeColor(QColor("#FF0000"))
71
- ## Folding visual : we will use boxes
72
- editor.setFolding(QsciScintilla.BoxedTreeFoldStyle)
73
- ## Braces matching
74
- editor.setBraceMatching(QsciScintilla.SloppyBraceMatch)
75
- ## Editing line color
76
- editor.setCaretLineVisible(True)
77
- editor.setCaretLineBackgroundColor(QColor("#CDA869"))
78
- ## Margins colors
79
- # line numbers margin
80
- editor.setMarginsBackgroundColor(QColor("#333333"))
81
- editor.setMarginsForegroundColor(QColor("#CCCCCC"))
82
- # folding margin colors (foreground,background)
83
- editor.setFoldMarginColors(QColor("#99CC66"),QColor("#333300"))
84
- # uncommenting this exception causes code-completion not to work.
85
- raise Exception("Why does this exception make code-completion work?")
86
-
87
-
88
- app = QApplication(sys.argv)
89
- mw = Main()
90
- mw.show()
91
- app.exec_()
Widget/clexer.py DELETED
@@ -1,204 +0,0 @@
1
- import sys
2
- from PyQt4.QtCore import SIGNAL, SLOT, QString
3
- from PyQt4.QtGui import QApplication, QMainWindow, QColor, QFont
4
- from PyQt4.Qsci import QsciScintilla, QsciLexerCustom
5
-
6
- # The most important and hard part of this code was given by Baz WALTER on the PyQt list.
7
-
8
- if sys.hexversion < 0x020600F0:
9
- print('python 2.6 or greater is required by this program')
10
- sys.exit(1)
11
-
12
- _sample = """
13
- /* This example uses
14
- this multi-line coment
15
- which can be extanded or retracted.
16
-
17
- The end must be the following line.
18
- */
19
-
20
- A text outside a MultiLinesComment
21
- is not retactable.
22
-
23
-
24
- /* Another
25
-
26
- test.
27
- */
28
- """
29
-
30
-
31
- class MainWindow(QMainWindow):
32
- def __init__(self):
33
- QMainWindow.__init__(self)
34
- self.setWindowTitle('Custom Lexer For Config Files')
35
- self.setGeometry(50, 200, 400, 400)
36
- self.editor = QsciScintilla(self)
37
- self.editor.setUtf8(True)
38
-
39
- # + OR - TO FOLD OR UNFOLD
40
- self.editor.setFolding(QsciScintilla.BoxedTreeFoldStyle)
41
- # LINES' NUMBER IN THE MARGIN
42
- self.editor.setMarginLineNumbers(1,True)
43
- self.editor.setMarginWidth(1, QString("-------"))
44
- # OK for 3 digits. This was found by direct tests...
45
-
46
- self.setCentralWidget(self.editor)
47
- self.lexer = ConfigLexer(self.editor)
48
- self.editor.setLexer(self.lexer)
49
- self.editor.setText(_sample)
50
-
51
-
52
- class ConfigLexer(QsciLexerCustom):
53
- def __init__(self, parent):
54
- QsciLexerCustom.__init__(self, parent)
55
- self._styles = {
56
- 0: 'Default',
57
- 1: 'MultiLinesComment_Start',
58
- 2: 'MultiLinesComment',
59
- 3: 'MultiLinesComment_End',
60
- 4: 'SingleLineComment'
61
- }
62
- for key,value in self._styles.iteritems():
63
- setattr(self, value, key)
64
- self._foldcompact = True
65
- self.__comment = [self.MultiLinesComment,
66
- self.MultiLinesComment_End,
67
- self.MultiLinesComment_Start,
68
- self.SingleLineComment]
69
-
70
- def foldCompact(self):
71
- return self._foldcompact
72
-
73
- def setFoldCompact(self, enable):
74
- self._foldcompact = bool(enable)
75
-
76
- def language(self):
77
- return 'Config Files'
78
-
79
- def description(self, style):
80
- return self._styles.get(style, '')
81
-
82
- def defaultColor(self, style):
83
- if style == self.Default:
84
- return QColor('#000000')
85
- elif style in self.__comment:
86
- return QColor('#A0A0A0')
87
- return QsciLexerCustom.defaultColor(self, style)
88
-
89
- def defaultFont(self, style):
90
- if style in self.__comment:
91
- if sys.platform in ('win32', 'cygwin'):
92
- return QFont('Comic Sans MS', 9, QFont.Bold)
93
- return QFont('Bitstream Vera Serif', 9, QFont.Bold)
94
- return QsciLexerCustom.defaultFont(self, style)
95
-
96
- def defaultPaper(self, style):
97
- # Here we change the color of the background.
98
- # We want to colorize all the background of the line.
99
- # This is done by using the following method defaultEolFill() .
100
- if style in self.__comment:
101
- return QColor('#FFEECC')
102
- return QsciLexerCustom.defaultPaper(self, style)
103
-
104
- def defaultEolFill(self, style):
105
- # This allowed to colorize all the background of a line.
106
- if style in self.__comment:
107
- return True
108
- return QsciLexerCustom.defaultEolFill(self, style)
109
-
110
- def styleText(self, start, end):
111
- editor = self.editor()
112
- if editor is None:
113
- return
114
-
115
- SCI = editor.SendScintilla
116
- GETFOLDLEVEL = QsciScintilla.SCI_GETFOLDLEVEL
117
- SETFOLDLEVEL = QsciScintilla.SCI_SETFOLDLEVEL
118
- HEADERFLAG = QsciScintilla.SC_FOLDLEVELHEADERFLAG
119
- LEVELBASE = QsciScintilla.SC_FOLDLEVELBASE
120
- NUMBERMASK = QsciScintilla.SC_FOLDLEVELNUMBERMASK
121
- WHITEFLAG = QsciScintilla.SC_FOLDLEVELWHITEFLAG
122
- set_style = self.setStyling
123
-
124
- source = ''
125
- if end > editor.length():
126
- end = editor.length()
127
- if end > start:
128
- source = bytearray(end - start)
129
- SCI(QsciScintilla.SCI_GETTEXTRANGE, start, end, source)
130
- if not source:
131
- return
132
-
133
- compact = self.foldCompact()
134
-
135
- index = SCI(QsciScintilla.SCI_LINEFROMPOSITION, start)
136
- if index > 0:
137
- pos = SCI(QsciScintilla.SCI_GETLINEENDPOSITION, index - 1)
138
- prevState = SCI(QsciScintilla.SCI_GETSTYLEAT, pos)
139
- else:
140
- prevState = self.Default
141
-
142
- self.startStyling(start, 0x1f)
143
-
144
- for line in source.splitlines(True):
145
- # Try to uncomment the following line to see in the console
146
- # how Scintiallla works. You have to think in terms of isolated
147
- # lines rather than globally on the whole text.
148
- # print line
149
-
150
- length = len(line)
151
- # We must take care of empty lines.
152
- # This is done here.
153
- if length == 1:
154
- if prevState == self.MultiLinesComment or prevState == self.MultiLinesComment_Start:
155
- newState = self.MultiLinesComment
156
- else:
157
- newState = self.Default
158
- # We work with a non empty line.
159
- else:
160
- if line.startswith('/*'):
161
- newState = self.MultiLinesComment_Start
162
- elif line.startswith('*/'):
163
- if prevState == self.MultiLinesComment or prevState == self.MultiLinesComment_Start:
164
- newState = self.MultiLinesComment_End
165
- else:
166
- newState = self.Default
167
- elif line.startswith('//'):
168
- if prevState == self.MultiLinesComment or prevState == self.MultiLinesComment_Start:
169
- newState = self.MultiLinesComment
170
- else:
171
- newState = self.SingleLineComment
172
- elif prevState == self.MultiLinesComment or prevState == self.MultiLinesComment_Start:
173
- newState = self.MultiLinesComment
174
- else:
175
- newState = self.Default
176
-
177
- set_style(length, newState)
178
-
179
- # Definition of the folding.
180
- # Documentation : http://scintilla.sourceforge.net/ScintillaDoc.html#Folding
181
- if newState == self.MultiLinesComment_Start:
182
- if prevState == self.MultiLinesComment:
183
- level = LEVELBASE + 1
184
- else:
185
- level = LEVELBASE | HEADERFLAG
186
- elif newState == self.MultiLinesComment or newState == self.MultiLinesComment_End:
187
- level = LEVELBASE + 1
188
- else:
189
- level = LEVELBASE
190
-
191
- SCI(SETFOLDLEVEL, index, level)
192
-
193
- pos = SCI(QsciScintilla.SCI_GETLINEENDPOSITION, index)
194
- prevState = SCI(QsciScintilla.SCI_GETSTYLEAT, pos)
195
-
196
- index += 1
197
-
198
-
199
- if __name__ == "__main__":
200
- app = QApplication(sys.argv)
201
- app.connect(app, SIGNAL('lastWindowClosed()'), app, SLOT('quit()'))
202
- win = MainWindow()
203
- win.show()
204
- sys.exit(app.exec_())
Widget/custom.py DELETED
@@ -1,183 +0,0 @@
1
- #########################################################
2
- ## customize Title bar
3
- ## dotpy.ir
4
- ## iraj.jelo@gmail.com
5
- #########################################################
6
- import sys
7
- from PyQt4 import QtGui
8
- from PyQt4 import QtCore
9
- from PyQt4.QtCore import Qt
10
-
11
-
12
- class TitleBar(QtGui.QDialog):
13
- def __init__(self, parent=None):
14
- QtGui.QWidget.__init__(self, parent)
15
- self.setWindowFlags(Qt.FramelessWindowHint);
16
- css = """
17
-
18
- QWidget
19
- {
20
- Background: #AA00AA;
21
- color:white;
22
- font:12px bold;
23
- font-weight:bold;
24
- border-radius: 1px;
25
- height: 11px;
26
-
27
- }
28
- QDialog{
29
- Background-image:url('img/titlebar bg.png');
30
- font-size:12px;
31
- color: black;
32
-
33
- }
34
- QToolButton{
35
- Background:#AA00AA;
36
- font-size:11px;
37
- }
38
- QToolButton:hover{
39
- Background:n #FF00FF;
40
- font-size:11px;
41
- }
42
- """
43
-
44
- self.setAutoFillBackground(True)
45
- self.setBackgroundRole(QtGui.QPalette.Highlight)
46
- self.setStyleSheet(css)
47
-
48
- self.minimize=QtGui.QToolButton(self);
49
- self.minimize.setIcon(QtGui.QIcon('img/min.png'));
50
-
51
- self.maximize=QtGui.QToolButton(self);
52
- self.maximize.setIcon(QtGui.QIcon('img/max.png'));
53
-
54
- close=QtGui.QToolButton(self);
55
- close.setIcon(QtGui.QIcon('img/close.png'));
56
-
57
- self.minimize.setMinimumHeight(10);
58
- close.setMinimumHeight(10);
59
- self.maximize.setMinimumHeight(10);
60
-
61
- label=QtGui.QLabel(self);
62
- label.setText("Window Title");
63
- self.setWindowTitle("Window Title");
64
- hbox=QtGui.QHBoxLayout(self);
65
-
66
- hbox.addWidget(label);
67
- hbox.addWidget(self.minimize);
68
- hbox.addWidget(self.maximize);
69
- hbox.addWidget(close);
70
- hbox.insertStretch(1,500);
71
- hbox.setSpacing(0);
72
- self.setSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Fixed);
73
- self.maxNormal=False;
74
-
75
- close.clicked.connect(self.close);
76
- self.minimize.clicked.connect(self.showSmall);
77
- self.maximize.clicked.connect(self.showMaxRestore);
78
-
79
-
80
- def showSmall(self):
81
- box.showMinimized();
82
-
83
- def showMaxRestore(self):
84
- if(self.maxNormal):
85
- box.showNormal();
86
- self.maxNormal= False;
87
- self.maximize.setIcon(QtGui.QIcon('img/max.png'));
88
- print'1'
89
-
90
- else:
91
- box.showMaximized();
92
- self.maxNormal= True;
93
- print '2'
94
- self.maximize.setIcon(QtGui.QIcon('img/max2.png'));
95
-
96
- def close(self):
97
- box.close()
98
-
99
- def mousePressEvent(self,event):
100
-
101
- if event.button() == Qt.LeftButton:
102
- box.moving = True; box.offset = event.pos()
103
-
104
- def mouseMoveEvent(self,event):
105
- if box.moving: box.move(event.globalPos()-box.offset)
106
-
107
-
108
- class Frame(QtGui.QFrame):
109
- def __init__(self, parent=None):
110
- QtGui.QFrame.__init__(self, parent)
111
- self.m_mouse_down= False;
112
- self.setFrameShape(QtGui.QFrame.StyledPanel)
113
- css = """
114
-
115
- QFrame
116
-
117
- {
118
- Background: #D700D7;
119
-
120
-
121
- color:white;
122
- font:13px ;
123
- font-weight:bold;
124
-
125
- }
126
-
127
-
128
- """
129
-
130
-
131
- self.setStyleSheet(css)
132
- self.setWindowFlags(Qt.FramelessWindowHint);
133
- self.setMouseTracking(True);
134
- self.m_titleBar= TitleBar(self);
135
- self.m_content= QtGui.QWidget(self);
136
-
137
- vbox=QtGui.QVBoxLayout(self);
138
- vbox.addWidget(self.m_titleBar);
139
- vbox.setMargin(0);
140
- vbox.setSpacing(0);
141
- layout=QtGui.QVBoxLayout(self);
142
- layout.addWidget(self.m_content);
143
- layout.setMargin(5);
144
- layout.setSpacing(0);
145
- vbox.addLayout(layout);
146
- # Allows you to access the content area of the frame
147
- # where widgets and layouts can be added
148
- def contentWidget(self):
149
- return self.m_content
150
- def titleBar(self):
151
- return self.m_titleBar
152
-
153
- def mousePressEvent(self,event):
154
- self.m_old_pos = event.pos();
155
- self.m_mouse_down = event.button()== Qt.LeftButton;
156
- def mouseMoveEvent(self,event):
157
-
158
- x=event.x();
159
- y=event.y();
160
-
161
- def mouseReleaseEvent(self,event):
162
- m_mouse_down=False;
163
-
164
-
165
-
166
-
167
- if __name__ == '__main__':
168
- app = QtGui.QApplication(sys.argv);
169
- box = Frame()
170
- box.move(60,60);
171
- l=QtGui.QVBoxLayout(box.contentWidget());
172
- l.setMargin(0);
173
- edit=QtGui.QLabel("""
174
- I would've did anything for you to show you how much I adored you
175
- But it's over now, it's too late to save our love
176
- Just promise me you'll think of me
177
- Every time you look up in the sky and see a star 'cuz I'm your star.
178
-
179
- """);
180
- l.addWidget(edit)
181
- box.show()
182
- app.exec_()
183
-
Widget/dra.py DELETED
@@ -1,68 +0,0 @@
1
- import sys
2
- from PyQt4 import QtGui, QtCore
3
-
4
- class TestTreeWidget(QtGui.QTreeWidget):
5
- def __init__(self, parent = None):
6
- super(TestTreeWidget, self).__init__(parent)
7
- self.setDragEnabled(True)
8
- self.setAcceptDrops(True)
9
-
10
- def startDrag(self, dropAction):
11
- # create mime data object
12
- mime = QtCore.QMimeData()
13
- mime.setData('text/xml', '???')
14
- # start drag
15
- drag = QtGui.QDrag(self)
16
- drag.setMimeData(mime)
17
- drag.start(QtCore.Qt.CopyAction | QtCore.Qt.CopyAction)
18
-
19
- def dragMoveEvent(self, event):
20
- if event.mimeData().hasUrls():
21
- event.setDropAction(QtCore.Qt.CopyAction)
22
- event.accept()
23
- else:
24
- event.ignore()
25
-
26
- def dragEnterEvent(self, event):
27
- if event.mimeData().hasUrls:
28
- event.accept()
29
- else:
30
- event.ignore()
31
-
32
- def dropEvent(self, event):
33
- if event.mimeData().hasUrls:
34
- event.acceptProposedAction()
35
- event.setDropAction(QtCore.Qt.CopyAction)
36
- event.accept()
37
- links = []
38
- for url in event.mimeData().urls():
39
- links.append(str(url.toLocalFile()))
40
- item = QtGui.QTreeWidgetItem(self)
41
- item.setText(0, str(url.toLocalFile()))
42
- self.addTopLevelItem(item)
43
- self.emit(QtCore.SIGNAL("dropped"), links)
44
- else:
45
- event.ignore()
46
-
47
- class MainForm(QtGui.QMainWindow):
48
- def __init__(self, parent=None):
49
- super(MainForm, self).__init__(parent)
50
-
51
- self.view = TestTreeWidget(self)
52
- self.view.setColumnCount(1)
53
- item0 = QtGui.QTreeWidgetItem(self.view)
54
- item0.setText(0, 'item0')
55
- item1 = QtGui.QTreeWidgetItem(self.view)
56
- item1.setText(0, 'item1')
57
- self.view.addTopLevelItems([item0, item1])
58
-
59
- self.setCentralWidget(self.view)
60
-
61
- def main():
62
- app = QtGui.QApplication(sys.argv)
63
- form = MainForm()
64
- form.show()
65
- app.exec_()
66
-
67
- if __name__ == '__main__':
68
- main()
Widget/keylex.py DELETED
@@ -1,358 +0,0 @@
1
-
2
- import sys
3
- from PyQt4.QtCore import SIGNAL, SLOT, QString,QStringList
4
- from PyQt4.QtGui import QApplication, QMainWindow, QColor, QFont
5
- from PyQt4.Qsci import QsciScintilla, QsciLexerCustom
6
-
7
- # The most important and hard part of this code was given by Baz WALTER on the PyQt list.
8
-
9
- if sys.hexversion < 0x020600F0:
10
- print('python 2.6 or greater is required by this program')
11
- sys.exit(1)
12
-
13
- _sample = """
14
- This example shows how to highlight some specific lines or words.
15
-
16
- + A first level title bold and red
17
- + A secund level title bold and blue with a yellow background
18
- Some text with green in green but also bold and underlined.
19
- The digits are gray with an orange backround. You don't believe it, look at that : 1 , 2 , ... , 123456789...
20
-
21
- It's very uggly but it shows how to do more pretty "highlighters".
22
-
23
- /*
24
- * credit scene
25
- */
26
- class CreditScene {
27
- foreground = null;
28
- okButton = null;
29
- layer = null;
30
-
31
- fadingOut = false;
32
-
33
- function onLoad() {
34
- stage.bgcolor(0, 0, 0, 1);
35
-
36
- local stageCenterX = stage.getWindowWidth() * 0.5;
37
- local stageCenterY = stage.getWindowHeight() * 0.5;
38
-
39
- local bgWidth = 480;
40
- local bgHeight = 320;
41
-
42
- if (useHD) {
43
- bgWidth = 960;
44
- bgHeight = 640;
45
- }
46
-
47
- if (background != null) {
48
- background.remove();
49
- }
50
-
51
- background = emo.Sprite(getHdImageName("credit_background.png"));
52
- background.moveCenter(stageCenterX, stageCenterY);
53
- background.setZ(0);
54
- background.load();
55
-
56
- layer = emo.Rectangle();
57
- layer.setSize(stage.getWindowWidth(), stage.getWindowHeight());
58
- layer.color(0.5, 0.5, 0.5, 0.78);
59
- layer.setZ(1);
60
- layer.load();
61
-
62
- foreground = emo.SpriteSheet(getHdImageName("credit.png"), bgWidth, bgHeight);
63
- foreground.moveCenter(stageCenterX, stageCenterY);
64
- foreground.setZ(2);
65
- foreground.load();
66
-
67
- foreground.animate(0, 2, 200, -1);
68
-
69
- local btWidth = 159;
70
- local btHeight = 52;
71
-
72
- if (useHD) {
73
- btWidth = 318;
74
- btHeight = 104;
75
- }
76
-
77
- okButton = emo.SpriteSheet(getHdImageName("credit_button.png"), btWidth, btHeight);
78
- okButton.move(
79
- foreground.getX() + foreground.getWidth() - okButton.getWidth(),
80
- foreground.getY() + foreground.getHeight() - okButton.getHeight());
81
- okButton.setZ(3);
82
- okButton.load();
83
- okButton.setFrame(1);
84
- }
85
-
86
- /*
87
- * Called when the app has gained focus
88
- */
89
- function onGainedFocus() {
90
- audio.playBGM();
91
- }
92
-
93
- /*
94
- * Called when the app has lost focus
95
- */
96
- function onLostFocus() {
97
- audio.pauseBGM();
98
- }
99
-
100
- function onDispose() {
101
- okButton.remove();
102
- foreground.remove();
103
- layer.remove();
104
- background.remove();
105
-
106
- background = null;
107
- }
108
-
109
- /*
110
- * touch event
111
- */
112
- function onMotionEvent(mevent) {
113
- local x = mevent.getX();
114
- local y = mevent.getY();
115
- if (mevent.getAction() == MOTION_EVENT_ACTION_DOWN) {
116
- if (okButton.contains(x, y)) {
117
- okButton.setFrame(0);
118
- audio.playSE0();
119
- if (!fadingOut) {
120
- fadingOut = true;
121
- stage.load(TitleScene(),
122
- null, emo.AlphaModifier(0, 1, 500, emo.easing.CubicOut));
123
- }
124
- }
125
- }
126
- }
127
- }
128
-
129
- """
130
-
131
-
132
-
133
- class MainWindow(QMainWindow):
134
- def __init__(self):
135
- QMainWindow.__init__(self)
136
- self.setWindowTitle('Custom Lexer For Config Files')
137
- self.setGeometry(50, 200, 400, 400)
138
- self.editor = QsciScintilla(self)
139
- self.editor.setUtf8(True)
140
-
141
- # LINES' NUMBER IN THE MARGIN
142
- self.editor.setMarginLineNumbers(1,True)
143
- self.editor.setMarginWidth(1, QString("-------"))
144
- # OK for 3 digits. This was found by direct tests...
145
- # WRAPING
146
- self.editor.setWrapMode(True)
147
-
148
- self.setCentralWidget(self.editor)
149
- self.lexer = ConfigLexer(self.editor)
150
- self.editor.setLexer(self.lexer)
151
- self.editor.setText(_sample)
152
-
153
-
154
- class ConfigLexer(QsciLexerCustom):
155
- def __init__(self, parent):
156
- QsciLexerCustom.__init__(self, parent)
157
- self._styles = {
158
- 0: 'Default',
159
- 1: 'FirstLevelTitle',
160
- 2: 'SecundLevelTitle',
161
- 3: 'Green',
162
- 4: 'Digits',
163
- 5: 'KeyWord1',
164
- 6: 'KeyWord2',
165
- 7: 'KeyWord3',
166
- 8: 'KeyWord4',
167
- }
168
- for key,value in self._styles.iteritems():
169
- setattr(self, value, key)
170
-
171
- self.lis = QStringList()
172
- self.lis<<"class" << "function"
173
- self.words1 = ['class','int', 'str', 'local', 'const', 'function', 'return', 'break']
174
- """
175
- 'int', 'str', 'local', 'const', 'function', 'return', 'break',
176
- 'continue', 'extends', 'constructor', 'foreach', 'for',
177
- 'while', 'do', 'case', 'try', 'vargc', 'default', 'resume', 'typeof',
178
- 'vargv', 'catch', 'delegate', 'instanceof', 'delete', 'if', 'switch',
179
- 'parent', 'clone', 'else', 'in', 'this', 'yield', 'enum', 'throw',
180
- 'static'
181
- ]
182
- """
183
- self.words2 = ['true', 'false', 'null']
184
-
185
- self.words3 = [
186
- 'rawdelete', 'rawin', 'array', 'seterrorhandler', 'setdebughook',
187
- 'enabledebuginfo', 'getroottable', 'setroottable', 'getconsttable',
188
- 'setconsttable', 'assert', 'print', 'compilestring', 'collectgarbage',
189
- 'type', 'getstackinfos', 'newthread', 'tofloat', 'tostring',
190
- 'tointeger', 'tochar', 'weakref', 'slice', 'find', 'tolower',
191
- 'toupper', 'len', 'rawget', 'rawset', 'clear', 'append', 'push',
192
- 'extend', 'pop', 'top', 'insert', 'remove', 'resize', 'sort',
193
- 'reverse', 'call', 'pcall', 'acall', 'pacall', 'bindenv', 'instance',
194
- 'getattributes', 'getclass', 'getstatus', 'ref'
195
- ]
196
-
197
- self.words4 = [
198
- 'init', 'dest', 'onLoad', 'onDispose', 'onGainedFocus','onMotionEvent',
199
- 'onLostFocus','onUpdate'
200
- ]
201
-
202
- def language(self):
203
- return 'Squirrel'
204
-
205
- def foldCompact(self):
206
- return self._foldcompact
207
-
208
- def setFoldCompact(self, enable):
209
- self._foldcompact = bool(enable)
210
-
211
- def description(self, style):
212
- return self._styles.get(style, '')
213
-
214
- def defaultColor(self, style):
215
- if style == self.Default:
216
- return QColor('#000000')
217
- elif style == self.FirstLevelTitle:
218
- return QColor('#FF0000')
219
- elif style == self.SecundLevelTitle:
220
- return QColor('#0000FF')
221
- elif style == self.Green:
222
- return QColor('#00FF00')
223
- elif style == self.Digits:
224
- return QColor('#AAAAAA')
225
- elif style == self.KeyWord1:
226
- return QColor('#8000FF')
227
- elif style == self.KeyWord2:
228
- return QColor('#400080')
229
- elif style == self.KeyWord3:
230
- return QColor('#FF0000')
231
- elif style == self.KeyWord4:
232
- return QColor('#000000')
233
-
234
- return QsciLexerCustom.defaultColor(self, style)
235
-
236
- def defaultFont(self, style):
237
- font = QsciLexerCustom.defaultFont(self, style)
238
-
239
- if style == self.FirstLevelTitle or style == self.SecundLevelTitle:
240
- font.setBold(True)
241
- elif style == self.Green:
242
- font.setBold(True)
243
- font.setUnderline(True)
244
-
245
- return font
246
-
247
- def defaultPaper(self, style):
248
- # Here we change the color of the background.
249
- # We want to colorize all the background of the line.
250
- # This is done by using the following method defaultEolFill() .
251
- if style == self.SecundLevelTitle:
252
- return QColor('#FFFF99')
253
- elif style == self.Digits:
254
- return QColor('#FFCC66')
255
-
256
- return QsciLexerCustom.defaultPaper(self, style)
257
-
258
- def defaultEolFill(self, style):
259
- # This allowed to colorize all the background of a line.
260
- if style == self.SecundLevelTitle:
261
- return True
262
- return QsciLexerCustom.defaultEolFill(self, style)
263
-
264
- def paintKeywords(self,source,start):
265
- for word in self.lis:
266
- word = QString(word)
267
- if(source.contains(word)):
268
- p = source.count(word)
269
- index = 0
270
- while (p != 0):
271
- begin = source.indexOf(word,index)
272
- index = begin +1
273
- self.startStyling (start + begin)
274
- self.setStyling (len(word), self.Green)
275
- self.startStyling (start + begin)
276
- p-=1
277
-
278
-
279
- def styleText(self, start, end):
280
- editor = self.editor()
281
- if editor is None:
282
- return
283
-
284
- SCI = editor.SendScintilla
285
- set_style = self.setStyling
286
-
287
- source = ''
288
- if end > editor.length():
289
- end = editor.length()
290
- if end > start:
291
- data = bytearray(end - start + 1)
292
- source = QString(data)
293
- SCI(QsciScintilla.SCI_GETTEXTRANGE, start, end, source)
294
- if not source:
295
- return
296
- self.paintKeywords(source, start)
297
- #self.startStyling(start, 0x1f)
298
-
299
- #index = SCI(QsciScintilla.SCI_LINEFROMPOSITION, start)
300
-
301
-
302
- """
303
- for line in source.splitlines(True):
304
- # Try to uncomment the following line to see in the console
305
- # how Scintiallla works. You have to think in terms of isolated
306
- # lines rather than globally on the whole text.
307
- # print line
308
-
309
- length = len(line)
310
-
311
- if line.startswith('+'):
312
- newState = self.FirstLevelTitle
313
- elif line.startswith('\t+') or line.startswith(' +'):
314
- newState = self.SecundLevelTitle
315
- else:
316
- pos = SCI(QsciScintilla.SCI_GETLINEENDPOSITION, index) - length + 1
317
- i = 0
318
- while i < length:
319
- wordLength = 1
320
-
321
- self.startStyling(i + pos, 0x1f)
322
-
323
- if chr(line[i]) in '0123456789':
324
- #newState = self.Digits
325
- pass
326
- else:
327
- newState = self.gett(line[i:])
328
- wordLength = 5
329
-
330
-
331
- if line[i:].startswith("class"):
332
- newState = self.KeyWord2
333
- wordLength = len('class')
334
- elif line[i:].startswith('function'):
335
- newState = self.KeyWord2
336
- wordLength = len('function')
337
- elif line[i:].startswith('null'):
338
- newState = self.KeyWord2
339
- wordLength = len('null')
340
- else:
341
- newState = self.Default
342
-
343
-
344
- i += wordLength
345
- set_style(wordLength, newState)
346
- newState = None
347
-
348
- if newState:
349
- set_style(length, newState)
350
-
351
- index += 1
352
- """
353
-
354
- if __name__ == "__main__":
355
- app = QApplication(sys.argv)
356
- win = MainWindow()
357
- win.show()
358
- sys.exit(app.exec_())
Widget/scint.py DELETED
@@ -1,35 +0,0 @@
1
- #!/usr/bin/env python
2
- # -*- coding: latin1 -*-
3
-
4
- """
5
- Basic use of the QScintilla2 widget
6
-
7
- Note : name this file "qt4_sci_ac_test.py"
8
- Base code originally from: http://kib2.free.fr/tutos/PyQt4/QScintilla2.html
9
- """
10
-
11
- import sys
12
- from PyQt4.QtGui import QApplication
13
- from PyQt4 import QtCore, QtGui, Qsci
14
- from PyQt4.Qsci import QsciScintilla, QsciScintillaBase, QsciLexerPython
15
-
16
-
17
- if __name__ == "__main__":
18
- app = QApplication(sys.argv)
19
- editor = QsciScintilla()
20
- lexer = QsciLexerPython()
21
-
22
- api = Qsci.QsciAPIs(lexer)
23
- api.load("emo.api")
24
- api.prepare()
25
- editor.setLexer(lexer)
26
- editor.setAutoCompletionThreshold(1)
27
- editor.setAutoCompletionSource(QsciScintilla.AcsAPIs)
28
- editor.show()
29
- editor.setText(open("scint.py").read())
30
- sys.exit(app.exec_())
31
-
32
-
33
-
34
-
35
-
Widget/snippet.py DELETED
@@ -1,61 +0,0 @@
1
- import sys
2
- import os
3
- from PyQt4 import QtGui, QtCore
4
-
5
- class TestListView(QtGui.QListWidget):
6
- def __init__(self, type, parent=None):
7
- super(TestListView, self).__init__(parent)
8
- self.setAcceptDrops(True)
9
- self.setIconSize(QtCore.QSize(72, 72))
10
-
11
- def dragEnterEvent(self, event):
12
- if event.mimeData().hasUrls:
13
- event.accept()
14
- else:
15
- event.ignore()
16
-
17
- def dragMoveEvent(self, event):
18
- if event.mimeData().hasUrls:
19
- event.setDropAction(QtCore.Qt.CopyAction)
20
- event.accept()
21
- else:
22
- event.ignore()
23
-
24
- def dropEvent(self, event):
25
- if event.mimeData().hasUrls:
26
- event.setDropAction(QtCore.Qt.CopyAction)
27
- event.accept()
28
- links = []
29
- for url in event.mimeData().urls():
30
- links.append(str(url.toLocalFile()))
31
- self.emit(QtCore.SIGNAL("dropped"), links)
32
- else:
33
- event.ignore()
34
-
35
- class MainForm(QtGui.QMainWindow):
36
- def __init__(self, parent=None):
37
- super(MainForm, self).__init__(parent)
38
-
39
- self.view = TestListView(self)
40
- self.connect(self.view, QtCore.SIGNAL("dropped"), self.pictureDropped)
41
- self.setCentralWidget(self.view)
42
-
43
- def pictureDropped(self, l):
44
- for url in l:
45
- if os.path.exists(url):
46
- print(url)
47
- icon = QtGui.QIcon(url)
48
- pixmap = icon.pixmap(72, 72)
49
- icon = QtGui.QIcon(pixmap)
50
- item = QtGui.QListWidgetItem(url, self.view)
51
- item.setIcon(icon)
52
- item.setStatusTip(url)
53
-
54
- def main():
55
- app = QtGui.QApplication(sys.argv)
56
- form = MainForm()
57
- form.show()
58
- app.exec_()
59
-
60
- if __name__ == '__main__':
61
- main()
Widget/test.api DELETED
@@ -1,6 +0,0 @@
1
- Constant1
2
- Constant2
3
- unknownFunction(??)
4
- knownFunction(name, directory)
5
- knownFunction2(number,string)
6
- module.function(??)
Widget/test.prepared DELETED
Binary file
Widget/tree.py CHANGED
@@ -1,5 +1,5 @@
1
1
  from PyQt4.QtGui import (QTreeWidgetItem,QTreeWidget,QMessageBox,
2
- QIcon,QDrag,QMenu,QAction,QInputDialog,QCursor)
2
+ QIcon,QDrag,QMenu,QAction,QInputDialog,QCursor,QToolBar)
3
3
  from PyQt4.QtCore import SIGNAL,Qt,QMimeData
4
4
  from globals import (oslistdir,ospathisdir,ospathsep,ospathjoin,ospathexists,
5
5
  ospathbasename,os_icon,osremove,osrename,ospathdirname,
@@ -183,11 +183,13 @@ class Tree(QTreeWidget):
183
183
  action_Open.triggered.connect(lambda:self.openProject(item))
184
184
  action_Close = QAction('Close', self)
185
185
  action_Close.triggered.connect(lambda:self.closeProject(item))
186
+ action_Refresh = QAction('Refresh', self)
187
+ action_Refresh.triggered.connect(lambda:self.refreshProject(item))
186
188
  action_RenameProject = QAction('Rename Project', self)
187
189
  action_RenameProject.triggered.connect(lambda:self.renameProject(item))
188
190
  action_RenameDir = QAction('Rename Dir', self)
189
191
  action_RenameDir.triggered.connect(lambda:self.renameDir(item))
190
- action_Rename = QAction('Rename', self)
192
+ action_Rename = QAction('Rename...', self)
191
193
  action_Rename.triggered.connect(lambda:self.rename(item))
192
194
  action_Delete = QAction(os_icon('trash'),'Delete', self)
193
195
  action_Delete.triggered.connect(lambda:self.delete(item))
@@ -201,6 +203,7 @@ class Tree(QTreeWidget):
201
203
  menu.addAction(action_RenameProject)
202
204
  menu.addAction(action_Delete)
203
205
  menu.addSeparator()
206
+ menu.addAction(action_Refresh)
204
207
  menu.addAction(action_Close)
205
208
  else:
206
209
  menu.addAction(action_Open)
@@ -229,16 +232,6 @@ class Tree(QTreeWidget):
229
232
  self.takeTopLevelItem(self.indexOfTopLevelItem(item))
230
233
  self.addClosedProject(item.getPath()[0])
231
234
 
232
-
233
- def newFolder(self,item):
234
- pass
235
- def addFolder(self,item):
236
- pass
237
- def newFile(self,item):
238
- pass
239
- def addFile(self,item):
240
- pass
241
-
242
235
  def renameProject(self,item):
243
236
  text,ok = QInputDialog.getText(self,"QInputDialog::getText()","New Name:")
244
237
  if (ok and text != ''):
@@ -247,7 +240,36 @@ class Tree(QTreeWidget):
247
240
  #print newname
248
241
  osrename(item.getPath(),newname)
249
242
  except:
250
- QMessageBox.about(self,"Could Not Rename","Could Not Rename The File")
243
+ QMessageBox.about(self,"Error","Could Not Rename The File")
244
+
245
+ def refreshProject(self,item):
246
+ pass
247
+
248
+
249
+ def newFolder(self,item):
250
+ text,ok = QInputDialog.getText(self,"QInputDialog::getText()","Name:")
251
+ if (ok and text != ''):
252
+ fname = ospathdirname(item.getPath())
253
+
254
+ try:
255
+ print fname+'/'+text
256
+ osmkdir(fname+'/'+text,0755)
257
+ except:
258
+ QMessageBox.about(self,"Error","Could Not Create The File")
259
+ def addFolder(self,item):
260
+ pass
261
+ def newFile(self,item):
262
+ text,ok = QInputDialog.getText(self,"QInputDialog::getText()","Name:")
263
+ if (ok and text != ''):
264
+ fname = ospathjoin(ospathdirname(item.getPath()),str(text))
265
+ try:
266
+ nfile = open(fname,'w')
267
+ nfile.close()
268
+ except:
269
+ QMessageBox.about(self,"Error","Could Not Create The File")
270
+
271
+ def addFile(self,item):
272
+ pass
251
273
 
252
274
  def renameDir(self,item):
253
275
  text,ok = QInputDialog.getText(self,"QInputDialog::getText()","New Name:")
@@ -257,7 +279,7 @@ class Tree(QTreeWidget):
257
279
  #print newname
258
280
  osrename(item.getPath(),newname)
259
281
  except:
260
- QMessageBox.about(self,"Could Not Rename","Could Not Rename The File")
282
+ QMessageBox.about(self,"Error","Could Not Rename The File")
261
283
 
262
284
  def rename(self,item):
263
285
  text,ok = QInputDialog.getText(self,"QInputDialog::getText()","New Name:")
@@ -267,7 +289,7 @@ class Tree(QTreeWidget):
267
289
  #print newname
268
290
  osrename(item.getPath(),newname)
269
291
  except:
270
- QMessageBox.about(self,"Could Not Rename","Could Not Rename The File")
292
+ QMessageBox.about(self,"Error","Could Not Rename The File")
271
293
 
272
294
  def delete(self,item):
273
295
  reply = QMessageBox.question(self,
@@ -281,4 +303,4 @@ class Tree(QTreeWidget):
281
303
  #print item.getPath()
282
304
  recycle(item.getPath())
283
305
  except:
284
- QMessa
306
+ QMessageBox.about(self,"Error","Could Not Delete The File")
Widget/tree.pyc CHANGED
Binary file
config.yaml CHANGED
@@ -6,6 +6,7 @@ ADB:
6
6
  shell kill
7
7
  File:
8
8
  - C:/CODE/assets/main.nut
9
+ - C:/CODE/assets/howtoscene.nut
9
10
  Project:
10
11
  - C:/CODE/assets/
11
12
  Recent:
globals.py CHANGED
@@ -2,7 +2,7 @@ import os
2
2
  from platform import system,python_version
3
3
  from PyQt4.QtGui import QIcon
4
4
  from send2trash import send2trash
5
-
5
+ from config import Config
6
6
  #Python accesses local variables much more efficiently than global variables.
7
7
  oslistdir = os.listdir
8
8
  ospathisdir = os.path.isdir
@@ -11,6 +11,7 @@ ospathjoin = os.path.join
11
11
  ospathexists = os.path.exists
12
12
  ospathbasename = os.path.basename
13
13
  ospathdirname = os.path.dirname
14
+ osmkdir = os.mkdir
14
15
  osremove = os.remove
15
16
  osrename = os.rename
16
17
  workDir = os.getcwd()
@@ -19,5 +20,13 @@ recycle = send2trash
19
20
  OS_NAME = system()
20
21
  PY_VERSION = python_version()
21
22
 
23
+ config = Config()
24
+ workSpace = config.workSpace()
25
+ fontSize = config.fontSize()
26
+ fontName = config.fontName()
27
+ iconSize = config.iconSize()
28
+ iconDir = ospathjoin(workDir,"Icons")
29
+ adb = config.adb()
30
+
22
31
  def os_icon(name):
23
32
  return QIcon(":/{0}.gif".format("Icons"+ospathsep+name))
main.py CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env python
2
2
  __author__ = "pyros2097"
3
3
  __license__ = "GPLv3"
4
- __version__ = "0.42"
4
+ __version__ = "0.43"
5
5
  __copyright__ = 'Copyright (c) 2012, pyros2097'
6
6
  __credits__ = ['pyros2097', 'eclipse']
7
7
  __email__ = 'pyros2097@gmail.com'
@@ -14,64 +14,41 @@ __email__ = 'pyros2097@gmail.com'
14
14
  from PyQt4.QtGui import (QMainWindow,QApplication,QPixmap,QSplashScreen,
15
15
  QIcon,QAction,QMenu,QMessageBox,QWidgetAction,
16
16
  QCheckBox,QFileDialog,QToolButton,QPushButton)
17
- from PyQt4.QtCore import (SIGNAL,Qt,QProcess,QStringList,QString,
17
+ from PyQt4.QtCore import (SIGNAL,Qt,QStringList,QString,
18
18
  QT_VERSION_STR,PYQT_VERSION_STR,QSize)
19
19
 
20
- from ui_simple import Ui_MainWindow
20
+ from ui import Ui_MainWindow
21
21
  import icons_rc
22
22
 
23
- from Widget import Editor,PyInterp
23
+ from Widget import Editor,PyInterp,Adb
24
24
  #from Dialog import *
25
25
  from config import Config
26
- #from styles import *
26
+ from adb import Adb
27
- from globals import ospathsep,ospathjoin,ospathbasename,workDir,OS_NAME,PY_VERSION,os_icon
27
+ from globals import (ospathsep,ospathjoin,ospathbasename,workDir,
28
+ OS_NAME,PY_VERSION,os_icon,config,workSpace,fontSize,fontName,
28
- import threading
29
+ iconSize,iconDir,adb)
29
30
 
30
31
 
31
32
 
32
- config = Config()
33
- workSpace = config.workSpace()
34
- fontSize = config.fontSize()
35
- fontName = config.fontName()
36
- iconSize = config.iconSize()
37
- iconDir = ospathjoin(workDir,"Icons")
38
- adb = config.adb()
39
-
40
-
41
- class myThread (threading.Thread):
42
- def __init__(self, proc):
43
- threading.Thread.__init__(self)
44
- self.proc = proc
45
-
46
- def run(self):
47
- #self.proc()
48
- print "Starting "
49
- print "Exiting "
50
33
 
51
34
  class MainWindow(QMainWindow, Ui_MainWindow):
52
35
  def __init__(self, parent=None):
53
- super(MainWindow, self).__init__(parent)
36
+ QMainWindow.__init__(self,parent)
54
- self.setupUi(self)
37
+ self.setupUi(self)
55
38
  #Important must be empty
56
39
  self.files = []
57
40
  self.projects = []
58
41
  self.recent = None
59
42
  self.dirty = None
60
- self.isRunning = False
61
43
  self.isFull = False
62
- self.isCmd = False
63
- self.CmdThread = None
64
- self.process = QProcess(self)
44
+ self.aaa = Adb(self)
65
- self.cmdText = ""
66
45
  self.setWindowTitle("Sabel")
67
46
  self.setWindowIcon(os_icon("sample"))
68
47
  self.init()
69
- #print self.width()
70
48
 
71
49
  def init(self):
72
50
  self.initConfig()
73
51
  self.initToolBar()
74
- self.initCommand()
75
52
  self.initTree()
76
53
  self.initProjects()
77
54
  #self.initStyles()
@@ -110,10 +87,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
110
87
  #self.textEdit.setStyleSheet(scl)
111
88
  #self.toolbar.setStyleSheet(ttl)
112
89
 
113
- def initCommand(self):
114
- self.connect(self.process, SIGNAL("readyReadStandardOutput()"), self.readOutput)
115
- self.connect(self.process, SIGNAL("readyReadStandardError()"), self.readErrors)
116
-
117
90
  def initInterpreter(self):
118
91
  self.ipy = PyInterp(self)
119
92
  self.ipy.initInterpreter(locals())
@@ -123,16 +96,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
123
96
  def initToolBar(self):
124
97
  self.action_NewProject = QAction(os_icon('newprj_wiz'), 'Project', self)
125
98
  self.action_NewProject.setShortcut('Ctrl+P')
126
- self.action_NewProject.triggered.connect(self.openProject)
99
+ self.action_NewProject.triggered.connect(self.newProject)
127
100
  self.action_NewProject.setToolTip("Create a New Project")
128
101
  self.action_NewProject.setStatusTip("Create a New Project")
129
102
 
130
- self.action_New = QAction(os_icon('new_untitled_text_file'), 'New', self)
131
- self.action_New.setShortcut('Ctrl+N')
132
- self.action_New.triggered.connect(self.fileNew)
133
- self.action_New.setToolTip("Create a New File")
134
- self.action_New.setStatusTip("Create a New File")
135
-
136
103
  self.action_Open = QAction(os_icon('__imp_obj'), 'Open', self)
137
104
  self.action_Open.setShortcut('Ctrl+O')
138
105
  self.action_Open.triggered.connect(self.fileOpen)
@@ -156,19 +123,15 @@ class MainWindow(QMainWindow, Ui_MainWindow):
156
123
  self.action_About.triggered.connect(self.about)
157
124
  self.action_Run = QAction(os_icon('lrun_obj'), 'Run', self)
158
125
  self.action_Run.setShortcut('Ctrl+R')
159
- self.action_Run.triggered.connect(self.run)
126
+ self.action_Run.triggered.connect(self.aaa.run)
160
127
  self.action_RunFile = QAction(os_icon('start_ccs_task'), 'File', self)
161
- self.action_RunFile.triggered.connect(self.runFile)
162
128
  self.action_Stop = QAction(os_icon('term_sbook'), 'Stop', self)
163
129
  self.action_Stop.setShortcut('Ctrl+Q')
164
- self.action_Stop.triggered.connect(self.stop)
130
+ self.action_Stop.triggered.connect(self.aaa.stop)
165
- self.action_Cmd = QAction(os_icon('monitor_obj'), 'Cmd', self)
166
- self.action_Cmd.setShortcut('Ctrl+B')
167
- self.action_Cmd.triggered.connect(self.cmd)
168
131
  self.action_Design = QAction(os_icon('task_set'), 'Design', self)
169
- self.action_Design.triggered.connect(self.stop)
132
+ #self.action_Design.triggered.connect(self.stop)
170
133
  self.action_Todo = QAction(os_icon('task_set'), 'Todo', self)
171
- self.action_Todo.triggered.connect(self.stop)
134
+ #self.action_Todo.triggered.connect(self.stop)
172
135
  #Only variation CHeck Later
173
136
  self.action_Options = QAction(QIcon(":/{0}.png".format("Icons"+ospathsep+'emblem-system')), 'Options', self)
174
137
  self.action_Options.triggered.connect(self.options)
@@ -226,8 +189,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
226
189
  self.toolbar.setAllowedAreas(Qt.AllToolBarAreas)
227
190
 
228
191
  self.toolbar.addAction(self.action_NewProject)
229
- #self.toolbar.addAction(self.action_OpenProject)
230
- self.toolbar.addAction(self.action_New)
231
192
  self.toolbar.addAction(self.action_Open)
232
193
  self.toolbar.addAction(self.action_Save)
233
194
  self.toolbar.addAction(self.action_SaveAll)
@@ -235,7 +196,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
235
196
  self.toolbar.addAction(self.action_Run)
236
197
  self.toolbar.addAction(self.action_RunFile)
237
198
  self.toolbar.addAction(self.action_Stop)
238
- self.toolbar.addAction(self.action_Cmd)
239
199
  self.toolbar.addSeparator()
240
200
  self.toolbar.addAction(self.action_Design)
241
201
  self.toolbar.addAction(self.action_Todo)
@@ -270,7 +230,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
270
230
  else:
271
231
  for i in nfile:
272
232
  self.createTab(i)
273
- #This line sets the opened file to display Important not checked
233
+ #This line sets the opened file to display first Important not checked
274
234
  self.tabWidget.setCurrentIndex(len(self.files)-1)
275
235
 
276
236
 
@@ -280,7 +240,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
280
240
  done = True
281
241
  if self.dirty[index]:
282
242
  reply = QMessageBox.question(self,
283
- "IDE - Unsaved Changes",
243
+ "Sabel IDE - Unsaved Changes",
284
244
  "Save unsaved changes?",
285
245
  QMessageBox.Yes|QMessageBox.No|QMessageBox.Cancel)
286
246
  if reply == QMessageBox.Cancel:
@@ -292,7 +252,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
292
252
  config.removeFile(self.files[index])
293
253
  self.files.remove(self.files[index])
294
254
  self.tabWidget.removeTab(index)
295
- return True
255
+ #return True
296
256
 
297
257
  def setDirty(self,file):
298
258
  '''On change of text in textEdit window, set the flag
@@ -345,7 +305,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
345
305
  def help(self):
346
306
  QMessageBox.about(self, "About Simple Editor","This is The Help")
347
307
 
348
- def openProject(self):
308
+ def newProject(self):
349
309
  fname = str(QFileDialog.getExistingDirectory(self,"Open File"))
350
310
  if not (fname == ""):
351
311
  fname = fname+"/"
@@ -368,18 +328,21 @@ class MainWindow(QMainWindow, Ui_MainWindow):
368
328
 
369
329
  def full(self):
370
330
  if not self.isFull:
371
- self.setWindowFlags(Qt.Window | Qt.CustomizeWindowHint)
331
+ self.setWindowState(Qt.WindowFullScreen)
372
332
  self.isFull = True
373
333
  else:
374
- self.setWindowFlags(Qt.Window)
334
+ self.setWindowState(Qt.WindowMaximized)
375
335
  self.isFull = False
336
+
337
+ def cmd(self):
338
+ if(self.tabWidget_3.isHidden()):
339
+ self.tabWidget_3.show()
340
+ else:
341
+ self.tabWidget_3.hide()
376
342
 
377
343
  def options(self):
378
344
  pass
379
345
 
380
- def fileNew(self):
381
- pass
382
-
383
346
  def fileOpen(self):
384
347
  '''Open file'''
385
348
  fname = str(QFileDialog.getOpenFileName(self,
@@ -430,9 +393,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
430
393
 
431
394
 
432
395
  def closeEvent(self, event):
433
- if(self.process.isOpen()):
396
+ #check this ine adb.exe process is always on
434
- self.process.kill()
435
- self.process.close()
397
+ self.aaa.close()
436
398
  for i in self.dirty:
437
399
  if i:
438
400
  reply = QMessageBox.question(self,
@@ -443,70 +405,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
443
405
  pass
444
406
  elif reply == QMessageBox.Yes:
445
407
  self.fileSaveAll()
446
-
447
-
448
- def cmd(self):
408
+
449
- if(self.tabWidget_3.isHidden()):
450
- self.tabWidget_3.show()
451
- else:
452
- self.tabWidget_3.hide()
453
-
454
-
455
- def runn(self):
456
- self.CmdThread = myThread(self.run())
457
- self.CmdThread.start()
458
-
459
- def runFile(self):
460
- if self.isRunning == False:
461
- self.cmd()
462
- self.process.start("python")
463
-
464
-
465
- def run(self):
466
- if self.isRunning == False:
467
- if self.process.isOpen():
468
- self.process.kill()
469
- self.isRunning = True
470
- self.action_Run.setDisabled(True)
471
- self.action_Stop.setEnabled(True)
472
- if(self.tabWidget_3.isHidden()):
473
- self.tabWidget_3.show()
474
- self.textEdit.clear()
475
- self.tabWidget_3.setCurrentIndex(1)
476
- #Running: C:/CODE/Tools/icons.py (Wed Aug 08 17:15:55 2012)
477
- self.textEdit.append("Pushing main.nut\n")
478
- self.process.start(adb[0])
479
- self.process.waitForFinished()
480
- self.process.kill()
481
- self.textEdit.append("Starting Activity\n")
482
- self.process.start(adb[1])
483
- self.process.waitForFinished()
484
- self.textEdit.append("Logging")
485
- self.process.kill()
486
- self.process.start(adb[2])
487
-
488
- def stop(self):
489
- if self.isRunning == True:
490
- self.isRunning = False
491
- self.action_Stop.setDisabled(True)
492
- self.textEdit.append("Stopped")
493
- self.process.kill()
494
- self.process.start(adb[3])
495
- self.process.waitForFinished()
496
- self.process.kill()
497
- if not(self.tabWidget_3.isHidden()):
498
- self.tabWidget_3.hide()
499
- self.action_Run.setEnabled(True)
500
-
501
- def readOutput(self):
502
- self.textEdit.append(QString(self.process.readAllStandardOutput()))
503
- sb = self.textEdit.verticalScrollBar()
504
- sb.setValue(sb.maximum())
505
- # self.cmdText += self.textEdit.toPlainText()
506
- # print self.cmdText
507
- def readErrors(self):
508
- self.textEdit_2.append("error: " + QString(self.process.readAllStandardError()))
509
-
510
409
  def findCurrentText(self):
511
410
  #print self.caseSensitive.isChecked()
512
411
  #print self.wholeWord.isChecked()
styles.py DELETED
@@ -1,119 +0,0 @@
1
- stl = """
2
- QTabWidget::tab-bar {
3
- left: 2px; /* move to the right by 2px */
4
- }
5
-
6
- /* Style the tab using the tab sub-control. Note that
7
- * it reads QTabBar _not_ QTabWidget
8
- */
9
- QTabBar::tab {
10
- min-width: 15px;
11
- max-width: 800px;
12
- padding: 2px 12px;
13
- font-size: .75em;
14
- }
15
-
16
- QTabBar::tab:!selected {
17
- margin-top: 1px; /* make non-selected tabs look smaller */
18
- }
19
-
20
- /* make use of negative margins for overlapping tabs */
21
- QTabBar::tab:selected {
22
- /* expand/overlap to the left and right by 4px */
23
- /* margin-left: -1px; */
24
- /* margin-right: -1px;*/
25
- }
26
-
27
- QTabBar::tab:first:selected {
28
- /* first selected tab has nothing to overlap with on the left */
29
- margin-left: 0;
30
- }
31
-
32
- QTabBar::tab:last:selected {
33
- /* last selected tab has nothing to overlap with on the right */
34
- margin-right: 0;
35
- }
36
-
37
- QTabBar::tab:only-one {
38
- /* if there is only one tab, we don't want overlapping margins */
39
- margin-left: 0;
40
- margin-right: 0;
41
- }
42
- """
43
-
44
- dtl = """
45
- QDockWidget {
46
- border: 1px solid lightgray;
47
- titlebar-close-icon: url(close.png);
48
- titlebar-normal-icon: url(undock.png);
49
- }
50
-
51
- QDockWidget::title {
52
- text-align: left; /* align the text to the left */
53
- background: lightgray;
54
- padding-left: 5px;
55
- }
56
-
57
- QDockWidget::close-button, QDockWidget::float-button {
58
- border: 1px solid transparent;
59
- background: darkgray;
60
- padding: 0px;
61
- }
62
-
63
- QDockWidget::close-button:hover, QDockWidget::float-button:hover {
64
- background: gray;
65
- }
66
-
67
- QDockWidget::close-button:pressed, QDockWidget::float-button:pressed {
68
- padding: 1px -1px -1px 1px;
69
- }
70
- """
71
-
72
- ttl = """
73
- QToolBar {
74
- //background: black;
75
- spacing: 3px; /* spacing between items in the tool bar */
76
- }
77
-
78
- QToolBar::handle {
79
- //image: url(handle.png);
80
- }
81
- """
82
- statl = """
83
- QStatusBar {
84
- background: brown;
85
- }
86
-
87
- QStatusBar::item {
88
- border: 1px solid red;
89
- border-radius: 3px;
90
- }
91
- """
92
-
93
- scl = """
94
- QScrollBar:horizontal {
95
- border: 2px solid grey;
96
- background: #32CC99;
97
- height: 15px;
98
- margin: 0px 20px 0 20px;
99
- }
100
- QScrollBar::handle:horizontal {
101
- background: white;
102
- min-width: 20px;
103
- }
104
- QScrollBar::add-line:horizontal {
105
- border: 2px solid grey;
106
- background: #32CC99;
107
- width: 20px;
108
- subcontrol-position: right;
109
- subcontrol-origin: margin;
110
- }
111
-
112
- QScrollBar::sub-line:horizontal {
113
- border: 2px solid grey;
114
- background: #32CC99;
115
- width: 20px;
116
- subcontrol-position: left;
117
- subcontrol-origin: margin;
118
- }
119
- """
ui_simple.py → ui.py RENAMED
@@ -22,21 +22,20 @@ class Ui_MainWindow(object):
22
22
  self.tabWidget_3.setMaximumSize(16777215,200)
23
23
  self.tabWidget_3.setMinimumSize(0,75)
24
24
  self.tabWidget_3.setObjectName("tabWidget_3")
25
- #bottom = QtGui.QFrame(self)
26
- #bottom.setFrameShape(QtGui.QFrame.StyledPanel)
27
- #bottom.setMaximumSize(16777215,200)
28
25
 
29
26
  #Tree
30
27
  self.tab_5 = QtGui.QWidget()
31
28
  self.tab_5.setObjectName("tab_5")
32
- self.horizontalLayoutWidget_2 = QtGui.QWidget(self.tab_5)
33
- self.horizontalLayoutWidget_2.setGeometry(QtCore.QRect(0, 9, 191, 601))
29
+ self.tab_5.setMaximumSize(QtCore.QSize(200, 16777215))
34
- self.horizontalLayoutWidget_2.setObjectName("horizontalLayoutWidget_2")
35
- self.horizontalLayout_3 = QtGui.QHBoxLayout(self.horizontalLayoutWidget_2)
30
+ self.horizontalLayout_3 = QtGui.QVBoxLayout(self.tab_5)#QHBoxLayout(self.tab_5)
36
31
  self.horizontalLayout_3.setMargin(0)
37
32
  self.horizontalLayout_3.setObjectName("horizontalLayout_3")
38
- self.treeWidget = Tree(self.horizontalLayoutWidget_2)
33
+ self.treeWidget = Tree(self.tab_5)
39
34
  self.treeWidget.setObjectName("treeWidget")
35
+ self.treebar = QtGui.QToolBar()
36
+ action_Folder = QtGui.QAction(os_icon('newfolder_wiz'),'New Folder', self)
37
+ self.treebar.addAction(action_Folder)
38
+ self.horizontalLayout_3.addWidget(self.treebar)
40
39
  self.horizontalLayout_3.addWidget(self.treeWidget)
41
40
 
42
41
 
@@ -50,17 +49,14 @@ class Ui_MainWindow(object):
50
49
  self.textEdit = QtGui.QTextEdit(self.tab_6)
51
50
  self.textEdit.setObjectName("textEdit")
52
51
  self.horizontalLayout_2.addWidget(self.textEdit)
53
-
52
+
54
53
  #Error
55
54
  self.tab_7 = QtGui.QWidget()
56
55
  self.tab_7.setObjectName("tab_7")
57
- self.horizontalLayoutWidget_4 = QtGui.QWidget(self.tab_7)
56
+ self.horizontalLayout_4 = QtGui.QHBoxLayout(self.tab_7)
58
- self.horizontalLayoutWidget_4.setGeometry(QtCore.QRect(0, -1, 16777215, 200))
59
- self.horizontalLayoutWidget_4.setObjectName("horizontalLayoutWidget_4")
60
- self.horizontalLayout_4 = QtGui.QHBoxLayout(self.horizontalLayoutWidget_4)
61
57
  self.horizontalLayout_4.setMargin(0)
62
58
  self.horizontalLayout_4.setObjectName("horizontalLayout_4")
63
- self.textEdit_2 = QtGui.QTextEdit(self.horizontalLayoutWidget_4)
59
+ self.textEdit_2 = QtGui.QTextEdit(self.tab_7)
64
60
  self.textEdit_2.setObjectName("textEdit_2")
65
61
  self.horizontalLayout_4.addWidget(self.textEdit_2)
66
62
 
@@ -84,7 +80,6 @@ class Ui_MainWindow(object):
84
80
  self.replaceAll = QtGui.QPushButton(self.tab_8)
85
81
  self.replaceAll.setText("Replace All")
86
82
  self.replaceAll.clicked.connect(self.replaceAllText)
87
-
88
83
  self.caseSensitive = QtGui.QToolButton(self.tab_8)
89
84
  self.caseSensitive.setText("cs")
90
85
  self.caseSensitive.setCheckable(True)
@@ -98,7 +93,6 @@ class Ui_MainWindow(object):
98
93
  self.backward.setText("bk")
99
94
  self.backward.setCheckable(True)
100
95
  self.backward.setDisabled(True)
101
-
102
96
  self.horizontalLayout_5.addWidget(self.find)
103
97
  self.horizontalLayout_5.addWidget(self.lineEdit)
104
98
  self.horizontalLayout_5.addWidget(self.lineEdit_2)
@@ -116,11 +110,12 @@ class Ui_MainWindow(object):
116
110
  self.tabWidget_3.addTab(self.tab_7,"Error")
117
111
  self.tabWidget_3.addTab(self.tab_6,"Output")
118
112
  self.tabWidget_3.setTabIcon(0,os_icon("message_error"))
119
- self.tabWidget_3.setTabIcon(1,os_icon("sample"))
113
+ self.tabWidget_3.setTabIcon(1,os_icon("monitor_obj"))
120
114
 
121
115
  #Splitters
122
116
  self.split1 = QtGui.QSplitter(QtCore.Qt.Horizontal)
123
117
  self.split1.addWidget(self.tabWidget)
118
+ #self.split1.addWidget(self.tab_5)
124
119
  self.split1.addWidget(self.tabWidget_2)
125
120
  self.split2 = QtGui.QSplitter(QtCore.Qt.Vertical)
126
121
  self.split2.addWidget(self.split1)
@@ -135,7 +130,6 @@ class Ui_MainWindow(object):
135
130
  self.statusbar.setObjectName("statusbar")
136
131
  MainWindow.setStatusBar(self.statusbar)
137
132
  self.tabWidget.setCurrentIndex(-1)
138
- self.tabWidget_2.setCurrentIndex(0)
139
133
  self.tab_8.hide()
140
134
 
141
135
  #Status
ui_simple.pyc CHANGED
Binary file