96ba573a pyros2097

13 years ago
Minor save
Files changed (10) hide show
  1. Widget/editor.py +5 -2
  2. Widget/tab.py +1 -37
  3. Widget/tab.pyc +0 -0
  4. Widget/tree.py +72 -11
  5. Widget/tree.pyc +0 -0
  6. config.py +2 -0
  7. config.yaml +1 -4
  8. globals.py +1 -0
  9. main.py +20 -20
  10. ui.py → window.py +14 -10
Widget/editor.py CHANGED
@@ -1,5 +1,5 @@
1
- from PyQt4.QtCore import *
1
+ from PyQt4.QtCore import SIGNAL
2
- from PyQt4.QtGui import *
2
+ from PyQt4.QtGui import QFontMetrics, QFont, QPixmap, QColor,
3
3
  from PyQt4.Qsci import QsciScintilla, QsciLexerPython ,QsciAPIs
4
4
  from globals import ospathjoin,workDir,fontSize,fontName
5
5
 
@@ -62,6 +62,9 @@ class Editor(QsciScintilla):
62
62
  #self.setAutoCompletionSource(QsciScintilla.AcsAll)
63
63
  #self.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1, 'Courier')
64
64
 
65
+ def setColorStyle(self,styleIndex):
66
+
67
+
65
68
 
66
69
  def code_complete(self):
67
70
  self.api.add("emo.Runtime?0(use = runtime)")
Widget/tab.py CHANGED
@@ -71,40 +71,4 @@ class Tab(QTabWidget):
71
71
  event.ignore()
72
72
 
73
73
  def addItem(self,l):
74
- self.emit(SIGNAL("dropped"),l)
74
+ self.emit(SIGNAL("dropped"),l)
75
-
76
-
77
- class MyWindow(QtGui.QMainWindow):
78
- def __init__(self):
79
- QtGui.QMainWindow.__init__(self)
80
- self.initUI()
81
-
82
- def initUI(self):
83
- self.centralwidget=QtGui.QWidget(self)
84
- self.tabMain = Tab(self.centralwidget)
85
- self.tabOne = QtGui.QWidget()
86
- self.tabOne.edit = QtGui.QLineEdit(self.tabOne)
87
- self.tabOne.edit.setText(QtCore.PYQT_VERSION_STR) #Qt Version
88
- self.tabOneLayout = QtGui.QVBoxLayout(self.tabOne)
89
- self.tabOneLayout.addWidget(self.tabOne.edit)
90
- self.tabMain.addTab(self.tabOne, "First Tab")
91
- self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget)
92
- self.verticalLayout.addWidget(self.tabMain)
93
- self.setCentralWidget(self.centralwidget)
94
- self.connect(self.tabMain, SIGNAL("dropped"), self.addg)
95
-
96
- def addg(self,l):
97
- print l
98
-
99
-
100
-
101
-
102
- if __name__ == '__main__':
103
- app = QtGui.QApplication([])
104
- frame = MyWindow()
105
- frame.show()
106
- app.exec_()
107
-
108
-
109
-
110
-
Widget/tab.pyc CHANGED
Binary file
Widget/tree.py CHANGED
@@ -1,6 +1,6 @@
1
1
  from PyQt4.QtGui import (QTreeWidgetItem,QTreeWidget,QMessageBox,
2
2
  QIcon,QDrag,QMenu,QAction,QInputDialog,QCursor,QToolBar)
3
- from PyQt4.QtCore import SIGNAL,Qt,QMimeData,QUrl
3
+ from PyQt4.QtCore import SIGNAL,Qt,QMimeData,QUrl,QPoint
4
4
  from globals import (oslistdir,ospathisdir,ospathsep,ospathjoin,ospathexists,
5
5
  ospathbasename,os_icon,osremove,osrename,ospathdirname,
6
6
  recycle,ospathnormpath,oswalk)
@@ -109,6 +109,13 @@ class Tree(QTreeWidget):
109
109
  if not ospathjoin(d).startswith('.'):
110
110
  i = Dir(parent,d,path)
111
111
  self.readFiles(i,ospathjoin(path,d))
112
+
113
+ def readMainDir(self,parent,path):
114
+ for d in oslistdir(path):
115
+ if ospathisdir(ospathjoin(path,d)):
116
+ if not ospathjoin(d).startswith('.'):
117
+ i = Dir(parent,d,path)
118
+ self.readMainFiles(i,ospathjoin(path,d))
112
119
 
113
120
  def readFiles(self,parent,path):
114
121
  for f in oslistdir(path):
