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


Python QMenu.clear方法代码示例

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


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

示例1: Add_to_playlist_btn

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import clear [as 别名]
class Add_to_playlist_btn(QPushButton):
    def __init__(self):
        super().__init__('+')
        self.setToolTip('添加到歌单')
        self.menu = QMenu()
        self.playlists = []

    def mousePressEvent(self, event):
        self.set_playlists_options()
        self.menu.exec(event.globalPos())

    def set_playlists_options(self):
        playlists = ControllerApi.api.get_user_playlist()
        if not ControllerApi.api.is_response_ok(playlists):
            return
        self.playlists = playlists
        self.menu.clear()
        for playlist in playlists:
            if ControllerApi.api.is_playlist_mine(playlist):
                name = playlist['name']
                pid = playlist['id']
                action = QAction(name, self)
                action.triggered.connect(partial(self.add_to_playlist, pid))
                self.menu.addAction(action)

    def add_to_playlist(self, pid):
        if not ControllerApi.state['current_mid']:
            return False
        flag = ControllerApi.api.add_song_to_playlist(ControllerApi.state['current_mid'], pid)
        if flag:
            ControllerApi.notify_widget.show_message('◕◡◔', '加入歌单成功')
        else:
            ControllerApi.notify_widget.show_message('◕◠◔', '加入歌单失败, 可能早已在列表了哦')
开发者ID:1635594911,项目名称:FeelUOwn,代码行数:35,代码来源:add_to_playlist_btn.py

示例2: build_tray_menu

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import clear [as 别名]
 def build_tray_menu(self):
     # Avoid immediate GC of old menu when window closed via its action
     if self.tray.contextMenu() is None:
         m = QMenu()
         self.tray.setContextMenu(m)
     else:
         m = self.tray.contextMenu()
         m.clear()
     for window in self.windows:
         submenu = m.addMenu(window.wallet.basename())
         submenu.addAction(_("Show/Hide"), window.show_or_hide)
         submenu.addAction(_("Close"), window.close)
     m.addAction(_("Dark/Light"), self.toggle_tray_icon)
     m.addSeparator()
     m.addAction(_("Exit Electrum"), self.close)
开发者ID:faircoin,项目名称:electrumfair,代码行数:17,代码来源:__init__.py

示例3: Synchronizer

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import clear [as 别名]
class Synchronizer(Plugin):
    Name = 'Synchronizer'

    def __init__(self):
        self.syncMenu = QMenu('Synchronization')
        self.menu_action = MainWindow().menuTools.addMenu(self.syncMenu)

        self.addPeerAction = QAction('Manage connected peers', MainWindow())
        self.addPeerAction.triggered.connect(self.manage_peers)
        self.syncMenu.addAction(self.addPeerAction)

        self.showIpAction = QAction('Show your IP', MainWindow())
        self.showIpAction.triggered.connect(self.show_ip)
        self.syncMenu.addAction(self.showIpAction)

        self.peers = []
        self.cue_media = {}

    def init(self):
        Application().layout.cue_executed.connect(self.remote_execute,
                                                  mode=Connection.Async)

    def manage_peers(self):
        manager = PeersDialog(self.peers)
        manager.exec_()

    def show_ip(self):
        ip = 'Your IP is:' + os.linesep
        ip += socket.gethostbyname(socket.gethostname())
        QMessageBox.information(MainWindow(), 'Your IP', ip)

    def reset(self):
        self.peers.clear()
        self.cue_media.clear()
        self.syncMenu.clear()

    def remote_execute(self, cue):
        for peer in self.peers:
            try:
                peer['proxy'].execute(cue.index)
            except Exception:
                logging.error('REMOTE: controlling failed')
                logging.debug('REMOTE: ' + traceback.format_exc())
开发者ID:chippey,项目名称:linux-show-player,代码行数:45,代码来源:synchronizer.py

示例4: FontWindow

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import clear [as 别名]

#.........这里部分代码省略.........
            return
        font.reloadInfo()
        font.reloadKerning()
        font.reloadGroups()
        font.reloadFeatures()
        font.reloadLib()
        font.reloadGlyphs(font.keys())
        self.setWindowModified(False)

    # Edit

    def undo(self):
        glyph = self.glyphCellView.lastSelectedGlyph()
        glyph.undo()

    def redo(self):
        glyph = self.glyphCellView.lastSelectedGlyph()
        glyph.redo()

    def markColor(self):
        color = self.sender().data()
        if color is not None:
            color = color.getRgbF()
        glyphs = self.glyphCellView.glyphs()
        for index in self.glyphCellView.selection():
            glyph = glyphs[index]
            glyph.markColor = color

    def cut(self):
        self.copy()
        glyphs = self.glyphCellView.glyphs()
        for index in self.glyphCellView.selection():
            glyph = glyphs[index]
            glyph.clear()

    def copy(self):
        glyphs = self.glyphCellView.glyphs()
        pickled = []
        for index in sorted(self.glyphCellView.selection()):
            pickled.append(glyphs[index].serialize(
                blacklist=("name", "unicode")
            ))
        clipboard = QApplication.clipboard()
        mimeData = QMimeData()
        mimeData.setData("application/x-trufont-glyph-data",
                         pickle.dumps(pickled))
        clipboard.setMimeData(mimeData)

    def copyAsComponent(self):
        glyphs = self.glyphCellView.glyphs()
        pickled = []
        for index in self.glyphCellView.selection():
            glyph = glyphs[index]
            componentGlyph = glyph.__class__()
            componentGlyph.width = glyph.width
            component = componentGlyph.instantiateComponent()
            component.baseGlyph = glyph.name
            pickled.append(componentGlyph.serialize())
        clipboard = QApplication.clipboard()
        mimeData = QMimeData()
        mimeData.setData("application/x-trufont-glyph-data",
                         pickle.dumps(pickled))
        clipboard.setMimeData(mimeData)

    def paste(self):
        clipboard = QApplication.clipboard()
