Ejemplo n.º 1
0
def get_icon(icon_ref, for_widget=None):
    '''
    If icon ref is an int, for_widget must not be None
    and its current QStyle will be used to return
    the Qt icon pointed by icon_ref.
    
    If icon_ref is a 2D tuple, it is used to call
    get_pixmap(*icon_ref)
    
    If icon_ref is a file path, an icon is created
    from this file.
    
    '''
    try:
        from kabaret.gui import import_qt
    except ImportError:
        raise ImportError('The kabaret.gui package must be available to create icon resources')
    QtCore, QtGui = import_qt()
        
    if isinstance(icon_ref, int):
        style = for_widget.style()
        return style.standardIcon(icon_ref)

    global _ICONCACHE
    if icon_ref in _ICONCACHE:
        return _ICONCACHE[icon_ref]

    pix = None
    try:
        pix = get_pixmap(*icon_ref)
    except:
        try:
            if os.path.isfile(icon_ref):
                pix = QtGui.QPixmap(icon_ref)
        except TypeError:
            pass
        
    if pix is None:
        raise NotFoundError('Cannot find icon for %r'%(icon_ref,))
    
    icon = QtGui.QIcon(pix)
    _ICONCACHE[icon_ref] = icon 
    return icon
Ejemplo n.º 2
0
def get_pixmap(folder_name, pixmap_name):
    '''
    Same as get, but returns a QPixmap
    '''
    global _PIXCACHE
    path = get(folder_name, pixmap_name)
    if path in _PIXCACHE:
        return _PIXCACHE[path]
    
    try:
        from kabaret.gui import import_qt
    except ImportError:
        raise ImportError('The kabaret.gui package must be available to create pixmap resources')
    QtCore, QtGui = import_qt()

    ret = QtGui.QPixmap(path)
    _PIXCACHE[path] = ret
    
    return ret
Ejemplo n.º 3
0
'''


'''

import fnmatch

from kabaret.gui import import_qt
QtCore, QtGui = import_qt()


class SelectAppHostDialog(QtGui.QDialog):
    def __init__(self, parent, client):
        super(SelectAppHostDialog, self).__init__(parent)
        self.client = client
        self.filter = '*'
        self._selected = None

        self.setWindowTitle('Connect to AppHost')

        self.setLayout(QtGui.QVBoxLayout())

        header = QtGui.QLabel('Select a Project AppHost to use:', self)
        self.layout().addWidget(header)

        lo = QtGui.QHBoxLayout()
        self.layout().addLayout(lo)
        filter_lb = QtGui.QLabel('Filter:', self)
        lo.addWidget(filter_lb)
        self.le = QtGui.QLineEdit(self.client.project_name or '', self)
        self.le.editingFinished.connect(self.set_filter)