コード例 #1
0
    def build(self, menu=None, iteration=0, category=None, output={}):
        it = menu.iter()
        it_type = it
        while it_type != GMenu.TreeItemType.INVALID:
            if it_type == GMenu.TreeItemType.DIRECTORY:

                item = it.get_directory()
                icon = icons.get(item.get_icon().get_names()[0])
                comment = item.get_comment()
                category = item.get_name()
                #dump(categorie, iteration)
                output[f'{category}'] = {}
                output[f'{category}']['icon'] = icon
                output[f'{category}']['description'] = comment
                output[f'{category}']['apps'] = []
                self.build(item, iteration + 1, category, output)

            elif it_type == GMenu.TreeItemType.ENTRY:

                item = it.get_entry()
                app = item.get_app_info()
                name = app.get_display_name()
                generic = app.get_generic_name()
                description = app.get_description()
                icon = app.get_icon()
                keywords = " ".join(app.get_keywords())
                path = item.get_desktop_file_path()

                if isinstance(icon, Gio.ThemedIcon):
                    icon = icon.get_names()[0]
                elif isinstance(icon, Gio.FileIcon):
                    icon = icon.get_file().get_path()

                icon = icons.get(icon)
                #dump(name, iteration+1)

                if not generic:
                    generic = "Generic name not available"

                if not description:
                    description = "Description not available"

                output[f'{category}']['apps'].append({
                    'category': f'{category}',
                    'name': f'{name}',
                    'generic': f'{generic}',
                    'description': f'{description}',
                    'icon': f'{icon}',
                    'keywords': f'{keywords}',
                    'path': f'{path}'
                })

            it_type = it.next()

        return output
コード例 #2
0
ファイル: Preferences.py プロジェクト: Tayyib/uludag
    def __init__(self, parent=None):
        PreferencesDialog.PreferencesDialog.__init__(self, parent)
        
        self.iface = PisiIface.Iface()

        #add icons to buttons
        self.addButton.setIconSet(Icons.loadIconSet("add", KIcon.Small))
        self.editButton.setIconSet(Icons.loadIconSet("configure", KIcon.Small))
        self.removeButton.setIconSet(Icons.loadIconSet("remove", KIcon.Small))
        self.moveUpButton.setIconSet(Icons.loadIconSet("up", KIcon.Small))
        self.moveDownButton.setIconSet(Icons.loadIconSet("down", KIcon.Small))
        self.buttonOk.setIconSet(Icons.loadIconSet("button_ok", KIcon.Small))
        self.buttonCancel.setIconSet(Icons.loadIconSet("button_cancel", KIcon.Small))
        self.buttonHelp.setIconSet(Icons.loadIconSet("help", KIcon.Small))

        self.parent = parent
        self.connect(self.addButton, SIGNAL("clicked()"), self.addNewRepo)
        self.connect(self.editButton, SIGNAL("clicked()"), self.editRepo)
        self.connect(self.removeButton, SIGNAL("clicked()"), self.removeRepo)
        self.connect(self.repoListView, SIGNAL("selectionChanged()"), self.updateButtons)
        self.connect(self.moveUpButton, SIGNAL("clicked()"), self.moveUp)
        self.connect(self.moveDownButton, SIGNAL("clicked()"), self.moveDown)
        self.connect(self.buttonOk, SIGNAL("clicked()"), self.saveSettings)
        self.connect(self.intervalCheck, SIGNAL("toggled(bool)"), self.enableCheckInterval)
        self.connect(self.useCacheCheck, SIGNAL("toggled(bool)"), self.enableUseCache)
        self.connect(self.clearCacheButton, SIGNAL("clicked()"), self.clearAllCached)
        self.connect(self.buttonHelp, SIGNAL("clicked()"), self.showHelp)
        self.connect(self.useHttpForAll, SIGNAL("toggled(bool)"), self.useHttpToggled)
        self.connect(self.useBandwidthLimit, SIGNAL("toggled(bool)"), self.bandwidthSettingChanged)
        self.connect(self.bandwidthValue, SIGNAL("valueChanged(int)"), self.bandwidthSettingChanged)

        self.connect(self.httpProxy, SIGNAL("textChanged(const QString&)"), self.proxyDataChanged)
        self.connect(self.httpProxyPort, SIGNAL("valueChanged(int)"), self.proxyDataChanged)
        self.connect(self.httpsProxy, SIGNAL("textChanged(const QString&)"), self.proxyDataChanged)
        self.connect(self.httpsProxyPort, SIGNAL("valueChanged(int)"), self.proxyDataChanged)
        self.connect(self.ftpProxy, SIGNAL("textChanged(const QString&)"), self.proxyDataChanged)
        self.connect(self.ftpProxyPort, SIGNAL("valueChanged(int)"), self.proxyDataChanged)
        self.connect(self.noProxyButton, SIGNAL("toggled(bool)"), self.proxyDataChanged)

        self.editButton.setEnabled(False)
        self.removeButton.setEnabled(False)

        self.repoListView.setSorting(-1)
        self.updateListView()
        self.updateButtons()

        self.onlyGuiApp.setChecked(self.parent.settings.getBoolValue(Settings.general, "ShowOnlyGuiApp"))
        self.intervalCheck.setChecked(self.parent.settings.getBoolValue(Settings.general, "UpdateCheck"))
        self.intervalSpin.setValue(self.parent.settings.getNumValue(Settings.general, "UpdateCheckInterval"))
        self.systemTray.setChecked(self.parent.settings.getBoolValue(Settings.general, "SystemTray"))
        self.noProxyButton.setChecked(True)
        self.getProxySettings()
        self.getCacheSettings()
        self.getBandwidthSetting()

        # This is to not call setRepositories unnecessarily
        self.reposChanged = False
        self.bandwidthChanged = False
        self.proxyChanged = False