开发者ID:madig,项目名称:trufont,代码行数:70,代码来源:fontWindow.py

示例5: SystemTrayIcon

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import clear [as 别名]
class SystemTrayIcon(QMainWindow):
    def __init__(self, parent=None):
        super(SystemTrayIcon, self).__init__(parent)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.settings = QSettings()
        self.language = self.settings.value('Language') or ''
        self.temp_decimal_bool = self.settings.value('Decimal') or False
        # initialize the tray icon type in case of first run: issue#42
        self.tray_type = self.settings.value('TrayType') or 'icon&temp'
        cond = conditions.WeatherConditions()
        self.temporary_city_status = False
        self.conditions = cond.trans
        self.clouds = cond.clouds
        self.wind = cond.wind
        self.wind_dir = cond.wind_direction
        self.wind_codes = cond.wind_codes
        self.inerror = False
        self.tentatives = 0
        self.baseurl = 'http://api.openweathermap.org/data/2.5/weather?id='
        self.accurate_url = 'http://api.openweathermap.org/data/2.5/find?q='
        self.forecast_url = ('http://api.openweathermap.org/data/2.5/forecast/'
                             'daily?id=')
        self.day_forecast_url = ('http://api.openweathermap.org/data/2.5/'
                                 'forecast?id=')
        self.wIconUrl = 'http://openweathermap.org/img/w/'
        apikey = self.settings.value('APPID') or ''
        self.appid = '&APPID=' + apikey
        self.forecast_icon_url = self.wIconUrl
        self.timer = QTimer(self)
        self.timer.timeout.connect(self.refresh)
        self.menu = QMenu()
        self.citiesMenu = QMenu(self.tr('Cities'))
        self.tempCityAction = QAction(self.tr('&Temporary city'), self)
        self.refreshAction = QAction(self.tr('&Update'), self)
        self.settingsAction = QAction(self.tr('&Settings'), self)
        self.aboutAction = QAction(self.tr('&About'), self)
        self.exitAction = QAction(self.tr('Exit'), self)
        self.exitAction.setIcon(QIcon(':/exit'))
        self.aboutAction.setIcon(QIcon(':/info'))
        self.refreshAction.setIcon(QIcon(':/refresh'))
        self.settingsAction.setIcon(QIcon(':/configure'))
        self.tempCityAction.setIcon(QIcon(':/tempcity'))
        self.citiesMenu.setIcon(QIcon(':/bookmarks'))
        self.menu.addAction(self.settingsAction)
        self.menu.addAction(self.refreshAction)
        self.menu.addMenu(self.citiesMenu)
        self.menu.addAction(self.tempCityAction)
        self.menu.addAction(self.aboutAction)
        self.menu.addAction(self.exitAction)
        self.settingsAction.triggered.connect(self.config)
        self.exitAction.triggered.connect(qApp.quit)
        self.refreshAction.triggered.connect(self.manual_refresh)
        self.aboutAction.triggered.connect(self.about)
        self.tempCityAction.triggered.connect(self.tempcity)
        self.systray = QSystemTrayIcon()
        self.systray.setContextMenu(self.menu)
        self.systray.activated.connect(self.activate)
        self.systray.setIcon(QIcon(':/noicon'))
        self.systray.setToolTip(self.tr('Searching weather data...'))
        self.notification = ''
        self.notification_temp = 0
        self.notifications_id = ''
        self.systray.show()
        # The dictionnary has to be intialized here. If there is an error
        # the program couldn't become functionnal if the dictionnary is
        # reinitialized in the weatherdata method
        self.weatherDataDico = {}
        # The traycolor has to be initialized here for the case when we cannot
        # reach the tray method (case: set the color at first time usage)
        self.traycolor = ''
        self.refresh()

    def icon_loading(self):
        self.gif_loading = QMovie(":/loading")
        self.gif_loading.frameChanged.connect(self.update_gif)
        self.gif_loading.start()

    def update_gif(self):
        gif_frame = self.gif_loading.currentPixmap()
        self.systray.setIcon(QIcon(gif_frame))

    def manual_refresh(self):
        self.tentatives = 0
        self.refresh()

    def cities_menu(self):
        # Don't add the temporary city in the list
        if self.temporary_city_status:
            return
        self.citiesMenu.clear()
        cities = self.settings.value('CityList') or []
        if type(cities) is str:
            cities = eval(cities)
        try:
            current_city = (self.settings.value('City') + '_' +
                        self.settings.value('Country') + '_' +
                        self.settings.value('ID'))
        except:
            # firsttime run,if clic cancel in setings without any city configured
            pass
