Exemplo n.º 1
0
    def run(self):
        #TODO parse command line for addition arguments
        msmlgui.shared.msml_app = MsmlApp(add_search_path=["/home/weigl/workspace/msml/share/"])

        app = QtGui.QApplication(sys.argv)
        app.setAttribute(Qt.AA_DontShowIconsInMenus, False)

        QIcon.setThemeName("tango")

        for path in QtGui.QIcon.themeSearchPaths():
            print "%s/%s" % (path, QtGui.QIcon.themeName())

            print QIcon.hasThemeIcon("document-open")


        #TODO parse command line for open files
        frame = MSMLMainFrame()

        from path import path

        f = path("/home/weigl/workspace/msml/examples/BunnyExample/bunny.msml.xml")
        frame.open_file(f)
        frame.show()
        #    frame.save_file_as()

        #   from .helper.scene_text import scene_to_text
        #    print scene_to_text(frame.msml_model)
        sys.exit(app.exec_())
Exemplo n.º 2
0
    def run(self):
        #TODO parse command line for addition arguments
        msmlgui.shared.msml_app = MsmlApp(
            add_search_path=["/home/weigl/workspace/msml/share/"])

        app = QtGui.QApplication(sys.argv)
        app.setAttribute(Qt.AA_DontShowIconsInMenus, False)

        QIcon.setThemeName("tango")

        for path in QtGui.QIcon.themeSearchPaths():
            print "%s/%s" % (path, QtGui.QIcon.themeName())

            print QIcon.hasThemeIcon("document-open")

        #TODO parse command line for open files
        frame = MSMLMainFrame()

        from path import path

        f = path(
            "/home/weigl/workspace/msml/examples/BunnyExample/bunny.msml.xml")
        frame.open_file(f)
        frame.show()
        #    frame.save_file_as()

        #   from .helper.scene_text import scene_to_text
        #    print scene_to_text(frame.msml_model)
        sys.exit(app.exec_())
Exemplo n.º 3
0
    def __init__(self,
                 action,
                 menu,
                 group=None,
                 icon=None,
                 shortcut='',
                 tooltip=None,
                 whats_this=None,
                 checkable=False,
                 checked=False,
                 enabled=True,
                 parent=None):

        category, name = menu
        QAction.__init__(self, name, parent)

        self.category = category
        self.group = group
        self.triggered.connect(action)
        self.menu_name = name
        # the first action in a group decides on the location
        if icon and QIcon.hasThemeIcon(icon):
            self.setIcon(QIcon.fromTheme(icon))
        if tooltip:
            self.setToolTip(tooltip)
        if whats_this:
            self.setWhatsThis(whats_this)
        self.setCheckable(checkable)
        self.setChecked(checked)
        self.setShortcut(shortcut)
        self.setEnabled(enabled)
            def __init__(self, executable, iconPath, parent=None):
                super(GuiApplicationLinux, self).__init__(iconPath)

                self.eventLoop = 'qt'
                self.app = QApplication(
                    sys.argv)  # this should be done before anything else
                self.executable = executable

                if QIcon.hasThemeIcon(iconPath):
                    icon = QIcon.fromTheme(iconPath)
                else:
                    icon = QIcon(iconPath)

                self.statusIcon = QSystemTrayIcon(icon, parent)
                self.menu = QMenu(parent)

                exitAction = self.menu.addAction("Exit")
                exitAction.triggered.connect(self.quit)

                self.statusIcon.setContextMenu(self.menu)

                def activate(reason):
                    if reason == QSystemTrayIcon.Trigger:
                        return self.launchExecutable()

                QObject.connect(
                    self.statusIcon,
                    SIGNAL("activated(QSystemTrayIcon::ActivationReason)"),
                    activate)

                self.statusIcon.show()
Exemplo n.º 5
0
def iconFromTheme(*names, **kwargs):
    size = kwargs["size"] if "size" in kwargs else 32
    try:
        from PyKDE4.kdeui import KIcon

        for name in names:
            if KIcon.hasThemeIcon(name):
                return KIcon(name)
    except:
        pass
    if get_desktop() == "generic":
        try:
            from gtk import icon_theme_get_default

            iconTheme = icon_theme_get_default()
            for name in names:
                iconInfo = iconTheme.lookup_icon(name, size, 0)
                if iconInfo:
                    return QIcon(iconInfo.get_filename())
        except:
            pass
    for name in names:
        if QIcon.hasThemeIcon(name):
            return QIcon(QIcon.fromTheme(name))

        return QIcon()
Exemplo n.º 6
0
            def __init__(self, executable, iconPath, parent=None):
                super(GuiApplicationLinux, self).__init__(iconPath)

                self.eventLoop = "qt"
                self.app = QApplication(sys.argv)  # this should be done before anything else
                self.executable = executable

                if QIcon.hasThemeIcon(iconPath):
                    icon = QIcon.fromTheme(iconPath)
                else:
                    icon = QIcon(iconPath)

                self.statusIcon = QSystemTrayIcon(icon, parent)
                self.menu = QMenu(parent)

                exitAction = self.menu.addAction("Exit")
                exitAction.triggered.connect(self.quit)

                self.statusIcon.setContextMenu(self.menu)

                def activate(reason):
                    if reason == QSystemTrayIcon.Trigger:
                        return self.launchExecutable()

                QObject.connect(self.statusIcon, SIGNAL("activated(QSystemTrayIcon::ActivationReason)"), activate)

                self.statusIcon.show()
