Exemplo n.º 1
0
    def __addBasicActions(self):
        """
        basic action 
        """
        self.regAction("gotohome",\
            QAction(QIcon(getPath("iconDir",'home.png')),QApplication.translate("default", "MainTab"),self,triggered=self.__evt_home))
        self.regAction("close",\
            QAction(QIcon(getPath("iconDir",'close.png')),QApplication.translate("default", "Close"),self,triggered=self.__evt_close_tab))
        self.regAction("perferences",\
            QAction(QIcon(getPath("iconDir",'settings.png')),QApplication.translate("default", "Preferences..."),self,triggered=self.__evt_preferences))
        self.regAction("plguinInfos", \
            QAction(QApplication.translate("default","Plugin Infos..."),self,triggered=lambda : PluginInfoDialog(self).show()))
        self.regAction("plguinRequest", \
            QAction(QApplication.translate("default","Available plugins..."),self,triggered=lambda : PluginRequestDialog(self).show()))

        self.getAction("gotohome").setShortcut(Prefs.new().getShortcut(
            "gotohome", "Ctrl+H"))
        self.getAction("close").setShortcut(Prefs.new().getShortcut(
            "close", "Ctrl+W"))
        self.getAction("perferences").setShortcut(Prefs.new().getShortcut(
            "perferences", ""))
        self.getAction("plguinInfos").setShortcut(Prefs.new().getShortcut(
            "plguinInfos", ""))
        self.getAction("plguinRequest").setShortcut(Prefs.new().getShortcut(
            "plguinRequest", ""))
Exemplo n.º 2
0
class TestIconLoader(unittest.TestCase):
    def setUp(self):
        from PyQt5.QtGui import QApplication
        self.app = QApplication([])

    def tearDown(self):
        self.app.exit()
        del self.app

    def test_loader(self):
        loader = icon_loader()
        self.assertEqual(loader.search_paths(), DEFAULT_SEARCH_PATHS)
        icon = loader.get("icons/CanvasIcon.png")
        self.assertTrue(not icon.isNull())

        path = loader.find(":icons/CanvasIcon.png")
        self.assertTrue(os.path.isfile(path))
        icon = loader.get(":icons/CanvasIcon.png")
        self.assertTrue(not icon.isNull())

    def test_from_desc(self):
        from .registry.description import (
            WidgetDescription, CategoryDescription
        )

        desc = WidgetDescription.from_module(
            "Orange.OrangeWidgets.Data.OWFile"
        )

        loader = icon_loader.from_description(desc)
        path = loader.find(desc.icon)
        self.assertTrue(os.path.isfile(path))
        icon = loader.get(desc.icon)
        self.assertTrue(not icon.isNull())

        desc = CategoryDescription.from_package("Orange.OrangeWidgets.Data")
        loader = icon_loader.from_description(desc)
        path = loader.find("icons/file.svg")
        self.assertTrue(os.path.isfile(path))
        icon = loader.get("icons/file.svg")
        self.assertTrue(not icon.isNull())

    def test_package_reflection(self):
        from Orange.OrangeWidgets.Data import OWFile
        from Orange.OrangeWidgets import Data
        package_name = Data.__name__
        p1 = package("Orange.OrangeWidgets.Data.OWFile.OWFile")
        self.assertEqual(p1, package_name)

        p2 = package("Orange.OrangeWidgets.Data.OWFile")
        self.assertEqual(p2, package_name)

        p3 = package("Orange.OrangeWidgets.Data")
        self.assertEqual(p3, package_name)

        p4 = package(OWFile.__name__)
        self.assertEqual(p4, package_name)

        dirname = package_dirname(package_name)
        self.assertEqual(dirname, os.path.dirname(Data.__file__))
Exemplo n.º 3
0
    def __init__(self,parent = None):
        """
        Constructor
        """
        QDialog.__init__(self,parent)
        self.setupUi(self)


        #center this window 
        screen = QDesktopWidget().screenGeometry()
        size = self.geometry()
        self.move((screen.width()-size.width())/2, (screen.height()-size.height())/2)
        
        self.baseConfigItem={
                    "applicationPage":[QApplication.translate("ApplicationPage","Application"),getPath("iconDir","preferences-application.png"),"sklib.ui.cpages.applicationPage",None],
                    "shortcutsPage":[QApplication.translate("ShortcutsPage","Shortcuts"),getPath("iconDir","preferences-shortcuts.png"),"sklib.ui.cpages.shortcutsPage","applicationPage"],
                    }
        #read from plugins 
        for plugin in PluginAdapter().new().getPlugins():
            if hasattr(plugin,"getConfigPages"):
                ptems = plugin.getConfigPages()
                for pkey in ptems.keys():
                    if not self.baseConfigItem.__contains__(pkey):
                        self.baseConfigItem[pkey]=ptems[pkey]
        #end plugin parse
        self.itmDict = {}
        self.setupTreeList()
        self.btn.button(QDialogButtonBox.Apply).setEnabled(False)
        QObject.connect(self.configItemList, SIGNAL("itemClicked (QTreeWidgetItem *,int)"),self.evt_click)
        QObject.connect(self.btn, SIGNAL("clicked (QAbstractButton *)"),self.evt_btn_click)