コード例 #3
0
    def __init__(self):
        super(Window, self).__init__()

        # Config --------------------------------------
        self.objectList = {}
        self.systemIcon = {
            'folder':
            QIcon(QApplication.style().standardIcon(QStyle.SP_DirIcon)),
            'folderLink':
            QIcon(QApplication.style().standardIcon(QStyle.SP_DirLinkIcon)),
            'file':
            QIcon(QApplication.style().standardIcon(QStyle.SP_FileIcon)),
            'quit':
            QIcon(QApplication.style().standardIcon(
                QStyle.SP_DialogCloseButton))
        }
        self.filetypeIcon = Icons.icon_filetypes_flat(self)
        self.includeExclude = IncludeExclude()
        self.includeExclude.includePaths = ['Examples']
        self.includeExclude.includeExtensions = ['md', 'py', 'png']
        self.includeExclude.excludeFilenames = ['gitignore']
        self.includeExclude.excludePaths = ['git', '__pycache__']

        # --------------------------------------------
        self.create_menu()
        self.add_directory(
            '&Scripts',
            '/media/m/Data/Development/Phyton/TreeViewUltraMenu/Python-UltraMenu'
        )
        self.add_exit()
コード例 #4
0
ファイル: ScriptLoader.py プロジェクト: acarl123/MovingBoxes
	def LoadMenu (self):
		#clear the menu
		for s in self.Scripts:
			self.Menu.RemoveItem(s.MenuItem)
		
		self.Scripts = []
		if (os.path.exists("./Scripts")):
			for filename in os.listdir("./Scripts"):
				sf = ScriptFile("./Scripts/" + filename,self,False)
				if (sf.IsRunOnce):
					if sf.File not in self.RunScripts:
						self.RunScripts.add(sf.File)
						self.ExecuteScript(sf.File)
				else:
					self.Scripts.append(sf)
					
		if (os.path.exists(self.SpecialDir)):
			for filename in os.listdir(self.SpecialDir):
				sf = ScriptFile(self.SpecialDir + "/" + filename,self,True)
				if (sf.IsRunOnce):
					if sf.File not in self.RunScripts:
						self.RunScripts.add(sf.File)
						self.ExecuteScript(sf.File)
				else:
					self.Scripts.append(sf)
		
		
		self.Scripts = sorted(self.Scripts, key=lambda s: s.Name)
		
		for s in reversed(self.Scripts):
			s.MenuItem = wx.MenuItem(self.Menu,wx.ID_ANY,s.Name,s.Description)
			if (s.Special):
				s.MenuItem.SetBitmap(Icons.getstarBitmap())
			self.Menu.PrependItem(s.MenuItem)
			self.Navigator.Bind(wx.EVT_MENU,s.OnClicked,s.MenuItem)
コード例 #5
0
    def __get_wifi_percentage_average(self, quality, signal):
        """Gets WiFi percentage average.

        Args:
            quality: WiFi quality.
            signal: WiFi signal.
        """
        icon = Icons.Icons()              # Icon
        average = (quality + signal) / 2  # Average
        
        # Average: Useless
        if 0 <= average <= 19:
            icon.show_icon("wifi1")
        # Average: Weak
        elif 20 <= average <= 39:
            icon.show_icon("wifi2")
        # Average: Fair
        elif 40 <= average <= 59:
            icon.show_icon("wifi3")
        # Average: Good
        elif 60 <= average <= 79:
            icon.show_icon("wifi4")
        # Average: Excellent
        elif 80 <= average <= 100:
            icon.show_icon("wifi5")
コード例 #6
0
    def get_internet_device(self):
        """Gets the Internet devices status.
        """
        icon = Icons.Icons()  # Icon

        # Device names which might be used by the OS
        devices_wireless = DEV_WIRELESS
        devices_wireless_alfa = DEV_WIRELESS_ALFA
        devices_wiring = DEV_WIRING
        devices = devices_wireless + devices_wireless_alfa + devices_wiring

        # Executing command and parsing output
        cmd = subprocess.Popen(['ip', 'link'], stdout=subprocess.PIPE)
        cmd_out, cmd_err = cmd.communicate()

        # Looking for device statuses
        for device in devices:
            if device in cmd_out:
                cmddev = subprocess.Popen(['ip', 'addr', 'show', device], stdout=subprocess.PIPE)
                cmddev_out, cmddev_err = cmddev.communicate()
                cmddev_outparsed = str(cmddev_out).split(' ')
                status = cmddev_outparsed[8]

                # Ethernet device
                if device in devices_wiring:
                    if status == "UP":
                        icon.show_icon("ethernet")
                # Alfa antenna
                if device in devices_wireless_alfa:
                    if status == "UP":
                        icon.show_icon("alfa")
                # Internal WiFi chip
                if device in devices_wireless:
                    if status == "UP":
                        icon.show_icon("cpu")
コード例 #7
0
    def get_brightness(self):
        """Prints the current level of brightness.
        """
        icon = Icons.Icons()  # Icon

        # Opening file containing current brightness
        try:
            brightcur_file = open(BRIGHT_C)
            brightcur = brightcur_file.read()
            brightcur_file.close()
        except:
            sys.stdout.write("^fg(%s)!E! BrightCur^fg()" % Colors.CL_BASE08)

        # Opening file containing maximal brightness
        try:
            brightmax_file = open(BRIGHT_M)
            brightmax = brightmax_file.read()
            brightmax_file.close()
        except:
            sys.stdout.write("^fg(%s)!E! BrightMax^fg()" % Colors.CL_BASE08)

        # Casting into integers
        brightcur_level = int(brightcur)
        brightmax_level = int(brightmax)

        # Calculating brightness percentage and printing information
        brightness = (100 * brightcur_level) / brightmax_level
        icon.show_icon("brightness")
        sys.stdout.write("%d%%" % brightness)
コード例 #8
0
ファイル: Clock.py プロジェクト: sljrobin/.dotfiles
    def get_time(self):
        """Prints the current time.
        """
        icon = Icons.Icons()  # Icon
        current_time = time.strftime("%H:%M:%S", time.gmtime())  # Current time

        icon.show_icon("clock")
        sys.stdout.write("%s" % current_time)
コード例 #9
0
ファイル: Clock.py プロジェクト: sljrobin/.dotfiles
    def get_date(self):
        """Prints the current date.
        """
        icon = Icons.Icons()  # Icon
        current_date = time.strftime("%d/%m/%Y", time.gmtime())  # Current date

        icon.show_icon("calendar")
        sys.stdout.write("%s" % current_date)
コード例 #10
0
ファイル: Disk.py プロジェクト: sljrobin/.dotfiles
    def show_disks(self):
        """Shows all the information about all the disks. 
        """
        icon = Icons.Icons()  # Icon

        # For every disk, listing information
        icon.show_icon("disk")
        for disk in DISKS:
            self.__get_info(disk)
