当前位置: 首页>>代码示例>>Python>>正文


Python QMenu.setStyleSheet方法代码示例

本文整理汇总了Python中PyQt5.QtWidgets.QMenu.setStyleSheet方法的典型用法代码示例。如果您正苦于以下问题:Python QMenu.setStyleSheet方法的具体用法?Python QMenu.setStyleSheet怎么用?Python QMenu.setStyleSheet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtWidgets.QMenu的用法示例。


在下文中一共展示了QMenu.setStyleSheet方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: contextMenuEvent

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import setStyleSheet [as 别名]
    def contextMenuEvent(self,event):
        # print(dir(event))
        rightMenu = QMenu(self)
        # rightMenu.setWindowOpacity(0.9); 
        # pos = QGraphicsColorizeEffect(rightMenu)
        # pos.setColor(QColor("red"))
        # pos.setStrength()
        # rightMenu.setGraphicsEffect(pos)
        

        # print(dir(rightMenu))
        rightMenu.setStyleSheet(qss_rightmenu) 
        loveAction = QAction(u"添加收藏", self, triggered=self.noexc)
        delAction = QAction(u"删除文件", self, triggered=self.deleteSongItem)    
        rateAction = QAction(u"我要打分", self, triggered=self.noexc)    
        cmAction = QAction(u"评论", self, triggered=self.noexc)  
        moreAction = QAction(u"歌曲详情", self, triggered=self.noexc)  
        moneyAction = QAction(u"打赏", self, triggered=self.noexc)  
        rightMenu.addAction(loveAction)
        rightMenu.addAction(delAction)
        rightMenu.addAction(rateAction)
        rightMenu.addAction(cmAction)
        rightMenu.addAction(moreAction)
        rightMenu.addAction(moneyAction)
        rightMenu.exec_(QCursor.pos())
开发者ID:codeAB,项目名称:music-player,代码行数:27,代码来源:mywidget.py

示例2: contextMenuEvent

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import setStyleSheet [as 别名]
 def contextMenuEvent(self, QContextMenuEvent):
     menu = QMenu()
     show_in_hex_view = menu.addAction("Show in HexView")
     show_in_disassembler = menu.addAction("Show in Disassembler")
     font_size = self.font().pointSize()
     menu.setStyleSheet("font-size: " + str(font_size) + "pt;")
     action = menu.exec_(QContextMenuEvent.globalPos())
     if action == show_in_hex_view:
         parent = GuiUtils.search_parents_by_function(self, "hex_dump_address")
         if parent.objectName() == "MainWindow_MemoryView":
             address = self.text().split("=")[-1]
             address_int = int(address, 16)
             parent.hex_dump_address(address_int)
     elif action == show_in_disassembler:
         parent = GuiUtils.search_parents_by_function(self, "disassemble_expression")
         if parent.objectName() == "MainWindow_MemoryView":
             address = self.text().split("=")[-1]
             parent.disassemble_expression(address)
开发者ID:korcankaraokcu,项目名称:PINCE,代码行数:20,代码来源:RegisterLabel.py

示例3: rightMenuShow

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import setStyleSheet [as 别名]
	def rightMenuShow(self,point):
		self.current_context_item = self.songList.itemAt(point)
		if self.current_context_item is None:
			return False
		rightMenu = QMenu(self.songList)
		# print(dir(rightMenu))
		rightMenu.setStyleSheet("QMenu{ width:100px;border:none;padding:5px; } QMenu::item{ background-color: transparent;width:70px;text-align:center;height:25px; margin:0px 0px;border-bottom:1px solid #EEE;padding-left:20px;color:#333 }  QMenu::item:selected{ color:red;border-bottom:1px solid pink;background:none; }") 
		loveAction = QAction(u"添加收藏", self, triggered=self.deleteSongItem)
		delAction = QAction(u"删除", self, triggered=self.deleteSongItem)    
		rateAction = QAction(u"我要打分", self, triggered=self.deleteSongItem)    
		cmAction = QAction(u"评论", self, triggered=self.deleteSongItem)  
		moreAction = QAction(u"歌曲详情", self, triggered=self.deleteSongItem)  
		moneyAction = QAction(u"打赏", self, triggered=self.deleteSongItem)  
		rightMenu.addAction(loveAction)
		rightMenu.addAction(delAction)
		rightMenu.addAction(rateAction)
		rightMenu.addAction(cmAction)
		rightMenu.addAction(moreAction)
		rightMenu.addAction(moneyAction)
		rightMenu.exec_(QCursor.pos())