Exemplo n.º 7
0
 def __init__(self, iconName):
     if QIcon.hasThemeIcon(iconName):
         icon = QIcon.fromTheme(iconName)
     else:
         icon = QIcon(iconName)
     size = icon.availableSizes()[0]
     self.image = icon.pixmap(size).toImage().convertToFormat(QImage.Format_ARGB32)
     self.image = self.image.rgbSwapped()  # otherwise colors are weird :/
 def __init__(self, iconName):
     if QIcon.hasThemeIcon(iconName):
         icon = QIcon.fromTheme(iconName)
     else:
         icon = QIcon(iconName)
     size = icon.availableSizes()[0]
     self.image = icon.pixmap(size).toImage().convertToFormat(
         QImage.Format_ARGB32)
     self.image = self.image.rgbSwapped(
     )  # otherwise colors are weird :/
Exemplo n.º 9
0
    def icon(self, iconName):
        """
		Retrieves an icon from the theme
		
		Arguments:
		iconName -- the name of the icon
		
		Returns:
		A QIcon		
		"""

        if iconName in self.mapping:
            icon = self.mapping[iconName]
        else:
            icon = "edit-undo"
        if not QIcon.hasThemeIcon(icon):
            print "libqnotero._themes.icon(): failed to find '%s'" % icon
        return QIcon.fromTheme("icon", Default.icon(self, iconName))
Exemplo n.º 10
0
	def icon(self, iconName):
	
		"""
		Retrieves an icon from the theme
		
		Arguments:
		iconName -- the name of the icon
		
		Returns:
		A QIcon		
		"""
	
		if iconName in self.mapping:
			icon = self.mapping[iconName]
		else:
			icon = "edit-undo"			
		if not QIcon.hasThemeIcon(icon):
			print "libqnotero._themes.icon(): failed to find '%s'" % icon
		return QIcon.fromTheme("icon", Default.icon(self, iconName))
Exemplo n.º 11
0
def get(name):
    """Returns an icon with the specified name."""
    if QIcon.hasThemeIcon(name):
        return QIcon.fromTheme(name)
    try:
        return _cache[name]
    except KeyError:
        icon = _cache[name] = QIcon()
        # first try SVG
        fname = 'icons:{0}.svg'.format(name)
        if QFile(fname).exists():
            icon.addFile(fname)
        else:
            # then try different sizes
            for size in (16, 22, 32, 48):
                fname = 'icons:{1}x{1}/{0}.png'.format(name, size or '')
                if QFile(fname).exists():
                    qsize = QSize(size, size) if size else QSize()
                    icon.addFile(fname, qsize)
        return icon
Exemplo n.º 12
0
def get(name):
    """Returns an icon with the specified name."""
    if QIcon.hasThemeIcon(name):
        return QIcon.fromTheme(name)
    try:
        return _cache[name]
    except KeyError:
        icon = _cache[name] = QIcon()
        # first try SVG
        fname = 'icons:{0}.svg'.format(name)
        if QFile(fname).exists():
            icon.addFile(fname)
        else:
            # then try different sizes
            for size in (16, 22, 32, 48):
                fname = 'icons:{1}x{1}/{0}.png'.format(name, size or '')
                if QFile(fname).exists():
                    qsize = QSize(size, size) if size else QSize()
                    icon.addFile(fname, qsize)
        return icon
Exemplo n.º 13
0
    def __init__(self, *args, **kwargs):

        try:
            appdir = kwargs.pop('appdir')
        except KeyError:
            pass

        CadAppQt.__init__(self)

        # set application directory
        appdata.set('APPDIR', appdir)

        # Search for icons in './icons/kubos'.
        if appdata.get('APPDIR') is not None:
            ip = _QIcon.themeSearchPaths() + [
                _path.join(appdata.get('APPDIR'), 'icons')
            ]
            _QIcon.setThemeSearchPaths(ip)
            _QIcon.setThemeName('kubos')
        if appdata.get('mode'):
            if _QIcon.hasThemeIcon('kubos-' + appdata.get('mode')):
                appdata.set('icon',
                            _QIcon.fromTheme('kubos-' + appdata.get('mode')))
            else:
                appdata.set('icon', _QIcon.fromTheme('kubos'))
        else:
            appdata.set('icon', _QIcon.fromTheme('kubos'))

        appdata.set('AUTHORS', 'Marko Knöbl')
        appdata.set('VERSION', '0.2b2')
        self.doc = doc_ctrl
        # 'win' cannot be imported before creating a QApplication
        from gui import win
        self.win = win
        self.update_title()
        self.viewer = win.viewer_3d
        self._menu_bar = self.win.menuBar()
        self._menus = {}
        self._actiongroups = {}

        self._toolbars = {}
Exemplo n.º 14
0
    def __init__(self):

        super().__init__()

        self.setWindowTitle('Yabai')

        QIcon.setThemeName('oxygenNOT') # TEST
        if not QIcon.hasThemeIcon('document-open'):
            QIcon.setThemeSearchPaths(['gui/icons'])
            QIcon.setThemeName('oxygen_parts')
        # TODO: This way of checking for the theme's existence is ugly
        # as f**k, so you'd better think of a better way to do it.

        self.createActions()
        self.createMenus()
        self.createToolBars()
        self.createStatusBar()

        for action in Config.checkedActions:
            if action in View.fitModes:
                fitMode = action
                break
        else:
            fitMode = 'view_fitBest'

        self.view = View('core/black.ori', fitMode)
        self.setCentralWidget(self.view)

        # Add all the action to the view, so that they can be
        # triggered even when there are no menus/toolbars
        # visible as it is in fullscreen mode:
        for action in self.actions.values():
            if not isinstance(action, QActionGroup):
                self.view.addAction(action)

        self.show()