#.........这里部分代码省略.........
开发者ID:pmattern,项目名称:meteo-qt,代码行数:103,代码来源:meteo_qt.py

示例6: HistoryMenu

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import clear [as 别名]
class HistoryMenu(E5ModelMenu):
    """
    Class implementing the history menu.
    
    @signal openUrl(QUrl, str) emitted to open a URL in the current tab
    @signal newUrl(QUrl, str) emitted to open a URL in a new tab
    """
    openUrl = pyqtSignal(QUrl, str)
    newUrl = pyqtSignal(QUrl, str)
    
    def __init__(self, parent=None, tabWidget=None):
        """
        Constructor
        
        @param parent reference to the parent widget (QWidget)
        @param tabWidget reference to the tab widget managing the browser
            tabs (HelpTabWidget
        """
        E5ModelMenu.__init__(self, parent)
        
        self.__tabWidget = tabWidget
        
        self.__historyManager = None
        self.__historyMenuModel = None
        self.__initialActions = []
        self.__mostVisitedMenu = None
        
        self.__closedTabsMenu = QMenu(self.tr("Closed Tabs"))
        self.__closedTabsMenu.aboutToShow.connect(
            self.__aboutToShowClosedTabsMenu)
        self.__tabWidget.closedTabsManager().closedTabAvailable.connect(
            self.__closedTabAvailable)
        
        self.setMaxRows(7)
        
        self.activated.connect(self.__activated)
        self.setStatusBarTextRole(HistoryModel.UrlStringRole)
    
    def __activated(self, idx):
        """
        Private slot handling the activated signal.
        
        @param idx index of the activated item (QModelIndex)
        """
        if self._keyboardModifiers & Qt.ControlModifier:
            self.newUrl.emit(
                idx.data(HistoryModel.UrlRole),
                idx.data(HistoryModel.TitleRole))
        else:
            self.openUrl.emit(
                idx.data(HistoryModel.UrlRole),
                idx.data(HistoryModel.TitleRole))
    
    def prePopulated(self):
        """
        Public method to add any actions before the tree.
       
        @return flag indicating if any actions were added (boolean)
        """
        if self.__historyManager is None:
            import Helpviewer.HelpWindow
            self.__historyManager = \
                Helpviewer.HelpWindow.HelpWindow.historyManager()
            self.__historyMenuModel = HistoryMenuModel(
                self.__historyManager.historyTreeModel(), self)
            self.setModel(self.__historyMenuModel)
        
        # initial actions
        for act in self.__initialActions:
            self.addAction(act)
        if len(self.__initialActions) != 0:
            self.addSeparator()
        self.setFirstSeparator(self.__historyMenuModel.bumpedRows())
        
        return False
    
    def postPopulated(self):
        """
        Public method to add any actions after the tree.
        """
        if len(self.__historyManager.history()) > 0:
            self.addSeparator()
        
        if self.__mostVisitedMenu is None:
            self.__mostVisitedMenu = HistoryMostVisitedMenu(10, self)
            self.__mostVisitedMenu.setTitle(self.tr("Most Visited"))
            self.__mostVisitedMenu.openUrl.connect(self.openUrl)
            self.__mostVisitedMenu.newUrl.connect(self.newUrl)
        self.addMenu(self.__mostVisitedMenu)
        act = self.addMenu(self.__closedTabsMenu)
        act.setIcon(UI.PixmapCache.getIcon("trash.png"))
        act.setEnabled(self.__tabWidget.canRestoreClosedTab())
        self.addSeparator()
        
        act = self.addAction(UI.PixmapCache.getIcon("history.png"),
                             self.tr("Show All History..."))
        act.triggered.connect(self.__showHistoryDialog)
        act = self.addAction(UI.PixmapCache.getIcon("historyClear.png"),
                             self.tr("Clear History..."))
        act.triggered.connect(self.__clearHistoryDialog)
#.........这里部分代码省略.........
开发者ID:Darriall,项目名称:eric,代码行数:103,代码来源:HistoryMenu.py

示例7: TabWidget

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import clear [as 别名]