Exemplo n.º 4
0
    def setUp(self):
        import logging

        from PyQt5.QtGui import QApplication, QGraphicsScene, QGraphicsView, \
                                QPainter

        from PyQt5.QtCore import QTimer

        logging.basicConfig()

        self.app = QApplication([])
        self.scene = QGraphicsScene()
        self.view = QGraphicsView(self.scene)
        self.view.setRenderHints(
            QPainter.Antialiasing | \
            QPainter.SmoothPixmapTransform | \
            QPainter.TextAntialiasing
            )
        self.view.resize(500, 300)
        self.view.show()
        QTimer.singleShot(10000, self.app.exit)

        def my_excepthook(etype, value, tb):
            sys.setrecursionlimit(1010)
            traceback.print_exception(etype, value, tb)

        self._orig_excepthook = sys.excepthook
        sys.excepthook = my_excepthook
        self.singleShot = QTimer.singleShot
Exemplo n.º 5
0
class Client(QWebPage):
    def __init__(self, url):
        self.app = QApplication(sys.argv)
        QWebPage.__init__(self)
        self.loadFinished.load(QUrl(url))
        self.app.exec_()

    def on_page_load(self):
        self.app.quit()
Exemplo n.º 6
0
    def update_record_progress_bar(self):
        global ser_reader_thread, recording, values_to_record, record_start_time

        rate = ser_reader_thread.sps
        while recording:
            self.progress.setValue(100 / (values_to_record / rate) * (time.time() - record_start_time)) # map recorded/to_record => 0% - 100%
            QApplication.processEvents() 
            time.sleep(0.01)
        self.progress.setValue(0)
Exemplo n.º 7
0
 def showMessage(self, msg):
     """
     Public method to show a message in the bottom part of the splashscreen.
     
     @param msg message to be shown (string or QString)
     """
     QSplashScreen.showMessage(self, msg, self.labelAlignment,
                               QColor(Qt.black))
     QApplication.processEvents()
Exemplo n.º 8
0
 def __init__(self):
     """
     Constructor
     """
     seeking = QPixmap(getPath('iconDir', 'splash.png'))
     self.labelAlignment = \
         Qt.Alignment(Qt.AlignBottom | Qt.AlignRight | Qt.AlignAbsolute)
     QSplashScreen.__init__(self, seeking)
     self.show()
     QApplication.flush()
Exemplo n.º 9
0
 def preview_theme(self):
     if self.list_skins.currentRow() == 0:
         qss_file = resources.NINJA_THEME
     else:
         file_name = ("%s.qss" % self.list_skins.currentItem().text())
         qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD,
                                             file_name)
     with open(qss_file) as f:
         qss = f.read()
     QApplication.instance().setStyleSheet(qss)
Exemplo n.º 10
0
 def __evt_contextmenu(self,point):
     """
     show the right menu
     """
     item = self.pluginList.currentItem()
     if item:
         menu = QMenu(self)
         action = QAction(QApplication.translate("default","Install plugins..."),self,triggered=lambda:self.__evt_install_plugin(item))
         menu.addAction(action)
         action = QAction(QApplication.translate("default","Uninstall plugins..."),self)
         menu.addAction(action)
         menu.exec_(self.mapToGlobal(self.pluginList.mapTo(self,point)))
Exemplo n.º 11
0
 def __init__(self):
     """
     (1) Add a tabWidget
     (2) Setup the main Window
     (3) Some basic event slot
     (4) read datas(menus , actions) 
     """
     QMainWindow.__init__(self)
     
     # attrs 
     # Notice: These attributes can not be put outside init method 
     
     self.__actions = {}
     self.__menus = {}
     self.__globalActionGroup = QActionGroup(self)
     
     #the main widget(Tab) that show all things 
     self.tabs = MainTabWidget(self)
     self.setCentralWidget(self.tabs)
     
     view = SKMainTabShow(self,self.tabs)
     self.tabs.addTab(view,QIcon(getPath("iconDir",'main.png')),QApplication.translate("default", "MainTab"))
     
     QObject.connect(self, SIGNAL("updateWindows()"),self.__updateWindows)
     
     self.__addBasicMenus()
     self.__addBasicActions()
Exemplo n.º 12
0
    def test_devel_vein_basin_segmentation(self):
        pth = r"E:\data\medical\processed\mik2018 para\P09_paraall_cropped.pklz"
        datap = io3d.read(pth)
        labels = {
            "1": 1,
            "2": 2,
            "3": 3,
            "4": 4,
            "5": 5,
            "6": 6,
        }
        from PyQt5.QtGui import QApplication, QPushButton
        app = QApplication(sys.argv)
        import seededitorqt


        se = seededitorqt.QTSeedEditor(datap["data3d"], contours=datap["segmentation"])

        def split(obj):
            import lisa.virtual_resection as vr


            print(np.max(datap["data3d"]))
            print(np.unique(se.seeds))
            out, sepobj = vr.split_vessel(datap, se.seeds, method="separate labels", input_seeds_label2=2)
            print(np.unique(out))
            se.seeds = out
            se.contours = out
            se.setView(se.actual_view)
        qpb = QPushButton("Ahoj")
        qpb.clicked.connect(split)
        wg = se.my_layout.layout().itemAt(0).itemAt(2).addWidget(qpb)

        se.exec_()
