def __init__(self, parent, locals={}, log=''): QextScintilla.__init__(self, parent, 'Console') self.locals = mydict(locals) self.interpreter = Interpreter(self.locals) self.resize(500, 300) lex = QextScintillaLexerPython() # font = QFont(QApplication.font()) # font.setPointSize(.8*font.pointSize()) # lex.setDefaultFont(font) # lex.setFont(font, 0) self.setLexer(lex) self.zoomOut() self.zoomOut() # self.SendScintilla(self.SCI_SETHSCROLLBAR, False) self.SendScintilla(self.SCI_SETSCROLLWIDTH, 100) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) sys.stdout = self sys.stdin = self self.last_lines = [] self.more = False self.reading = False # history self.history = settings.get('script', 'history') # self.history = project.settings['/grafit/console/history'] if self.history is None: self.history = [] else: self.history = self.history.split('\n') self.pointer = 0 sys.ps1 = '>>> ' sys.ps2 = '... ' self.completer = rlcompleter.Completer() self.current_object = None self.set_current_object(None) self.locals['go'] = self.set_current_object self.write(sys.ps1)
def __init__(self): MainWindowUI.__init__(self) self.mainbox = QVBox(self) self.setCentralWidget(self.mainbox) self.workspace = QWorkspace(self.mainbox) self.workspace.setScrollBarsEnabled(True) self.connect(self.workspace, SIGNAL("windowActivated(QWidget *)"), self.on_window_activated) self.recent = settings.get('windows', 'recent') if self.recent in [None, '']: self.recent = [] else: self.recent = [s for s in self.recent.split(' ') if os.path.isfile(s)] self.recentids = [] self.connect(self.File, SIGNAL('aboutToShow()'), self.fileMenuAboutToShow) self.connect(self.Window, SIGNAL('aboutToShow()'), self.windowMenuAboutToShow) ### status bar ################################################################################# self.statusBar().show() self.statusBar().message("Welcome to Grafity", 1000) self.statuslabel = QLabel(self, 'Pikou') self.statusBar().addWidget(self.statuslabel, 0, True) self.statuslabel.setText("") self.progressbar = QProgressBar(100, self) self.statusBar().addWidget(self.progressbar, 0, True) self.progressbar.hide() ### bottom panel ############################################################################### locals = {} # locals['undo'] = undo # locals['redo'] = redo locals['main'] = self self.bpanel = Panel(self, QMainWindow.DockBottom) self.script = Console(self.bpanel, locals=locals) self.script.runsource('from grafity import *') self.script.runsource('from grafity.arrays import *') self.bpanel.add('Script', getimage('console'), self.script) ### left panel ################################################################################# self.lpanel = Panel(self, QMainWindow.DockLeft) self.explorer = ProjectExplorer(self.lpanel) # self.explorer.connect('activated', self.on_activated) self.lpanel.add('Explorer', getimage('folder'), self.explorer) self.lpanel.btns['Explorer'].setOn(True) self.actionlist = ActionList(self.lpanel) self.lpanel.add('Actions', getimage('undo'), self.actionlist) ### right panel ################################################################################ self.rpanel = Panel(self, QMainWindow.DockRight) # self.graph_data = GraphData(self.bpanel, self) # self.graph_style = GraphStyle(self.bpanel, self) # self.graph_axes = GraphAxes(self.bpanel, self) # self.graph_fit = GraphFit(self.bpanel, self) # self.rpanel.add('Data', getimage('worksheet'), self.graph_data) # self.rpanel.add('Style', getimage('style'), self.graph_style) # self.rpanel.add('Axes', getimage('axes'), self.graph_axes) # self.rpanel.add('fit', getimage('function'), self.graph_fit) # self.open_project(grafity.Project())#'../test/pdms.gt')) # global_connect('status-message', self.status_message) self.worksheet_toolbar.hide() self.graph_toolbar.hide() self.script_toolbar.hide() self.rpanel.hide() self.column_tool_submenus = {'': self.Column} for i, (name, function, image) in enumerate(column_tools): if '/' in name: path, name = name.split('/') else: path = '' if path not in self.column_tool_submenus: self.column_tool_submenus[path] = QPopupMenu() self.Column.insertItem(path, self.column_tool_submenus[path]) menu = self.column_tool_submenus[path] if image is not None: item = menu.insertItem(QIconSet(getimage(image)), name) else: item = menu.insertItem(name) menu.connectItem(item, self.on_column_tool) menu.setItemParameter(item, i) self.menubar.removeItem(self.menubar.idAt(2)) self.menubar.removeItem(self.menubar.idAt(2)) self.menubar.removeItem(self.menubar.idAt(2)) self.menubar.removeItem(self.menubar.idAt(2)) self.active = None if len(graph_modes): self.act_graph_extra = QAction(self.act_graph, 'act_extra') self.act_graph_extra.setToggleAction(1) self.act_graph_extra.addTo(self.graph_toolbar) self.btn = btn = self.graph_toolbar.queryList('QToolButton')[-1] cm = QPopupMenu (self) self.connect(cm, SIGNAL('activated(int)'), self.on_mode_btn) for i, tool in enumerate(graph_modes): cm.insertItem(QIconSet(getimage(tool.image)), tool.name, i) btn.setPopup(cm) btn.setPopupDelay(0) self.on_mode_btn(0) self.graph_toolbar.addSeparator() self.graph_text.addTo(self.graph_toolbar)