开发者ID:codeAB,项目名称:music-player,代码行数:22,代码来源:main.py

示例4: contextMenuEvent

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import setStyleSheet [as 别名]
    def contextMenuEvent(self, event):
        popup_menu = self.createStandardContextMenu()
        # color: rgb(154, 190, 154);
        menu_style = "QMenu { background-color: rgb(38,38,38);selection-color: black; selection-background-color: grey;}"
        popup_menu.setStyleSheet(menu_style)

        # Select the word under the cursor.
        cursor = self.textCursor()
        cursor.select(QTextCursor.WordUnderCursor)
        self.setTextCursor(cursor)

        # Check if the selected word is misspelled and offer spelling
        # suggestions if it is.
        if enchant and self.dict:
            if self.textCursor().hasSelection():
                text = str(self.textCursor().selectedText())
                if self.dict.check(text):
                    self.gotoHelp = QAction('Goto in Help', self)
                    self.gotoHelp.triggered.connect(self.showInHelpFile)
                    popup_menu.insertAction(popup_menu.actions()[0], self.gotoHelp)
                    popup_menu.insertSeparator(popup_menu.actions()[1])
                if not self.dict.check(text):
                    spell_menu = QMenu(QCoreApplication.translate('app', 'Spelling Suggestions'), self)
                    spell_menu.setStyleSheet(menu_style)
                    for word in self.dict.suggest(text):
                        # print('word is ',word)
                        action = SpellAction(word, spell_menu)
                        action.correct.connect(self.correctWord)
                        spell_menu.addAction(action)
                    # Only add the spelling suggests to the menu if there are
                    # suggestions.
                    if len(spell_menu.actions()) != 0:
                        popup_menu.insertSeparator(popup_menu.actions()[0])
                        popup_menu.insertMenu(popup_menu.actions()[0], spell_menu)

        # FIXME: add change dict and disable spellcheck options

        popup_menu.exec_(event.globalPos())
开发者ID:hovo1990,项目名称:GROM,代码行数:40,代码来源:textedit.py