コード例 #11
0
ファイル: Tree.py プロジェクト: FedoraScientific/salome-yacs
 def __init__(self,parent,text,item,after=None):
   if after is None:
     QListViewItem.__init__(self,parent,text)
   else:
     QListViewItem.__init__(self,parent,after,text)
   self.item=item
   self.setPixmap(0,Icons.get_image(item.getIconName()))
   self.setExpandable(self.item.isExpandable())
   self.children = []
コード例 #12
0
    def __init__(self, designMode = False, showMaximized=False, noBorder=False):
        qt.QWidget.__init__(self)

        self.launchInDesignMode = designMode
        self.hardwareRepository = HardwareRepository.HardwareRepository()
        self.showMaximized = showMaximized
        self.noBorder = noBorder
        self.windows = []
        self.splashScreen = BlissSplashScreen(Icons.load('splash'), qt.Qt.WDestructiveClose)
        self.splashScreen.show()
        self.timestamp = 0
コード例 #13
0
    def __init__(self, designMode = False, showMaximized=False, noBorder=False):
        qt.QWidget.__init__(self)

        self.launchInDesignMode = designMode
        self.hardwareRepository = HardwareRepository.HardwareRepository()
        self.showMaximized = showMaximized
        self.noBorder = noBorder
        self.windows = []
        self.splashScreen = BlissSplashScreen(Icons.load('splash'), qt.Qt.WDestructiveClose)
        self.splashScreen.show()
        self.timestamp = 0
コード例 #14
0
        def OnInit(self):
            mysession = leginon.leginondata.SessionData()
            mynode = node.Node('mnode', session=mysession)

            icon = wx.EmptyIcon()
            icon.CopyFromBitmap(Icons.icon("imagebrowser"))

            frame = wx.Frame(None, -1, 'Image Browser')
            frame.SetIcon(icon)
            frame.node = mynode
            ImageBrowserPanel(frame)
            frame.Fit()
            self.SetTopWindow(frame)
            frame.Show()
            return True
コード例 #15
0
                def OnInit(self):
                        mysession = leginon.leginondata.SessionData()
                        mynode = node.Node('mnode', session=mysession)

                        icon = wx.EmptyIcon()
                        icon.CopyFromBitmap(Icons.icon("imagebrowser"))
                        
                        frame = wx.Frame(None, -1, 'Image Browser')
                        frame.SetIcon(icon)
                        frame.node=mynode
                        ImageBrowserPanel(frame)
                        frame.Fit()
                        self.SetTopWindow(frame)
                        frame.Show()
                        return True
コード例 #16
0
ファイル: Volume.py プロジェクト: sljrobin/.dotfiles
    def show_info(self):
        """Shows all information for Volume.
        """
        icon = Icons.Icons()  # Icon
        headp_on = "Pin-ctls: 0x00:"  # Headphones: Plugged
        headp_off = "Pin-ctls: 0x40: OUT"  # Headphones: Unplugged
        mute_on = "off"  # Mute: ON
        mute_off = "on"  # Mute: OFF

        # Getting information
        info_headp = self.__get_headphones()
        info_mute = self.__get_mute()
        info_volume = self.__get_volume()

        # Handling icon: Headphones: Plugged
        if info_headp == headp_on:
            icon.show_icon("headphones")
        # Handling icon: Headphones: Unplugged
        elif info_headp == headp_off:
            # Volume: 000 - 030
            if 0 <= info_volume <= 30:
                icon.show_icon("volume030")
            # Volume: 031 - 070
            elif 31 <= info_volume <= 70:
                icon.show_icon("volume070")
            # Volume: 071 - 100
            elif 71 <= info_volume <= 100:
                icon.show_icon("volume100")

        # Mute: ON
        if info_mute == mute_on:
            sys.stdout.write("^fg(%s)%s%%^fg()" %\
                (Colors.CL_BASE03, info_volume))
        # Mute: OFF
        elif info_mute == mute_off:
            # Volume: 000 - 060
            if 0 <= info_volume <= 60:
                sys.stdout.write("^fg(%s)%s%%^fg()" %\
                    (Colors.CL_BASE0B, info_volume))
            # Volume: 061 - 080
            elif 61 <= info_volume <= 80:
                sys.stdout.write("^fg(%s)%s%%^fg()" %\
                    (Colors.CL_BASE09, info_volume))
            # Volume: 081 - 100
            elif 81 <= info_volume <= 100:
                sys.stdout.write("^fg(%s)%s%%^fg()" %\
                    (Colors.CL_BASE08, info_volume))
コード例 #17
0
ファイル: PageGeneral.py プロジェクト: vlinhd11/webserver
    def __call__(self):
        ports = PortsWidget()
        network = NetworkWidget()
        network.bind('submit_success', ports.refresh.JS_to_refresh())

        tabs = CTK.Tab()
        tabs.Add(_('Network'), network)
        tabs.Add(_('Ports to listen'), ports)
        tabs.Add(_('Permissions'), PermsWidget())
        tabs.Add(_('Icons'), Icons.Icons_Widget())
        tabs.Add(_('Mime types'), Mime.MIME_Widget())

        page = Page.Base(_("General"), body_id='general', helps=HELPS)
        page += CTK.RawHTML("<h1>%s</h1>" % (_('General Settings')))
        page += tabs
        page += CTK.RawHTML(js=JS_SCROLL)

        return page.Render()
コード例 #18
0
ファイル: Music.py プロジェクト: sljrobin/.dotfiles
    def show_song(self):
        """Shows information about the current playing song.
        """
        icon = Icons.Icons()  # Icon

        # Getting status
        status = self.__get_music_status()
        if status == "playing":
            icon.show_icon("music_play")
            self.__format_metadata(Colors.CL_BASE0B, Colors.CL_BASE0D,\
                                   Colors.CL_BASE0A, Colors.CL_BASE08,\
                                   Colors.CL_BASE09, Colors.CL_BASE0E)
        elif status == "paused":
            icon.show_icon("music_pause")
            self.__format_metadata(Colors.CL_BASE04, Colors.CL_BASE04,\
                                   Colors.CL_BASE04, Colors.CL_BASE04,\
                                   Colors.CL_BASE04, Colors.CL_BASE04)
        else:
            icon.show_icon("music_stop")