Exemplo n.º 13
0
    def configUI(self):
        screen_size = QApplication.primaryScreen().size()
        self.setWindowTitle("CSIRatioA")
        self.setWindowFlags(Qt.WindowCloseButtonHint
                            | Qt.WindowMinimizeButtonHint
                            | Qt.WindowMaximizeButtonHint)
        self.resize(800, 450)
        self.move(screen_size.width() - 800 - 100, 100)

        # pygtgrapg global config
        pg.setConfigOptions(antialias=True)  # Antialiasing
        pg.setConfigOptions(foreground=(232, 232, 232))  # Black
        pg.setConfigOptions(background=(25, 25, 25))  # White

        # plot area
        self.win = pg.GraphicsWindow()

        # plot init
        self.initPlot()

        # update cache
        self.task = GetDataThread(self)
        self.task.start()

        # plot refresh
        self.PlotTimer()
Exemplo n.º 14
0
    def __init__(self,dlg):
        """
        Constructor
        """
        QWidget.__init__(self)
        self.setupUi(self)


        #center this window 
        screen = QDesktopWidget().screenGeometry()
        size = self.geometry()
        self.move((screen.width()-size.width())/2, (screen.height()-size.height())/2)
        self.shortcutsList.header().setResizeMode(0,QHeaderView.ResizeToContents)


        self.dlg = dlg
        
        self.shortcutDialog = ShortcutDialog()
        
        self.__setupActions(QApplication.translate("default","Global"),Seeking.new().getActions())
        self.__setupPlugins()
        
        QObject.connect(self.shortcutsList,\
                SIGNAL("itemDoubleClicked (QTreeWidgetItem *,int)"),\
                self.__evt_dbclick)
        QObject.connect(self.shortcutsList, SIGNAL("itemChanged (QTreeWidgetItem *,int)"),self.__has_change)
        QObject.connect(self.searchEdit,SIGNAL("textChanged (const QString&)"),self.__search)
        QObject.connect(self.shortcutDialog,SIGNAL("shortcutChanged"),self.__shortcut)
Exemplo n.º 15
0
    def __init__(self, dlg):
        """
        Constructor
        """
        QWidget.__init__(self)
        self.setupUi(self)

        #center this window
        screen = QDesktopWidget().screenGeometry()
        size = self.geometry()
        self.move((screen.width() - size.width()) / 2,
                  (screen.height() - size.height()) / 2)
        self.shortcutsList.header().setResizeMode(0,
                                                  QHeaderView.ResizeToContents)

        self.dlg = dlg

        self.shortcutDialog = ShortcutDialog()

        self.__setupActions(QApplication.translate("default", "Global"),
                            Seeking.new().getActions())
        self.__setupPlugins()

        QObject.connect(self.shortcutsList,\
                SIGNAL("itemDoubleClicked (QTreeWidgetItem *,int)"),\
                self.__evt_dbclick)
        QObject.connect(self.shortcutsList,
                        SIGNAL("itemChanged (QTreeWidgetItem *,int)"),
                        self.__has_change)
        QObject.connect(self.searchEdit,
                        SIGNAL("textChanged (const QString&)"), self.__search)
        QObject.connect(self.shortcutDialog, SIGNAL("shortcutChanged"),
                        self.__shortcut)
Exemplo n.º 16
0
def main():
    parser = OptionParser(description='Simple VTK Viewer')
    parser.add_option('-f',
                      '--filename',
                      action='store',
                      dest='in_filename',
                      default=None,
                      help=help['in_file'])
    (options, args) = parser.parse_args()

    if options.in_filename is None:
        raise IOError('No VTK data!')

    app = QApplication(sys.argv)
    viewer = QVTKViewer(options.in_filename)
    sys.exit(app.exec_())
Exemplo n.º 17
0
 def __init__(self, coding):
     """
     Constructor
     """
     ERR = QApplication.translate(
         "CodingError", "The coding '%1' is wrong for the given text.")
     self.errorMessage = ERR.arg(coding)
    def initialise_window(self):
        self.load_picture()
        self.app = QApplication([])
        self.win = MyQtWidget()

        #####################################
        ## Layout
        #####################################
        self.layout = QGridLayout()
        self.win.setLayout(self.layout)

        self.createRecordGroupBox()
        self.createDefaultGroupBox()
        self.createImageGroupBox()
        self.createSwitchFormGroupBox()
        self.createCalibrationFormGroupBox()
        self.createParamGroupBox()
        self.createPumpGroupBox()
        self.createTextGroupBox()
        self.resetPath()

        self.layout.addWidget(self.imageForm, 0, 0, 1, 3)

        self.layout.addWidget(self.textForm, 0, 4, 1, 3)

        self.layout.addWidget(self.paramForm, 2, 0, 1, 1)
        self.layout.addWidget(self.calibrationForm, 2, 1, 1, 1)
        self.layout.addWidget(self.pumpForm, 2, 2, 1, 1)

        self.layout.addWidget(self.switchForm, 3, 1, 1, 1)
        self.layout.addWidget(self.defaultForm, 3, 2, 1, 1)
        self.layout.addWidget(self.recordForm, 3, 0, 1, 1)

        self.win.show()
        return self.win