示例5: MainWindow

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import setStyleSheet [as 别名]
class MainWindow(QSystemTrayIcon):

    """Main widget for UnicodEmoticons,not really a window since not needed."""

    def __init__(self, icon, parent=None):
        """Tray icon main widget."""
        super(MainWindow, self).__init__(icon, parent)
        log.info("Iniciando {}.".format(__doc__))
        self.setIcon(icon)
        self.setToolTip(__doc__ + "\nPick 1 Emoticon, use CTRL+V to Paste it!")
        self.traymenu = QMenu("Emoticons")
        self.traymenu.addAction("Emoticons").setDisabled(True)
        self.traymenu.setIcon(icon)
        self.traymenu.setStyleSheet(QSS_STYLE.strip())
        self.traymenu.addSeparator()
        self.activated.connect(self.click_trap)
        # menus
        list_of_labels = sorted(UNICODEMOTICONS.keys())
        menu0 = self.traymenu.addMenu(list_of_labels[0].title())
        menu1 = self.traymenu.addMenu(list_of_labels[1].title())
        menu2 = self.traymenu.addMenu(list_of_labels[2].title())
        menu3 = self.traymenu.addMenu(list_of_labels[3].title())
        menu4 = self.traymenu.addMenu(list_of_labels[4].title())
        menu5 = self.traymenu.addMenu(list_of_labels[5].title())
        menu6 = self.traymenu.addMenu(list_of_labels[6].title())
        menu7 = self.traymenu.addMenu(list_of_labels[7].title())
        menu8 = self.traymenu.addMenu(list_of_labels[8].title())
        menu9 = self.traymenu.addMenu(list_of_labels[9].title())
        menu10 = self.traymenu.addMenu(list_of_labels[10].title())
        menu11 = self.traymenu.addMenu(list_of_labels[11].title())
        menu12 = self.traymenu.addMenu(list_of_labels[12].title())
        menu13 = self.traymenu.addMenu(list_of_labels[13].title())
        menu14 = self.traymenu.addMenu(list_of_labels[14].title())
        menu15 = self.traymenu.addMenu(list_of_labels[15].title())
        menu16 = self.traymenu.addMenu(list_of_labels[16].title())
        menu17 = self.traymenu.addMenu(list_of_labels[17].title())
        menu18 = self.traymenu.addMenu(list_of_labels[18].title())
        menu19 = self.traymenu.addMenu(list_of_labels[19].title())
        menu20 = self.traymenu.addMenu(list_of_labels[20].title())
        menu21 = self.traymenu.addMenu(list_of_labels[21].title())
        menu22 = self.traymenu.addMenu(list_of_labels[22].title())
        menu23 = self.traymenu.addMenu(list_of_labels[23].title())
        menu24 = self.traymenu.addMenu(list_of_labels[24].title())
        menu25 = self.traymenu.addMenu(list_of_labels[25].title())
        menu26 = self.traymenu.addMenu(list_of_labels[26].title())
        menu27 = self.traymenu.addMenu(list_of_labels[27].title())
        menu28 = self.traymenu.addMenu(list_of_labels[28].title())
        menu29 = self.traymenu.addMenu(list_of_labels[29].title())
        menu30 = self.traymenu.addMenu(list_of_labels[30].title())
        menu31 = self.traymenu.addMenu(list_of_labels[31].title())
        menu32 = self.traymenu.addMenu(list_of_labels[32].title())
        self.traymenu.addSeparator()
        menuhtml0 = self.traymenu.addMenu("HTML5 Code")
        for index, item in enumerate((
            menu0, menu1, menu2, menu3, menu4, menu5, menu6, menu7, menu8,
            menu9, menu10, menu11, menu12, menu13, menu14, menu15, menu16,
            menu17, menu18, menu19, menu20, menu21, menu22, menu23, menu24,
            menu25, menu26, menu27, menu28, menu29, menu30, menu31, menu32,
                )):
            item.setStyleSheet(("font-size:25px;padding:0;margin:0;border:0;"
                                "font-family:Oxygen;menu-scrollable:1;"))
            item.setFont(QFont('Oxygen', 25))
            self.build_submenu(UNICODEMOTICONS[list_of_labels[index]], item)
        # html entities
        added_html_entities = []
        menuhtml0.setStyleSheet("font-size:25px;padding:0;margin:0;border:0;")
        for html_char in tuple(sorted(entities.html5.items())):
            if html_char[1] in HTMLS:
                added_html_entities.append(
                    html_char[0].lower().replace(";", ""))
                if not html_char[0].lower() in added_html_entities:
                    action = menuhtml0.addAction(html_char[1])
                    action.triggered.connect(
                        lambda _, ch=html_char[0]:
                            QApplication.clipboard().setText(
                                "&{html_entity}".format(html_entity=ch)))
        self.traymenu.addSeparator()
        # help
        helpMenu = self.traymenu.addMenu("Help...")
        helpMenu.addAction("About Python 3",
                           lambda: open_new_tab('https://www.python.org'))
        helpMenu.addAction("About " + __doc__, lambda: open_new_tab(__url__))
        helpMenu.addSeparator()
        if not sys.platform.startswith("win"):
            helpMenu.addAction("View Source Code", lambda: call(
                ('xdg-open ' if sys.platform.startswith("linux") else 'open ')
                + __file__, shell=True))
        helpMenu.addSeparator()
        helpMenu.addAction("Report Bugs", lambda:
                           open_new_tab(__url__ + '/issues?state=open'))
        helpMenu.addAction("Check for updates", lambda: Downloader())
        self.traymenu.addSeparator()
        self.traymenu.addAction("Quit", lambda: self.close())
        self.setContextMenu(self.traymenu)
        self.show()
        self.add_autostart()

    def build_submenu(self, char_list, submenu):
        """Take a list of characters and a submenu and build actions on it."""
        for _char in sorted(char_list):
#.........这里部分代码省略.........
开发者ID:flying-sheep,项目名称:unicodemoticon,代码行数:103,代码来源:unicodemoticon.py