@@ -199,7 +206,20 @@ class Tree(QTreeWidget):
199
206
  action_Open.triggered.connect(lambda:self.openProject(item))
200
207
  action_Close = QAction('Close', self)
201
208
  action_Close.triggered.connect(lambda:self.closeProject(item))
209
+
210
+ action_OpenFile = QAction(os_icon('__imp_obj'),'Open', self)
211
+ action_OpenFile.triggered.connect(lambda:self.openFile(item))
212
+ action_RunFile = QAction(os_icon('nav_go'),'Python Run', self)
213
+ action_RunFile.triggered.connect(lambda:self.runFile(item))
214
+ action_CopyFile = QAction(os_icon('file_obj'),'Copy', self)
215
+ action_CopyFile.triggered.connect(lambda:self.copyFile(item))
216
+ action_CopyDir = QAction(os_icon('file_obj'),'Copy', self)
217
+ action_CopyDir.triggered.connect(lambda:self.copyDir(item))
218
+ action_PasteFile = QAction(os_icon('paste_edit'),'Paste', self)
219
+ action_PasteFile.triggered.connect(lambda:self.pasteFile(item))
220
+ action_PasteDir = QAction(os_icon('paste_edit'),'Paste', self)
221
+ action_PasteDir.triggered.connect(lambda:self.pasteDir(item))
202
- action_RefreshProject = QAction('Refresh', self)
222
+ action_RefreshProject = QAction(os_icon('refresh_tab'),'Refresh', self)
203
223
  action_RefreshProject.triggered.connect(lambda:self.refreshProject(item))
204
224
  action_RemoveProject = QAction('Remove', self)
205
225
  action_RemoveProject.triggered.connect(lambda:self.removeProject(item))
@@ -233,11 +253,22 @@ class Tree(QTreeWidget):
233
253
  menu.addAction(action_Folder)
234
254
  menu.addAction(action_File)
235
255
  menu.addSeparator()
256
+ menu.addAction(action_CopyDir)
257
+ menu.addAction(action_PasteDir)
236
258
  menu.addAction(action_RenameDir)
237
259
  menu.addAction(action_DeleteDir)
238
260
  else:
261
+ menu1 = QMenu(self)
262
+ menu1.setTitle("Run As")
263
+ menu1.addAction(action_RunFile)
264
+
265
+ menu.addAction(action_OpenFile)
266
+ menu.addMenu(menu1)
267
+ menu.addSeparator()
268
+ menu.addAction(action_CopyFile)
269
+ menu.addAction(action_PasteFile)
239
- menu.addAction(action_Rename)
270
+ menu.addAction(action_RenameFile)
240
- menu.addAction(action_Delete)
271
+ menu.addAction(action_DeleteFile)
241
272
 
242
273
  menu.popup(QCursor.pos())
243
274
 
@@ -257,6 +288,17 @@ class Tree(QTreeWidget):
257
288
  self.takeTopLevelItem(self.indexOfTopLevelItem(item))
258
289
  self.addProject(itempath)
259
290
 
291
+ def refreshAllProjects(self):
292
+ for pro in self.projects:
293
+ ind = self.projects.index(pro)
294
+ #self.takeTopLevelItem(ind)
295
+ if(self.closed[ind]):
296
+ print ind+pro
297
+ self.addClosedProject(pro)
298
+ else:
299
+ print ind+pro
300
+ self.addProject(pro)
301
+
260
302
  def removeProject(self,item):
261
303
  pass
262
304
 
@@ -282,16 +324,35 @@ class Tree(QTreeWidget):
282
324
  except:
283
325
  QMessageBox.about(self,"Error","Could Not Create The File")
284
326
 
327
+ def openFile(self):
328
+ pass
329
+
330
+ def runFile(self):
331
+ pass
332
+
333
+ def copyFile(self):
334
+ pass
335
+
336
+ def copyDir(self):
337
+ pass
338
+
339
+ def pasteFile(self):
340
+ pass
341
+
342
+ def pasteDir(self):
343
+ pass
344
+
285
345
  def renameProject(self,item):
286
346
  itempath = item.getPath()
287
347
  text,ok = QInputDialog.getText(self,"QInputDialog::getText()","New Name:")
288
348
  if (ok and text != ''):
289
- newname = ospathjoin(ospathdirname(itempath),str(text))
349
+ newname = ospathjoin(ospathdirname(itempath))
290
350
  try:
351
+ print itempath
291
- #print newname
352
+ print newname
292
- osrename(itempath,newname)
353
+ #osrename(itempath,newname)
293
- self.takeTopLevelItem(self.indexOfTopLevelItem(item))
354
+ #self.takeTopLevelItem(self.indexOfTopLevelItem(item))
294
- self.addProject(newname)
355
+ #self.addProject(newname)
295
356
  except:
296
357
  QMessageBox.about(self,"Error","Could Not Rename The File")
297
358
 
@@ -301,11 +362,11 @@ class Tree(QTreeWidget):
301
362
  if (ok and text != ''):
302
363
  newname = ospathjoin(ospathdirname(itempath),str(text))
303
364
  try:
304
- #print newname
365
+ print newname
305
366
  osrename(itempath,newname)
306
367
  p = item.parent()
307
368
  p.removeChild(item)
308
- self.readDir(p,ospathdirname(newname))
369
+ #self.refreshAllProjects()
309
370
  except:
310
371
  QMessageBox.about(self,"Error","Could Not Rename The File")
311
372
 
Widget/tree.pyc CHANGED
Binary file
config.py CHANGED
@@ -20,6 +20,8 @@ class Config:
20
20
  return self.readSetting('fontname')
21
21
  def iconSize(self):
22
22
  return int(self.readSetting('iconsize'))
23
+ def colorStyle(self):
24
+ return int(self.readSetting('colorstyle'))
23
25
 
24
26
  def projects(self):
25
27
  return self.read('Project')
config.yaml CHANGED
@@ -19,7 +19,4 @@ Setting:
19
19
  style: 0
20
20
  thresh: 1
21
21
  workspace: C:/CODE/
22
- Styles:
22
+ Style: 0
23
- default:
24
- bg: white
25
- color: black
globals.py CHANGED
@@ -28,6 +28,7 @@ workSpace = config.workSpace()
28
28
  fontSize = config.fontSize()
29
29
  fontName = config.fontName()
30
30
  iconSize = config.iconSize()
31
+ colorStyle = config.colorStyle
31
32
  iconDir = ospathjoin(workDir,"Icons")
32
33
  adblist = config.adb()
33
34
 
main.py CHANGED
@@ -1,37 +1,35 @@
1
1
  #!/usr/bin/env python
2
2
  __author__ = "pyros2097"
3
3
  __license__ = "GPLv3"
4
- __version__ = "0.46"
4
+ __version__ = "0.47"
5
5
  __copyright__ = 'Copyright (c) 2012, pyros2097'
6
6
  __credits__ = ['pyros2097', 'eclipse']
7
7
  __email__ = 'pyros2097@gmail.com'
8
8
 
9
+
10
+
9
11
  #TODO:
10
12
  #Add options for all GUI
11
13
  #Add Project Options
12
14
  #Add error markers
13
15
 
