forked from M-Labs/artiq
1
0
Fork 0

gui: fix new() being called with arguments by qt (closes #444)

This commit is contained in:
Robert Jördens 2016-05-25 23:13:00 +02:00
parent f5da3f63aa
commit f24f7380f5
1 changed files with 4 additions and 4 deletions

View File

@ -4,6 +4,7 @@ import sys
import string import string
import shlex import shlex
from functools import partial from functools import partial
from itertools import count
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5 import QtCore, QtGui, QtWidgets
@ -296,7 +297,7 @@ class AppletsDock(QtWidgets.QDockWidget):
self.table.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.table.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
new_action = QtWidgets.QAction("New applet", self.table) new_action = QtWidgets.QAction("New applet", self.table)
new_action.triggered.connect(self.new) new_action.triggered.connect(lambda: self.new())
self.table.addAction(new_action) self.table.addAction(new_action)
templates_menu = QtWidgets.QMenu() templates_menu = QtWidgets.QMenu()
for name, template in _templates: for name, template in _templates:
@ -370,9 +371,8 @@ class AppletsDock(QtWidgets.QDockWidget):
def new(self, uid=None): def new(self, uid=None):
if uid is None: if uid is None:
uid = next(iter(set(range(len(self.applet_uids) + 1)) uid = next(i for i in count() if i not in self.applet_uids)
- self.applet_uids)) assert uid not in self.applet_uids, uid
assert uid not in self.applet_uids
self.applet_uids.add(uid) self.applet_uids.add(uid)
row = self.table.rowCount() row = self.table.rowCount()