示例6: Music

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import setStyleSheet [as 别名]
class Music(QWidget):
	def __init__(self):
		super().__init__()
		self.currentSonger = ''
		self.setWindowIcon(QIcon("image/tray.png"))
		self.setWindowTitle("SYL - 音乐盛宴")
		self.setObjectName("box")
		# 窗口无边框
		self.setWindowFlags(Qt.FramelessWindowHint)
		# 窗口居于所有窗口的顶端 
		# self.setWindowFlags(Qt.WindowOverridesSystemGestures)
		# 窗口居于所有窗口的顶端  针对部分X11
		# self.setWindowFlags(Qt.X11BypassWindowManagerHint)
		# 初始化基本UI界面
		self.initUI()
		# 初始化播放核心
		self.initplayer()
		# 显示主界面
		self.show()
		self.widget1 = index()
		self.widget1.setParent(self)

		
		
	def initUI(self):
		# 获取电脑屏幕宽高 让主界面初始化后处于屏幕中间
		wh = QApplication.desktop().screenGeometry()
		self.screen_w , self.screen_h = wh.width() ,wh.height()
		self.setGeometry(int((self.screen_w-300)/2),int((self.screen_h-600)/2),300,600)
		# self.setWindowOpacity(0.97); 

		#当前播放歌曲的封面 
		songer_img = DragLabel(self)
		# songer_img.setwinflag.connect(self.setwinflag)
		songer_img.setParent(self)
		songer_img.resize(300,200)

		self.picture = QLabel(songer_img)
		self.picture.resize(300,200)
		self.picture.setStyleSheet("QLabel{ border-image:url("+conf['pifu']+")}")

		# syl = QLabel(songer_img)
		# syl.setGeometry(15,5,34,15)
		# syl.setStyleSheet("QLabel{ border-image:url(image/newimg/logo.png);}")

		# ================================
		songinfo = QLabel(songer_img)
		songinfo.setGeometry(0,30,300,80)
		songinfo.setStyleSheet("QLabel{ background:transparent;}")

		songpic = QLabel(songinfo)
		songpic.setGeometry(10,0,80,80)
		songpic.setStyleSheet("QLabel{ border-image:url(image/newimg/user.jpg);border-radius:2px;}")

		self.songname = QLabel("老鼠爱大米 - 香香",songinfo)
		self.songname.setGeometry(105,0,210,25)
		self.songname.setStyleSheet("QLabel{ color:#EEE;font-size:15px;}")
		uploaduser = QLabel("By 张三的歌",songinfo)
		uploaduser.move(105,25)
		# uploaduser.setCursor(QCursor(Qt.PointingHandCursor))
		uploaduser.setStyleSheet("QLabel{ color:yellow;font-size:15px;} QLabel:hover{color:red}")

		fenshu = QLabel("评分 - 7.6",songinfo)
		fenshu.setGeometry(105,50,210,25)
		# self.picture.setGraphicsEffect(QGraphicsBlurEffect())
		fenshu.setStyleSheet("QLabel{ color:#EEE;font-size:15px;}")


		songtool = QLabel(songer_img)
		songtool.setGeometry(0,110,300,35)
		songtool.setStyleSheet("QLabel{ background:transparent;}")

		# 喜欢歌曲
		lovesong = QLabel(songtool)
		lovesong.setGeometry(20,10,25,25)
		lovesong.setStyleSheet("QLabel{ border-image:url(image/newimg/kg_ic_player_liked.png);}")
		# 评论
		pinglun = QLabel(songtool)
		pinglun.setGeometry(50,5,33,33)
		pinglun.setStyleSheet("QLabel{ border-image:url(image/newimg/pinglun.png);}")
		# 歌曲更多信息
		songmore = QLabel("查看这首歌的更多资料",songtool)
		songmore.move(100,10)
		# songmore.setCursor(QCursor(Qt.PointingHandCursor))
		songmore.setStyleSheet("QLabel{ color:#BBB} QLabel:hover{color:pink}")


		# ======================================

		# 顶部工具栏
		# 隐藏
		btn = QPushButton("",self)
		btn.setGeometry(270,0,15,32)
		# btn.setCursor(QCursor(Qt.PointingHandCursor))
		btn.setStyleSheet("QPushButton{ border:none;color:white;background:transparent;border-image:url(image/newimg/mini.png) } QPushButton:hover{ border-image:url(image/newimg/mini_2.png) } ")
		btn.clicked.connect(self.close)

		# 换皮肤
		btn = QPushButton("",self)
		btn.setGeometry(230,10,20,20)
