Esempio n. 1
0
def launch_new_instance():
    app = QtGui.QApplication(sys.argv)
    controller = CSVTableController()
    controller.show_window()
    sys.exit(app.exec_())
Esempio n. 2
0
from PySide import QtGui,QtCore


class test(QtGui.QWidget):
    def __init__(self,parent=None):
        super(test, self).__init__(parent)
        main_lay = QtGui.QVBoxLayout()
        self.progress = QtGui.QProgressBar()
        self.button = QtGui.QPushButton('ok')
        self.button.clicked.connect(self.progress_test)
        main_lay.addWidget(self.progress)
        main_lay.addWidget(self.button)
        self.setLayout(main_lay)

    def progress_test(self):
        num = int(20000)
        self.progress.setMinimum(0)
        self.progress.setMaximum(num)
        for i in range(num+1):
            print i
            self.progress.setValue(i)

if __name__ == '__main__':
    app = QtGui.QApplication([])
    t = test()
    t.show()
    app.exec_()
Esempio n. 3
0
def main():
    app = QtGui.QApplication(sys.argv)
    ex = ColorLab()
    sys.exit(app.exec_())
def main():
    app = QtGui.QApplication(sys.argv)
    window = CubeGraphic()
    window.show()
    sys.exit(app.exec_())
Esempio n. 5
0
def main():

    app = QtGui.QApplication(sys.argv)
    ex = MicrobugLoader()
    sys.exit(app.exec_())