Exemplo n.º 19
0
    def __init__(self):
        """
        (1) Add a tabWidget
        (2) Setup the main Window
        (3) Some basic event slot
        (4) read datas(menus , actions) 
        """
        QMainWindow.__init__(self)

        # attrs
        # Notice: These attributes can not be put outside init method

        self.__actions = {}
        self.__menus = {}
        self.__globalActionGroup = QActionGroup(self)

        #the main widget(Tab) that show all things
        self.tabs = MainTabWidget(self)
        self.setCentralWidget(self.tabs)

        view = SKMainTabShow(self, self.tabs)
        self.tabs.addTab(view, QIcon(getPath("iconDir", 'main.png')),
                         QApplication.translate("default", "MainTab"))

        QObject.connect(self, SIGNAL("updateWindows()"), self.__updateWindows)

        self.__addBasicMenus()
        self.__addBasicActions()
Exemplo n.º 20
0
def main():

	#print sys.argv+["-cmd", "-gnome-terminal"]
	nargv = sys.argv

	# instanciation des objets principaux
	app = QApplication(nargv)
	myapp = EBimage(app)

	myapp.showMinimized()
	# les .app sous macos nécessitent cela pour que l'appli s'affiche en FG
	if "darwin" in sys.platform and ".app/" in sys.argv[0]:
		myapp.raise_()

	# lancement de la boucle Qt
	sys.exit(app.exec_())
Exemplo n.º 21
0
def main():

    #print sys.argv+["-cmd", "-gnome-terminal"]
    nargv = sys.argv

    # instanciation des objets principaux
    app = QApplication(nargv)
    myapp = EBimage(app)

    myapp.showMinimized()
    # les .app sous macos nécessitent cela pour que l'appli s'affiche en FG
    if "darwin" in sys.platform and ".app/" in sys.argv[0]:
        myapp.raise_()

    # lancement de la boucle Qt
    sys.exit(app.exec_())
Exemplo n.º 22
0
class QAppTestCase(unittest.TestCase):
    def setUp(self):
        self.app = QApplication([])
        QTimer.singleShot(20000, self.app.exit)

    def tearDown(self):
        if hasattr(self, "scene"):
            self.scene.clear()
            self.scene.deleteLater()
            self.app.processEvents()
            del self.scene
        self.app.processEvents()
        del self.app
        gc.collect()

    def singleShot(self, *args):
        QTimer.singleShot(*args)
Exemplo n.º 23
0
 def __evt_contextmenu(self, point):
     """
     show the right menu
     """
     item = self.pluginList.currentItem()
     if item:
         menu = QMenu(self)
         action = QAction(QApplication.translate("default",
                                                 "Install plugins..."),
                          self,
                          triggered=lambda: self.__evt_install_plugin(item))
         menu.addAction(action)
         action = QAction(
             QApplication.translate("default", "Uninstall plugins..."),
             self)
         menu.addAction(action)
         menu.exec_(self.mapToGlobal(self.pluginList.mapTo(self, point)))
Exemplo n.º 24
0
    def loadDcmDir(self, event=None, filename=None):
        self.statusBar().showMessage('Loading DICOM data...')
        QApplication.processEvents()


        # TODO uninteractive Serie selection



        #self.data3d, self.metadata = dcmr.dcm_read_from_dir(datadir)
        datadir = dcmr.get_dcmdir_qt(self.qt_app)

        # @TODO dialog v qt
        reader = dcmr.DicomReader(datadir)#, qt_app=self.qt_app)
        self.data3d = reader.get_3Ddata()
        self.metadata = reader.get_metaData()
        self.inps['series_number'] = reader.series_number
        self.inps['datadir'] = datadir

        self.statusBar().showMessage('DICOM data loaded')
Exemplo n.º 25
0
 def __addBasicActions(self):
     """
     basic action 
     """
     self.regAction("gotohome",\
         QAction(QIcon(getPath("iconDir",'home.png')),QApplication.translate("default", "MainTab"),self,triggered=self.__evt_home))
     self.regAction("close",\
         QAction(QIcon(getPath("iconDir",'close.png')),QApplication.translate("default", "Close"),self,triggered=self.__evt_close_tab))
     self.regAction("perferences",\
         QAction(QIcon(getPath("iconDir",'settings.png')),QApplication.translate("default", "Preferences..."),self,triggered=self.__evt_preferences))
     self.regAction("plguinInfos", \
         QAction(QApplication.translate("default","Plugin Infos..."),self,triggered=lambda : PluginInfoDialog(self).show()))
     self.regAction("plguinRequest", \
         QAction(QApplication.translate("default","Available plugins..."),self,triggered=lambda : PluginRequestDialog(self).show()))
     
     self.getAction("gotohome").setShortcut(Prefs.new().getShortcut("gotohome","Ctrl+H"))
     self.getAction("close").setShortcut(Prefs.new().getShortcut("close","Ctrl+W"))
     self.getAction("perferences").setShortcut(Prefs.new().getShortcut("perferences",""))
     self.getAction("plguinInfos").setShortcut(Prefs.new().getShortcut("plguinInfos",""))
     self.getAction("plguinRequest").setShortcut(Prefs.new().getShortcut("plguinRequest",""))
