Esempio n. 1
0
def main():
    filename = sys.argv[1]

    app = qt.QApplication(sys.argv)
    win = Window(filename)
    win.show()
    app.exec_()
Esempio n. 2
0
def main(args):
    app = qt.QApplication(sys.argv)
    win = testMcceWidget(6)
    app.setMainWidget(win)
    win.show()
    app.connect(app, qt.SIGNAL("lastWindowClosed()"), app, qt.SLOT("quit()"))
    app.exec_loop()
Esempio n. 3
0
def main(application):
    import qt
    from twisted.internet import qtreactor
    app = qt.QApplication([])
    qtreactor.install(app)

    import sys
    from twisted.internet import reactor

    from shtoom.ui.qtui import ShtoomMainWindow
    UI = ShtoomMainWindow()
    UI.connectApplication(application)
    UI.show()

    from shtoom import log
    if application.getPref('stdout'):
        import sys
        log.startLogging(sys.stdout, setStdout=False)
    else:
        log.startLogging(UI.getLogger(), setStdout=False)

    reactor.addSystemEventTrigger('after', 'shutdown', app.quit)
    app.connect(app, qt.SIGNAL("lastWindowClosed()"), reactor.stop)

    return UI
Esempio n. 4
0
def testPreview():
    """
    """
    import sys
    import os.path

    if len(sys.argv) < 2:
        print("give an image file as parameter please.")
        sys.exit(1)

    if len(sys.argv) > 2:
        print("only one parameter please.")
        sys.exit(1)

    filename = sys.argv[1]

    a = qt.QApplication(sys.argv)
 
    p = qt.QPrinter()
    #p.setPrintToFile(1)
    p.setOutputToFile(1)
    p.setOutputFileName(os.path.splitext(filename)[0]+".ps")
    p.setColorMode(qt.QPrinter.Color)

    w = PrintPreview( parent = None, printer = p, name = 'Print Prev',
                      modal = 0, fl = 0)
    w.resize(400,500)

    w.addPixmap(qt.QPixmap(qt.QImage(filename)))
    #w.addImage(qt.QImage(filename))
    w.addImage(qt.QImage(filename))

    w.exec_loop()
Esempio n. 5
0
 def __init__(self, input=None, MinOpacity=0.0, MaxOpacity=0.1):
     import qt
     import vtk
     from vtk.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
     self.__MinOpacity__ = MinOpacity
     self.__MaxOpacity__ = MaxOpacity
     # every QT app needs an app
     self.__app__ = qt.QApplication(['itkviewer'])
     # create the widget
     self.__widget__ = QVTKRenderWindowInteractor()
     self.__ren__ = vtk.vtkRenderer()
     self.__widget__.GetRenderWindow().AddRenderer(self.__ren__)
     self.__itkvtkConverter__ = None
     self.__volumeMapper__ = vtk.vtkVolumeTextureMapper2D()
     self.__volume__ = vtk.vtkVolume()
     self.__volumeProperty__ = vtk.vtkVolumeProperty()
     self.__volume__.SetMapper(self.__volumeMapper__)
     self.__volume__.SetProperty(self.__volumeProperty__)
     self.__ren__.AddVolume(self.__volume__)
     self.__outline__ = None
     self.__outlineMapper__ = None
     self.__outlineActor__ = None
     self.AdaptColorAndOpacity(0, 255)
     if input:
         self.SetInput(input)
         self.AdaptColorAndOpacity()
Esempio n. 6
0
def QVTKRenderWidgetConeExample():
    """A simple example that uses the QVTKRenderWindowInteractor
    class.  """

    # every QT app needs an app
    app = qt.QApplication(['QVTKRenderWindowInteractor'])

    # create the widget
    widget = QVTKRenderWindowInteractor()
    widget.Initialize()
    widget.Start()
    # if you dont want the 'q' key to exit comment this.
    widget.AddObserver("ExitEvent", lambda o, e, a=app: a.quit())

    ren = vtk.vtkRenderer()
    widget.GetRenderWindow().AddRenderer(ren)

    cone = vtk.vtkConeSource()
    cone.SetResolution(8)

    coneMapper = vtk.vtkPolyDataMapper()
    coneMapper.SetInput(cone.GetOutput())

    coneActor = vtk.vtkActor()
    coneActor.SetMapper(coneMapper)

    ren.AddActor(coneActor)

    # show the widget
    widget.show()
    # close the application when window is closed
    app.setMainWidget(widget)
    # start event processing
    app.exec_loop()