コード例 #19
0
ファイル: Preferences.py プロジェクト: Tayyib/uludag
    def __init__(self, parent=None):
        PreferencesDialog.PreferencesDialog.__init__(self, parent)
        
        #add icons to buttons
        self.addButton.setIconSet(Icons.loadIconSet("add", KIcon.Small))
        self.editButton.setIconSet(Icons.loadIconSet("configure", KIcon.Small))
        self.removeButton.setIconSet(Icons.loadIconSet("remove", KIcon.Small))
        self.moveUpButton.setIconSet(Icons.loadIconSet("up", KIcon.Small))
        self.moveDownButton.setIconSet(Icons.loadIconSet("down", KIcon.Small))
        self.buttonOk.setIconSet(Icons.loadIconSet("ok", KIcon.Small))
        self.buttonCancel.setIconSet(Icons.loadIconSet("cancel", KIcon.Small))
        self.buttonHelp.setIconSet(Icons.loadIconSet("help1", KIcon.Small))

        self.parent = parent
        self.connect(self.addButton, SIGNAL("clicked()"), self.addNewRepo)
        self.connect(self.editButton, SIGNAL("clicked()"), self.editRepo)
        self.connect(self.removeButton, SIGNAL("clicked()"), self.removeRepo)
        self.connect(self.repoListView, SIGNAL("selectionChanged()"), self.updateButtons)
        self.connect(self.moveUpButton, SIGNAL("clicked()"), self.moveUp)
        self.connect(self.moveDownButton, SIGNAL("clicked()"), self.moveDown)
        self.connect(self.buttonOk, SIGNAL("clicked()"), self.saveSettings)
        self.connect(self.intervalCheck, SIGNAL("toggled(bool)"), self.enableCheckInterval)
        self.connect(self.useCacheCheck, SIGNAL("toggled(bool)"), self.enableUseCache)
        self.connect(self.clearCacheButton, SIGNAL("clicked()"), self.clearAllCached)
        self.connect(self.buttonHelp, SIGNAL("clicked()"), self.showHelp)

        self.editButton.setEnabled(False)
        self.removeButton.setEnabled(False)

        self.repoListView.setSorting(-1)
        self.updateListView()
        self.updateButtons()

        self.onlyGuiApp.setChecked(self.parent.settings.getBoolValue(Settings.general, "ShowOnlyGuiApp"))
        self.intervalCheck.setChecked(self.parent.settings.getBoolValue(Settings.general, "UpdateCheck"))
        self.intervalSpin.setValue(self.parent.settings.getNumValue(Settings.general, "UpdateCheckInterval"))
        self.systemTray.setChecked(self.parent.settings.getBoolValue(Settings.general, "SystemTray"))
        self.getCacheSettings()
        self.reposChanged = False
コード例 #20
0
    def __init__(self, parent, icon, text=None, callback=None, tooltip=None):
        QToolButton.__init__(self, parent)

        self.setIconSet(QIconSet(Icons.load(icon)))

        if type(text) != types.StringType:
            tooltip = callback
            callback = text
        else:
            self.setTextLabel(text)
            self.setTextPosition(QToolButton.BesideIcon)
            self.setUsesTextLabel(True)

        if callback is not None:
            QObject.connect(self, SIGNAL("clicked()"), callback)

        if tooltip is not None:
            QToolTip.add(self, tooltip)

        self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
コード例 #21
0
    def __init__(self, parent, icon, text=None, callback=None, tooltip=None):
        QToolButton.__init__(self, parent)

        self.setIconSet(QIconSet(Icons.load(icon)))

        if type(text) != types.StringType:
            tooltip = callback
            callback = text
        else:
            self.setTextLabel(text)
            self.setTextPosition(QToolButton.BesideIcon)
            self.setUsesTextLabel(True)

        if callback is not None:
            QObject.connect(self, SIGNAL("clicked()"), callback)

        if tooltip is not None:
            QToolTip.add(self, tooltip)

        self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
コード例 #22
0
ファイル: Clock.py プロジェクト: sljrobin/.dotfiles
    def get_uptime(self):
        """Prints the current uptime.
        """
        icon = Icons.Icons()  # Icon
        unit_m = 60  # Unit: Minute
        unit_h = unit_m * 60  # Unit: Hour
        unit_d = unit_h * 24  # Unit: Day

        # Opening file containing information
        try:
            data_file = open("/proc/uptime")
            data = data_file.read().split()
            data_file.close()
        except:
            sys.stdout.write("^fg(%s)!E! UptimeFile^fg()" % Colors.CL_BASE08)

        # Selecting information
        value = float(data[0])

        # Casting in good time units
        value_d = int(value / unit_d)
        value_h = int((value % unit_d) / unit_h)
        value_m = int((value % unit_h) / unit_m)
        value_s = int(value % unit_m)

        # Adding leading zeros
        value_d_fmt = str(value_d).zfill(2)
        value_h_fmt = str(value_h).zfill(2)
        value_m_fmt = str(value_m).zfill(2)
        value_s_fmt = str(value_s).zfill(2)

        # Printing information
        icon.show_icon("uptime")
        sys.stdout.write("%s:" % value_d_fmt)
        sys.stdout.write("%s:" % value_h_fmt)
        sys.stdout.write("%s:" % value_m_fmt)
        sys.stdout.write("%s" % value_s_fmt)