Exemplo n.º 26
0
 def __evt_contextmenu(self,point):
     """
     show the right menu
     """
     item = self.pluginList.currentItem()
     if item:
         menu = QMenu(self)
        
         
         if item.text(4)=="True":
             
             action = QAction(QApplication.translate("PluginInfoDialog", "DeActive"),self,\
                              triggered=lambda re,name=item.text(0):self.__evt_toggle_active(name, False))
             #core plugin not allowed disabled
             action.setEnabled(not PluginAdapter.new().getPluginByName(item.text(0)).packageName == "__core__")
         else:
             action = QAction(QApplication.translate("PluginInfoDialog", "Active"),self,\
                              triggered=lambda re,name=item.text(0):self.__evt_toggle_active(name, True))
             
         menu.addAction(action)
         menu.exec_(self.mapToGlobal(self.pluginList.mapTo(self,point)))
Exemplo n.º 27
0
    def __evt_contextmenu(self, point):
        """
        show the right menu
        """
        item = self.pluginList.currentItem()
        if item:
            menu = QMenu(self)

            if item.text(4) == "True":

                action = QAction(QApplication.translate("PluginInfoDialog", "DeActive"),self,\
                                 triggered=lambda re,name=item.text(0):self.__evt_toggle_active(name, False))
                #core plugin not allowed disabled
                action.setEnabled(not PluginAdapter.new().getPluginByName(
                    item.text(0)).packageName == "__core__")
            else:
                action = QAction(QApplication.translate("PluginInfoDialog", "Active"),self,\
                                 triggered=lambda re,name=item.text(0):self.__evt_toggle_active(name, True))

            menu.addAction(action)
            menu.exec_(self.mapToGlobal(self.pluginList.mapTo(self, point)))
Exemplo n.º 28
0
    def saveDcm(self, event=None, filename=None):
        if self.dcm_3Ddata is not None:
            self.statusBar().showMessage('Saving DICOM data...')
            QApplication.processEvents()

            if filename is None:
                filename = str(QFileDialog.getSaveFileName(self, 'Save DCM file',
                                                           filter='Files (*.dcm)'))[0]
            if len(filename) > 0:
                savemat(filename, {'data': self.dcm_3Ddata,
                                   'voxelsize_mm': self.voxel_size_mm,
                                   'offsetmm': self.dcm_offsetmm},
                                   appendmat=False)

                self.setLabelText(self.text_dcm_out, filename)
                self.statusBar().showMessage('Ready')

            else:
                self.statusBar().showMessage('No output file specified!')

        else:
            self.statusBar().showMessage('No DICOM data!')
Exemplo n.º 29
0
def to(text):
    try:
        from PyQt5.QtGui import QGuiApplication as QApplication

    except ImportError:
        try:
            from PyQt4.QtGui import QApplication

        except ImportError:
            from PySide.QtGui import QApplication

    app = QApplication([])
    app.clipboard().setText(text)
    app = None
Exemplo n.º 30
0
def cmd():
    #print sys.argv+["-cmd", "-gnome-terminal"]
    nargv = sys.argv
    # instanciation des objets principaux
    app = QApplication(nargv)
    myapp = EBimage(app)

    # Load info arguments to Class
    # matrice file
    myapp.matricePathFile = relativeToAbsolutePath(args.matriceParam)
    # order file
    myapp.orderPathFile = relativeToAbsolutePath(args.orderMatriceParam)
    # PCA value
    myapp.PCAvalue = args.pcaParam
    # DA value
    myapp.DAvalue = args.daParam
    # pop min value
    myapp.popMinValue = args.nbpopiParam
    # pop max value
    myapp.popMaxValue = args.nbpopmParam
    # pgraph value
    myapp.graphType = args.graphParam

    # working dir path
    workingDir = "/".join(
        relativeToAbsolutePath(
            args.orderMatriceParam).encode("utf-8").split("/")[:-1]) + "/"
    myapp.workingDir = workingDir.encode("utf-8")
    # basename
    basename = relativeToAbsolutePath(
        args.orderMatriceParam).encode("utf-8").split("/")[-1].split(".")[0]
    myapp.basename = basename.encode("utf-8")
    # pathFileOut dir path
    pathFileOut = workingDir + basename + "/"
    myapp.pathFileOut = pathFileOut.encode("utf-8")

    # rm old folder
    myapp.rmOld = args.rmOldParam

    # Run programme
    myapp.run()
Exemplo n.º 31
0
def getPercentReplacementHelp():
    """
    Function to get the help text for the supported %-codes.
    
    @returns help text (QString)
    """
    return QApplication.translate(
        "Utilities",
        """<p>You may use %-codes as placeholders in the string."""
        """ Supported codes are:"""
        """<table>"""
        """<tr><td>%C</td><td>column of the cursor of the current editor</td></tr>"""
        """<tr><td>%D</td><td>directory of the current editor</td></tr>"""
        """<tr><td>%F</td><td>filename of the current editor</td></tr>"""
        """<tr><td>%H</td><td>home directory of the current user</td></tr>"""
        """<tr><td>%L</td><td>line of the cursor of the current editor</td></tr>"""
        """<tr><td>%P</td><td>path of the current project</td></tr>"""
        """<tr><td>%S</td><td>selected text of the current editor</td></tr>"""
        """<tr><td>%U</td><td>username of the current user</td></tr>"""
        """<tr><td>%%</td><td>the percent sign</td></tr>"""
        """</table>"""
        """</p>""")