Esempio n. 7
0
 def test_doc_urls(self):
     _ = qt.QApplication([])
     w = qt.QWidget()
     self.assertEqual(
         docscraper.doc_urls(w),
         ['https://doc.qt.io/qtforpython/PySide2/QtWidgets/QWidget.html',
          'https://doc.qt.io/qtforpython/PySide2/QtCore/QObject.html',
          'https://doc.qt.io/qtforpython/PySide2/QtGui/QPaintDevice.html'])
Esempio n. 8
0
def main(args):
    app = Qt.QApplication(args)
    fonts = Qt.QFontDatabase()
    if Qt.QString('Verdana') in fonts.families():
        app.setFont(Qt.QFont('Verdana'))
    demo = make()
    app.setMainWidget(demo)
    sys.exit(app.exec_loop())
Esempio n. 9
0
def _create_qApp():
    """
    Only one qApp can exist at a time, so check before creating one
    """
    if qt.QApplication.startingUp():
        if DEBUG: print "Starting up QApplication"
        global qApp
        qApp = qt.QApplication( [" "] )
        qt.QObject.connect( qApp, qt.SIGNAL( "lastWindowClosed()" ),
                            qApp, qt.SLOT( "quit()" ) )
Esempio n. 10
0
def _create_qApp():
    """
    Only one qApp can exist at a time, so check before creating one
    """
    if qt.QApplication.startingUp():
        if DEBUG: print "Starting up QApplication"
        global qApp
        qApp = qt.QApplication([" "])
        qt.QObject.connect(qApp, qt.SIGNAL("lastWindowClosed()"), qApp,
                           qt.SLOT("quit()"))
        #remember that matplotlib created the qApp - will be used by show()
        _create_qApp.qAppCreatedHere = True
Esempio n. 11
0
def qMain(wintype, args=None):
    """ qMain(wintype, title, args) -> returns a KDE application and its window

    """
    if args is None:
        args = sys.argv[0:1]

    app = qt.QApplication(args)
    win = wintype()

    app.connect(app, sigLastClosed, app, slotQuit)
    app.setMainWidget(win)
    return (win, app)
Esempio n. 12
0
def globalSetup():
    global QTAPP, VTAPP, VTApp

    # Avoid <QApplication: There should be max one application object> errors:
    # if an instance of QApplication already exists then use a pointer to it
    try:
        qt.qApp.argv()
        QTAPP = qt.qApp
    except RuntimeError:
        QTAPP = qt.QApplication(sys.argv)
    from vitables.vtapp import VTApp
    VTAPP = VTApp(keep_splash=False)
    QTAPP.setMainWidget(VTAPP.gui)
def main(args):
    app = qt.QApplication(args)
    demo = make()
    app.setMainWidget(demo)
    zoomer = Qwt.QwtPlotZoomer(Qwt.QwtPlot.xBottom, Qwt.QwtPlot.yLeft,
                               Qwt.QwtPicker.DragSelection,
                               Qwt.QwtPicker.AlwaysOff, demo.canvas())
    zoomer.setRubberBandPen(qt.QPen(qt.Qt.green))
    picker = Qwt.QwtPlotPicker(Qwt.QwtPlot.xBottom, Qwt.QwtPlot.yLeft,
                               Qwt.QwtPicker.NoSelection,
                               Qwt.QwtPlotPicker.CrossRubberBand,
                               Qwt.QwtPicker.AlwaysOn, demo.canvas())
    picker.setTrackerPen(qt.QPen(qt.Qt.red))
    sys.exit(app.exec_loop())
Esempio n. 14
0
    def __init__(self):
        self._original_excepthook = sys.excepthook
                                             
        self.qapp = qt.QApplication([])
        self._configuration = CONF                                 
    
                                               
        self._shell_envs = dict()
    
                              
        self._security_manager = SecurityManager()
    
                                        
        self._model_controller = model.controller.ModelController(security_manager = self._security_manager)
        
                                      
                                                         
        self.plugin_manager = PluginManager(os.path.join(CONF.getConfigPath(),"plugins"))
        
        self._workspace_manager = WorkspaceManager(self._model_controller,
                                                   self.plugin_manager.createController("ReportManager"))

        model.guiapi.setMainApp(self)

                                       
        self._main_window = MainWindow(CONF.getAppname(), self, self._model_controller)
        self.qapp.setMainWidget(self._main_window)
    
                                        
                                                                    
        self._splash_screen = qt.QSplashScreen(qt.QPixmap(os.path.join(CONF.getImagePath(),"splash2.png")),
                                               qt.Qt.WStyle_StaysOnTop)
    
                                                                                   
        if not self.getLogger().isGUIOutputRegistered():
                                                 
            self.logger.registerGUIOutput(self._main_window.getLogConsole())
    
                             
        notifier = model.log.getNotifier()
        notifier.widget = self._main_window
    
                                                             
                                
                 
        model.guiapi.setMainApp(self)