#.........这里部分代码省略.........
开发者ID:codeAB,项目名称:music-player,代码行数:103,代码来源:main.py

示例7: MainWindow

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import setStyleSheet [as 别名]
class MainWindow(QSystemTrayIcon):

    """Main widget for UnicodEmoticons,not really a window since not needed."""

    def __init__(self, icon, parent=None):
        """Tray icon main widget."""
        super(MainWindow, self).__init__(icon, parent)
        log.debug("Iniciando {}.".format(__doc__))
        self.setIcon(icon)
        self.setToolTip(__doc__ + "\nPick 1 Emoticon, use CTRL+V to Paste it!")
        self.traymenu = QMenu("Emoticons")
        self.traymenu.addAction("Emoticons").setDisabled(True)
        self.traymenu.setIcon(icon)
        self.traymenu.addSeparator()
        self.activated.connect(self.click_trap)
        # menus
        list_of_labels = sorted(UNICODEMOTICONS.keys())
        menu0 = self.traymenu.addMenu(list_of_labels[0].title())
        menu1 = self.traymenu.addMenu(list_of_labels[1].title())
        menu2 = self.traymenu.addMenu(list_of_labels[2].title())
        menu3 = self.traymenu.addMenu(list_of_labels[3].title())
        menu4 = self.traymenu.addMenu(list_of_labels[4].title())
        menu5 = self.traymenu.addMenu(list_of_labels[5].title())
        menu6 = self.traymenu.addMenu(list_of_labels[6].title())
        menu7 = self.traymenu.addMenu(list_of_labels[7].title())
        menu8 = self.traymenu.addMenu(list_of_labels[8].title())
        menu9 = self.traymenu.addMenu(list_of_labels[9].title())
        menu10 = self.traymenu.addMenu(list_of_labels[10].title())
        menu11 = self.traymenu.addMenu(list_of_labels[11].title())
        menu12 = self.traymenu.addMenu(list_of_labels[12].title())
        menu13 = self.traymenu.addMenu(list_of_labels[13].title())
        menu14 = self.traymenu.addMenu(list_of_labels[14].title())
        menu15 = self.traymenu.addMenu(list_of_labels[15].title())
        menu16 = self.traymenu.addMenu(list_of_labels[16].title())
        menu17 = self.traymenu.addMenu(list_of_labels[17].title())
        menu18 = self.traymenu.addMenu(list_of_labels[18].title())
        menu19 = self.traymenu.addMenu(list_of_labels[19].title())
        menu20 = self.traymenu.addMenu(list_of_labels[20].title())
        menu21 = self.traymenu.addMenu(list_of_labels[21].title())
        menu22 = self.traymenu.addMenu(list_of_labels[22].title())
        menu23 = self.traymenu.addMenu(list_of_labels[23].title())
        menu24 = self.traymenu.addMenu(list_of_labels[24].title())
        menu25 = self.traymenu.addMenu(list_of_labels[25].title())
        menu26 = self.traymenu.addMenu(list_of_labels[26].title())
        menu27 = self.traymenu.addMenu(list_of_labels[27].title())
        menu28 = self.traymenu.addMenu(list_of_labels[28].title())
        menu29 = self.traymenu.addMenu(list_of_labels[29].title())
        menu30 = self.traymenu.addMenu(list_of_labels[30].title())
        menu31 = self.traymenu.addMenu(list_of_labels[31].title())
        menu32 = self.traymenu.addMenu(list_of_labels[32].title())
        self.traymenu.addSeparator()
        menuhtml0 = self.traymenu.addMenu("HTML5 Code")
        log.debug("Building Emoticons SubMenus.")
        for index, item in enumerate((
            menu0, menu1, menu2, menu3, menu4, menu5, menu6, menu7, menu8,
            menu9, menu10, menu11, menu12, menu13, menu14, menu15, menu16,
            menu17, menu18, menu19, menu20, menu21, menu22, menu23, menu24,
            menu25, menu26, menu27, menu28, menu29, menu30, menu31, menu32,
                )):
            item.setStyleSheet(("font-size:25px;padding:0;margin:0;border:0;"
                                "font-family:Oxygen;menu-scrollable:1;"))
            item.setFont(QFont('Oxygen', 25))
            self.build_submenu(UNICODEMOTICONS[list_of_labels[index]], item)
        # html entities
        added_html_entities = []
        menuhtml0.setStyleSheet("font-size:25px;padding:0;margin:0;border:0;")
        for html_char in tuple(sorted(entities.html5.items())):
            if html_char[1] in HTMLS.strip().replace("\n", ""):
                added_html_entities.append(
                    html_char[0].lower().replace(";", ""))
                if not html_char[0].lower() in added_html_entities:
                    action = menuhtml0.addAction(html_char[1])
                    action.hovered.connect(lambda ch=html_char: log.debug(ch))
                    action.triggered.connect(
                        lambda _, ch=html_char[0]:
                            QApplication.clipboard().setText(
                                "&{html_entity}".format(html_entity=ch)))
        self.traymenu.addSeparator()
        # help
        helpMenu = self.traymenu.addMenu("Options...")
        helpMenu.addAction("About Python 3",
                           lambda: open_new_tab('https://python.org'))
        helpMenu.addAction("About Qt 5", lambda: open_new_tab('http://qt.io'))
        helpMenu.addAction("About " + __doc__, lambda: open_new_tab(__url__))
        helpMenu.addSeparator()
        helpMenu.addAction("View Source Code", lambda: open_new_tab(__file__))
        helpMenu.addSeparator()
        helpMenu.addAction("Report Bugs", lambda:
                           open_new_tab(__url__ + '/issues?state=open'))
        helpMenu.addAction("Check for updates", lambda: Downloader())
        helpMenu.addSeparator()
        helpMenu.addAction("Set Icon", self.set_icon)
        helpMenu.addAction("Set UI Style", lambda: open_new_tab(path.join(
            self.get_or_set_config_folder("unicodemoticon"),
            "unicodemoticon.css")))
        self.traymenu.addSeparator()
        self.traymenu.addAction("Quit", lambda: self.close())
        self.setContextMenu(self.traymenu)
        self.show()
        self.add_desktop_files()