Exemplo n.º 32
0
 def __addBasicMenus(self):
     """
     basic menus 
     """
     #menu bar that plugins can call
     self.regMenu("file",\
                  self.menuBar().addMenu(QApplication.translate("default", "&File")))
     self.regMenu("edit",\
                  self.menuBar().addMenu(QApplication.translate("default", "Edit")))
     self.regMenu("settings",\
                  self.menuBar().addMenu(QApplication.translate("default", "Settings")))
     self.regMenu("window",\
                  self.menuBar().addMenu(QApplication.translate("default", "Window")))
     self.regMenu("plugins",\
                  self.menuBar().addMenu(QApplication.translate("default", "Plugins")))
     self.regMenu("help",\
                  self.menuBar().addMenu(QApplication.translate("AboutSeeking", "Help")))
Exemplo n.º 33
0
 def __addBasicMenus(self):
     """
     basic menus 
     """
     #menu bar that plugins can call
     self.regMenu("file",\
                  self.menuBar().addMenu(QApplication.translate("default", "&File")))
     self.regMenu("edit",\
                  self.menuBar().addMenu(QApplication.translate("default", "Edit")))
     self.regMenu("settings",\
                  self.menuBar().addMenu(QApplication.translate("default", "Settings")))
     self.regMenu("window",\
                  self.menuBar().addMenu(QApplication.translate("default", "Window")))
     self.regMenu("plugins",\
                  self.menuBar().addMenu(QApplication.translate("default", "Plugins")))
     self.regMenu("help",\
                  self.menuBar().addMenu(QApplication.translate("AboutSeeking", "Help")))
Exemplo n.º 34
0
#!/usr/bin/env python3

import finplot as fplt
from functools import lru_cache
from PyQt5.QtWidgets import QGraphicsView, QComboBox, QLabel
from PyQt5.QtGui import QApplication, QGridLayout
from threading import Thread
import yfinance as yf

app = QApplication([])
win = QGraphicsView()
win.setWindowTitle('TradingView wannabe')
layout = QGridLayout()
win.setLayout(layout)
win.resize(600, 500)

combo = QComboBox()
combo.setEditable(True)
[
    combo.addItem(i) for i in
    'AMRK FB GFN REVG TSLA TWTR WMT CT=F GC=F ^FTSE ^N225 EURUSD=X ETH-USD'.
    split()
]
layout.addWidget(combo, 0, 0, 1, 1)
info = QLabel()
layout.addWidget(info, 0, 1, 1, 1)

ax = fplt.create_plot_widget(win, init_zoom_periods=100)
win.axs = [ax]  # finplot requres this property
layout.addWidget(ax.ax_widget, 1, 0, 1, 2)
Exemplo n.º 35
0
import time

from pyqtgraph.opengl import GLViewWidget, MeshData
from pyqtgraph.opengl.items.GLMeshItem import GLMeshItem

from PyQt5.QtGui import QApplication


volume = load(os.path.join(os.path.split(__file__)[0], 'data/input/sample.npy'))


t0 = time.time()
vertices, normals, faces = march(volume, 0)  # zero smoothing rounds
smooth_vertices, smooth_normals, faces = march(volume, 4)  # 4 smoothing rounds
t1 = time.time()
print("took", t1 - t0, "sec")

app = QApplication([])
view = GLViewWidget()

mesh = MeshData(vertices / 100.0, faces)  # scale down - otherwise camera is misplaced
# or mesh = MeshData(smooth_vertices / 100, faces)
mesh._vertexNormals = normals
# or mesh._vertexNormals = smooth_normals

item = GLMeshItem(meshdata=mesh, color=[1, 0, 0, 1], shader="normalColor")

view.addItem(item)
view.show()
app.exec_()
Exemplo n.º 36
0
 def __evt_changeLanguage(self,locale):
     Prefs.new().setLanguage(locale)
     QMessageBox.information(self,"Success",QApplication.translate("default","Success , this Will take effect at the next time"))
Exemplo n.º 37
0
        self.setModal(True)
        self.resize(500, 250)

        vbox.addWidget(QLabel("Actualización de la lista de episodios:"))
        self.text = QPlainTextEdit()
        self.text.setReadOnly(True)
        vbox.addWidget(self.text)

        bbox = QDialogButtonBox(QDialogButtonBox.Cancel)
        bbox.rejected.connect(self.reject)
        vbox.addWidget(bbox)

    def append(self, text):
        """Append some text in the dialog."""
        self.text.appendPlainText(text.strip())

    def closeEvent(self, event):
        """It was closed."""
        self.closed = True


if __name__ == '__main__':
    import sys

    from PyQt5.QtGui import QApplication
    app = QApplication(sys.argv)

    frame = UpdateDialog()
    frame.show()
    frame.exec_()