Esempio n. 15
0
    def mainloop(self, sys_exit=0, banner=None):

        import qt

        self._banner = banner

        if qt.QApplication.startingUp():
            a = qt.QApplication(sys.argv)

        self.timer = qt.QTimer()
        qt.QObject.connect(self.timer, qt.SIGNAL('timeout()'), self.on_timer)

        self.start()
        self.timer.start(self.TIMEOUT, True)
        while True:
            if self.IP._kill: break
            self.exec_loop()
        self.join()
Esempio n. 16
0
#!/usr/bin/env python
import cPickle
import sys
import os
import pprint
import qt
MXCUBE_ROOT = os.path.abspath(
    os.path.join(os.path.dirname(os.path.realpath(__file__)), ".."))
sys.path.insert(0, MXCUBE_ROOT)
app = qt.QApplication([])

from BlissFramework.Utils import PropertyBag
#from BlissFramework import Configuration

if __name__ == '__main__':
    if len(sys.argv) > 2:
        try:
            cfg = open(sys.argv[2], 'r')
            gui = open(sys.argv[1], 'r')
        except Exception, e:
            print 'Could not open file', e
    else:
        print 'Usage: %s <.gui file> <cfg file> > new .gui file' % sys.argv[0]

    gui_config = eval(gui.read())
    #config_obj = Configuration.Configuration()
    #config_obj.load(gui_config)
    cfg = eval(cfg.read())

    def find(item_name, config=gui_config):
        for x in config:
Esempio n. 17
0
if not options.source:
    print "no source specified"
    sys.exit(1)

poldek.lib_init()

ctx = poldek.poldek_ctx()
#poldek_set_verbose(1)
src = poldek.source(options.source)
ctx.configure(ctx.CONF_SOURCE, src)
ctx.load_config()
if not ctx.setup():
    print "poldek setup failed"
    sys.exit(1)

print "Loading packages..."
arr = ctx.get_avail_packages()
print "Loaded %d packages" % len(arr)
if len(arr) == 0:
    sys.exit(0)

a = qt.QApplication(sys.argv)

w = MainWindow()
w.setGeometry(100, 100, 900, 700)
a.setMainWidget(w)