14
- from PyQt4.QtGui import (QMainWindow,QApplication,QPixmap,QSplashScreen,QMessageBox,
16
+ from PyQt4.QtGui import (QApplication,QPixmap,QSplashScreen,QMessageBox,
15
17
  QIcon,QAction,QCheckBox,QFileDialog)
16
18
  from PyQt4.QtCore import SIGNAL,Qt,QStringList,QString
17
19
 
18
20
 
19
- from ui import Ui_MainWindow
20
- import icons_rc
21
21
 
22
+ import icons_rc
23
+ from window import Window
22
24
  from Widget import Editor,PyInterp,Adb
23
- #from Dialog import *
24
25
  from globals import (ospathsep,ospathjoin,ospathbasename,workDir,
25
26
  OS_NAME,PY_VERSION,os_icon,config,workSpace,
26
27
  iconSize,iconDir,ospathexists)
27
28
 
28
29
 
29
-
30
-
31
- class MainWindow(QMainWindow, Ui_MainWindow):
30
+ class MainWindow(Window):
32
- def __init__(self, parent=None):
31
+ def __init__(self, parent = None):
33
- QMainWindow.__init__(self,parent)
32
+ Window.__init__(self,parent)
34
- self.setupUi(self)
35
33
  #Important must be empty this is a reference
36
34
  self.files = []
37
35
  self.projects = None
@@ -39,8 +37,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
39
37
  self.dirty = None
40
38
  self.isFull = False
41
39
  self.adb = Adb(self)
42
- self.setWindowTitle("Sabel")
43
- self.setWindowIcon(os_icon("sample"))
44
40
  self.init()
45
41
 
46
42
  def init(self):
@@ -48,7 +44,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
48
44
  self.initToolBar()
49
45
  self.initProjects()
50
46
  self.connect(self, SIGNAL('triggered()'), self.closeEvent)
51
- self.connect(self.tabWidget,SIGNAL("dropped"), self.createTab)
47
+ self.connect(self.tabWidget,SIGNAL("dropped"), self.createTabs)
52
48
  #self.initInterpreter()
53
49
 
54
50
  def initConfig(self):
@@ -93,7 +89,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
93
89
  if len(self.files) != 0:
94
90
  for i in self.files:
95
91
  if(i == nfile):
96
- QMessageBox.about(self,"Can't Open","File Already Open\n"+nfile)
92
+ #print "File Already Open\n"+nfile
93
+ self.tabWidget.setCurrentIndex(self.files.index(nfile))
97
94
  return
98
95
  if type(nfile) == str:
99
96
  if(ospathexists(nfile)):
@@ -120,12 +117,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
120
117
  #dont know must check this the last file is not removed executes only
121
118
  #twice when it has to remove 3 files
122
119
  #check sel.files
123
- print len(config.files())
120
+ #print len(config.files())
124
121
  config.removeFile(nfile)
125
122
  QMessageBox.about(self,"Can't Open","File Does Not Exist or Locked\n"+nfile)
123
+
126
- else:
124
+ def createTabs(self,link):
127
- for i in nfile:
125
+ for i in link:
128
- self.createTab(i)
126
+ self.createTab(i)
129
127
 
130
128
  def closeTab(self,index):
131
129
  '''Boolean result invocation method.'''
@@ -139,7 +137,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
139
137
  done = False
140
138
  elif reply == QMessageBox.Yes:
141
139
  done = self.fileSave(index)
142
-
140
+ elif reply == QMessageBox.No:
141
+ self.clearDirty(index)
142
+ done = True
143
143
  if(done):
144
144
  #print index
145
145
  config.removeFile(self.files[index])
ui.py → window.py RENAMED
@@ -1,6 +1,7 @@
1
1
  from PyQt4.QtGui import (QAction,QIcon,QMessageBox,QWidgetAction,QMenu,QWidget,
2
2
  QHBoxLayout,QVBoxLayout,QTabWidget,QToolBar,QTextEdit,
3
- QLineEdit,QPushButton,QToolButton,QSplitter,QStatusBar)
3
+ QLineEdit,QPushButton,QToolButton,QSplitter,QStatusBar,
4
+ QMainWindow)
4
5
  from PyQt4.QtCore import QSize,Qt, QT_VERSION_STR,PYQT_VERSION_STR
5
6
  from Widget import Tab,Tree
6
7
 
@@ -9,13 +10,16 @@ from globals import (ospathsep,ospathjoin,ospathbasename,workDir,
9
10
  iconSize,iconDir)
10
11
 
11
12
 
12
- __version__ = "0.46"
13
+ __version__ = "0.47"
13
14
 
14
- class Ui_MainWindow(object):
15
+ class Window(QMainWindow):
15
- def setupUi(self, MainWindow):
16
+ def __init__(self,parent = None):
17
+ QMainWindow.__init__(self,parent)
16
- MainWindow.setObjectName("MainWindow")
18
+ self.setObjectName("self")
17
- MainWindow.resize(758, 673)
19
+ self.resize(758, 673)
20
+ self.setWindowTitle("Sabel")
21
+ self.setWindowIcon(os_icon("sample"))
18
- self.centralwidget = QWidget(MainWindow)
22
+ self.centralwidget = QWidget(self)
19
23
  self.centralwidget.setObjectName("centralwidget")
20
24
  self.horizontalLayout = QHBoxLayout(self.centralwidget)
21
25
  self.horizontalLayout.setObjectName("horizontalLayout")
@@ -145,7 +149,7 @@ class Ui_MainWindow(object):
145
149
 
146
150
 
147
151
  #Status
148
- self.statusbar = QStatusBar(MainWindow)
152
+ self.statusbar = QStatusBar(self)
149
153
  self.statusbar.setObjectName("statusbar")
150
154
  self.cmdButton = QPushButton(self)
151
155
  self.cmdButton.setFlat(True)
@@ -164,8 +168,8 @@ class Ui_MainWindow(object):
164
168
  self.statusbar.setFixedHeight(18)
165
169
 
166
170
  #Init
167
- MainWindow.setCentralWidget(self.centralwidget)
171
+ self.setCentralWidget(self.centralwidget)
168
- MainWindow.setStatusBar(self.statusbar)
172
+ self.setStatusBar(self.statusbar)
169
173
  self.tabWidget.setTabsClosable(True)
170
174
  self.tabWidget.setTabShape(0)
171
175
  #QtGui.QApplication.setStyle(QtGui.QStyleFactory.create('Cleanlooks'))