Exemplo n.º 38
0
def startup():

    import gettext
    _ = gettext.gettext

    import os
    import sys

    from optparse import OptionParser

    from PyQt5.QtGui import QApplication

    from mnemosyne.libmnemosyne import Mnemosyne

    # Parse options.

    parser = OptionParser()
    parser.usage = "%prog [<database_file>]"
    parser.add_option("-d",
                      "--datadir",
                      dest="data_dir",
                      help=_("data directory"),
                      default=None)
    (options, args) = parser.parse_args()

    # Check if we have to override the data_dir determined in libmnemosyne,
    # either because we explicitly specified a data_dir on the command line,
    # or because there is a mnemosyne2 directory present in the current directory.
    # The latter is handy when Mnemosyne is run from a USB key, so that there
    # is no need to refer to a drive letter which can change from computer to
    # computer.
    data_dir = None
    if options.data_dir != None:
        data_dir = os.path.abspath(options.data_dir)
    elif os.path.exists(os.path.join(os.getcwd(), "mnemosyne2")):
        data_dir = os.path.abspath(os.path.join(os.getcwd(), "mnemosyne2"))

    # Filename argument.
    if len(args) > 0:
        filename = os.path.abspath(args[0])
    else:
        filename = None

    # Load the Mnemosyne library.
    mnemosyne = Mnemosyne(upload_science_logs=True)

    # Initialise GUI toolkit.
    a = QApplication(sys.argv)
    a.setApplicationName("Mnemosyne")
    # TODO: install translator for Qt messages.
    # Under Windows, move out of library.zip to get the true prefix.
    # from mnemosyne.pyqt_ui.main_window import prefix
    #if sys.platform == "win32":
    #    prefix = os.path.split(prefix)[0]
    #    prefix = os.path.split(prefix)[0]
    #    prefix = os.path.split(prefix)[0]
    #translator = QTranslator(a)
    #translator.load("qt_" + loc + ".qm", os.path.join(prefix, 'locale'))
    #a.installTranslator(translator)

    # Add other components we need. The translator should obviously come first,
    # and the UI components should come in the order they should be instantiated,
    # but apart from that, the order does not matter.
    mnemosyne.components.insert(
        0, ("mnemosyne.libmnemosyne.translator", "GetTextTranslator"))
    mnemosyne.components.append(("mnemosyne.pyqt_ui.main_wdgt", "MainWdgt"))
    mnemosyne.components.append(
        ("mnemosyne.pyqt_ui.review_wdgt", "ReviewWdgt"))
    mnemosyne.components.append(
        ("mnemosyne.pyqt_ui.configuration", "PyQtConfiguration"))
    mnemosyne.components.append(
        ("mnemosyne.pyqt_ui.pyqt_render_chain", "PyQtRenderChain"))
    mnemosyne.components.append(
        ("mnemosyne.pyqt_ui.add_cards_dlg", "AddCardsDlg"))
    mnemosyne.components.append(
        ("mnemosyne.pyqt_ui.edit_card_dlg", "EditCardDlg"))
    mnemosyne.components.append(
        ("mnemosyne.pyqt_ui.browse_cards_dlg", "BrowseCardsDlg"))
    mnemosyne.components.append(
        ("mnemosyne.pyqt_ui.activate_cards_dlg", "ActivateCardsDlg"))
    mnemosyne.components.append(
        ("mnemosyne.pyqt_ui.cloned_card_types_list_dlg",
         "ClonedCardTypesListDlg"))
    mnemosyne.components.append(
        ("mnemosyne.pyqt_ui.card_appearance_dlg", "CardAppearanceDlg"))
    mnemosyne.components.append(
        ("mnemosyne.pyqt_ui.activate_plugins_dlg", "ActivatePluginsDlg"))
    mnemosyne.components.append(
        ("mnemosyne.pyqt_ui.statistics_dlg", "StatisticsDlg"))
    mnemosyne.components.append(
        ("mnemosyne.pyqt_ui.card_type_wdgt_generic", "GenericCardTypeWdgt"))
    mnemosyne.components.append(
        ("mnemosyne.pyqt_ui.statistics_wdgts_plotting", "ScheduleWdgt"))
    mnemosyne.components.append(
        ("mnemosyne.pyqt_ui.statistics_wdgts_plotting", "RetentionScoreWdgt"))
    mnemosyne.components.append(
        ("mnemosyne.pyqt_ui.statistics_wdgts_plotting", "GradesWdgt"))
    mnemosyne.components.append(
        ("mnemosyne.pyqt_ui.statistics_wdgts_plotting", "EasinessWdgt"))
    mnemosyne.components.append(
        ("mnemosyne.pyqt_ui.statistics_wdgts_plotting", "CardsAddedWdgt"))
    mnemosyne.components.append(
        ("mnemosyne.pyqt_ui.statistics_wdgt_html", "HtmlStatisticsWdgt"))
    mnemosyne.components.append(
        ("mnemosyne.pyqt_ui.criterion_wdgt_default", "DefaultCriterionWdgt"))
    mnemosyne.components.append(
        ("mnemosyne.pyqt_ui.configuration_dlg", "ConfigurationDlg"))
    mnemosyne.components.append(("mnemosyne.pyqt_ui.sync_dlg", "SyncDlg"))
    mnemosyne.components.append(
        ("mnemosyne.pyqt_ui.qt_sync_server", "QtSyncServer"))
    mnemosyne.components.append(
        ("mnemosyne.pyqt_ui.configuration_wdgt_main", "ConfigurationWdgtMain"))
    mnemosyne.components.append(
        ("mnemosyne.pyqt_ui.configuration_wdgt_sync_server",
         "ConfigurationWdgtSyncServer"))

    # Run Mnemosyne.
    mnemosyne.initialise(data_dir=data_dir, filename=filename)
    mnemosyne.main_widget().show()
    mnemosyne.main_widget().raise_()  # Needed for OSX.
    # TODO: check first run wizard.
    #if config()["first_run"] == True:
    #    w.productTour()
    #    config()["first_run"] = False
    #elif config()["show_daily_tips"] == True:
    #    w.Tip()

    a.exec_()
    mnemosyne.finalise()