w.fillPackageList(arr)
w.show()
sys.exit(a.exec_loop())
Esempio n. 18
0
def checkMandatoryModules():
    try:
        from PyQt4 import QtGui, QtCore

        if os.name == "nt":
            pywin32IsAvailable = False
            try:
                import win32api, win32con, win32com

                pywin32IsAvailable = True
            except:
                pass
            if pywin32IsAvailable is False:
                app = QtGui.QApplication(sys.argv)
                w = QtGui.QWidget()
                l = QtGui.QVBoxLayout(w)
                pbtn = QtGui.QPushButton('Quit', w)
                pbtn.clicked.connect(QtCore.QCoreApplication.instance().quit)
                lblAlert = QtGui.QLabel(
                    "<br><b><a href='https://sourceforge.net/projects/pywin32/'>'Python for Windows Extensions'</a> (pywin32) named module has NOT installed on your system.</b><br><br>You have to install it on your system to run Hamsi Manager.<br><br>",
                    w)
                lblAlert.setOpenExternalLinks(True)
                l.addWidget(lblAlert)
                l.addWidget(pbtn)
                w.setLayout(l)
                w.setWindowTitle('Critical Error!')
                w.show()
                w.setMinimumWidth(400)
                sys.exit(app.exec_())
        return True
    except:
        try:
            import qt

            qtHamsiManagerApp = qt.QApplication(sys.argv)
            panel = qt.QWidget()
            panel.vblMain = qt.QVBoxLayout(panel)
            lblInfo = qt.QLabel(
                "<br><b>PyQt4 is not installed:</b><br>You have to install \"PyQt4\" on your system to run Hamsi Manager.",
                panel)
            pbtnClose = qt.QPushButton("OK", panel)
            panel.connect(pbtnClose, qt.SIGNAL("clicked()"),
                          qtHamsiManagerApp.quit)
            hbox0 = qt.QHBoxLayout()
            hbox0.addStretch(2)
            hbox0.addWidget(pbtnClose, 1)
            vbox0 = qt.QVBoxLayout()
            vbox0.addWidget(lblInfo)
            vbox0.addLayout(hbox0)
            hbox1 = qt.QHBoxLayout()
            hbox1.addStretch(20)
            hbox1.addLayout(vbox0, 500)
            hbox1.addStretch(5)
            panel.vblMain.addLayout(hbox1)
            panel.setCaption("Critical Error!")
            panel.show()
            panel.setMinimumWidth(400)
            qtHamsiManagerApp.enter_loop()
        except:
            try:
                import gtk

                def destroy(widget, data=None):
                    gtk.main_quit()

                window = gtk.Window(gtk.WINDOW_TOPLEVEL)
                window.connect("destroy", destroy)
                window.set_title("Critical Error!")
                button = gtk.Button("OK")
                label = gtk.Label("PyQt4 is not installed.")
                label2 = gtk.Label(
                    "You have to install \"PyQt4\" on your system to run Hamsi Manager."
                )
                label2.set_line_wrap(True)
                button.connect("clicked", gtk.main_quit, None)
                vbox = gtk.VBox(False, 5)
                hbox = gtk.HBox(window)
                window.add(hbox)
                hbox.pack_start(vbox, False, False, 0)
                window.set_border_width(5)
                hbox0 = gtk.HBox(False)
                hbox0.pack_start(label, 0, 0, 0)
                hbox1 = gtk.HBox(False)
                label3 = gtk.Label("")
                hbox1.pack_start(label3, 0, 0, 0)
                hbox1.pack_start(button, 0, 0, 0)
                vbox.pack_start(hbox0, False, False, 0)
                vbox.pack_start(label2, False, False, 0)
                vbox.pack_start(hbox1, False, False, 0)
                layout = gtk.Layout(None, None)
                button.set_size_request(120, 25)
                label2.set_size_request(350, 35)
                label3.set_size_request(230, 25)
                window.show_all()
                gtk.main()
            except:
                try:
                    import Tkinter

                    tMainWindow = Tkinter.Tk()
                    tMainWindow.geometry("350x100")
                    tMainWindow.title("Critical Error!")
                    lbl1 = Tkinter.Label(text="PyQt4 is not installed.")
                    lbl1.pack()
                    lbl2 = Tkinter.Label(text="You have to install \"PyQt4\"")
                    lbl2.pack()
                    lbl3 = Tkinter.Label(
                        text="on your system to run HamsiManager.")
                    lbl3.pack()
                    btnClose = Tkinter.Button(text="OK",
                                              command=tMainWindow.quit)
                    btnClose.pack(side=Tkinter.RIGHT)
                    Tkinter.mainloop()
                except:
                    print("Critical Error!")
                    print(
                        "You have to install \"PyQt4\" on your system to run Hamsi Manager."
                    )
        return False
Esempio n. 19
0
def main(args):
    app = qt.QApplication(args)
    demo = make()
    app.setMainWidget(demo)
    sys.exit(app.exec_loop())
Esempio n. 20
0
        self.master = master
        self.code = code
        if code:
            self.start_construction()
            exec code
            self.end_construction()

    def settitle(self, title):
        self.win.setCaption(title)

    def close(self):
        self.win.done(1)

main_running = False


def exec_loop():
    global main_running
    if not main_running:
        main_running = True
        QAP.exec_loop()
        main_running = False


def terminate():
    global main_running
    main_running = False


QAP = qt.QApplication([])
Esempio n. 21
0
def error_msg_qt( msg, parent=None ):
    if not is_string_like( msg ):
        msg = ','.join( map( str,msg ) )
                         
    qt.QMessageBox.warning( None, "Matplotlib", msg, qt.QMessageBox.Ok )

def exception_handler( type, value, tb ):
    """Handle uncaught exceptions
    It does not catch SystemExit
    """
    msg = ''
    # get the filename attribute if available (for IOError)
    if hasattr(value, 'filename') and value.filename != None:
        msg = value.filename + ': '
    if hasattr(value, 'strerror') and value.strerror != None:
        msg += value.strerror
    else:
        msg += str(value)

    if len( msg ) : error_msg_qt( msg )


FigureManager = FigureManagerQT

# We need one and only one QApplication before we can build any Qt widgets
# Detect if a QApplication exists.
createQApp = qt.QApplication.startingUp()
if createQApp:
    if DEBUG: print "Starting up QApplication"
    qtapplication = qt.QApplication( [" "] )