#.........这里部分代码省略.........
        Private slot to show the tab context menu.
        
        @param coord the position of the mouse pointer (QPoint)
        @param index index of the tab the menu is requested for (integer)
        """
        if self.editors:
            self.contextMenuEditor = self.widget(index).getEditor()
            if self.contextMenuEditor:
                self.saveMenuAct.setEnabled(
                    self.contextMenuEditor.isModified())
                fileName = self.contextMenuEditor.getFileName()
                self.copyPathAct.setEnabled(bool(fileName))
                if fileName:
                    rej = "{0}.rej".format(fileName)
                    self.openRejectionsMenuAct.setEnabled(os.path.exists(rej))
                else:
                    self.openRejectionsMenuAct.setEnabled(False)
            
            self.contextMenuIndex = index
            self.leftMenuAct.setEnabled(index > 0)
            self.rightMenuAct.setEnabled(index < self.count() - 1)
            self.firstMenuAct.setEnabled(index > 0)
            self.lastMenuAct.setEnabled(index < self.count() - 1)
            
            self.closeOthersMenuAct.setEnabled(self.count() > 1)
            
            coord = self.mapToGlobal(coord)
            self.__menu.popup(coord)
        
    def __showNavigationMenu(self):
        """
        Private slot to show the navigation button menu.
        """
        self.__navigationMenu.clear()
        for index in range(self.count()):
            act = self.__navigationMenu.addAction(self.tabIcon(index),
                                                  self.tabText(index))
            act.setData(index)
        
    def __navigationMenuTriggered(self, act):
        """
        Private slot called to handle the navigation button menu selection.
        
        @param act reference to the selected action (QAction)
        """
        index = act.data()
        if index is not None:
            self.setCurrentIndex(index)
        
    def showIndicator(self, on):
        """
        Public slot to set the indicator on or off.
        
        @param on flag indicating the dtate of the indicator (boolean)
        """
        if on:
            self.indicator.setColor(QColor("green"))
        else:
            self.indicator.setColor(QColor("red"))
        
    def addTab(self, assembly, title):
        """
        Public method to add a new tab.
        
        @param assembly editor assembly object to be added
            (QScintilla.EditorAssembly.EditorAssembly)
开发者ID:paulmadore,项目名称:Eric-IDE,代码行数:70,代码来源:Tabview.py

示例8: Browser

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import clear [as 别名]