コード例 #23
0
ファイル: Appli.py プロジェクト: FedoraScientific/salome-yacs
  def initActions(self):
    self.actions = []

    self.newAct=QAction('New', QIconSet(Icons.get_image("new")), '&New',
                          QKeySequence("CTRL+N"),self)
    self.newAct.setStatusTip('Open an empty editor window')
    self.newAct.setWhatsThis( """<b>New</b>"""
            """<p>An empty editor window will be created.</p>""")
    self.newAct.connect(self.newAct,SIGNAL('activated()'), self.newProc)
    self.actions.append(self.newAct)

    self.prefAct=QAction('Preferences',QIconSet(Icons.get_image("configure.png")),'&Preferences...',
                           0, self)
    self.prefAct.setStatusTip('Set the prefered configuration')
    self.prefAct.setWhatsThis("""<b>Preferences</b>"""
                              """<p>Set the configuration items of the application"""
                              """ with your prefered values.</p>""")
    self.prefAct.connect(self.prefAct,SIGNAL('activated()'), self.handlePreferences)
    self.actions.append(self.prefAct)

    self.runAct=QAction('Run',QIconSet(Icons.get_image("run.png")),'&Run',0,self)
    self.runAct.connect(self.runAct,SIGNAL('activated()'), self.run)
    self.runAct.setStatusTip('Run the selected schema')
    self.actions.append(self.runAct)

    self.suspAct=QAction('Suspend/resume',QIconSet(Icons.get_image("suspend-resume.gif")),'&Suspend/resume',0,self)
    self.suspAct.connect(self.suspAct,SIGNAL('activated()'), self.susp)
    self.suspAct.setStatusTip('Suspend/resume the selected schema')
    self.actions.append(self.suspAct)

    self.stepAct=QAction('Step',QIconSet(Icons.get_image("steps.png")),'&Step',0,self)
    self.stepAct.connect(self.stepAct,SIGNAL('activated()'), self.step)
    self.stepAct.setStatusTip('Step the selected schema')
    self.actions.append(self.stepAct)

    self.stopAct=QAction('Stop',QIconSet(Icons.get_image("kill.png")),'&Stop',0,self)
    self.stopAct.connect(self.stopAct,SIGNAL('activated()'), self.stop)
    self.stopAct.setStatusTip('Stop the selected schema')
    self.actions.append(self.stopAct)

    self.cataToolAct=QAction('Catalog Tool',0,self,"catatool")
    self.cataToolAct.connect(self.cataToolAct,SIGNAL('activated()'), self.cata_tool)
    self.actions.append(self.cataToolAct)
コード例 #24
0
 def enableCommand(self):
     self.cmdExecute.setTextLabel(self.cmdObject.userName())
     self.cmdExecute.setEnabled(True)
     self.cmdExecute.setIconSet(QIconSet(Icons.load("launch")))
コード例 #25
0
 def commandLaunched(self,*args):
     self.cmdExecute.setTextLabel("abort")
     self.cmdExecute.setIconSet(QIconSet(Icons.load("stop")))
コード例 #26
0
 def enableCommand(self):
     self.cmdExecute.setTextLabel(self.cmdObject.userName())
     self.cmdExecute.setEnabled(True)
     self.cmdExecute.setIconSet(QIconSet(Icons.load("launch")))
コード例 #27
0
    def show_wifi(self):
        """Handles all the information about WiFi.
        """
        icon = Icons.Icons()  # Icon

        # Getting WiFi Device and checking there is an existing one
        wifi_device = self.__get_wifi_device()
        # No device
        if wifi_device == None:
            icon.show_icon("offline")
        # Device found
        else:
            # Getting unsecured networks
            #self.__get_wifi_unsecured_networks(wifi_device)

            # Executing command and parsing output
            cmd = subprocess.Popen(['/sbin/iwconfig', wifi_device],\
                stdout=subprocess.PIPE)
            cmd_out, cmd_err = cmd.communicate()
            cmd_outparsed = cmd_out.split('\n')
            
            # Looking for WiFi information
            for line in cmd_outparsed:
                if "ESSID" in line:
                    wifi_essid = self.__get_wifi_essid(line)
                if "Link Quality" in line:
                    wifi_quality = self.__get_wifi_quality(line)
                if "Signal level" in line:
                    wifi_signal = self.__get_wifi_signal(line)
                    wifi_signal_dbm = self.__get_wifi_signal_dbm(line)

            # ESSID
            if wifi_essid == "off/any":
                sys.stdout.write("")
            else:
                sys.stdout.write("^fg(%s) [^fg()^fg(%s)%s^fg()^fg(%s)]  ^fg()" %\
                    (Colors.CL_BASE02,\
                     Colors.CL_BASE0E, wifi_essid,\
                     Colors.CL_BASE02))

            # Average
            self.__get_wifi_percentage_average(wifi_quality, wifi_signal)

            # Signal: Fair
            if 0 <= wifi_signal <= 29:
                sys.stdout.write("^fg(%s)%s%%^fg() " %\
                    (Colors.CL_BASE08, wifi_signal))
                sys.stdout.write("^fg(%s)[^fg()^fg(%s)%s dBm^fg()^fg(%s)]^fg()" %\
                    (Colors.CL_BASE02,\
                     Colors.CL_BASE03, wifi_signal_dbm,\
                     Colors.CL_BASE02))
            # Signal: Good
            elif 30 <= wifi_quality <= 39:
                sys.stdout.write("^fg(%s)%s%%^fg() " %\
                    (Colors.CL_BASE0D, wifi_signal))
                sys.stdout.write("^fg(%s)[^fg()^fg(%s)%s dBm^fg()^fg(%s)]^fg()" %\
                    (Colors.CL_BASE02,\
                     Colors.CL_BASE03, wifi_signal_dbm,\
                     Colors.CL_BASE02))
            # Signal: Excellent
            elif 40 <= wifi_quality <= 100:
                sys.stdout.write("^fg(%s)%s%%^fg() " %\
                    (Colors.CL_BASE0B, wifi_signal))
                sys.stdout.write("^fg(%s)[^fg()^fg(%s)%s dBm^fg()^fg(%s)]^fg()" %\
                    (Colors.CL_BASE02,\
                     Colors.CL_BASE03, wifi_signal_dbm,\
                     Colors.CL_BASE02))

            sys.stdout.write("^fg(%s) / ^fg()" % Colors.CL_BASE04)

            # Link Quality: Fair
            if 0 <= wifi_quality <= 49:
                sys.stdout.write("^fg(%s)%s%%^fg()" %\
                    (Colors.CL_BASE08, wifi_quality))
            # Link Quality: Good
            elif 50 <= wifi_quality <= 79:
                sys.stdout.write("^fg(%s)%s%%^fg()" %\
                    (Colors.CL_BASE0D, wifi_quality))
            # Link Quality: Excellent
            elif 80 <= wifi_quality <= 100:
                sys.stdout.write("^fg(%s)%s%%^fg()" %\
                    (Colors.CL_BASE0B, wifi_quality))