Esempio n. 6
0
    def setUpClass(cls):
        """setup once
        """
        # remove the transaction manager
        db.DBSession.remove()

        cls.repo_path = tempfile.mkdtemp()

        from anima import defaults
        defaults.local_storage_path = tempfile.mktemp()

        db.setup({
            'sqlalchemy.url': 'sqlite:///:memory:',
            'sqlalchemy.echo': 'false'
        })
        db.init()

        # create Power Users Group
        cls.power_users_group = Group(name='Power Users')
        db.DBSession.add(cls.power_users_group)
        db.DBSession.commit()

        # create a LocalSession first
        cls.admin = User.query.all()[0]
        cls.lsession = LocalSession()
        cls.lsession.store_user(cls.admin)
        cls.lsession.save()

        # create a repository
        cls.test_repo1 = Repository(name='Test Repository',
                                    windows_path='T:/TestRepo/',
                                    linux_path='/mnt/T/TestRepo/',
                                    osx_path='/Volumes/T/TestRepo/')

        cls.test_structure1 = Structure(name='Test Project Structure',
                                        templates=[],
                                        custom_template='')

        cls.status_new = Status.query.filter_by(code='NEW').first()
        cls.status_wip = Status.query.filter_by(code='WIP').first()
        cls.status_cmpl = Status.query.filter_by(code='CMPL').first()

        cls.project_status_list = StatusList(
            name='Project Statuses',
            statuses=[cls.status_new, cls.status_wip, cls.status_cmpl],
            target_entity_type=Project)

        # create a couple of projects
        cls.test_project1 = Project(name='Project 1',
                                    code='P1',
                                    repository=cls.test_repo1,
                                    structure=cls.test_structure1,
                                    status_list=cls.project_status_list)

        cls.test_project2 = Project(name='Project 2',
                                    code='P2',
                                    repository=cls.test_repo1,
                                    structure=cls.test_structure1,
                                    status_list=cls.project_status_list)

        cls.test_project3 = Project(name='Project 3',
                                    code='P3',
                                    repository=cls.test_repo1,
                                    structure=cls.test_structure1,
                                    status_list=cls.project_status_list)

        cls.projects = [
            cls.test_project1, cls.test_project2, cls.test_project3
        ]

        cls.test_user1 = User(
            name='Test User',
            # groups=[self.power_users_group],
            login='******',
            email='*****@*****.**',
            password='******')
        db.DBSession.add(cls.test_user1)
        db.DBSession.commit()

        cls.admin.projects.append(cls.test_project1)
        cls.admin.projects.append(cls.test_project2)
        cls.admin.projects.append(cls.test_project3)
        cls.test_user1.projects.append(cls.test_project1)
        cls.test_user1.projects.append(cls.test_project2)
        cls.test_user1.projects.append(cls.test_project3)

        # project 1
        cls.test_task1 = Task(
            name='Test Task 1',
            project=cls.test_project1,
            resources=[cls.admin],
        )

        cls.test_task2 = Task(
            name='Test Task 2',
            project=cls.test_project1,
            resources=[cls.admin],
        )

        cls.test_task3 = Task(
            name='Test Task 2',
            project=cls.test_project1,
            resources=[cls.admin],
        )

        # project 2
        cls.test_task4 = Task(
            name='Test Task 4',
            project=cls.test_project2,
            resources=[cls.admin],
        )

        cls.test_task5 = Task(
            name='Test Task 5',
            project=cls.test_project2,
            resources=[cls.admin],
        )

        cls.test_task6 = Task(
            name='Test Task 6',
            parent=cls.test_task5,
            resources=[cls.admin],
        )

        cls.test_task7 = Task(
            name='Test Task 7',
            parent=cls.test_task5,
            resources=[],
        )

        cls.test_task8 = Task(
            name='Test Task 8',
            parent=cls.test_task5,
            resources=[],
        )

        cls.test_task9 = Task(
            name='Test Task 9',
            parent=cls.test_task5,
            resources=[],
        )

        # +-> Project 1
        # | |
        # | +-> Task1
        # | |
        # | +-> Task2
        # | |
        # | +-> Task3
        # |
        # +-> Project 2
        # | |
        # | +-> Task4
        # | |
        # | +-> Task5
        # |   |
        # |   +-> Task6
        # |   |
        # |   +-> Task7 (no resource)
        # |   |
        # |   +-> Task8 (no resource)
        # |   |
        # |   +-> Task9 (no resource)
        # |
        # +-> Project 3

        # record them all to the db
        db.DBSession.add_all([
            cls.admin, cls.test_project1, cls.test_project2, cls.test_project3,
            cls.test_task1, cls.test_task2, cls.test_task3, cls.test_task4,
            cls.test_task5, cls.test_task6, cls.test_task7, cls.test_task8,
            cls.test_task9
        ])
        db.DBSession.commit()

        cls.all_tasks = [
            cls.test_task1, cls.test_task2, cls.test_task3, cls.test_task4,
            cls.test_task5, cls.test_task6, cls.test_task7, cls.test_task8,
            cls.test_task9
        ]

        # create versions
        cls.test_version1 = Version(cls.test_task1,
                                    created_by=cls.admin,
                                    created_with='Test',
                                    description='Test Description')
        db.DBSession.add(cls.test_version1)
        db.DBSession.commit()

        cls.test_version2 = Version(cls.test_task1,
                                    created_by=cls.admin,
                                    created_with='Test',
                                    description='Test Description')
        db.DBSession.add(cls.test_version2)
        db.DBSession.commit()

        cls.test_version3 = Version(cls.test_task1,
                                    created_by=cls.admin,
                                    created_with='Test',
                                    description='Test Description')
        cls.test_version3.is_published = True
        db.DBSession.add(cls.test_version3)
        db.DBSession.commit()

        cls.test_version4 = Version(cls.test_task1,
                                    take_name='Main@GPU',
                                    created_by=cls.admin,
                                    created_with='Test',
                                    description='Test Description')
        cls.test_version4.is_published = True
        db.DBSession.add(cls.test_version4)
        db.DBSession.commit()

        if not QtGui.QApplication.instance():
            logger.debug('creating a new QApplication')
            cls.app = QtGui.QApplication(sys.argv)
        else:
            logger.debug('using the present QApplication: %s' % QtGui.qApp)
            # self.app = QtGui.qApp
            cls.app = QtGui.QApplication.instance()

        # cls.test_environment = TestEnvironment()
        cls.dialog = version_creator.MainDialog()
