def new_consolle(self): self.a = [] console = PythonConsole() console.push_local_ns('getData', self.getData) console.push_local_ns('getCurrent', self.getCurrent) console.show() console.eval_executor(gevent.spawn)
def main(rts): pg.setConfigOptions(antialias=True) app = QtWidgets.QApplication(sys.argv) # phasor_plot = gui.PhasorPlot(rts, update_freq=30) grid_plt = GridPlot(rts, update_freq=1) # ts_plot = gui.TimeSeriesPlot(rts, ['speed', 'angle'], update_freq=30) # , 'speed', 'e_q_t', 'e_d_t', 'e_q_st', 'e_d_st']) # stats_plot = gui.SimulationStatsPlot(rts, update_freq=30) # Add Control Widgets # line_outage_ctrl = gui.LineOutageWidget(rts) # excitation_ctrl = gui.GenCtrlWidget(rts) console = PythonConsole() console.push_local_ns('rts', rts) console.push_local_ns('grid_plt', grid_plt) # console.push_local_ns('ts_plot', ts_plot) # console.push_local_ns('phasor_plot', phasor_plot) # console.push_local_ns('line_outage_ctrl', line_outage_ctrl) # console.push_local_ns('excitation_ctrl', excitation_ctrl) console.show() console.eval_in_thread() app.exec_() return app
class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.setWindowModality(QtCore.Qt.NonModal) MainWindow.resize(1440, 800) MainWindow.setMinimumSize(QtCore.QSize(1440, 800)) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(":/image/icon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) MainWindow.setWindowIcon(icon) MainWindow.setStyleSheet("background-color:whitesmoke;\n" "font-size:20px;\n" "font-weight:bold;") self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.gridLayout = QtWidgets.QGridLayout(self.centralwidget) self.gridLayout.setObjectName("gridLayout") self.gridFrame = QtWidgets.QFrame(self.centralwidget) self.gridFrame.setSizeIncrement(QtCore.QSize(0, 4)) self.gridFrame.setObjectName("gridFrame") self.gridLayout_2 = QtWidgets.QGridLayout(self.gridFrame) self.gridLayout_2.setContentsMargins(0, 0, 0, 0) self.gridLayout_2.setObjectName("gridLayout_2") self.symbol_table = QtWidgets.QListView(self.gridFrame) self.symbol_table.setMinimumSize(QtCore.QSize(250, 0)) self.symbol_table.setMaximumSize(QtCore.QSize(250, 16777215)) self.symbol_table.setStyleSheet("border: 2px solid silver;") self.symbol_table.setProperty("isWrapping", True) self.symbol_table.setObjectName("symbol_table") self.gridLayout_2.addWidget(self.symbol_table, 0, 0, 1, 1) self.graphicsView = PhotoViewer(self.gridFrame) self.graphicsView.setStyleSheet("border: 2px solid silver;") self.graphicsView.setObjectName("graphicsView") self.gridLayout_2.addWidget(self.graphicsView, 0, 1, 1, 1) self.gridLayout.addWidget(self.gridFrame, 0, 0, 1, 1) self.console = PythonConsole(self.centralwidget) self.console.setMinimumSize(QtCore.QSize(0, 200)) self.console.setMaximumSize(QtCore.QSize(16777215, 200)) self.console.setSizeIncrement(QtCore.QSize(0, 1)) self.console.setStyleSheet("QFrame{\n" "border: 2px solid silver;\n" "}") self.console.setObjectName("console") self.gridLayout.addWidget(self.console, 1, 0, 1, 1) MainWindow.setCentralWidget(self.centralwidget) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "Easy Paging"))
def new_console(tabto=None, floating=False, dockingarea=QtCore.Qt.RightDockWidgetArea): """ Create a new console and float it as a max widget tabto: name of a widget on top of which the console should be tabbed floating: True to float the console, False to leave it docked dockingarea: The docking area for docking the window (default = right) """ main_window = GetQMaxMainWindow() # create and setup a console console = PythonConsole(formats=HUGOS_THEME) console.setStyleSheet("background-color: #333333;") # create a dock widget for the console dock_widget = QDockWidget(main_window) dock_widget.setWidget(console) dock_widget.setObjectName("pyconsole") dock_widget.setWindowTitle("Python Console") main_window.addDockWidget(dockingarea, dock_widget) if not tabto is None: tabw = main_window.findChild(QWidget, tabto) main_window.tabifyDockWidget(tabw, dock_widget) dock_widget.setFloating(floating) dock_widget.show() # make the console do stuff console.eval_queued() return console
# -*- coding: utf-8 -*- #/usr/bin/python import sys from pyqtconsole.qt.QtWidgets import QApplication from pyqtconsole.console import PythonConsole def greet(): print("hello world") if __name__ == '__main__': app = QApplication([]) console = PythonConsole() console.push_local_ns('greet', greet) console.show() console.eval_queued() sys.exit(app.exec_())
import sys from threading import Thread from PyQt5.QtWidgets import QApplication from pyqtconsole.console import PythonConsole app = QApplication([]) console = PythonConsole() console.show() console.eval_in_thread() sys.exit(app.exec_())
#! /usr/bin/env python # -*- coding: utf-8 -*- import sys from qtpy.QtWidgets import QApplication from pyqtconsole.console import PythonConsole def greet(): print("hello world") if __name__ == '__main__': app = QApplication([]) console = PythonConsole() console.push_local_ns('greet', greet) console.show() console.eval_in_thread() sys.exit(app.exec_())
# to trigger a microthread anytime self._idle_period = idle_period # IDLE timer: on_idle is called whenever no Qt events left for # processing self._timer = QTimer() self._timer.timeout.connect(self.process_events) self._timer.start(0) def __enter__(self): pass def __exit__(self, *exc_info): self._timer.stop() def process_events(self): # Cooperative yield, allow gevent to monitor file handles via libevent gevent.sleep(self._idle_period) if __name__ == '__main__': app = QApplication([]) console = PythonConsole() console.push_local_ns('greet', greet) console.show() console.eval_executor(gevent.spawn) with GEventProcessing(): sys.exit(app.exec_())
#! /usr/bin/env python # -*- coding: utf-8 -*- import sys from qtpy.QtWidgets import QApplication from pyqtconsole.console import PythonConsole from pyqtconsole.highlighter import format def greet(): print("hello world") if __name__ == '__main__': app = QApplication([]) console = PythonConsole(formats={'keyword': format('darkBlue', 'bold')}) console.push_local_ns('greet', greet) console.show() console.eval_queued() sys.exit(app.exec_())
def main(rts): update_freq = 30 pg.setConfigOptions(antialias=True) app = QtWidgets.QApplication(sys.argv) phasor_plot = gui.PhasorPlot(rts, update_freq=update_freq) ts_plot = gui.TimeSeriesPlot( rts, ['speed', 'angle'], update_freq=update_freq ) # , 'speed', 'e_q_t', 'e_d_t', 'e_q_st', 'e_d_st']) grid_plot = gui.GridPlot3D(rts, update_freq=update_freq, z_ax='abs_pu', rotating=False) # , use_colors=True) grid_plot_angle = gui.GridPlot3D(rts, update_freq=update_freq, z_ax='angle', rotating=False) # , use_colors=True) # stats_plot = gui.SimulationStatsPlot(rts, update_freq=30) # Add Control Widgets line_outage_ctrl = gui.LineOutageWidget(rts) gen_ctrl = gui.GenCtrlWidget(rts) console = PythonConsole() console.push_local_ns('rts', rts) console.push_local_ns('ts_plot', ts_plot) console.push_local_ns('phasor_plot', phasor_plot) console.push_local_ns('line_outage_ctrl', line_outage_ctrl) console.push_local_ns('gen_ctrl', gen_ctrl) console.show() console.eval_in_thread() app.exec_() return app
# -*- coding: utf-8 -*- #/usr/bin/python import sys from pyqtconsole.qt.QtWidgets import QApplication from pyqtconsole.console import PythonConsole def greet(): print("hello world") if __name__ == '__main__': app = QApplication([]) console = PythonConsole() console.push_local_ns('greet', greet) console.show() console.eval_queued() print(dir(PythonConsole())) console.print("Ahoy there") sys.exit(app.exec_())
def main(rts): app = QtWidgets.QApplication(sys.argv) phasor_plot = PhasorPlot(rts, update_freq=25) ts_plot = TimeSeriesPlotFast(rts, ['angle', 'speed'], update_freq=25) # , 'speed', 'e_q_t', 'e_d_t', 'e_q_st', 'e_d_st']) stats_plot = SimulationStatsPlot(rts, update_freq=25) # , 'speed', 'e_q_t', 'e_d_t', 'e_q_st', 'e_d_st']) # Add Control Widgets line_outage_ctrl = LineOutageWidget(rts) excitation_ctrl = GenCtrlWidget(rts) # console = PythonConsole() console = PythonConsole() console.push_local_ns('rts', rts) # console.push_local_ns('ts_plot', ts_plot) console.push_local_ns('phasor_plot', phasor_plot) console.push_local_ns('line_outage_ctrl', line_outage_ctrl) console.push_local_ns('excitation_ctrl', excitation_ctrl) console.show() console.eval_in_thread() app.exec_() return app
from pyqtconsole.qt.QtCore import QTimer from pyqtconsole.qt.QtWidgets import QApplication from pyqtconsole.console import PythonConsole def gevent_wait(): try: gevent.wait(0.01) except: gevent.sleep(0.01) def greet(): print("hello world") if __name__ == '__main__': app = QApplication([]) console = PythonConsole() console.push_local_ns('greet', greet) console.show() gevent_timer = QTimer() gevent_timer.timeout.connect(gevent_wait) gevent_timer.start(0) task = gevent.spawn(console.repl) sys.exit(app.exec_())
# -*- coding: utf-8 -*- #/usr/bin/python import sys from pyqtconsole.qt.QtWidgets import QApplication from pyqtconsole.console import PythonConsole def greet(): print("hello world") if __name__ == '__main__': app = QApplication([]) console = PythonConsole() console.push_local_ns('greet', greet) console.show() console.eval_in_thread() sys.exit(app.exec_())