コード例 #28
0
    def show_info(self):
        """Shows all information for Battery.
        """
        icon = Icons.Icons()  # Icon

        # Getting information
        info_ac = self.__get_ac()  # AC
        info_bat0 = self.__get_power(BAT0_N, BAT0_F)  # Bat 0
        info_bat1 = self.__get_power(BAT1_N, BAT1_F)  # Bat 1
        info_batx = (info_bat0 + info_bat1) / 2  # Bat x
        info_time = self.__get_time()  # Time

        # Handling icon: AC: ON
        if info_ac == '1':
            icon.show_icon("ac")
        # Handling icon: AC: OFF
        elif info_ac == '0':
            # Battery power average: 000 - 009
            if 0 <= info_batx <= 9:
                icon.show_icon("battery010")
            # Battery power average: 010 - 019
            elif 10 <= info_batx <= 19:
                icon.show_icon("battery020")
            # Battery power average: 020 - 029
            elif 20 <= info_batx <= 29:
                icon.show_icon("battery030")
            # Battery power average: 030 - 039
            elif 30 <= info_batx <= 39:
                icon.show_icon("battery040")
            # Battery power average: 040 - 049
            elif 40 <= info_batx <= 49:
                icon.show_icon("battery050")
            # Battery power average: 050 - 059
            elif 50 <= info_batx <= 59:
                icon.show_icon("battery060")
            # Battery power average: 060 - 069
            elif 60 <= info_batx <= 69:
                icon.show_icon("battery070")
            # Battery power average: 070 - 079
            elif 70 <= info_batx <= 79:
                icon.show_icon("battery080")
            # Battery power average: 080 - 089
            elif 80 <= info_batx <= 89:
                icon.show_icon("battery090")
            # Battery power average: 090 - 100
            elif 90 <= info_batx <= 100:
                icon.show_icon("battery100")
            # Battery power average: case not handled
            else:
                sys.stdout.write("^fg(%s)!E! BatxTime^fg()" %\
                    Colors.CL_BASE08)
                icon.show_icon("ac")

        # Battery's Time
        sys.stdout.write("^fg(%s)%s^fg()" % (Colors.CL_BASE04, info_time))
        sys.stdout.write(" ")

        # Battery 0: 000% - 010%
        if 0 <= info_bat0 <= 10:
            sys.stdout.write("^fg(%s)%s%%^fg()" %\
                (Colors.CL_BASE08, info_bat0))
        # Battery 0: 011% - 035%
        elif 11 <= info_bat0 <= 35:
            sys.stdout.write("^fg(%s)%s%%^fg()" %\
                (Colors.CL_BASE09, info_bat0))
        # Battery 0: 036% - 075%
        elif 36 <= info_bat0 <= 75:
            sys.stdout.write("^fg(%s)%s%%^fg()" %\
                (Colors.CL_BASE0D, info_bat0))
        # Battery 0: 076% - 100%
        elif 76 <= info_bat0 <= 100:
            sys.stdout.write("^fg(%s)%s%%^fg()" %\
                (Colors.CL_BASE0B, info_bat0))
        # Battery 0: Case not handled
        else:
            sys.stdout.write("^fg(%s)!E! Bat0Per^fg()" % Colors.CL_BASE08)

        sys.stdout.write(" ")

        # Battery 1: 000% - 010%
        if 0 <= info_bat1 <= 10:
            sys.stdout.write("^fg(%s)%s%%^fg()" %\
                (Colors.CL_BASE08, info_bat1))
        # Battery 1: 011% - 035%
        elif 11 <= info_bat1 <= 35:
            sys.stdout.write("^fg(%s)%s%%^fg()" %\
                (Colors.CL_BASE09, info_bat1))
        # Battery 1: 036% - 075%
        elif 36 <= info_bat1 <= 75:
            sys.stdout.write("^fg(%s)%s%%^fg()" %\
                (Colors.CL_BASE0D, info_bat1))
        # Battery 1: 076% - 100%
        elif 76 <= info_bat1 <= 100:
            sys.stdout.write("^fg(%s)%s%%^fg()" %\
                (Colors.CL_BASE0B, info_bat1))
        # Battery 1: Case not handled
        else:
            sys.stdout.write("^fg(%s)!E! Bat1Per^fg()" % Colors.CL_BASE08)
コード例 #29
0
    def __init__(self, cmdObject, *args):
        QVBox.__init__(self, *args)
        
        self.cmdObject = cmdObject
        self.entryWidgets = {}
        self.arguments = cmdObject.getArguments()

        self.setSpacing(5)
        self.setMargin(0)

        if len(self.arguments) > 0: 
          entryWidgetsGrid = QGrid(3, self)
          entryWidgetsGrid.setSpacing(0)
          entryWidgetsGrid.setMargin(5)

          for argname, argtype, onchange, valuefrom in self.arguments:
	    QLabel(argname, entryWidgetsGrid)
            QLabel(' : ', entryWidgetsGrid)
            cmdobj = DummyCallable()
            chanobj = None
            if onchange is not None:
               cmd, container_ref = onchange
               container = container_ref()
               if container is not None:
                 cmdobj = container.getCommandObject(cmd)
            if valuefrom is not None:
               chan, container_ref = valuefrom
               container = container_ref()
               if container is not None:
                  chanobj = container.getChannelObject(chan)
                  
            if argtype == 'combo':
                combobox = QComboBox(entryWidgetsGrid)
                combobox._items = {}
                for name, value in cmdObject.getComboArgumentItems(argname):
                    combobox.insertItem(name)
                    combobox._items[name]=value
                    
                    def activated(text, widget=combobox, cmdobj=cmdobj):
                        cmdobj(str(widget._items[str(text)]))

                    QObject.connect(combobox, SIGNAL("activated(const QString&)"), activated)
                combobox._activated=activated   
                def valuechanged(value, widget=combobox, chanobj=chanobj):
                    try:
                      for i in range(widget.count()):
                        if widget._items[str(widget.text(i))]==value:
                           widget.setCurrentItem(i)
                           break
                    except:
                      logging.getLogger().exception("%s: could not set item", self.name())
                if chanobj is not None:
                    chanobj.connectSignal("update", valuechanged)
                
                combobox._valuechanged=valuechanged
                self.entryWidgets[argname] = combobox 
            else:
                lineedit=QLineEdit('', entryWidgetsGrid)
                def onreturnpressed(widget=lineedit, cmdobj=cmdobj):
                    cmdobj(str(widget.text()))
                QObject.connect(lineedit, SIGNAL("returnPressed()"), onreturnpressed) 
                def valuechanged(value, widget=lineedit, chanobj=chanobj):
                    try:
                       widget.setText(str(value))
                    except:
                      logging.getLogger().exception("%s: could not set text", self.name())
                if chanobj is not None:
                    chanobj.connectSignal("update", valuechanged)
                lineedit._valuechanged=valuechanged
                lineedit._onreturnpressed=onreturnpressed
                self.entryWidgets[argname]=lineedit
            self.entryWidgets[argname]._onchange = cmdobj
            self.entryWidgets[argname]._from = chanobj
        cmdExecuteBox = QHBox(self)
        HorizontalSpacer(cmdExecuteBox)
        self.cmdExecute = QToolButton(cmdExecuteBox)
        self.cmdExecute.setTextLabel(cmdObject.userName())
        self.cmdExecute.setUsesTextLabel(True)
        self.cmdExecute.setIconSet(QIconSet(Icons.load("launch")))
        self.cmdExecute.setTextPosition(QToolButton.BesideIcon)
        HorizontalSpacer(cmdExecuteBox)        

        cmdObject.connectSignal("commandBeginWaitReply", self.commandLaunched)
        cmdObject.connectSignal('commandReplyArrived', self.commandReplyArrived)
        cmdObject.connectSignal('commandFailed', self.commandReplyArrived)
        cmdObject.connectSignal('commandAborted', self.commandReplyArrived)
        cmdObject.connectSignal('connected', self.connected)
        cmdObject.connectSignal('disconnected', self.disconnected)
	cmdObject.connectSignal('commandReady', self.enableCommand)
	cmdObject.connectSignal('commandNotReady', self.disableCommand)
        self.connect(self.cmdExecute, SIGNAL('clicked()'), self.launchCommand)