Esempio n. 7
0
    def on_import_click(self):
        self.current_software_tools.debug_msg("Trying to launch project")
        """Called when the import button is clicked. Attempts to import file with child's 
        'import_file' function.
        """
        currentPath = self.configReader.get_path(self.template, self.get_token_dict())
        self.finalPath = os.path.join(currentPath, self.file_line_edit.text())

        # Check if file exists
        if not os.path.isfile(self.finalPath):
            QtGuiWidgets.QMessageBox.information(self, "File Doesn't Exist", 
                                                "Please select an existing file")
        else:
            if self.import_file(self.finalPath):
                self.close()


    def import_file(self, file_path):
        """Just a placeholder. Should be overridden by child."""
        self.current_software_tools.debug_msg("Here we go!")
        return True

    def get_extensions(self):
        return []
# Debugging -----------------------------------------------
if __name__== '__main__':
    app = QtGuiWidgets.QApplication(sys.argv)
    ex = Importer(app.activeWindow(), 'maya')
    app.exec_()
Esempio n. 8
0
File: main.py Progetto: wdbm/toxygen
    def main(self):
        """
        Main function of app. loads login screen if needed and starts main screen
        """
        app = QtGui.QApplication(sys.argv)
        app.setWindowIcon(QtGui.QIcon(curr_directory() + '/images/icon.png'))
        self.app = app

        if platform.system() == 'Linux':
            QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_X11InitThreads)

        # application color scheme
        with open(curr_directory() + '/styles/style.qss') as fl:
            dark_style = fl.read()
        app.setStyleSheet(dark_style)

        encrypt_save = toxes.ToxES()

        if self.path is not None:
            path = os.path.dirname(self.path) + '/'
            name = os.path.basename(self.path)[:-4]
            data = ProfileHelper(path, name).open_profile()
            if encrypt_save.is_data_encrypted(data):
                data = self.enter_pass(data)
            settings = Settings(name)
            self.tox = profile.tox_factory(data, settings)
        else:
            auto_profile = Settings.get_auto_profile()
            if not auto_profile[0]:
                # show login screen if default profile not found
                current_locale = QtCore.QLocale()
                curr_lang = current_locale.languageToString(
                    current_locale.language())
                langs = Settings.supported_languages()
                if curr_lang in langs:
                    lang_path = langs[curr_lang]
                    translator = QtCore.QTranslator()
                    translator.load(curr_directory() + '/translations/' +
                                    lang_path)
                    app.installTranslator(translator)
                    app.translator = translator
                ls = LoginScreen()
                ls.setWindowIconText("Toxygen")
                profiles = ProfileHelper.find_profiles()
                ls.update_select(map(lambda x: x[1], profiles))
                _login = self.Login(profiles)
                ls.update_on_close(_login.login_screen_close)
                ls.show()
                app.connect(app, QtCore.SIGNAL("lastWindowClosed()"), app,
                            QtCore.SLOT("quit()"))
                app.exec_()
                if not _login.t:
                    return
                elif _login.t == 1:  # create new profile
                    _login.name = _login.name.strip()
                    name = _login.name if _login.name else 'toxygen_user'
                    pr = map(lambda x: x[1], ProfileHelper.find_profiles())
                    if name in list(pr):
                        msgBox = QtGui.QMessageBox()
                        msgBox.setWindowTitle(
                            QtGui.QApplication.translate(
                                "MainWindow", "Error", None,
                                QtGui.QApplication.UnicodeUTF8))
                        text = (QtGui.QApplication.translate(
                            "MainWindow",
                            'Profile with this name already exists', None,
                            QtGui.QApplication.UnicodeUTF8))
                        msgBox.setText(text)
                        msgBox.exec_()
                        return
                    self.tox = profile.tox_factory()
                    self.tox.self_set_name(
                        bytes(_login.name, 'utf-8') if _login.
                        name else b'Toxygen User')
                    self.tox.self_set_status_message(b'Toxing on Toxygen')
                    reply = QtGui.QMessageBox.question(
                        None, 'Profile {}'.format(name),
                        QtGui.QApplication.translate(
                            "login", 'Do you want to set profile password?',
                            None, QtGui.QApplication.UnicodeUTF8),
                        QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
                    if reply == QtGui.QMessageBox.Yes:
                        set_pass = SetProfilePasswordScreen(encrypt_save)
                        set_pass.show()
                        self.app.connect(self.app,
                                         QtCore.SIGNAL("lastWindowClosed()"),
                                         self.app, QtCore.SLOT("quit()"))
                        self.app.exec_()
                    reply = QtGui.QMessageBox.question(
                        None, 'Profile {}'.format(name),
                        QtGui.QApplication.translate(
                            "login",
                            'Do you want to save profile in default folder? If no, profile will be saved in program folder',
                            None, QtGui.QApplication.UnicodeUTF8),
                        QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
                    if reply == QtGui.QMessageBox.Yes:
                        path = Settings.get_default_path()
                    else:
                        path = curr_directory() + '/'
                    try:
                        ProfileHelper(path, name).save_profile(
                            self.tox.get_savedata())
                    except Exception as ex:
                        print(str(ex))
                        log('Profile creation exception: ' + str(ex))
                        msgBox = QtGui.QMessageBox()
                        msgBox.setText(
                            QtGui.QApplication.translate(
                                "login",
                                'Profile saving error! Does Toxygen have permission to write to this directory?',
                                None, QtGui.QApplication.UnicodeUTF8))
                        msgBox.exec_()
                        return
                    path = Settings.get_default_path()
                    settings = Settings(name)
                    if curr_lang in langs:
                        settings['language'] = curr_lang
                    settings.save()
                else:  # load existing profile
                    path, name = _login.get_data()
                    if _login.default:
                        Settings.set_auto_profile(path, name)
                    data = ProfileHelper(path, name).open_profile()
                    if encrypt_save.is_data_encrypted(data):
                        data = self.enter_pass(data)
                    settings = Settings(name)
                    self.tox = profile.tox_factory(data, settings)
            else:
                path, name = auto_profile
                data = ProfileHelper(path, name).open_profile()
                if encrypt_save.is_data_encrypted(data):
                    data = self.enter_pass(data)
                settings = Settings(name)
                self.tox = profile.tox_factory(data, settings)

        if Settings.is_active_profile(path, name):  # profile is in use
            reply = QtGui.QMessageBox.question(
                None, 'Profile {}'.format(name),
                QtGui.QApplication.translate(
                    "login",
                    'Other instance of Toxygen uses this profile or profile was not properly closed. Continue?',
                    None, QtGui.QApplication.UnicodeUTF8),
                QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
            if reply != QtGui.QMessageBox.Yes:
                return
        else:
            settings.set_active_profile()

        lang = Settings.supported_languages()[settings['language']]
        translator = QtCore.QTranslator()
        translator.load(curr_directory() + '/translations/' + lang)
        app.installTranslator(translator)
        app.translator = translator

        # tray icon
        self.tray = QtGui.QSystemTrayIcon(
            QtGui.QIcon(curr_directory() + '/images/icon.png'))
        self.tray.setObjectName('tray')

        self.ms = MainWindow(self.tox, self.reset, self.tray)
        app.aboutToQuit.connect(self.ms.close_window)

        class Menu(QtGui.QMenu):
            def newStatus(self, status):
                if not Settings.get_instance().locked:
                    profile.Profile.get_instance().set_status(status)
                    self.aboutToShow()
                    self.hide()

            def aboutToShow(self):
                status = profile.Profile.get_instance().status
                act = self.act
                if status is None or Settings.get_instance().locked:
                    self.actions()[1].setVisible(False)
                else:
                    self.actions()[1].setVisible(True)
                    act.actions()[0].setChecked(False)
                    act.actions()[1].setChecked(False)
                    act.actions()[2].setChecked(False)
                    act.actions()[status].setChecked(True)
                self.actions()[2].setVisible(
                    not Settings.get_instance().locked)

            def languageChange(self, *args, **kwargs):
                self.actions()[0].setText(
                    QtGui.QApplication.translate(
                        'tray', 'Open Toxygen', None,
                        QtGui.QApplication.UnicodeUTF8))
                self.actions()[1].setText(
                    QtGui.QApplication.translate(
                        'tray', 'Set status', None,
                        QtGui.QApplication.UnicodeUTF8))
                self.actions()[2].setText(
                    QtGui.QApplication.translate(
                        'tray', 'Exit', None, QtGui.QApplication.UnicodeUTF8))
                self.act.actions()[0].setText(
                    QtGui.QApplication.translate(
                        'tray', 'Online', None,
                        QtGui.QApplication.UnicodeUTF8))
                self.act.actions()[1].setText(
                    QtGui.QApplication.translate(
                        'tray', 'Away', None, QtGui.QApplication.UnicodeUTF8))
                self.act.actions()[2].setText(
                    QtGui.QApplication.translate(
                        'tray', 'Busy', None, QtGui.QApplication.UnicodeUTF8))

        m = Menu()
        show = m.addAction(
            QtGui.QApplication.translate('tray', 'Open Toxygen', None,
                                         QtGui.QApplication.UnicodeUTF8))
        sub = m.addMenu(
            QtGui.QApplication.translate('tray', 'Set status', None,
                                         QtGui.QApplication.UnicodeUTF8))
        onl = sub.addAction(
            QtGui.QApplication.translate('tray', 'Online', None,
                                         QtGui.QApplication.UnicodeUTF8))
        away = sub.addAction(
            QtGui.QApplication.translate('tray', 'Away', None,
                                         QtGui.QApplication.UnicodeUTF8))
        busy = sub.addAction(
            QtGui.QApplication.translate('tray', 'Busy', None,
                                         QtGui.QApplication.UnicodeUTF8))
        onl.setCheckable(True)
        away.setCheckable(True)
        busy.setCheckable(True)
        m.act = sub
        exit = m.addAction(
            QtGui.QApplication.translate('tray', 'Exit', None,
                                         QtGui.QApplication.UnicodeUTF8))

        def show_window():
            def show():
                if not self.ms.isActiveWindow():
                    self.ms.setWindowState(self.ms.windowState()
                                           & ~QtCore.Qt.WindowMinimized
                                           | QtCore.Qt.WindowActive)
                    self.ms.activateWindow()
                self.ms.show()

            if not Settings.get_instance().locked:
                show()
            else:

                def correct_pass():
                    show()
                    Settings.get_instance().locked = False

                self.p = UnlockAppScreen(toxes.ToxES.get_instance(),
                                         correct_pass)
                self.p.show()

        def tray_activated(reason):
            if reason == QtGui.QSystemTrayIcon.DoubleClick:
                show_window()

        def close_app():
            if not Settings.get_instance().locked:
                settings.closing = True
                self.ms.close()

        m.connect(show, QtCore.SIGNAL("triggered()"), show_window)
        m.connect(exit, QtCore.SIGNAL("triggered()"), close_app)
        m.connect(m, QtCore.SIGNAL("aboutToShow()"), lambda: m.aboutToShow())
        sub.connect(onl, QtCore.SIGNAL("triggered()"), lambda: m.newStatus(0))
        sub.connect(away, QtCore.SIGNAL("triggered()"), lambda: m.newStatus(1))
        sub.connect(busy, QtCore.SIGNAL("triggered()"), lambda: m.newStatus(2))

        self.tray.setContextMenu(m)
        self.tray.show()
        self.tray.activated.connect(tray_activated)

        self.ms.show()

        updating = False
        if settings['update'] and updater.updater_available(
        ) and updater.connection_available():  # auto update
            version = updater.check_for_updates()
            if version is not None:
                if settings['update'] == 2:
                    updater.download(version)
                    updating = True
                else:
                    reply = QtGui.QMessageBox.question(
                        None, 'Toxygen',
                        QtGui.QApplication.translate(
                            "login",
                            'Update for Toxygen was found. Download and install it?',
                            None, QtGui.QApplication.UnicodeUTF8),
                        QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
                    if reply == QtGui.QMessageBox.Yes:
                        updater.download(version)
                        updating = True

        if updating:
            data = self.tox.get_savedata()
            ProfileHelper.get_instance().save_profile(data)
            settings.close()
            del self.tox
            return

        plugin_helper = PluginLoader(self.tox, settings)  # plugin support
        plugin_helper.load()

        start()
        # init thread
        self.init = self.InitThread(self.tox, self.ms, self.tray)
        self.init.start()

        # starting threads for tox iterate and toxav iterate
        self.mainloop = self.ToxIterateThread(self.tox)
        self.mainloop.start()
        self.avloop = self.ToxAVIterateThread(self.tox.AV)
        self.avloop.start()

        if self.uri is not None:
            self.ms.add_contact(self.uri)

        app.connect(app, QtCore.SIGNAL("lastWindowClosed()"), app,
                    QtCore.SLOT("quit()"))
        app.exec_()

        self.init.stop = True
        self.mainloop.stop = True
        self.avloop.stop = True
        plugin_helper.stop()
        stop()
        self.mainloop.wait()
        self.init.wait()
        self.avloop.wait()
        data = self.tox.get_savedata()
        ProfileHelper.get_instance().save_profile(data)
        settings.close()
        del self.tox
Esempio n. 9
0
def main():
    QtGui.QApplication.setStyle("plastique")
    app = QtGui.QApplication(sys.argv)
    MainWindow().run(app)
Esempio n. 10
0
def main():
    app = QtGui.QApplication(sys.argv)
    main_form = MainForm()
    sys.exit(app.exec_())
Esempio n. 11
0
def main():
    app = QtGui.QApplication([])
    w = WebSiteTester()
    w.show()
    app.exec_()
Esempio n. 12
0
 def run(self):
     app = QtGui.QApplication(sys.argv)
     app.aboutToQuit.connect(app.deleteLater)
     window = HomeWidget()
     app.exec_()
Esempio n. 13
0
    def __init__( self, width=256, height=256, title=None, visible=True,
                  decoration=True, fullscreen=False, config=None, context=None):

        window.Window.__init__(self, width, height, title, visible,
                               decoration, fullscreen, config, context)

        if config is None:
            config = configuration.Configuration()
        set_configuration(config)

        self._native_app = QtGui.QApplication.instance()
        if self._native_app is None:
            self._native_app = QtGui.QApplication(sys.argv)

        self._native_window = QtOpenGL.QGLWidget(__glformat__)
        self._native_window.resize(width, height)
        self._native_window.makeCurrent()
        self._native_window.setAutoBufferSwap(False)
        self._native_window.setMouseTracking(True)
        self._native_window.setWindowTitle(self._title)
        self._native_window.show()

        def paint_gl():
            self.dispatch_event("on_draw")
        self._native_window.paintGL = paint_gl

        def resize_gl(width, height):
            self.dispatch_event("on_resize", width, height)
        self._native_window.resizeGL = resize_gl

        def close_event(event):
            __windows__.remove(self)
            for i in range(len(self._timer_stack)):
                handler, interval = self._timer_stack[i]
                self._clock.unschedule(handler)
            self.dispatch_event("on_close")
        self._native_window.closeEvent = close_event

        def mouse_press_event(event):
            x = event.pos().x()
            y = event.pos().y()
            button = __mouse_map__.get(event.button(), window.mouse.UNKNOWN)
            self._button = button
            self._mouse_x = x
            self._mouse_y = y
            self.dispatch_event("on_mouse_press", x, y, button)
        self._native_window.mousePressEvent = mouse_press_event

        def mouse_release_event(event):
            x = event.pos().x()
            y = event.pos().y()
            button = __mouse_map__.get(event.button(), window.mouse.UNKNOWN)
            self._button = window.mouse.NONE
            self._mouse_x = x
            self._mouse_y = y
            self.dispatch_event("on_mouse_release", x, y, button)
        self._native_window.mouseReleaseEvent = mouse_release_event

        def mouse_move_event(event):
            x = event.pos().x()
            y = event.pos().y()
            dx = x - self._mouse_x
            dy = y - self._mouse_y
            self._mouse_x = x
            self._mouse_y = y
            if self._button is not window.mouse.NONE:
                self.dispatch_event('on_mouse_drag', x, y, dx, dy, self._button)
            else:
                self.dispatch_event('on_mouse_motion', x, y, dx, dy)
        self._native_window.mouseMoveEvent = mouse_move_event

        def wheel_event(event):
            if event.orientation == QtCore.Qt.Horizontal:
                offset_x = event.delta()
                offset_y = 0
            else:
                offset_x = 0
                offset_y = event.delta()
            x = event.pos().x()
            y = event.pos().y()
            self.dispatch_event("on_mouse_scroll", x, y, offset_x, offset_y)

        self._native_window.wheelEvent = wheel_event

        def key_press_event(event):
            code = self._keyboard_translate(event.key())
            modifiers = self._modifiers_translate(event.modifiers())
            self.dispatch_event("on_key_press", code, modifiers)
            self.dispatch_event("on_character", event.text())
        self._native_window.keyPressEvent = key_press_event

        def key_release_event(event):
            code = self._keyboard_translate(event.key())
            modifiers = self._modifiers_translate(event.modifiers())
            self.dispatch_event("on_key_release", code, modifiers)
        self._native_window.keyReleaseEvent = key_release_event

        __windows__.append(self)
Esempio n. 14
0
def main():
	app = QtGui.QApplication(sys.argv)
	test = testWidget()
	test.show()
	sys.exit(app.exec_())
Esempio n. 15
0
def run():
    app = QtGui.QApplication(sys.argv)
    window = MainWindow()
    window.show()
    app.exec_()
Esempio n. 16
0
def pilot_dcm2nii():
    """
    Imports
    -------

    This code needs 'capsul' and 'mmutils' package in order to instanciate and
    execute the pipeline and to get a toy dataset.
    These packages are available in the 'neurospin' source list or in pypi.
    """
    import os
    import sys
    import shutil
    import tempfile
    from capsul.study_config.study_config import StudyConfig
    from capsul.process.loader import get_process_instance
    from mmutils.toy_datasets import get_sample_data
    """
    Parameters
    ----------

    The 'pipeline_name' parameter contains the location of the pipeline XML
    description that will perform the DICOMs conversion, and the 'outdir' the
    location of the pipeline's results: in this case a temporary directory.
    """
    pipeline_name = "dcmio.dcmconverter.dcm_to_nii.xml"
    outdir = tempfile.mkdtemp()
    """
    Capsul configuration
    --------------------

    A 'StudyConfig' has to be instantiated in order to execute the pipeline
    properly. It enables us to define the results directory through the
    'output_directory' attribute, the number of CPUs to be used through the
    'number_of_cpus' attributes, and to specify that we want a log of the
    processing step through the 'generate_logging'. The 'use_scheduler'
    must be set to True if more than 1 CPU is used.
    """
    study_config = StudyConfig(modules=[],
                               output_directory=outdir,
                               number_of_cpus=1,
                               generate_logging=True,
                               use_scheduler=True)
    """
    Get the toy dataset
    -------------------

    The toy dataset is composed of a 3D heart dicom image that is downloaded
    if it is necessary throught the 'get_sample_data' function and exported
    locally in a 'heart.dcm' file.
    """
    dicom_dataset = get_sample_data("dicom")
    dcmfolder = os.path.join(outdir, "dicom")
    if not os.path.isdir(dcmfolder):
        os.makedirs(dcmfolder)
    shutil.copy(dicom_dataset.barre, os.path.join(dcmfolder, "heart.dcm"))
    """
    Pipeline definition
    -------------------

    The pipeline XML description is first imported throught the
    'get_process_instance' method, and the resulting pipeline instance is
    parametrized: in this example we decided to set the date in the converted
    file name and we set two DICOM directories to be converted in Nifti
    format.
    """
    pipeline = get_process_instance(pipeline_name)
    pipeline.date_in_filename = True
    pipeline.dicom_directories = [dcmfolder, dcmfolder]
    pipeline.additional_informations = [[("Provided by", "Neurospin@2015")],
                                        [("Provided by", "Neurospin@2015"),
                                         ("TR", "1500")]]

    pipeline.dcm_tags = [("TR", [("0x0018", "0x0080")]),
                         ("TE", [("0x0018", "0x0081")])]
    """
    Pipeline representation
    -----------------------

    By executing this block of code, a pipeline representation can be
    displayed. This representation is composed of boxes connected to each
    other.
    """
    if 0:
        from capsul.qt_gui.widgets import PipelineDevelopperView
        from PySide import QtGui
        app = QtGui.QApplication(sys.argv)
        view1 = PipelineDevelopperView(pipeline)
        view1.show()
        app.exec_()
    """
    Pipeline execution
    ------------------

    Finally the pipeline is eecuted in the defined 'study_config'.
    """
    study_config.run(pipeline)
    """
    Access the result
    -----------------

    The 'nibabel' package is used to load the generated images. We display the
    numpy array shape and the stored repetiton and echo times: in order
    to load the 'descrip' image field we use the 'json' package.
    """
    import json
    import copy
    import nibabel

    generated_images = pipeline.filled_converted_files

    for fnames in generated_images:
        print(">>>", fnames, "...")
        im = nibabel.load(fnames[0])
        print("shape=", im.get_data().shape)
        header = im.get_header()
        a = str(header["descrip"])
        a = a.strip()
        description = json.loads(copy.deepcopy(a))
        print("TE=", description["TE"])
        print("TR=", description["TR"])
        print("Provided by=", description["Provided by"])
def main():

    app = QtGui.QApplication(sys.argv)
    t = Tetris()
    t.show()
    sys.exit(app.exec_())
Esempio n. 18
0
def main():
    app = QtGui.QApplication(sys.argv)
    ex = purchaseTicketsWidget(
    )  #Using Bruce Wayne to Test Widget as standalone
    ex.show()
    sys.exit(app.exec_())
Esempio n. 19
0
'''
library for constructing dimension SVGs
'''

assert __name__ == "__main__"
import sys
from .tst_setup import dummyViewObject, XML_SVG_Wrapper
from PySide import QtGui, QtCore, QtSvg

app = QtGui.QApplication(
    sys.argv)  #need to be defined before drawingDimensioning ... :(
from drawingDimensioning.svgConstructor import *
from drawingDimensioning.selectionOverlay import generateSelectionGraphicsItems
from drawingDimensioning.linearDimension import linearDimensionSVG_points as linearDimensionSVG

width = 640
height = 480
textRenderer = SvgTextRenderer(font_family='Verdana',
                               font_size='16pt',
                               fill="red")

graphicsScene = QtGui.QGraphicsScene(0, 0, width, height)
graphicsScene.addText("Linear dimensioning testing app.\nEsc to Exit")

dimensions = []


class DimensioningRect(QtGui.QGraphicsRectItem):
    def __init__(self, *args):
        super(DimensioningRect, self).__init__(*args)
        svgRenderer = QtSvg.QSvgRenderer()
Esempio n. 20
0
def main():

    app = QtGui.QApplication(sys.argv)
    ex = MainWindow()
    sys.exit(app.exec_())
 def run(self):
     self.app = QtGui.QApplication(sys.argv)
     self.myapp = MainWindow()
     self.myapp.show()
     self.app.exec_()
Esempio n. 22
0
def run():
    appl = QtGui.QApplication(sys.argv)
    form = MainWindow()
    form.show()
    appl.exec_()
Esempio n. 23
0
def main():
    app = QtGui.QApplication(sys.argv)
    main = CalculatorApp()
    main.show()
    sys.exit(app.exec_())
Esempio n. 24
0
def main():

    app = QtGui.QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())
Esempio n. 25
0
def main():
    app = QtGui.QApplication(sys.argv)
    MainWindow().run(app)
Esempio n. 26
0
def main():
    app = QtGui.QApplication(sys.argv)
    win = Win()
    sys.exit(app.exec_())
Esempio n. 27
0
def run():
    app = QtGui.QApplication(sys.argv)
    main = Main()
    sys.exit(app.exec_())
Esempio n. 28
0
def run():
    #Starts UI loop
    app = QtGui.QApplication(sys.argv)
    main = Main()
    sys.exit(app.exec_())
Esempio n. 29
0
import sys, time

from PySide import QtGui, QtCore


class test():
    def progress(self):
        widget = QtGui.QProgressDialog("Show Progress", "Stop", 0, 10)
        widget.show()
        for row in range(10):
            QtCore.QCoreApplication.instance().processEvents()
            widget.setValue(row)
            time.sleep(.1)


if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    test().progress()
Esempio n. 30
0
def main():

    app = QtGui.QApplication(sys.argv)
    ex = MeatBagWindow()
    app.exec_()