Exemplo n.º 39
0
def main2():
    app = QApplication(sys.argv)
    mw = MainWindow()
    mw.run(qt_app=app)

    sys.exit(app.exec_())
Exemplo n.º 40
0
    def beginFinalInit(self):
        """
        @see: startup
        Notice the __init__ method . we just setup the basic widget.
        And after the language , style ,plugins etc had loaded .
        we call this method . 
        
        Never call it unless you know what's it
        """
        #when at linux platform . the icon is not visible at menu .
        for key in self.__actions.keys():
            self.__actions.get(key).setIconVisibleInMenu(True)
            
        #--------------->>Seeking init <<-----------------#
        # __init__ menu
        self.getMenu("settings").addAction(self.getAction("perferences"))
        
        
        #i18n , must restart program to make it in use
        action_languages = QAction(QIcon(getPath('iconDir','languages.png')),QApplication.translate("default", "Languages"),self)
        action_languages.setIconVisibleInMenu(True)
        menu_languages = QMenu(self)
        
        trans_dir = QDir(getPrccisePath("transDir","","coredir"))
        fileNames = trans_dir.entryList(['i18n*.qm'], QDir.Files,QDir.Name)
        qmFiles = [trans_dir.filePath(fn) for fn in fileNames]
    
        for qmf in qmFiles: 
            translator = QTranslator() 
            translator.load(qmf)
            action = menu_languages.addAction(translator.translate("default", "English"))
            action.triggered.connect(lambda re,locale=translator.translate("default", "locale"):self.__evt_changeLanguage(locale))
        
        action_languages.setMenu(menu_languages)
        self.getMenu("settings").addAction(action_languages)
        
        #style menu use signalmapper
        action_style = QAction(QIcon(getPath('iconDir','style.png')),QApplication.translate("default", "Style"),self)
        action_style.setIconVisibleInMenu(True)
        menu_style = QMenu(self)
        for style_item in QStyleFactory.keys():
            action = menu_style.addAction(style_item)
            action.triggered.connect(lambda re,style_item=style_item:changeStyle(style_item))
        action_style.setMenu(menu_style)
        self.getMenu("settings").addAction(action_style)
        
        menu_plugin = self.getMenu("plugins")
        
        menu_plugin.addAction(self.getAction("plguinInfos"))
        
        menu_plugin.addSeparator()
        menu_plugin.addAction(self.getAction("plguinRequest"))
        
        #--------------->>Seeking init <<-----------------#
        # __init__ toolbar
        toolBar = self.addToolBar(QApplication.translate("default","common"))
        
        toolBar.addAction(self.getAction("perferences"))
        toolBar.addAction(self.getAction("close"))
        toolBar.addAction(self.getAction("gotohome"))
        toolBar.addAction(self.getAction("help"))
        
        #--------------->>Seeking init <<-----------------#
        # __init__ status bar
        self.statusBar().showMessage("Seeking ...")
        
        
        #--------------->>Seeking init <<-----------------#
        #Effects of a loading progress .
        #Results appear in the tab of the interior, the window has no effect on the global
        self.overlay = Overlay(self.centralWidget())
        self.overlay.hide()

        #--------------->>Seeking init <<-----------------#
        #other
        self.emit(SIGNAL('updateWindows()'))
Exemplo n.º 41
0
 def update_steps_progress_bar(self, current_step):
     self.steps_progress_bar.setValue(current_step / self.steps_spin.value() * 100)
     QApplication.processEvents() 
Exemplo n.º 42
0
    def setMovie(self, movie):
        QLabel.setMovie(self, movie)
        s=movie.currentImage().size()
        self._movieWidth = s.width()
        self._movieHeight = s.height()

    def paintEvent(self, evt):
        QLabel.paintEvent(self, evt)
        p = QPainter(self)
        p.setFont(self.font())
        x = self._movieWidth + 6
        y = (self.height() + p.fontMetrics().xHeight()) / 2
        p.drawText(x, y, self._text)
        p.end()

    def sizeHint(self):
        fm = QFontMetrics(self.font())
        return QSize(self._movieWidth + 6 + fm.width(self._text),
                self._movieHeight)

    def setText(self, text):
        self._text = text

if __name__ == '__main__':
    import sys
    app = QApplication(sys.argv)
    l = QTextMovieLabel('Loading...', 'loading.gif')
    l.show()
    app.exec_()
Exemplo n.º 43
0
def changeStyle(style_name):
    QApplication.setStyle(QStyleFactory.create(style_name))
    QApplication.setPalette(QApplication.style().standardPalette())
    Prefs.new().setStyle(style_name)