コード例 #30
0
 def commandLaunched(self, *args):
     self.cmdExecute.setTextLabel("abort")
     self.cmdExecute.setIconSet(QIconSet(Icons.load("stop")))
コード例 #31
0
ファイル: YEAP.py プロジェクト: ExtraordinaryBen/YEAP
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        QMetaType.type("QItemSelection")
        self.setWindowTitle(APP_NAME)
        self.icons = Icons()
        self.setWindowIcon(self.style().standardIcon(QStyle.SP_TitleBarMenuButton))
        #self.setMinimumSize(500, 350)
        self.resize(500, 350)
        #self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)

        self.main_widget = MainWidget(self)
        self.setCentralWidget(self.main_widget)

        #Top ToolBar
        self.tb = self.addToolBar("Menu")
        self.tb.setMovable(False)
        self.tb.setContextMenuPolicy(Qt.PreventContextMenu)

        self.newAction = QAction(self.icons.New, "New", self)
        self.tb.addAction(self.newAction)
        self.newAction.triggered.connect(self.main_widget.newAnimation)
        self.newAction.setEnabled(False)

        self.openAction = QAction(self.icons.Open, "Open", self)
        self.tb.addAction(self.openAction)
        self.openAction.triggered.connect(self.main_widget.openAnimation)

        self.appendAction = QAction(self.icons.Append, "Append", self)
        self.tb.addAction(self.appendAction)
        self.appendAction.triggered.connect(self.main_widget.appendAnimation)
        self.appendAction.setEnabled(False)

        self.saveAction = QAction(self.icons.Save, "Save", self)
        self.tb.addAction(self.saveAction)
        self.saveAction.triggered.connect(self.main_widget.saveAnimation)
        self.saveAction.setEnabled(False)

        self.saveAsAction = QAction(self.icons.SaveAs, "SaveAs", self)
        self.tb.addAction(self.saveAsAction)
        self.saveAsAction.triggered.connect(self.main_widget.saveAsAnimation)
        self.saveAsAction.setEnabled(False)

        self.exportMP4Action = QAction(self.icons.Movie, "Export to MP4", self)
        self.tb.addAction(self.exportMP4Action)
        self.exportMP4Action.triggered.connect(self.main_widget.exportAnimation)
        self.exportMP4Action.setEnabled(False)

        self.tb.addWidget(SpacerWidget())

        #self.undoAction = QAction(self.icons.Undo, "Undo", self)
        #self.tb.addAction(self.undoAction)
        #self.undoAction.triggered.connect(self.main_widget.undoLastAction)
        #self.undoAction.setEnabled(False)

        self.copyAction = QAction(self.icons.Copy, "Copy", self)
        self.tb.addAction(self.copyAction)
        self.copyAction.triggered.connect(self.main_widget.copyFrame)
        self.copyAction.setEnabled(False)

        self.pasteAction = QAction(self.icons.Paste, "Paste", self)
        self.tb.addAction(self.pasteAction)
        self.pasteAction.triggered.connect(self.main_widget.pasteFrame)
        self.pasteAction.setEnabled(False)

        self.deleteAction = QAction(self.icons.Delete, "Delete", self)
        self.tb.addAction(self.deleteAction)
        self.deleteAction.triggered.connect(self.main_widget.deleteFrames)
        self.deleteAction.setEnabled(False)

        self.tb.addSeparator()

        self.optionsMenu = QMenu("Options", self)
        self.hideListAction = QAction("Hide Frame Reel", self.optionsMenu)
        self.hideListAction.setCheckable(True)
        self.hideListAction.triggered.connect(self.main_widget.toggleList)
        self.optionsMenu.addAction(self.hideListAction)

        self.optionButton = QToolButton(self)
        self.optionButton.setPopupMode(QToolButton.InstantPopup)
        self.optionButton.setFocusPolicy(Qt.NoFocus)
        self.optionButton.setIcon(self.icons.Options)
        self.optionButton.setMenu(self.optionsMenu)
        self.tb.addWidget(self.optionButton)
        #self.optionsMenu.triggered.connect()

        #Bottom ToolBar
        self.tb2 = QToolBar("PlayerControls")
        self.tb2.setMovable(False)
        self.tb2.setContextMenuPolicy(Qt.PreventContextMenu)

        self.tb2.addWidget(SpacerWidget())

        self.startAction = QAction(self.icons.Start, "First Frame", self)
        self.startAction.setEnabled(False)
        self.tb2.addAction(self.startAction)
        self.startAction.triggered.connect(self.main_widget.firstFrame)

        self.backAction = QAction(self.icons.Back, "Back Frame", self)
        self.backAction.setEnabled(False)
        self.tb2.addAction(self.backAction)
        self.backAction.triggered.connect(self.main_widget.backFrame)

        self.playBeginningAction = QAction(self.icons.PlayBeginning, "Play from Beginning", self)
        self.playBeginningAction.setEnabled(False)
        self.tb2.addAction(self.playBeginningAction)
        self.playBeginningAction.triggered.connect(self.main_widget.playBeginningAnimation)

        self.playAction = QAction(self.icons.Play, "Play", self)
        self.playAction.setEnabled(False)
        self.tb2.addAction(self.playAction)
        self.playAction.triggered.connect(self.main_widget.playCurrentAnimation)

        self.stopAction = QAction(self.icons.Stop, "Stop", self)
        self.stopAction.setEnabled(False)
        self.tb2.addAction(self.stopAction)
        self.stopAction.triggered.connect(self.main_widget.stopPlaying)

        self.loopAction = QAction(self.icons.Loop, "Loop", self)
        self.loopAction.setEnabled(False)
        self.loopAction.setCheckable(True)
        self.loopAction.triggered.connect(self.main_widget.ChangesMade)
        self.tb2.addAction(self.loopAction)

        self.nextAction = QAction(self.icons.Next, "Next Frame", self)
        self.nextAction.setEnabled(False)
        self.tb2.addAction(self.nextAction)
        self.nextAction.triggered.connect(self.main_widget.nextFrame)

        self.endAction = QAction(self.icons.End, "Last Frame", self)
        self.endAction.setEnabled(False)
        self.tb2.addAction(self.endAction)
        self.endAction.triggered.connect(self.main_widget.lastFrame)

        self.tb2.addWidget(SpacerWidget())

        self.dw = DelayWidget(self.tb)
        self.dw.delayLine.valueChanged.connect(self.main_widget.delay_handler)
        self.tb2.addWidget(self.dw)

        self.addToolBar(Qt.BottomToolBarArea, self.tb2)

        self.center()