#.........这里部分代码省略.........
                    if itm.isPython3File():
                        if itm.fileName().endswith('.py'):
                            self.unittestAct.setEnabled(True)
                        else:
                            self.unittestAct.setEnabled(False)
                        self.sourceMenu.popup(coord)
                    else:
                        self.editPixmapAct.setVisible(itm.isPixmapFile())
                        self.menu.popup(coord)
                elif isinstance(itm, BrowserClassItem) or \
                    isinstance(itm, BrowserMethodItem) or \
                        isinstance(itm, BrowserImportItem):
                    self.editPixmapAct.setVisible(False)
                    self.menu.popup(coord)
                elif isinstance(itm, BrowserClassAttributeItem):
                    self.attributeMenu.popup(coord)
                elif isinstance(itm, BrowserDirectoryItem):
                    if not index.parent().isValid():
                        self.removeFromToplevelAct.setEnabled(True)
                        self.addAsTopLevelAct.setEnabled(False)
                    else:
                        self.removeFromToplevelAct.setEnabled(False)
                        self.addAsTopLevelAct.setEnabled(True)
                    self.dirMenu.popup(coord)
                else:
                    self.backMenu.popup(coord)
            else:
                self.backMenu.popup(self.mapToGlobal(coord))
        
    def _showGotoMenu(self):
        """
        Protected slot to prepare the goto submenu of the attribute menu.
        """
        self.gotoMenu.clear()
        
        itm = self.model().item(self.currentIndex())
        linenos = itm.linenos()
        fileName = itm.fileName()
        
        for lineno in sorted(linenos):
            act = self.gotoMenu.addAction(
                self.tr("Line {0}".format(lineno)))
            act.setData([fileName, lineno])
        
    def _gotoAttribute(self, act):
        """
        Protected slot to handle the selection of the goto menu.
        
        @param act reference to the action (E5Action)
        """
        fileName, lineno = act.data()
        self.sourceFile[str, int].emit(fileName, lineno)
        
    def handlePreferencesChanged(self):
        """
        Public slot used to handle the preferencesChanged signal.
        """
        self.model().preferencesChanged()
        self._resort()
        
    def _openItem(self):
        """
        Protected slot to handle the open popup menu entry.
        """
        itmList = self.getSelectedItems(
            [BrowserFileItem, BrowserClassItem,
开发者ID:pycom,项目名称:EricShort,代码行数:70,代码来源:Browser.py

示例9: PlaylistWidget

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import clear [as 别名]
class PlaylistWidget(PlaylistWidgetBasic):
    play_music_at_row_signal = pyqtSignal(int)
    play_or_pause_signal = pyqtSignal(int)
    playing_list_changed_signal = pyqtSignal(str, str)
    musics_added_signal = pyqtSignal(bool)
    musics_removed_signal = pyqtSignal()
    musics_cleared_signal = pyqtSignal()
    musics_marked_signal = pyqtSignal()
    download_signal = pyqtSignal()
    show_artist_info_signal = pyqtSignal(str)
    show_song_info_signal = pyqtSignal(int)
    tag_values_changed_signal = pyqtSignal(int, str, str, str)
    playlist_changed_signal = pyqtSignal()
    def __init__(self, parent=None):
        super(PlaylistWidget, self).__init__(parent)
        self.songOperator = SongOperator(self)
        self.initial_params()
        self.set_attritutes()
        self.create_menu_items()
        self.create_connections()

    def create_connections(self):
        self.cellEntered.connect(self.cell_entered)
        self.customContextMenuRequested.connect(self.music_table_menu)  
        self.selectAllAction.triggered.connect(self.select_all_rows)
        self.selectInvertAction.triggered.connect(self.select_invert_rows)
        self.selectNoneAction.triggered.connect(self.select_none_rows)
        self.copytoMenu.triggered.connect(self.copy_to_other_playlist)
        self.movetoMenu.triggered.connect(self.move_to_other_playlist)
        self.addMusicAction.triggered.connect(self.add_musics)
        self.markSelectedAsFavoriteAction.triggered.connect(self.mark_selected_as_favorite)
        self.removeAction.triggered.connect(self.remove_musics)
        self.deleteAction.triggered.connect(self.delete_musics)
        self.clearListWidgetAction.triggered.connect(self.clear_musics)
        self.songSpecAction.triggered.connect(self.show_song_spec)
        self.artistSpecAction.triggered.connect(self.show_artist_info)
        self.downloadAction.triggered.connect(self.download_signal.emit)
        self.doubleClicked.connect(self.double_click_to_play)
        self.songOperator.wheel_event_triggered_signal.connect(self.wheelEvent)
        self.songOperator.double_clicked_signal.connect(self.double_click_to_play_with_row)
        self.songOperator.right_mouse_button_clicked_signal.connect(self.music_table_menu)
        self.songOperator.left_mouse_button_clicked_signal.connect(self.selectRow)
        self.songOperator.left_mouse_button_dragged_signal.connect(self.select_multi_rows)

    def cell_entered(self, row, column):
        if self.songOperator.isHidden():
            self.songOperator.set_contents(row, self.item(row, column).text())
            self.songOperator.show()
        oldRow = self.songOperator.get_row()
        if self.item(oldRow, column):
            self.item(oldRow, column).setText(self.playlist.get_music_title_at(oldRow))
        self.songOperator.set_contents(row, self.item(row, column).text())
        self.item(row, column).setText('')
        scrollBar = self.verticalScrollBar()
        scrolledValue = scrollBar.value()
#        if scrolledValue and scrolledValue == scrollBar.maximum():
#            scrolledValue -= 1
        self.songOperator.setGeometry(0, (row - scrolledValue)*self.rowHeight(row), 270, 31)
    
    def leaveEvent(self, event=None):
        self.hide_song_operator()
    
    def select_multi_rows(self, pos):
        exactPos = pos + self.songOperator.pos()
        item = self.itemAt(exactPos)
        if item:
            self.cell_entered(item.row(), 0)
            if not item.isSelected():  
                item.setSelected(True)
    
    def hide_song_operator(self):
        if not self.songOperator.isHidden():
            oldRow = self.songOperator.get_row()
            item = self.item(oldRow, 0)
            if item:
                item.setText(self.playlist.get_music_title_at(oldRow))
            self.songOperator.hide()
    
    def initial_params(self):
        self.files = []
        self.lock = None
        self.downloadDir = ''
        self.deleteFlag = False
        self.isPlaying = False
        self.playingList = Playlist()
        self.allPlaylistNames = []
        self.mode = 0
    
    def set_playlist_names(self, listNames):
        self.allPlaylistNames = listNames
    
    def set_lock(self, lock):
        self.lock = lock
    
    def set_download_dir(self, dir):
        self.downloadDir = dir
    
    def set_playing_status(self, playlist):
        self.playingList = playlist
 
#.........这里部分代码省略.........
开发者ID:Zheng-Yejian,项目名称:xyplayer,代码行数:103,代码来源:mytables.py

示例10: AbstractViewerContextMenu

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import clear [as 别名]

#.........这里部分代码省略.........

    def addOpenCloseActions(self):
        """Add actions to close documents.
        This is not implemented in the base class"""
        m = self._menu
        ac = self._actionCollection
        m.addAction(ac.viewer_open)
        docs = self._actionCollection.viewer_document_select.viewdocs()
        if docs:
            sm = QMenu(m)
            sm.setTitle(_("Close..."))
            m.addMenu(sm)
            sm.addAction(ac.viewer_close)
            multi_docs = len(docs) > 1
            ac.viewer_close_other.setEnabled(multi_docs)
            ac.viewer_close_all.setEnabled(multi_docs)
            sm.addAction(ac.viewer_close_other)
            sm.addAction(ac.viewer_close_all)

    def addReloadAction(self):
        """Add action to reload document."""
        current_document = self._panel.widget().currentViewdoc()
        if current_document:
            m = self._menu
            ac = self._actionCollection
            m.addAction(ac.viewer_reload)

    def addZoomActions(self):
        """Add actions to zoom the viewer"""
        m = self._menu
        m.addSeparator()
        sm = QMenu(m)
        sm.setTitle(_("Zoom"))
        m.addMenu(sm)
        ac = self._actionCollection
        sm.addAction(ac.viewer_fit_width)
        sm.addAction(ac.viewer_fit_height)
        sm.addAction(ac.viewer_fit_both)
        sm.addSeparator()
        sm.addAction(ac.viewer_zoom_in)
        sm.addAction(ac.viewer_zoom_out)
        sm.addAction(ac.viewer_zoom_original)

    def addSynchronizeAction(self):
        """Add an action telling the viewer to
        always try syncing with the input editor."""
        m = self._menu
        ac = self._actionCollection
        m.addAction(ac.viewer_sync_cursor)

    def addShowToolbarAction(self):
        """Add action to toggle the visibility of
        the viewer's toolbar"""
        m = self._menu
        ac = self._actionCollection
        m.addAction(ac.viewer_show_toolbar)

    def addHelpAction(self):
        """Add help menu item"""
        m = self._menu
        ac = self._actionCollection
        m.addSeparator()
        m.addAction(ac.viewer_help)

    def show(self, position, link, cursor, methods = None):
        """Build the panel's context menu dynamically.
        Implements the template method pattern to allow
        subclasses to override each step.
        If methods passes a list of methods these will be
        called instead to construct the menu, making it
        possible to change order or add methods not
        available in the base class."""

        self._position = position
        self._link = link
        self._cursor = cursor

        self._menu.clear()

        if not methods:
            # Actions affecting the current link(selection)
            self.addCopyImageAction()
            self.addCursorLinkActions()
            # Actions affecting the currently opened documents
            self.addShowActions()
            self.addOpenCloseActions()
            self.addReloadAction()
            # Actions affecting the viewer's state
            self.addZoomActions()
            self.addSynchronizeAction()
            self.addShowToolbarAction()
        else:
            for m in methods:
                m()
        # The help action is added always
        self.addHelpAction()

        # show it!
        if self._menu.actions():
            self._menu.exec_(position)
开发者ID:19joho66,项目名称:frescobaldi,代码行数:104,代码来源:contextmenu.py

示例11: HelpTabWidget

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import clear [as 别名]

#.........这里部分代码省略.........
        
        if linkName:
            browser.setSource(QUrl(linkName))
            if not browser.documentTitle():
                self.setTabText(index, self.__elide(linkName, Qt.ElideMiddle))
                self.setTabToolTip(index, linkName)
            else:
                self.setTabText(
                    index,
                    self.__elide(browser.documentTitle().replace("&", "&&")))
                self.setTabToolTip(index, browser.documentTitle())
        elif requestData:
            browser.load(*requestData)
    
    def newBrowserAfter(self, browser, link=None, requestData=None):
        """
        Public method to create a new web browser tab after a given one.
        
        @param browser reference to the browser to add after (HelpBrowser)
        @param link link to be shown (string or QUrl)
        @param requestData tuple containing the request data (QNetworkRequest,
            QNetworkAccessManager.Operation, QByteArray)
        """
        if browser:
            position = self.indexOf(browser) + 1
        else:
            position = -1
        self.newBrowser(link, requestData, position)
    
    def __showNavigationMenu(self):
        """
        Private slot to show the navigation button menu.
        """
        self.__navigationMenu.clear()
        for index in range(self.count()):
            act = self.__navigationMenu.addAction(
                self.tabIcon(index), self.tabText(index))
            act.setData(index)
    
    def __navigationMenuTriggered(self, act):
        """
        Private slot called to handle the navigation button menu selection.
        
        @param act reference to the selected action (QAction)
        """
        index = act.data()
        if index is not None:
            self.setCurrentIndex(index)
    
    def __windowCloseRequested(self):
        """
        Private slot to handle the windowCloseRequested signal of a browser.
        """
        page = self.sender()
        if page is None:
            return
        
        browser = page.view()
        if browser is None:
            return
        
        index = self.indexOf(browser)
        self.closeBrowserAt(index)
    
    def reloadAllBrowsers(self):
        """
开发者ID:testmana2,项目名称:test,代码行数:70,代码来源:HelpTabWidget.py

示例12: MultiProject

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import clear [as 别名]

#.........这里部分代码省略.........
        toolbarManager.addAction(self.addProjectAct, tb.windowTitle())
        toolbarManager.addAction(self.propsAct, tb.windowTitle())
        
        return tb
    
    def __showMenu(self):
        """
        Private method to set up the multi project menu.
        """
        self.menuRecentAct.setEnabled(len(self.recent) > 0)
        
        self.showMenu.emit("Main", self.__menus["Main"])
    
    def __syncRecent(self):
        """
        Private method to synchronize the list of recently opened multi
        projects with the central store.
        """
        for recent in self.recent[:]:
            if Utilities.samepath(self.pfile, recent):
                self.recent.remove(recent)
        self.recent.insert(0, self.pfile)
        maxRecent = Preferences.getProject("RecentNumber")
        if len(self.recent) > maxRecent:
            self.recent = self.recent[:maxRecent]
        self.__saveRecent()
    
    def __showContextMenuRecent(self):
        """
        Private method to set up the recent multi projects menu.
        """
        self.__loadRecent()
        
        self.recentMenu.clear()
        
        idx = 1
        for rp in self.recent:
            if idx < 10:
                formatStr = '&{0:d}. {1}'
            else:
                formatStr = '{0:d}. {1}'
            act = self.recentMenu.addAction(
                formatStr.format(
                    idx,
                    Utilities.compactPath(rp, self.ui.maxMenuFilePathLen)))
            act.setData(rp)
            act.setEnabled(QFileInfo(rp).exists())
            idx += 1
        
        self.recentMenu.addSeparator()
        self.recentMenu.addAction(self.tr('&Clear'), self.__clearRecent)
    
    def __openRecent(self, act):
        """
        Private method to open a multi project from the list of rencently
        opened multi projects.
        
        @param act reference to the action that triggered (QAction)
        """
        file = act.data()
        if file:
            self.openMultiProject(file)
    
    def __clearRecent(self):
        """
        Private method to clear the recent multi projects menu.
开发者ID:testmana2,项目名称:test,代码行数:70,代码来源:MultiProject.py

示例13: ObjectsDock

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import clear [as 别名]
class ObjectsDock(QDockWidget):
    def __init__(self, parent = None):
        super().__init__(parent)
        self.mExpandedGroups = QMapList()
        self.mObjectsView = ObjectsView()
        self.mMapDocument = None

        self.setObjectName("ObjectsDock")
        self.mActionObjectProperties = QAction(self)
        self.mActionObjectProperties.setIcon(QIcon(":/images/16x16/document-properties.png"))
        Utils.setThemeIcon(self.mActionObjectProperties, "document-properties")
        self.mActionObjectProperties.triggered.connect(self.objectProperties)
        handler = MapDocumentActionHandler.instance()
        widget = QWidget(self)
        layout = QVBoxLayout(widget)
        layout.setContentsMargins(5, 5, 5, 5)
        layout.setSpacing(0)
        layout.addWidget(self.mObjectsView)
        self.mActionNewLayer = QAction(self)
        self.mActionNewLayer.setIcon(QIcon(":/images/16x16/document-new.png"))
        self.mActionNewLayer.triggered.connect(handler.actionAddObjectGroup().triggered)
        self.mActionMoveToGroup = QAction(self)
        self.mActionMoveToGroup.setIcon(QIcon(":/images/16x16/layer-object.png"))
        toolBar = QToolBar()
        toolBar.setFloatable(False)
        toolBar.setMovable(False)
        toolBar.setIconSize(QSize(16, 16))
        toolBar.addAction(self.mActionNewLayer)
        toolBar.addAction(handler.actionDuplicateObjects())
        toolBar.addAction(handler.actionRemoveObjects())
        toolBar.addAction(self.mActionMoveToGroup)
        button = toolBar.widgetForAction(self.mActionMoveToGroup)
        self.mMoveToMenu = QMenu(self)
        button.setPopupMode(QToolButton.InstantPopup)
        button.setMenu(self.mMoveToMenu)
        self.mMoveToMenu.aboutToShow.connect(self.aboutToShowMoveToMenu)
        self.mMoveToMenu.triggered.connect(self.triggeredMoveToMenu)
        toolBar.addAction(self.mActionObjectProperties)
        layout.addWidget(toolBar)
        self.setWidget(widget)
        self.retranslateUi()
        DocumentManager.instance().documentAboutToClose.connect(self.documentAboutToClose)

    def setMapDocument(self, mapDoc):
        if (self.mMapDocument):
            self.saveExpandedGroups(self.mMapDocument)
            self.mMapDocument.disconnect()

        self.mMapDocument = mapDoc
        self.mObjectsView.setMapDocument(mapDoc)
        if (self.mMapDocument):
            self.restoreExpandedGroups(self.mMapDocument)
            self.mMapDocument.selectedObjectsChanged.connect(self.updateActions)

        self.updateActions()

    def changeEvent(self, e):
        super().changeEvent(e)
        x = e.type()
        if x==QEvent.LanguageChange:
            self.retranslateUi()
        else:
            pass

    def updateActions(self):
        if self.mMapDocument:
            count = self.mMapDocument.selectedObjects().count()
        else:
            count = 0
        enabled = count > 0
        self.mActionObjectProperties.setEnabled(count == 1)
        if (self.mMapDocument and (self.mMapDocument.map().objectGroupCount() < 2)):
            enabled = False
        self.mActionMoveToGroup.setEnabled(enabled)
        self.mActionMoveToGroup.setToolTip(self.tr("Move %n Object(s) to Layer", "", count))

    def aboutToShowMoveToMenu(self):
        self.mMoveToMenu.clear()
        for objectGroup in self.mMapDocument.map().objectGroups():
            action = self.mMoveToMenu.addAction(objectGroup.name())
            action.setData(QVariant(objectGroup))

    def triggeredMoveToMenu(self, action):
        handler = MapDocumentActionHandler.instance()
        objectGroup = action.data()
        handler.moveObjectsToGroup(objectGroup)

    def objectProperties(self):
        selectedObjects = self.mMapDocument.selectedObjects()
        mapObject = selectedObjects.first()
        self.mMapDocument.setCurrentObject(mapObject)
        self.mMapDocument.emitEditCurrentObject()

    def documentAboutToClose(self, mapDocument):
        self.mExpandedGroups.remove(mapDocument)

    def retranslateUi(self):
        self.setWindowTitle(self.tr("Objects"))
        self.mActionNewLayer.setToolTip(self.tr("Add Object Layer"))
        self.mActionObjectProperties.setToolTip(self.tr("Object Properties"))
#.........这里部分代码省略.........
开发者ID:theall,项目名称:Python-Tiled,代码行数:103,代码来源:objectsdock.py

示例14: MainWindow

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import clear [as 别名]

#.........这里部分代码省略.........
                Perso.infoName.value, QHeaderView.ResizeToContents)
        self.tblPersoInfos.horizontalHeader().setSectionResizeMode(
                Perso.infoData.value, QHeaderView.Stretch)
        self.tblPersoInfos.verticalHeader().hide()

    ###############################################################################
    # PLOTS
    ###############################################################################

    def changeCurrentPlot(self):
        index = self.lstPlots.currentPlotIndex()

        if not index.isValid():
            self.tabPlot.setEnabled(False)
            return

        self.tabPlot.setEnabled(True)
        self.txtPlotName.setCurrentModelIndex(index)
        self.txtPlotDescription.setCurrentModelIndex(index)
        self.txtPlotResult.setCurrentModelIndex(index)
        self.sldPlotImportance.setCurrentModelIndex(index)
        self.lstPlotPerso.setRootIndex(index.sibling(index.row(),
                                                     Plot.persos.value))
        subplotindex = index.sibling(index.row(), Plot.subplots.value)
        self.lstSubPlots.setRootIndex(subplotindex)
        if self.mdlPlots.rowCount(subplotindex):
            self.updateSubPlotView()

        # self.txtSubPlotSummary.setCurrentModelIndex(QModelIndex())
        self.txtSubPlotSummary.setEnabled(False)
        self._updatingSubPlot = True
        self.txtSubPlotSummary.setPlainText("")
        self._updatingSubPlot = False
        self.lstPlotPerso.selectionModel().clear()

    def updateSubPlotView(self):
        # Hide columns
        for i in range(self.mdlPlots.columnCount()):
            self.lstSubPlots.hideColumn(i)
        self.lstSubPlots.showColumn(Subplot.name.value)
        self.lstSubPlots.showColumn(Subplot.meta.value)

        self.lstSubPlots.horizontalHeader().setSectionResizeMode(
                Subplot.name.value, QHeaderView.Stretch)
        self.lstSubPlots.horizontalHeader().setSectionResizeMode(
                Subplot.meta.value, QHeaderView.ResizeToContents)
        self.lstSubPlots.verticalHeader().hide()

    def changeCurrentSubPlot(self, index):
        # Got segfaults when using textEditView model system, so ad hoc stuff.
        index = index.sibling(index.row(), Subplot.summary.value)
        item = self.mdlPlots.itemFromIndex(index)
        if not item:
            self.txtSubPlotSummary.setEnabled(False)
            return
        self.txtSubPlotSummary.setEnabled(True)
        txt = item.text()
        self._updatingSubPlot = True
        self.txtSubPlotSummary.setPlainText(txt)
        self._updatingSubPlot = False

    def updateSubPlotSummary(self):
        if self._updatingSubPlot:
            return

        index = self.lstSubPlots.currentIndex()
开发者ID:tdannecy,项目名称:manuskript,代码行数:70,代码来源:mainWindow.py

示例15: TrayStarter

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import clear [as 别名]

#.........这里部分代码省略.........
        """
        self.__startProc("eric6_iconeditor.py", "--config={0}".format(
            Utilities.getConfigDir()))

    def __startSnapshot(self):
        """
        Private slot to start the eric6 snapshot dialog.
        """
        self.__startProc("eric6_snap.py", "--config={0}".format(
            Utilities.getConfigDir()))

    def __startQRegExp(self):
        """
        Private slot to start the eric6 QRegExp editor dialog.
        """
        self.__startProc("eric6_qregexp.py", "--config={0}".format(
            Utilities.getConfigDir()))

    def __startPyRe(self):
        """
        Private slot to start the eric6 Python re editor dialog.
        """
        self.__startProc("eric6_re.py", "--config={0}".format(
            Utilities.getConfigDir()))

    def __showRecentProjectsMenu(self):
        """
        Private method to set up the recent projects menu.
        """
        self.recentProjects = []
        self.rsettings.sync()
        self.__loadRecentProjects()
        
        self.recentProjectsMenu.clear()
        
        idx = 1
        for rp in self.recentProjects:
            if idx < 10:
                formatStr = '&{0:d}. {1}'
            else:
                formatStr = '{0:d}. {1}'
            act = self.recentProjectsMenu.addAction(
                formatStr.format(
                    idx, Utilities.compactPath(rp, self.maxMenuFilePathLen)))
            act.setData(rp)
            idx += 1
    
    def __showRecentMultiProjectsMenu(self):
        """
        Private method to set up the recent multi projects menu.
        """
        self.recentMultiProjects = []
        self.rsettings.sync()
        self.__loadRecentMultiProjects()
        
        self.recentMultiProjectsMenu.clear()
        
        idx = 1
        for rmp in self.recentMultiProjects:
            if idx < 10:
                formatStr = '&{0:d}. {1}'
            else:
                formatStr = '{0:d}. {1}'
            act = self.recentMultiProjectsMenu.addAction(
                formatStr.format(
                    idx, Utilities.compactPath(rmp, self.maxMenuFilePathLen)))
开发者ID:Darriall,项目名称:eric,代码行数:70,代码来源:TrayStarter.py


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