class VariablesViewer( QWidget ): " Implements the variables viewer for a debugger " # First group of filters FilterGlobalAndLocal = 0 FilterGlobalOnly = 1 FilterLocalOnly = 2 def __init__( self, debugger, parent = None ): QWidget.__init__( self, parent ) self.__debugger = debugger self.__browser = VariablesBrowser( debugger, self ) self.__filter = Settings().debugGLFilter self.__hideMCFFilter = Settings().debugHideMCF self.__createLayout() self.setTabOrder( self.__browser, self.__execStatement ) self.setTabOrder( self.__execStatement, self.__execButton ) self.setTabOrder( self.__execButton, self.__evalStatement ) self.setTabOrder( self.__evalStatement, self.__evalButton ) self.__updateFilter() return def __createLayout( self ): " Creates the widget layout " verticalLayout = QVBoxLayout( self ) verticalLayout.setContentsMargins( 0, 0, 0, 0 ) verticalLayout.setSpacing( 0 ) headerFrame = QFrame() headerFrame.setFrameStyle( QFrame.StyledPanel ) headerFrame.setAutoFillBackground( True ) headerPalette = headerFrame.palette() headerBackground = headerPalette.color( QPalette.Background ) headerBackground.setRgb( min( headerBackground.red() + 30, 255 ), min( headerBackground.green() + 30, 255 ), min( headerBackground.blue() + 30, 255 ) ) headerPalette.setColor( QPalette.Background, headerBackground ) headerFrame.setPalette( headerPalette ) headerFrame.setFixedHeight( 24 ) self.__headerLabel = QLabel( "Variables" ) expandingSpacer = QSpacerItem( 10, 10, QSizePolicy.Expanding ) fixedSpacer = QSpacerItem( 3, 3 ) fixedSpacer1 = QSpacerItem( 5, 5 ) self.__mcfButton = QToolButton() self.__mcfButton.setCheckable( True ) self.__mcfButton.setChecked( self.__hideMCFFilter ) self.__mcfButton.setIcon( PixmapCache().getIcon( 'dbgfltmcf.png' ) ) self.__mcfButton.setFixedSize( 20, 20 ) self.__mcfButton.setToolTip( "Show/hide modules, classes and functions" ) self.__mcfButton.setFocusPolicy( Qt.NoFocus ) self.__mcfButton.clicked.connect( self.__onMCFFilter ) self.__globalAndLocalButton = QToolButton() self.__globalAndLocalButton.setCheckable( True ) self.__globalAndLocalButton.setChecked( self.__filter == VariablesViewer.FilterGlobalAndLocal ) self.__globalAndLocalButton.setIcon( PixmapCache().getIcon( 'dbgfltgl.png' ) ) self.__globalAndLocalButton.setFixedSize( 20, 20 ) self.__globalAndLocalButton.setToolTip( "Do not filter out global or local variables" ) self.__globalAndLocalButton.setFocusPolicy( Qt.NoFocus ) self.__globalAndLocalButton.clicked.connect( self.__onGlobalAndLocalFilter ) self.__localOnlyButton = QToolButton() self.__localOnlyButton.setCheckable( True ) self.__localOnlyButton.setChecked( self.__filter == VariablesViewer.FilterLocalOnly ) self.__localOnlyButton.setIcon( PixmapCache().getIcon( 'dbgfltlo.png' ) ) self.__localOnlyButton.setFixedSize( 20, 20 ) self.__localOnlyButton.setToolTip( "Filter out global variables" ) self.__localOnlyButton.setFocusPolicy( Qt.NoFocus ) self.__localOnlyButton.clicked.connect( self.__onLocalFilter ) self.__globalOnlyButton = QToolButton() self.__globalOnlyButton.setCheckable( True ) self.__globalOnlyButton.setChecked( self.__filter == VariablesViewer.FilterGlobalOnly ) self.__globalOnlyButton.setIcon( PixmapCache().getIcon( 'dbgfltgo.png' ) ) self.__globalOnlyButton.setFixedSize( 20, 20 ) self.__globalOnlyButton.setToolTip( "Filter out local variables" ) self.__globalOnlyButton.setFocusPolicy( Qt.NoFocus ) self.__globalOnlyButton.clicked.connect( self.__onGlobalFilter ) self.__execStatement = CDMComboBox( True ) self.__execStatement.setSizePolicy( QSizePolicy.Expanding, QSizePolicy.Expanding ) self.__execStatement.lineEdit().setToolTip( "Expression to be executed" ) self.__execStatement.setFixedHeight( 26 ) self.__execStatement.editTextChanged.connect( self.__execStatementChanged ) self.__execStatement.enterClicked.connect( self.__onEnterInExec ) self.__execButton = QPushButton( "Exec" ) # self.__execButton.setFocusPolicy( Qt.NoFocus ) self.__execButton.setEnabled( False ) self.__execButton.clicked.connect( self.__onExec ) self.__evalStatement = CDMComboBox( True ) self.__evalStatement.setSizePolicy( QSizePolicy.Expanding, QSizePolicy.Expanding ) self.__evalStatement.lineEdit().setToolTip( "Expression to be evaluated" ) self.__evalStatement.setFixedHeight( 26 ) self.__evalStatement.editTextChanged.connect( self.__evalStatementChanged ) self.__evalStatement.enterClicked.connect( self.__onEnterInEval ) self.__evalButton = QPushButton( "Eval" ) # self.__evalButton.setFocusPolicy( Qt.NoFocus ) self.__evalButton.setEnabled( False ) self.__evalButton.clicked.connect( self.__onEval ) headerLayout = QHBoxLayout() headerLayout.setContentsMargins( 0, 0, 0, 0 ) headerLayout.setSpacing( 0 ) headerLayout.addSpacerItem( fixedSpacer ) headerLayout.addWidget( self.__headerLabel ) headerLayout.addSpacerItem( expandingSpacer ) headerLayout.addWidget( self.__mcfButton ) headerLayout.addSpacerItem( fixedSpacer1 ) headerLayout.addWidget( self.__globalAndLocalButton ) headerLayout.addWidget( self.__localOnlyButton ) headerLayout.addWidget( self.__globalOnlyButton ) headerFrame.setLayout( headerLayout ) execEvalLayout = QGridLayout() execEvalLayout.setContentsMargins( 1, 1, 1, 1 ) execEvalLayout.setSpacing( 1 ) execEvalLayout.addWidget( self.__execStatement, 0, 0 ) execEvalLayout.addWidget( self.__execButton, 0, 1 ) execEvalLayout.addWidget( self.__evalStatement, 1, 0 ) execEvalLayout.addWidget( self.__evalButton, 1, 1 ) verticalLayout.addWidget( headerFrame ) verticalLayout.addWidget( self.__browser ) verticalLayout.addLayout( execEvalLayout ) return def __onMCFFilter( self ): " Triggered when modules/classes/functions filter changed " self.__hideMCFFilter = self.__mcfButton.isChecked() Settings().debugHideMCF = self.__hideMCFFilter self.__updateFilter() return def __onGlobalAndLocalFilter( self ): " Global and local filter has been pressed " self.__globalAndLocalButton.setChecked( True ) self.__localOnlyButton.setChecked( False ) self.__globalOnlyButton.setChecked( False ) if self.__filter == VariablesViewer.FilterGlobalAndLocal: # No changes return Settings().debugGLFilter = VariablesViewer.FilterGlobalAndLocal self.__filter = VariablesViewer.FilterGlobalAndLocal self.__updateFilter() return def __onLocalFilter( self ): " Local only filter has been pressed " self.__globalAndLocalButton.setChecked( False ) self.__localOnlyButton.setChecked( True ) self.__globalOnlyButton.setChecked( False ) if self.__filter == VariablesViewer.FilterLocalOnly: # No changes return Settings().debugGLFilter = VariablesViewer.FilterLocalOnly self.__filter = VariablesViewer.FilterLocalOnly self.__updateFilter() return def __onGlobalFilter( self ): " Global only filter has been pressed " self.__globalAndLocalButton.setChecked( False ) self.__localOnlyButton.setChecked( False ) self.__globalOnlyButton.setChecked( True ) if self.__filter == VariablesViewer.FilterGlobalOnly: # No changes return Settings().debugGLFilter = VariablesViewer.FilterGlobalOnly self.__filter = VariablesViewer.FilterGlobalOnly self.__updateFilter() return def updateVariables( self, areGlobals, frameNumber, variables ): " Triggered when a new set of variables is received " self.__browser.showVariables( areGlobals, variables, frameNumber ) self.__updateHeaderLabel() return def updateVariable( self, areGlobals, variables ): " Triggered when a new variable has been received " self.__browser.showVariable( areGlobals, variables ) self.__updateHeaderLabel() return def __updateHeaderLabel( self ): shown, total = self.__browser.getShownAndTotalCounts() if shown == 0 and total == 0: self.__headerLabel.setText( "Variables" ) else: self.__headerLabel.setText( "Variables (" + str( shown ) + " of " + str( total ) + ")" ) return def __textFilterChanged( self, text ): " Triggered when a text filter has been changed " self.__updateFilter() return def __updateFilter( self ): " Updates the current filter " self.__browser.setFilter( self.__hideMCFFilter, self.__filter, "" ) self.__updateHeaderLabel() return def clear( self ): " Clears the content " self.__browser.clear() self.__updateHeaderLabel() return def clearAll( self ): " Clears everything including the history " self.clear() self.__execStatement.lineEdit().setText( "" ) self.__execStatement.clear() self.__evalStatement.lineEdit().setText( "" ) self.__evalStatement.clear() return def __evalStatementChanged( self, text ): " Triggered when a eval statement is changed " text = str( text ).strip() self.__evalButton.setEnabled( text != "" ) return def __onEnterInEval( self ): " Enter/return in eval " self.__onEval() return def __onEval( self ): " Triggered when the Eval button is clicked " text = self.__evalStatement.currentText().strip() if text != "": currentFrame = GlobalData().mainWindow.getCurrentFrameNumber() self.__debugger.remoteEval( text, currentFrame ) self.__debugger.remoteClientVariables( 1, currentFrame ) # globals self.__debugger.remoteClientVariables( 0, currentFrame ) # locals return def __execStatementChanged( self, text ): " Triggered when a exec statement is changed " text = str( text ).strip() self.__execButton.setEnabled( text != "" ) return def __onEnterInExec( self ): " Enter/return clicked in exec " self.__onExec() return def __onExec( self ): " Triggered when the Exec button is clicked " text = self.__execStatement.currentText().strip() if text != "": currentFrame = GlobalData().mainWindow.getCurrentFrameNumber() self.__debugger.remoteExec( text, currentFrame ) self.__debugger.remoteClientVariables( 1, currentFrame ) # globals self.__debugger.remoteClientVariables( 0, currentFrame ) # locals return def switchControl( self, isInIDE ): " Switches the UI depending where the control flow is " self.__browser.setEnabled( isInIDE ) self.__globalAndLocalButton.setEnabled( isInIDE ) self.__localOnlyButton.setEnabled( isInIDE ) self.__globalOnlyButton.setEnabled( isInIDE ) self.__execStatement.setEnabled( isInIDE ) if isInIDE: text = self.__execStatement.currentText().strip() self.__execButton.setEnabled( text != "" ) else: self.__execButton.setEnabled( False ) self.__evalStatement.setEnabled( isInIDE ) if isInIDE: text = self.__evalStatement.currentText().strip() self.__evalButton.setEnabled( text != "" ) else: self.__evalButton.setEnabled( False ) return
class Window(QMainWindow): def __init__(self,parent = None): QMainWindow.__init__(self,parent) self.resize(1024,768) self.setWindowTitle("Sabel") self.setWindowIcon(Icons.sabel) self.centralwidget = QWidget(self) self.horizontalLayout = QHBoxLayout(self.centralwidget) self.horizontalLayout.setMargin(0) self.cmdList = config.cmds() self.paramList = config.params() '''A.Editor TabWidget''' '''This parent is for findbar and vertical layout''' self.editorLayoutWidget = QWidget(self) self.editorLayoutWidget.setMinimumWidth(800) self.tabWidget = EditorTab(self) self.editorLayout = QVBoxLayout(self.editorLayoutWidget) self.editorLayout.setMargin(0) self.editorLayout.addWidget(self.tabWidget) "0.Style Layout" self.styleLayoutWidget = QFrame() self.styleLayoutWidget.setFrameShape(QFrame.StyledPanel) self.styleLayout = QHBoxLayout(self.styleLayoutWidget) self.styleTest = QPushButton(self.styleLayoutWidget) self.styleTest.setText("Change Styles") self.styleTest.clicked.connect(self.changeStyleSheet) self.popWidget = Popup(self.styleLayoutWidget) self.styleLayout.addWidget(self.styleTest) self.styleLayout.addWidget(self.popWidget) self.styleLayout.setMargin(0) self.editorLayout.addWidget(self.styleLayoutWidget) self.styleLayoutWidget.hide() "1.Find Layout" self.findLayoutWidget = QFrame() self.findLayoutWidget.setFrameShape(QFrame.StyledPanel) self.findLayout = QHBoxLayout(self.findLayoutWidget) self.lineEdit = QLineEdit(self.findLayoutWidget) self.lineEdit_2 = QLineEdit(self.findLayoutWidget) self.findClose = QPushButton(self.findLayoutWidget) self.findClose.setIcon(Icons.close_view) self.findClose.setFlat(True) self.findClose.clicked.connect(self.findBarShow) self.find = QPushButton(self.findLayoutWidget) self.find.setText("Find") self.find.clicked.connect(self.findCurrentText) self.replacefind = QPushButton(self.findLayoutWidget) self.replacefind.setText("Replace/Find") self.replacefind.clicked.connect(self.replaceFindText) self.replace = QPushButton(self.findLayoutWidget) self.replace.setText("Replace") self.replace.clicked.connect(self.replaceCurrentText) self.replaceAll = QPushButton(self.findLayoutWidget) self.replaceAll.setText("Replace All") self.replaceAll.clicked.connect(self.replaceAllText) self.caseSensitive = QToolButton(self.findLayoutWidget) self.caseSensitive.setIcon(Icons.font) self.caseSensitive.setCheckable(True) self.wholeWord = QToolButton(self.findLayoutWidget) self.wholeWord.setText("ww") self.wholeWord.setCheckable(True) self.regex = QToolButton(self.findLayoutWidget) self.regex.setText("re") self.regex.setCheckable(True) self.backward = QToolButton(self.findLayoutWidget) self.backward.setText("bk") self.backward.setCheckable(True) self.backward.setDisabled(True) self.findLayout.addWidget(self.findClose) self.findLayout.addWidget(self.find) self.findLayout.addWidget(self.lineEdit) self.findLayout.addWidget(self.lineEdit_2) self.findLayout.addWidget(self.caseSensitive) self.findLayout.addWidget(self.wholeWord) self.findLayout.addWidget(self.regex) self.findLayout.addWidget(self.backward) self.findLayout.addWidget(self.replacefind) self.findLayout.addWidget(self.replace) self.findLayout.addWidget(self.replaceAll) self.findLayout.setMargin(0) self.findLayoutWidget.setMaximumHeight(25) self.editorLayout.addWidget(self.findLayoutWidget) self.findLayoutWidget.hide() '''B.Designer''' '''This parent is for widgetsbar and design layout''' self.designerLayoutWidget = QWidget(self) self.designerLayoutWidget.setMinimumWidth(800) self.designerWidget = Screen(self) self.designerLayoutWidget.hide() self.designerLayout = QVBoxLayout(self.designerLayoutWidget) self.designerLayout.setMargin(0) self.designerLayout.addWidget(self.designerWidget) '''C.Level Editor''' '''This parent is for spritesheets and level layout''' self.levelLayoutWidget = QWidget(self) self.levelLayoutWidget.setMinimumWidth(800) self.levelWidget = Level(self) self.levelLayoutWidget.hide() self.levelLayout = QVBoxLayout(self.levelLayoutWidget) self.levelLayout.setMargin(0) self.levelLayout.addWidget(self.levelWidget) '''D.Explorer TabWidget''' self.explorerTabWidget = TreeTab(self) #self.explorerTabWidget.setMaximumWidth(200) '''1.Project Tree''' self.tab_5 = QWidget() #self.tab_5.setMaximumWidth(200) self.VerticalLayout_2 = QVBoxLayout(self.tab_5)#QHBoxLayout(self.tab_5) self.VerticalLayout_2.setMargin(0) self.treeWidget = ProjectTree(self.tab_5) #self.treeWidget.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) #self.treeWidget.horizontalScrollBar().show() self.VerticalLayout_2.addWidget(self.treeWidget) '''2.Outline Tree''' self.tab_2 = QWidget() #self.tab_2.setMaximumWidth(200) self.VerticalLayout_3 = QVBoxLayout(self.tab_2) self.VerticalLayout_3.setMargin(0) self.outlineWidget = OutlineTree(self.tab_2) self.outlineWidget.itemDoubleClicked.connect(self.gotoLine) self.VerticalLayout_3.addWidget(self.outlineWidget) '''E.Output TabWidget''' self.outputTabWidget = OutputTab(self) self.tabWidget.currentChanged.connect(self.fileChanged) self.explorerTabWidget.currentChanged.connect(self.closeExplorer) self.outputTabWidget.currentChanged.connect(self.closeConsole) self.tabWidget.setTabsClosable(True) self.tabWidget.setTabShape(0) '''1.Output layout''' #must check self.tab_6 = QWidget() self.horizontalLayout_2 = QVBoxLayout(self.tab_6) self.horizontalLayout_2.setMargin(0) self.textEdit = QTextEdit() self.inputLayout = QHBoxLayout() self.inputLayout.setMargin(0) self.fileButton = QPushButton() self.fileButton.setText("File") self.fileButton.clicked.connect(self.getFile) self.runButton = QPushButton() self.runButton.setFlat(True) self.runButton.setIcon(Icons.go) self.combo = QComboBox() self.combo.setFixedWidth(100) self.comboAdd = QPushButton() self.comboAdd.setIcon(Icons.add) self.comboAdd.setFlat(True) self.comboAdd.clicked.connect(self.addCmd) self.comboDel = QPushButton() self.comboDel.setIcon(Icons.close_view) self.comboDel.setFlat(True) self.comboDel.clicked.connect(self.delCmd) self.combo2 = QComboBox() self.combo2.setFixedWidth(500) self.combo2Add = QPushButton() self.combo2Add.setIcon(Icons.add) self.combo2Add.setFlat(True) self.combo2Add.clicked.connect(self.addParam) self.combo2Del = QPushButton() self.combo2Del.setIcon(Icons.close_view) self.combo2Del.setFlat(True) self.combo2Del.clicked.connect(self.delParam) if(self.checkHasValue(self.cmdList)): for cmd in self.cmdList: self.combo.addItem(cmd) else: self.cmdList = [] if(self.checkHasValue(self.paramList)): for param in self.paramList: self.combo2.addItem(param) else: self.paramList = [] self.horizontalLayout_2.addWidget(self.textEdit) self.inputLayout.addWidget(QLabel("<b>Command:</b>")) self.inputLayout.addWidget(self.combo) self.inputLayout.addWidget(self.comboAdd) self.inputLayout.addWidget(self.comboDel) self.inputLayout.addWidget(QLabel("<b>Parameters:</b>")) self.inputLayout.addWidget(self.combo2) self.inputLayout.addWidget(self.combo2Add) self.inputLayout.addWidget(self.combo2Del) self.inputLayout.addWidget(self.fileButton) self.inputLayout.addWidget(self.runButton) self.horizontalLayout_2.addLayout(self.inputLayout) '''2.Error Layout''' self.tab_7 = QWidget() self.horizontalLayout_4 = QHBoxLayout(self.tab_7) self.horizontalLayout_4.setMargin(0) self.errorTree = ErrorTree(self.tab_7) self.errorTree.itemDoubleClicked.connect(self.errorLine) self.horizontalLayout_4.addWidget(self.errorTree) '''TabWidgets tabs''' #self.designerWidget.addTab(QWidget(self),"") #self.designerWidget.setTabIcon(0,Icons.close_view) #self.levelWidget.addTab(QWidget(self),"") #self.levelWidget.setTabIcon(0,Icons.close_view) self.explorerTabWidget.addTab(self.tab_5,"Projects") self.explorerTabWidget.addTab(self.tab_2,"Outline") self.explorerTabWidget.addTab(QWidget(self),"") self.explorerTabWidget.setTabIcon(0,Icons.cprj) self.explorerTabWidget.setTabIcon(1,Icons.envvar) self.explorerTabWidget.setTabIcon(2,Icons.close_view) self.outputTabWidget.addTab(self.tab_7,"Error") self.outputTabWidget.addTab(self.tab_6,"Output") self.outputTabWidget.addTab(QWidget(self),"") self.outputTabWidget.setTabIcon(0,Icons.error) self.outputTabWidget.setTabIcon(1,Icons.console_view) self.outputTabWidget.setTabIcon(2,Icons.close_view) '''Splitters''' self.split1 = QSplitter(Qt.Horizontal) self.split1.addWidget(self.explorerTabWidget) self.split1.addWidget(self.editorLayoutWidget) self.split1.addWidget(self.designerLayoutWidget) self.split1.addWidget(self.levelLayoutWidget) #self.split1.addWidget(self.tab_5) self.split2 = QSplitter(Qt.Vertical) self.split2.addWidget(self.split1) self.split2.addWidget(self.outputTabWidget) self.horizontalLayout.addWidget(self.split2) '''Status Bar''' self.statusbar = QStatusBar(self) self.aboutButton = QPushButton(self) self.aboutButton.setFlat(True) self.aboutButton.setIcon(Icons.anchor) self.aboutButton.clicked.connect(self.about) self.expButton = QPushButton(self) self.expButton.setFlat(True) self.expButton.setIcon(Icons.prj) self.expButton.clicked.connect(self.exp) self.cmdButton = QPushButton(self) self.cmdButton.setFlat(True) self.cmdButton.setIcon(Icons.console_view) self.cmdButton.clicked.connect(self.cmd) self.cmdButton.setShortcut('Ctrl+D') self.imgButton = QPushButton(self) self.imgButton.setFlat(True) self.imgButton.setIcon(Icons.color_palette) self.imgButton.clicked.connect(self.design) self.imgButton.setShortcut('Ctrl+I') self.findButton = QPushButton(self) self.findButton.setFlat(True) self.findButton.setIcon(Icons.find) self.findButton.setShortcut("Ctrl+F") self.findButton.clicked.connect(self.findBarShow) ''' self.zoominButton = QPushButton(self) self.zoominButton.setFlat(True) self.zoominButton.setIcon(Icons.zoomplus) self.zoominButton.clicked.connect(self.zoomin) self.zoomoutButton = QPushButton(self) self.zoomoutButton.setFlat(True) self.zoomoutButton.setIcon(Icons.zoomminus) self.zoomoutButton.clicked.connect(self.zoomout) ''' '''Status Text,Line Text, Progress Bar and Stop Button''' self.statusText = QLabel("Writable") #self.statusText.setAlignment(Qt.AlignCenter) self.statusText.setFixedWidth(200) self.lineText = QLabel("") self.lineText.setFixedWidth(50) self.progressbar = QProgressBar() self.progressbar.setMinimum(0) self.progressbar.setMaximum(100) self.stopButton = QPushButton(self) self.stopButton.setFlat(True) self.stopButton.setIcon(Icons.stop) self.stopButton.clicked.connect(self.forceStop) self.progressbar.hide() self.stopButton.hide() self.temp = False self.progress = False self.counter = 0 '''Adding all widgets to Status Bar''' self.statusbar.addWidget(self.aboutButton) self.statusbar.addWidget(self.expButton) self.statusbar.addWidget(self.cmdButton) self.statusbar.addWidget(self.imgButton) self.statusbar.addWidget(self.findButton) #self.statusbar.addWidget(QWidget(self)) #self.statusbar.addWidget(self.zoominButton) #self.statusbar.addWidget(self.zoomoutButton) self.statusbar.addWidget(self.statusText) self.statusbar.addWidget(self.lineText) self.statusbar.addWidget(self.progressbar) self.statusbar.addWidget(self.stopButton) #self.statusbar.setFixedHeight(18) ''''Initializing Coloring Style''' self.initEditorStyle() self.initStyleSheet() '''Adding Cental Widget and Status Bar''' self.setCentralWidget(self.centralwidget) self.setStatusBar(self.statusbar) self.textEdit.setReadOnly(True) def initStyleSheet(self): import stylesheet self.setStyleSheet(stylesheet.mainstyl) self.tabWidget.tabBar().setStyleSheet(stylesheet.stletabb) self.explorerTabWidget.tabBar().setStyleSheet(stylesheet.stletabb) self.outputTabWidget.tabBar().setStyleSheet(stylesheet.stletabb) self.popWidget.setStyleSheet(stylesheet.popbg) self.popWidget.hide() ''' This is for changing the palette/window colors to Theme ''' def initEditorStyle(self): pass #editStyle = config.readStyle() #print editStyle #pal = QPalette(self.explorerTabWidget.palette()) #print pal.color(QPalette.Base).name() #print pal.color(QPalette.Window).name() #pal.setColor(QPalette.Base,self.colorStyle.paper) #pal.setColor(QPalette.Text,self.colorStyle.color) #self.explorerTabWidget.setPalette(pal) #self.outputTabWidget.setPalette(pal) ''' This is only for testing dont know if it works for builds ''' def changeStyleSheet(self): ''' Dynamically load the changed stylesheet.py and load the modules and change the style at runtime saves countless deploys ''' import imp foo = imp.load_source('stletabb', workDir+"/stylesheet.py") #print foo.stletabb #self.setStyleSheet(stylesheet.mainstyl) self.tabWidget.tabBar().setStyleSheet(foo.stletabb) self.popWidget.setStyleSheet(foo.popbg) if(self.popWidget.isHidden()): self.popWidget.showPopup() def build_project(self): #current_file = self.files[self.tabWidget.currentIndex()] prj = self.treeWidget.getProject() if(prj != None): self.treeWidget.build(prj) def run_project(self): #current_file = self.files[self.tabWidget.currentIndex()] prj = self.treeWidget.getProject()#current_file) if(prj != None): self.treeWidget.run(prj) def forceStop(self): self.ant.kill() self.progressStop() def kill(self): self.deleteLater() #-----------------------------------------------------------------------------------# # Menu Actions Functions # #-----------------------------------------------------------------------------------# def run(self): if(config.mode() == 0): self.sq.run() elif(config.mode() == 1): self.adb.run() elif(config.mode() == 2): self.ios.run() elif(config.mode() == 3): self.c.run() def setMode(self, action): if(action.text() == "Squ"): config.setMode(0) self.toolBar.action_Build.setEnabled(False) self.toolBar.action_Run.setEnabled(False) elif(action.text() == "Emo"): config.setMode(1) self.toolBar.action_Build.setEnabled(True) self.toolBar.action_Run.setEnabled(True) elif(action.text() == "Android"): config.setMode(2) self.toolBar.action_Build.setEnabled(True) self.toolBar.action_Run.setEnabled(True) elif(action.text() == "ios"): config.setMode(3) self.toolBar.action_Build.setEnabled(False) self.toolBar.action_Run.setEnabled(False) def openCommand(self): text, ok = QInputDialog.getText(self, 'Run Command', 'Command:') cmd = str(text) if ok and cmd != "": import subprocess subprocess.Popen(cmd) def about(self): form = DialogAbout(self) def todo(self): form = DialogTodo(self) form.show() def help(self): QMessageBox.about(self,"Help","This is about all The Help that i can Give you now") def full(self): if not self.isFull: self.setWindowState(Qt.WindowFullScreen) self.isFull = True else: self.setWindowState(Qt.WindowMaximized) self.isFull = False def android(self): form = DialogAndroid(self) form.show() def antt(self): form = DialogAnt(self) form.show() def squirrel(self): form = DialogSquirrel(self) form.show() def findBarShow(self): if(self.findLayoutWidget.isHidden()): self.findLayoutWidget.show() else: self.findLayoutWidget.hide() def exp(self): if(self.explorerTabWidget.isHidden()): self.explorerTabWidget.show() else: self.explorerTabWidget.hide() def cmd(self): if(self.outputTabWidget.isHidden()): self.outputTabWidget.show() else: self.outputTabWidget.hide() def editor(self): if(self.editorLayoutWidget.isHidden()): self.editorLayoutWidget.show() self.levelLayoutWidget.hide() self.designerLayoutWidget.hide() def design(self): if(self.designerLayoutWidget.isHidden()): self.designerLayoutWidget.show() self.editorLayoutWidget.hide() self.levelLayoutWidget.hide() else: self.designerLayoutWidget.hide() self.editorLayoutWidget.show() def level(self): if(self.levelLayoutWidget.isHidden()): self.levelLayoutWidget.show() self.editorLayoutWidget.hide() self.designerLayoutWidget.hide() else: self.levelLayoutWidget.hide() self.editorLayoutWidget.show() def closeDesigner(self,no): pass ''' if(no == self.tiler.closeIndex()): if(self.tiler.isHidden()): self.tiler.show() else: self.tiler.setCurrentIndex(1) self.tiler.hide() ''' '''The current Changed idx of outputTabWidget is passed to this a param''' def closeConsole(self,no = 2): if(no == 2): if(self.outputTabWidget.isHidden()): self.outputTabWidget.show() else: self.outputTabWidget.setCurrentIndex(1) self.outputTabWidget.hide() def popOutput(self): if(self.outputTabWidget.isHidden()): self.outputTabWidget.show() self.outputTabWidget.setCurrentIndex(1) def popError(self): if(self.outputTabWidget.isHidden()): self.outputTabWidget.show() self.outputTabWidget.setCurrentIndex(0) '''The current Changed idx of explorerTabWidget is passed to this a param''' def closeExplorer(self,no = 2): if(no == 2): if(self.explorerTabWidget.isHidden()): self.explorerTabWidget.show() else: self.explorerTabWidget.setCurrentIndex(0) self.explorerTabWidget.hide() elif(no == 1): self.fileChanged(no) ''' This is to refresh the outline widget''' def fileChanged(self,no): if(self.explorerTabWidget.currentIndex() == 1): edt = self.tabWidget.widget(self.tabWidget.currentIndex()) source = edt.text() self.outlineWidget.parseText(source) def statusSaving(self): self.statusText.setText("Saving") def statusParsing(self): self.statusText.setText("Parsing") def statusWriting(self): self.statusText.setText("Writable") def statusRunning(self): self.statusText.setText("Running") def statusStopping(self): self.statusText.setText("Stopping") def statusCommand(self): self.statusText.setText("Command") def statusBuilding(self): self.statusText.setText("Building") def statusInstalling(self): self.statusText.setText("Installing") def statusCleaning(self): self.statusText.setText("Cleaning") def statusCreating(self): self.statusText.setText("Creating") def progressStart(self): self.progress == True self.temp == True if(self.progressbar.isHidden()): self.progressbar.show() if(self.stopButton.isHidden()): self.stopButton.show() self.progressbar.setValue(1) def progressStop(self): self.progress == False self.temp == False self.progressbar.setValue(100) if not(self.progressbar.isHidden()): self.progressbar.hide() if not(self.stopButton.isHidden()): self.stopButton.hide() def progressUpdate(self): if(self.progress): if(self.temp): self.counter += 1 self.progressbar.setValue(self.counter) if(self.counter == 100): self.temp = False else: self.counter -= 1 self.progressbar.setValue(self.counter) if(self.counter == 0): self.temp = True #-----------------------------------------------------------------------------------# # Editor Functions # #-----------------------------------------------------------------------------------# '''Search and Replace Functions''' def findCurrentText(self): edt = self.tabWidget.widget(self.tabWidget.currentIndex()) edt.findText(self.lineEdit.text(),self.regex.isChecked(),self.caseSensitive.isChecked(),self.wholeWord.isChecked(),self.backward.isChecked()) def replaceCurrentText(self): edt = self.tabWidget.widget(self.tabWidget.currentIndex()) edt.replaceText(self.lineEdit_2.text()) def replaceFindText(self): edt = self.tabWidget.widget(self.tabWidget.currentIndex()) edt.replaceText(self.lineEdit_2.text()) self.findCurrentText() def replaceAllText(self): edt = self.tabWidget.widget(self.tabWidget.currentIndex()) while(edt.findText(self.lineEdit.text(),self.regex.isChecked(),self.caseSensitive.isChecked(),self.wholeWord.isChecked(),self.backward.isChecked())): edt.replaceText(self.lineEdit_2.text()) def errorLine(self,error): index = self.tabWidget.currentIndex() edt = self.tabWidget.widget(index) '''To prevent File item double clicking''' if(error.isFile() == False): edt.setLine(error.line) '''Font Functions''' def zoomin(self): pass #for i in range(len(self.files)): # self.tabWidget.widget(i).zoomin() def zoomout(self): pass #for i in range(len(self.files)): # self.tabWidget.widget(i).zoomout() ''' Must implement Lexer ''' def setLexer(self, action): pass #print action.text() def setApi(self, action): #print action.text() for i in range(len(self.files)): #not QString self.tabWidget.widget(i).setApi(str(action.text())) def setFont(self,font): config.setFontName(str(font.family())) for i in range(len(self.files)): self.tabWidget.widget(i).setNewFont(font) def setFontSize(self,idx): fontSize = idx+1 config.setFontSize(fontSize) for i in range(len(self.files)): self.tabWidget.widget(i).setFontSize() def gotoLine(self,item): edt = self.tabWidget.widget(self.tabWidget.currentIndex()) edt.setLine(item.line) def updateLine(self,no,col): self.lineText.setText(str(no)+" : "+str(col)) def setMargin(self): mar = config.margin() if(mar == 0): config.setMargin(1) for i in range(len(self.files)): self.tabWidget.widget(i).setMargin(1) else: config.setMargin(0) for i in range(len(self.files)): self.tabWidget.widget(i).setMargin(0) ''' Toggle ''' def setIndent(self): indent = config.indent() if(indent == 0): config.setIndent(1) for i in range(len(self.files)): self.tabWidget.widget(i).setIndent(1) else: config.setIndent(0) for i in range(len(self.files)): self.tabWidget.widget(i).setIndent(0) ''' Toggle ''' def setWhiteSpace(self): white = config.whiteSpace() if(white == 0): config.setWhiteSpace(1) for i in range(len(self.files)): self.tabWidget.widget(i).setWhitespaceVisibility(True) else: config.setWhiteSpace(0) for i in range(len(self.files)): self.tabWidget.widget(i).setWhitespaceVisibility(False) ''' Toggle ''' def setEndLine(self): for i in range(len(self.files)): edt = self.tabWidget.widget(i) edt.setEolVisibility(not edt.eolVisibility()) def setEncoding(self, action): if(action.text() == "Ascii"): config.setAscii() for i in range(len(self.files)): self.tabWidget.widget(i).setUtf8(False) elif(action.text() == "Unicode"): config.setUnicode() for i in range(len(self.files)): self.tabWidget.widget(i).setUtf8(True) def setThreshold(self,val): config.setThresh(val) for i in range(len(self.files)): #print i self.tabWidget.widget(i).setThreshold(val) def setTabWidth(self,val): config.setTabWidth(val) for i in range(len(self.files)): #print i self.tabWidget.widget(i).setTabWidth(val) '''style Functions''' #-----------------------------------------------------------------------------------# # Command Functions # #-----------------------------------------------------------------------------------# def getFile(self): self.browsedialog = DialogBrowse(self) self.browsedialog.tree.itemDoubleClicked.connect(self.getName) self.browsedialog.show() def getName(self,item): if(item.isFile()): self.browsedialog.accept() fname = item.getPath() if not (fname == ""): index = self.combo2.currentIndex() text = str(self.combo2.itemText(index))+" "+fname self.combo2.setItemText(index,text) self.paramList.pop(index) self.paramList.insert(index,text) config.setParam(self.paramList) def addCmd(self,index): text, ok = QInputDialog.getText(self, 'Add Command', 'Command:') if(ok): if(str(text) != ''): cmd = str(text).upper() self.cmdList.append(cmd) #print self.cmdList self.combo.addItem(cmd) config.setCmd(self.cmdList) config.setParam(self.paramList) def delCmd(self): index = self.combo.currentIndex() self.combo.removeItem(index) self.cmdList.pop(index) #print self.cmdList config.setCmd(self.cmdList) def addParam(self,index): text, ok = QInputDialog.getText(self, 'Add Parameters', 'Params:') if(ok): if(str(text) != ''): param = str(text) self.paramList.append(param) self.combo2.addItem(param) config.setParam(self.paramList) def delParam(self): index = self.combo2.currentIndex() self.combo2.removeItem(index) self.paramList.pop(index) config.setParam(self.paramList) def checkHasValue(self,list): if(list != None and len(list) != 0): return True else: return False
class Window(QMainWindow): def __init__(self,parent = None): QMainWindow.__init__(self,parent) self.setObjectName("self") self.resize(758, 673) self.setWindowTitle("Sabel") self.setWindowIcon(Icons.sabel) self.centralwidget = QWidget(self) self.centralwidget.setObjectName("centralwidget") self.horizontalLayout = QHBoxLayout(self.centralwidget) self.horizontalLayout.setObjectName("horizontalLayout") self.horizontalLayout.setMargin(0) self.styleIndex = styleIndex #TabWidgets self.tab_1 = QWidget(self) self.tab_1.setObjectName("tab_1") self.tab_1.setMinimumWidth(800) self.tabWidget = Tab(self.tab_1) self.tabWidget.setObjectName("tabWidget") self.VericalLayout = QVBoxLayout(self.tab_1) self.VericalLayout.setMargin(0) self.VericalLayout.setObjectName("VericalLayout") self.VericalLayout.addWidget(self.tabWidget) self.tabWidget_2 = QTabWidget(self) #self.tabWidget_2.setMaximumWidth(200) self.tabWidget_2.setObjectName("tabWidget_2") self.tabWidget_3 = QTabWidget(self) self.tabWidget_3.setMaximumHeight(260) self.tabWidget_3.setObjectName("tabWidget_3") #Tree self.tab_5 = QWidget() self.tab_5.setObjectName("tab_5") #self.tab_5.setMaximumWidth(200) self.VerticalLayout_2 = QVBoxLayout(self.tab_5)#QHBoxLayout(self.tab_5) self.VerticalLayout_2.setMargin(0) self.VerticalLayout_2.setObjectName("horizontalLayout_3") self.treeWidget = Tree(self.tab_5) self.treeWidget.setObjectName("treeWidget") self.treeWidget.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.treeWidget.horizontalScrollBar().show() self.treebar = QToolBar() action_Folder = QAction(Icons.newfolder,'New Folder', self) action_Folder.triggered.connect(self.about) action_Android = QAction(Icons.android,'Android', self) action_Android.triggered.connect(self.android) action_Ant = QAction(Icons.ant_view,'Ant', self) action_Ant.triggered.connect(self.ant) self.treebar.addAction(action_Folder) self.treebar.addAction(action_Android) self.treebar.addAction(action_Ant) self.treebar.setIconSize(QSize(16,16)) self.VerticalLayout_2.addWidget(self.treebar) self.VerticalLayout_2.addWidget(self.treeWidget) #Outline self.tab_2 = QWidget() self.tab_2.setObjectName("tab_2") #self.tab_2.setMaximumWidth(200) self.VerticalLayout_3 = QVBoxLayout(self.tab_2) self.VerticalLayout_3.setMargin(0) self.VerticalLayout_3.setObjectName("VerticalLayout_3") self.outlineWidget = Tree(self.tab_2) self.outlineWidget.setObjectName("outlineWidget") self.VerticalLayout_3.addWidget(self.outlineWidget) #Output self.tab_6 = QWidget() self.tab_6.setObjectName("tab_6") #GGGGGGGGGGGGGGGGGGGG AWESOME self.horizontalLayout_2 = QVBoxLayout(self.tab_6) self.horizontalLayout_2.setMargin(0) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.textEdit = QTextEdit(self.tab_6) self.textEdit.setObjectName("textEdit") self.lineeEdit = QLineEdit(self.tab_6) self.lineeEdit.setObjectName("lineeEdit") self.label = QLabel(self.tab_6) self.label.setText("Input:") self.horizontalLayout_2.addWidget(self.textEdit) self.horizontalLayout_2.addWidget(self.label) self.horizontalLayout_2.addWidget(self.lineeEdit) #Error self.tab_7 = QWidget() self.tab_7.setObjectName("tab_7") self.horizontalLayout_4 = QHBoxLayout(self.tab_7) self.horizontalLayout_4.setMargin(0) self.horizontalLayout_4.setObjectName("horizontalLayout_4") self.textEdit_2 = QTextEdit(self.tab_7) self.textEdit_2.setObjectName("textEdit_2") self.horizontalLayout_4.addWidget(self.textEdit_2) #Find self.tab_8 = QWidget() self.tab_8.setObjectName("tab_8") self.horizontalLayout_5 = QHBoxLayout(self.tab_8) self.horizontalLayout_5.setObjectName("horizontalLayout_5") self.lineEdit = QLineEdit(self.tab_8) self.lineEdit.setObjectName("lineEdit") self.lineEdit_2 = QLineEdit(self.tab_8) self.lineEdit_2.setObjectName("lineEdit_2") self.findClose = QPushButton(self.tab_8) self.findClose.setIcon(Icons.close_view) self.findClose.setFlat(True) self.findClose.clicked.connect(self.findBarShow) self.find = QPushButton(self.tab_8) self.find.setText("Find") self.find.clicked.connect(self.findCurrentText) self.replacefind = QPushButton(self.tab_8) self.replacefind.setText("Replace/Find") self.replace = QPushButton(self.tab_8) self.replace.setText("Replace") self.replace.clicked.connect(self.replaceCurrentText) self.replaceAll = QPushButton(self.tab_8) self.replaceAll.setText("Replace All") self.replaceAll.clicked.connect(self.replaceAllText) self.caseSensitive = QToolButton(self.tab_8) self.caseSensitive.setText("cs") self.caseSensitive.setCheckable(True) self.wholeWord = QToolButton(self.tab_8) self.wholeWord.setText("ww") self.wholeWord.setCheckable(True) self.regex = QToolButton(self.tab_8) self.regex.setText("re") self.regex.setCheckable(True) self.backward = QToolButton(self.tab_8) self.backward.setText("bk") self.backward.setCheckable(True) self.backward.setDisabled(True) self.horizontalLayout_5.addWidget(self.findClose) self.horizontalLayout_5.addWidget(self.find) self.horizontalLayout_5.addWidget(self.lineEdit) self.horizontalLayout_5.addWidget(self.lineEdit_2) self.horizontalLayout_5.addWidget(self.caseSensitive) self.horizontalLayout_5.addWidget(self.wholeWord) self.horizontalLayout_5.addWidget(self.regex) self.horizontalLayout_5.addWidget(self.backward) self.horizontalLayout_5.addWidget(self.replacefind) self.horizontalLayout_5.addWidget(self.replace) self.horizontalLayout_5.addWidget(self.replaceAll) self.horizontalLayout_5.setMargin(0) self.tab_8.setMaximumHeight(25) self.VericalLayout.addWidget(self.tab_8) self.tab_8.hide() self.tabWidget_2.addTab(self.tab_5,"Projects") self.tabWidget_2.addTab(self.tab_2,"Outline") self.tabWidget_3.addTab(self.tab_7,"Error") self.tabWidget_3.addTab(self.tab_6,"Output") self.tabWidget_3.setTabIcon(0,Icons.error) self.tabWidget_3.setTabIcon(1,Icons.console_view) self.tabWidget.setTabsClosable(True) self.tabWidget.setTabShape(0) #Splitters self.split1 = QSplitter(Qt.Horizontal) self.split1.addWidget(self.tabWidget_2) self.split1.addWidget(self.tab_1) #self.split1.addWidget(self.tab_5) self.split2 = QSplitter(Qt.Vertical) self.split2.addWidget(self.split1) self.split2.addWidget(self.tabWidget_3) self.tabWidget_3.hide() self.horizontalLayout.addWidget(self.split2) #Status self.statusbar = QStatusBar(self) self.statusbar.setObjectName("statusbar") self.aboutButton = QPushButton(self) self.aboutButton.setFlat(True) self.aboutButton.setIcon(Icons.anchor) self.aboutButton.clicked.connect(self.about) self.cmdButton = QPushButton(self) self.cmdButton.setFlat(True) self.cmdButton.setIcon(Icons.console_view) self.cmdButton.clicked.connect(self.cmd) self.cmdButton.setShortcut('Ctrl+O') self.findButton = QPushButton(self) self.findButton.setFlat(True) self.findButton.setIcon(Icons.find) self.findButton.setShortcut("Ctrl+F") self.findButton.clicked.connect(self.findBarShow) self.zoominButton = QPushButton(self) self.zoominButton.setFlat(True) self.zoominButton.setIcon(Icons.zoomplus) self.zoominButton.clicked.connect(self.zoomin) self.zoomoutButton = QPushButton(self) self.zoomoutButton.setFlat(True) self.zoomoutButton.setIcon(Icons.zoomminus) self.zoomoutButton.clicked.connect(self.zoomout) self.fontButton = QPushButton(self) self.fontButton.setFlat(True) self.fontButton.setIcon(Icons.font) self.fontButton.clicked.connect(self.setFont) self.statusbar.addWidget(self.aboutButton) self.statusbar.addWidget(self.cmdButton) self.statusbar.addWidget(self.findButton) self.statusbar.addWidget(self.zoominButton) self.statusbar.addWidget(self.zoomoutButton) self.statusbar.addWidget(self.fontButton) #self.statusbar.setFixedHeight(18) #Init colorstyling self.colorStyle = None self.initColorStyle() #Init self.setCentralWidget(self.centralwidget) self.setStatusBar(self.statusbar) self.textEdit.setReadOnly(True) self.fontName = fontName #QtGui.QApplication.setStyle(QtGui.QStyleFactory.create('Cleanlooks')) def findBarShow(self): if(self.tab_8.isHidden()): self.tab_8.show() else: self.tab_8.hide() def initToolBar(self): self.action_NewProject = QAction(Icons.newprj, 'Project', self) self.action_NewProject.setShortcut('Ctrl+P') self.action_NewProject.triggered.connect(self.newProject) self.action_NewProject.setToolTip("Create a New Project") self.action_NewProject.setStatusTip("Create a New Project") self.action_Open = QAction(Icons.open, 'Open', self) self.action_Open.setShortcut('Ctrl+O') self.action_Open.triggered.connect(self.fileOpen) self.action_Open.setToolTip("Open File") self.action_Open.setStatusTip("Open File") self.action_Save = QAction(Icons.save, 'Save', self) self.action_Save.setShortcut('Ctrl+S') self.action_Save.triggered.connect(self.fileSave) self.action_Save.setToolTip("Save Current File") self.action_SaveAll = QAction(Icons.saveall, 'SaveAll', self) self.action_SaveAll.setShortcut('Ctrl+A') self.action_SaveAll.triggered.connect(self.fileSaveAll) self.action_SaveAll.setToolTip("Save All Files") self.action_Help = QAction(Icons.toc_open, 'Help', self) self.action_Help.triggered.connect(self.help) self.action_Run = QAction(Icons.run, 'Run', self) self.action_Run.setShortcut('Ctrl+R') self.action_Run.triggered.connect(self.adb.run) self.action_RunFile = QAction(Icons.go, 'File', self) self.action_RunFile.triggered.connect(self.command.setCmd) self.lineeEdit.returnPressed.connect(self.command.setCmdLine) self.action_Stop = QAction(Icons.stop, 'Stop', self) self.action_Stop.setShortcut('Ctrl+Q') self.action_Stop.triggered.connect(self.adb.stop) self.action_Design = QAction(Icons.task_set, 'Design', self) self.action_Todo = QAction(Icons.task_set, 'Todo', self) #self.action_Todo.triggered.connect(self.stop) #Only variation CHeck Later men = QMenu() self.threshSlider = QSlider() self.threshSlider.setTickPosition(QSlider.TicksLeft) self.threshSlider.setOrientation(Qt.Horizontal) self.threshSlider.setValue(threshold) self.threshSlider.setMinimum(0) self.threshSlider.setMaximum(5) self.threshSlider.valueChanged.connect(self.setThreshold) #self.threshSlider.setInvertedAppearance(True) self.threshSliderAction = QWidgetAction(men) self.threshSliderAction.setDefaultWidget(self.threshSlider) men.addAction(QAction("Ident",self)) men.addAction(QAction("Edit",self)) men.addAction(QAction("Paste",self)) men.addAction(QAction("Tabs",self)) men.addSeparator() men.addAction(QAction("Threshold",self)) men.addAction(self.threshSliderAction) self.action_Options = QAction(Icons.thread_view, 'Options', self) self.action_Options.setMenu(men) self.action_Options.triggered.connect(self.options) self.action_Full = QAction(Icons.fullscreen, 'Full', self) self.action_Full.setShortcut('Shift+Enter') self.action_Full.triggered.connect(self.full) self.action_Style = QAction(Icons.style, 'Style', self) men1 = QMenu() self.styleslist = [] self.style1 = QAction("All Hallow's Eve",self) self.style1.triggered.connect(lambda:self.style_clicked(1)) self.style1.setCheckable(True) self.style2 = QAction("Amy",self) self.style2.triggered.connect(lambda:self.style_clicked(2)) self.style2.setCheckable(True) self.style3 = QAction("Aptana Studio",self) self.style3.triggered.connect(lambda:self.style_clicked(3)) self.style3.setCheckable(True) self.style4 = QAction("Bespin",self) self.style4.triggered.connect(lambda:self.style_clicked(4)) self.style4.setCheckable(True) self.style5 = QAction("Blackboard",self) self.style5.triggered.connect(lambda:self.style_clicked(5)) self.style5.setCheckable(True) self.style6 = QAction("Choco",self) self.style6.triggered.connect(lambda:self.style_clicked(6)) self.style6.setCheckable(True) self.style7 = QAction("Cobalt",self) self.style7.triggered.connect(lambda:self.style_clicked(7)) self.style7.setCheckable(True) self.style8 = QAction("Dawn",self) self.style8.triggered.connect(lambda:self.style_clicked(8)) self.style8.setCheckable(True) self.style9 = QAction("Eclipse",self) self.style9.triggered.connect(lambda:self.style_clicked(9)) self.style9.setCheckable(True) self.styleslist.append(self.style1) self.styleslist.append(self.style2) self.styleslist.append(self.style3) self.styleslist.append(self.style4) self.styleslist.append(self.style5) self.styleslist.append(self.style6) self.styleslist.append(self.style7) self.styleslist.append(self.style8) self.styleslist.append(self.style9) men1.addActions(self.styleslist) self.action_Style.setMenu(men1) self.styleslist[self.styleIndex].setChecked(True) self.action_Stop.setDisabled(True) self.toolbar = self.addToolBar('ToolBar') self.toolbar.setIconSize(QSize(16,16)) self.setToolButtonStyle(Qt.ToolButtonTextUnderIcon) self.toolbar.setAllowedAreas(Qt.AllToolBarAreas) #self.toolbar.setFixedHeight(40) self.toolbar.addAction(self.action_NewProject) self.toolbar.addAction(self.action_Open) self.toolbar.addAction(self.action_Save) self.toolbar.addAction(self.action_SaveAll) self.toolbar.addSeparator() self.toolbar.addAction(self.action_Run) self.toolbar.addAction(self.action_RunFile) self.toolbar.addAction(self.action_Stop) self.toolbar.addSeparator() self.toolbar.addAction(self.action_Design) self.toolbar.addAction(self.action_Todo) self.toolbar.addAction(self.action_Options) self.toolbar.addAction(self.action_Style) self.toolbar.addSeparator() self.toolbar.addAction(self.action_Help) self.toolbar.addAction(self.action_Full) def about(self): QMessageBox.about(self, "About Sabel IDE", """ <b>Sabel</b> v%s <p> All rights reserved in accordance with GPL v3 or later. <p>This application can be used for Squirrel and EmoFramework Projects. <p>Squirrel Shell Copyright (c) 2006-2011, Constantin Makshin <p>Squirrel Copyright (c) Alberto Demichelis <p>zlib Copyright (c) Jean-loup Gailly and Mark Adler <p>Icons Copyright (c) Eclipse EPL <p>Emo-Framework Copyright (c) 2011 Kota Iguchi <p>Python %s - Qt %s - PyQt %s on %s <p>Created By: pyros2097 <p>THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ % ( __version__,PY_VERSION, QT_VERSION_STR, PYQT_VERSION_STR,OS_NAME)) def help(self): QMessageBox.about(self, "About Simple Editor","This is The Help") def full(self): if not self.isFull: self.setWindowState(Qt.WindowFullScreen) self.isFull = True else: self.setWindowState(Qt.WindowMaximized) self.isFull = False def android(self): form = DialogAndroid(self) form.show() def ant(self): pass def cmd(self): if(self.tabWidget_3.isHidden()): self.tabWidget_3.show() else: self.tabWidget_3.hide() def findCurrentText(self): edt = self.tabWidget.widget(self.tabWidget.currentIndex()) edt.findText(self.lineEdit.text(),self.regex.isChecked(),self.caseSensitive.isChecked(),self.wholeWord.isChecked(),self.backward.isChecked()) def replaceCurrentText(self): edt = self.tabWidget.widget(self.tabWidget.currentIndex()) done = edt.findText(self.lineEdit.text(),self.regex.isChecked(),self.caseSensitive.isChecked(),self.wholeWord.isChecked(),self.backward.isChecked()) if(done): edt.replaceText(self.lineEdit_2.text()) else: QMessageBox.about(self, "About Sabel IDE","Could Not Find Text") return done def replaceAllText(self): edt = self.tabWidget.widget(self.tabWidget.currentIndex()) while(edt.findText(self.lineEdit.text(),self.regex.isChecked(),self.caseSensitive.isChecked(),self.wholeWord.isChecked(),self.backward.isChecked())): edt.replaceText(self.lineEdit_2.text()) def zoomin(self): for i in range(len(self.files)): self.tabWidget.widget(i).zoomin() def zoomout(self): for i in range(len(self.files)): self.tabWidget.widget(i).zoomout() def setFont(self): font = QFont() font.setFamily(self.fontName) fdialog = QFontDialog(self) fdialog.show() fdialog.setCurrentFont(font) fdialog.accepted.connect(lambda:self.setFontName(fdialog.currentFont())) def setFontName(self,font): #print "accepted" #print font.family() self.fontName = str(font.family()) config.setFontName(self.fontName) for i in range(len(self.files)): self.tabWidget.widget(i).setFontName(self.fontName) def setThreshold(self,val): config.setThresh(val) for i in range(len(self.files)): self.tabWidget.widget(i).setThreshold(val) def initColorStyle(self): self.colorStyle = Styles[self.styleIndex] pal = QPalette(self.tabWidget_2.palette()) #print pal.color(QPalette.Base).name() #print pal.color(QPalette.Window).name() pal.setColor(QPalette.Base,self.colorStyle.paper) pal.setColor(QPalette.Text,self.colorStyle.color) self.tabWidget_2.setPalette(pal) self.tabWidget_3.setPalette(pal) def style_clicked(self,no): self.styleIndex = no -1 #print self.styleIndex for i in self.styleslist: if self.styleslist.index(i) == self.styleIndex: i.setChecked(True) else: i.setChecked(False) config.setstyleIndex(self.styleIndex) #self.initColorStyle() for i in range(len(self.files)): pass #self.tabWidget. #self.tabWidget.widget(i).setColorStyle(self.colorStyle)