コード例 #32
0
    def __init__(self, cmdObject, *args):
        QVBox.__init__(self, *args)

        self.cmdObject = cmdObject
        self.entryWidgets = {}
        self.arguments = cmdObject.getArguments()

        self.setSpacing(5)
        self.setMargin(0)

        if len(self.arguments) > 0:
            entryWidgetsGrid = QGrid(3, self)
            entryWidgetsGrid.setSpacing(0)
            entryWidgetsGrid.setMargin(5)

            for argname, argtype, onchange, valuefrom in self.arguments:
                QLabel(argname, entryWidgetsGrid)
                QLabel(' : ', entryWidgetsGrid)
                cmdobj = DummyCallable()
                chanobj = None
                if onchange is not None:
                    cmd, container_ref = onchange
                    container = container_ref()
                    if container is not None:
                        cmdobj = container.getCommandObject(cmd)
                if valuefrom is not None:
                    chan, container_ref = valuefrom
                    container = container_ref()
                    if container is not None:
                        chanobj = container.getChannelObject(chan)

                if argtype == 'combo':
                    combobox = QComboBox(entryWidgetsGrid)
                    combobox._items = {}
                    for name, value in cmdObject.getComboArgumentItems(
                            argname):
                        combobox.insertItem(name)
                        combobox._items[name] = value

                        def activated(text, widget=combobox, cmdobj=cmdobj):
                            cmdobj(str(widget._items[str(text)]))

                        QObject.connect(combobox,
                                        SIGNAL("activated(const QString&)"),
                                        activated)
                    combobox._activated = activated

                    def valuechanged(value, widget=combobox, chanobj=chanobj):
                        try:
                            for i in range(widget.count()):
                                if widget._items[str(widget.text(i))] == value:
                                    widget.setCurrentItem(i)
                                    break
                        except:
                            logging.getLogger().exception(
                                "%s: could not set item", self.name())

                    if chanobj is not None:
                        chanobj.connectSignal("update", valuechanged)

                    combobox._valuechanged = valuechanged
                    self.entryWidgets[argname] = combobox
                else:
                    lineedit = QLineEdit('', entryWidgetsGrid)

                    def onreturnpressed(widget=lineedit, cmdobj=cmdobj):
                        cmdobj(str(widget.text()))

                    QObject.connect(lineedit, SIGNAL("returnPressed()"),
                                    onreturnpressed)

                    def valuechanged(value, widget=lineedit, chanobj=chanobj):
                        try:
                            widget.setText(str(value))
                        except:
                            logging.getLogger().exception(
                                "%s: could not set text", self.name())

                    if chanobj is not None:
                        chanobj.connectSignal("update", valuechanged)
                    lineedit._valuechanged = valuechanged
                    lineedit._onreturnpressed = onreturnpressed
                    self.entryWidgets[argname] = lineedit
                self.entryWidgets[argname]._onchange = cmdobj
                self.entryWidgets[argname]._from = chanobj
        cmdExecuteBox = QHBox(self)
        HorizontalSpacer(cmdExecuteBox)
        self.cmdExecute = QToolButton(cmdExecuteBox)
        self.cmdExecute.setTextLabel(cmdObject.userName())
        self.cmdExecute.setUsesTextLabel(True)
        self.cmdExecute.setIconSet(QIconSet(Icons.load("launch")))
        self.cmdExecute.setTextPosition(QToolButton.BesideIcon)
        HorizontalSpacer(cmdExecuteBox)

        cmdObject.connectSignal("commandBeginWaitReply", self.commandLaunched)
        cmdObject.connectSignal('commandReplyArrived',
                                self.commandReplyArrived)
        cmdObject.connectSignal('commandFailed', self.commandReplyArrived)
        cmdObject.connectSignal('commandAborted', self.commandReplyArrived)
        cmdObject.connectSignal('connected', self.connected)
        cmdObject.connectSignal('disconnected', self.disconnected)
        cmdObject.connectSignal('commandReady', self.enableCommand)
        cmdObject.connectSignal('commandNotReady', self.disableCommand)
        self.connect(self.cmdExecute, SIGNAL('clicked()'), self.launchCommand)
コード例 #33
0
ファイル: Template.py プロジェクト: alexs2112/MTG-ProxyEngine
 def __init__(self, all_cards):
     Template.__init__(self, all_cards)
     self.icons = Icons.Icons()