#.........这里部分代码省略.........
开发者ID:janusnic,项目名称:unicodemoticon,代码行数:103,代码来源:unicodemoticon.py

示例8: startCybeSystemsApplication

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import setStyleSheet [as 别名]
    def startCybeSystemsApplication(self):

        #Set Loading TrayIcon
        self.setWindowIcon(QtGui.QIcon(appfolder + '/ressource/icons/icon.png'))

        img = QtGui.QImage()
        img.load(appfolder + '/ressource/icons/icon_loading.png')
        self.pixmap = QtGui.QPixmap.fromImage(img)
        self.icon = QtGui.QIcon()
        self.icon.addPixmap(self.pixmap)
        self.tray = QSystemTrayIcon(self.icon, self)
        self.tray.show()
        traymenu = QMenu()

        #Set Real Icon
        self.tray.hide()
        img = QtGui.QImage()
        img.load(appfolder + '/ressource/icons/icon.png')
        self.pixmap = QtGui.QPixmap.fromImage(img)
        self.icon = QtGui.QIcon()
        self.icon.addPixmap(self.pixmap)
        self.tray = QSystemTrayIcon(self.icon, self)
        self.tray.activated.connect(self.onTrayIconActivated)
        self.tray.setContextMenu(traymenu)
        self.tray.show()

        #Load Stylesheet
        if mainSettings['other']['theme'].lower() != 'default':
            if mainSettings['other']['theme'].lower() == 'steamlike':
                stylesheetFile = open(appfolder + '/ressource/ui/steamlike.stylesheet', "r")
            elif mainSettings['other']['theme'].lower() == 'darkorange':
                stylesheetFile = open(appfolder + '/ressource/ui/darkorange.stylesheet', "r")
            elif mainSettings['other']['theme'].lower() == 'maya':
                stylesheetFile = open(appfolder + '/ressource/ui/maya.stylesheet', "r")
            stylesheet = stylesheetFile.read()
            traymenu.setStyleSheet(stylesheet)
            stylesheetFile.close()

        trayoption_openBrowser_entry = QAction(QtGui.QIcon(self.icon), "Open Odoo", self)
        trayoption_openBrowser_entry.triggered.connect(lambda: webbrowser.open(mainSettings['odoo']['startpage']))
        traymenu.addAction(trayoption_openBrowser_entry)
        trayoption_openBrowser_entry.setIcon(QtGui.QIcon(appfolder + '/ressource/icons/world.png'))

        traymenu.addSeparator()

        tools = traymenu.addMenu('&Odoo')
        tools.setIcon(QtGui.QIcon(appfolder + '/ressource/icons/icon.png'))

        tools_odoo_restart = QAction(QtGui.QIcon(self.icon), "Restart Server", self)
        tools_odoo_restart.triggered.connect(lambda: (self.restartOdooMenuItem.emit()))
        tools.addAction(tools_odoo_restart)
        tools_odoo_restart.setIcon(QtGui.QIcon(appfolder + '/ressource/icons/start_server.png'))

        tools_odoo_stop = QAction(QtGui.QIcon(self.icon), "Stop Server", self)
        tools_odoo_stop.triggered.connect(lambda: (self.stopOdooMenuItem.emit()))
        tools.addAction(tools_odoo_stop)
        tools_odoo_stop.setIcon(QtGui.QIcon(appfolder + '/ressource/icons/stop_server.png'))

        #traymenu.addSeparator()

        tools = traymenu.addMenu('&PostgreSQL')
        tools.setIcon(QtGui.QIcon(appfolder + '/ressource/icons/postgresql.png'))

        tools_postgre_restart = QAction(QtGui.QIcon(self.icon), "Restart Server", self)
        tools_postgre_restart.triggered.connect(lambda: (self.restartPostgreMenuItem.emit()))
        tools.addAction(tools_postgre_restart)
        tools_postgre_restart.setIcon(QtGui.QIcon(appfolder + '/ressource/icons/start_server.png'))

        tools_postgre_stop = QAction(QtGui.QIcon(self.icon), "Stop Server", self)
        tools_postgre_stop.triggered.connect(lambda: (self.stopPostgreMenuItem.emit()))
        tools.addAction(tools_postgre_stop)
        tools_postgre_stop.setIcon(QtGui.QIcon(appfolder + '/ressource/icons/stop_server.png'))

        tools.addSeparator()

        tools_pgadmin = QAction(QtGui.QIcon(self.icon), "pgAdmin III", self)
        tools_pgadmin.triggered.connect(lambda: self.startpgadmin())
        tools.addAction(tools_pgadmin)
        tools_pgadmin.setIcon(QtGui.QIcon(appfolder + '/ressource/icons/cog.png'))

        traymenu.addSeparator()

        trayoption_quickconfig = QAction(QtGui.QIcon(self.icon), "Show Output/Config", self)
        trayoption_quickconfig.triggered.connect(lambda: self.showCommandLineWindowTryOption())
        traymenu.addAction(trayoption_quickconfig)
        trayoption_quickconfig.setIcon(QtGui.QIcon(appfolder + '/ressource/icons/application_osx_terminal.png'))

        traymenu.addSeparator()

        trayoption_exit_entry = QAction(QtGui.QIcon(self.icon), "Exit", self)
        trayoption_exit_entry.triggered.connect(lambda: self.trayOptionExit())
        traymenu.addAction(trayoption_exit_entry)
        trayoption_exit_entry.setIcon(QtGui.QIcon(appfolder + '/ressource/icons/cancel.png'))

        self.tray.showMessage('Odoo is Loading - Please wait','\nLeft click to open CommandWindow\nRight click to open Traymenu')

        self.showCommandLineWindow()
开发者ID:luannguyen49,项目名称:OdooPortable,代码行数:99,代码来源:OdooLauncher.py


注:本文中的PyQt5.QtWidgets.QMenu.setStyleSheet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。