PluginProjectDjango.py

branch
eric7
changeset 180
64339135bd61
parent 178
60c87e256fc7
child 181
2f5c3487139c
equal deleted inserted replaced
179:8413c2429808 180:64339135bd61
28 deactivateable = True 28 deactivateable = True
29 version = "10.0.1" 29 version = "10.0.1"
30 className = "ProjectDjangoPlugin" 30 className = "ProjectDjangoPlugin"
31 packageName = "ProjectDjango" 31 packageName = "ProjectDjango"
32 shortDescription = "Project support for Django projects." 32 shortDescription = "Project support for Django projects."
33 longDescription = ( 33 longDescription = """This plugin implements project support for Django projects."""
34 """This plugin implements project support for Django projects."""
35 )
36 needsRestart = False 34 needsRestart = False
37 pyqtApi = 2 35 pyqtApi = 2
38 # End-of-Header 36 # End-of-Header
39 37
40 error = "" 38 error = ""
43 41
44 42
45 def apiFiles(language): 43 def apiFiles(language):
46 """ 44 """
47 Module function to return the API files made available by this plugin. 45 Module function to return the API files made available by this plugin.
48 46
49 @param language language to get APIs for 47 @param language language to get APIs for
50 @type str 48 @type str
51 @return list of API filenames 49 @return list of API filenames
52 @rtype list of str 50 @rtype list of str
53 """ 51 """
54 if language in ["Python3"]: 52 if language in ["Python3"]:
55 apisDir = os.path.join(os.path.dirname(__file__), 53 apisDir = os.path.join(os.path.dirname(__file__), "ProjectDjango", "APIs")
56 "ProjectDjango", "APIs") 54 apis = glob.glob(os.path.join(apisDir, "*.api"))
57 apis = glob.glob(os.path.join(apisDir, '*.api'))
58 else: 55 else:
59 apis = [] 56 apis = []
60 return apis 57 return apis
61 58
62 59
63 def createDjangoPage(configDlg): 60 def createDjangoPage(configDlg):
64 """ 61 """
65 Module function to create the Django configuration page. 62 Module function to create the Django configuration page.
66 63
67 @param configDlg reference to the configuration dialog 64 @param configDlg reference to the configuration dialog
68 @type ConfigurationWidget 65 @type ConfigurationWidget
69 @return reference to the configuration page 66 @return reference to the configuration page
70 @rtype DjangoPage 67 @rtype DjangoPage
71 """ 68 """
72 global djangoPluginObject 69 global djangoPluginObject
73 from ProjectDjango.ConfigurationPage.DjangoPage import DjangoPage 70 from ProjectDjango.ConfigurationPage.DjangoPage import DjangoPage
71
74 page = DjangoPage(djangoPluginObject) 72 page = DjangoPage(djangoPluginObject)
75 return page 73 return page
76 74
77 75
78 def getConfigData(): 76 def getConfigData():
79 """ 77 """
80 Module function returning data as required by the configuration dialog. 78 Module function returning data as required by the configuration dialog.
81 79
82 @return dictionary containing the relevant data 80 @return dictionary containing the relevant data
83 @rtype dict 81 @rtype dict
84 """ 82 """
85 usesDarkPalette = ericApp().usesDarkPalette() 83 usesDarkPalette = ericApp().usesDarkPalette()
86 iconSuffix = "dark" if usesDarkPalette else "light" 84 iconSuffix = "dark" if usesDarkPalette else "light"
87 85
88 return { 86 return {
89 "djangoPage": [ 87 "djangoPage": [
90 QCoreApplication.translate("ProjectDjangoPlugin", "Django"), 88 QCoreApplication.translate("ProjectDjangoPlugin", "Django"),
91 os.path.join("ProjectDjango", "icons", 89 os.path.join("ProjectDjango", "icons", "django-{0}".format(iconSuffix)),
92 "django-{0}".format(iconSuffix)), 90 createDjangoPage,
93 createDjangoPage, None, None], 91 None,
92 None,
93 ],
94 } 94 }
95 95
96 96
97 def prepareUninstall(): 97 def prepareUninstall():
98 """ 98 """
105 105
106 class ProjectDjangoPlugin(QObject): 106 class ProjectDjangoPlugin(QObject):
107 """ 107 """
108 Class implementing the Django project plugin. 108 Class implementing the Django project plugin.
109 """ 109 """
110
110 PreferencesKey = "Django" 111 PreferencesKey = "Django"
111 112
112 lexerAssociations = { 113 lexerAssociations = {
113 "*.htm": "Pygments|HTML+Django/Jinja", 114 "*.htm": "Pygments|HTML+Django/Jinja",
114 "*.html": "Pygments|HTML+Django/Jinja", 115 "*.html": "Pygments|HTML+Django/Jinja",
115 } 116 }
116 117
117 def __init__(self, ui): 118 def __init__(self, ui):
118 """ 119 """
119 Constructor 120 Constructor
120 121
121 @param ui reference to the user interface object 122 @param ui reference to the user interface object
122 @type UserInterface 123 @type UserInterface
123 """ 124 """
124 QObject.__init__(self, ui) 125 QObject.__init__(self, ui)
125 self.__ui = ui 126 self.__ui = ui
126 self.__initialize() 127 self.__initialize()
127 128
128 self.__defaults = { 129 self.__defaults = {
129 "VirtualEnvironmentNamePy3": "", 130 "VirtualEnvironmentNamePy3": "",
130
131 "Python3ConsoleType": "ipython", 131 "Python3ConsoleType": "ipython",
132
133 "ServerAddress": "", 132 "ServerAddress": "",
134
135 "RecentNumberApps": 10, 133 "RecentNumberApps": 10,
136 "UseIPv6": False, 134 "UseIPv6": False,
137 "UseThreading": True, 135 "UseThreading": True,
138
139 "TranslationsEditor": "", 136 "TranslationsEditor": "",
140 "FuzzyTranslations": False, 137 "FuzzyTranslations": False,
141
142 "UseExternalBrowser": False, 138 "UseExternalBrowser": False,
143
144 "CheckDeployMode": False, 139 "CheckDeployMode": False,
145
146 "RecentNumberTestData": 10, 140 "RecentNumberTestData": 10,
147 "KeepTestDatabase": False, 141 "KeepTestDatabase": False,
148
149 "RecentNumberDatabaseNames": 10, 142 "RecentNumberDatabaseNames": 10,
150 } 143 }
151 if isWindowsPlatform(): 144 if isWindowsPlatform():
152 self.__defaults["ConsoleCommandNoClose"] = "cmd.exe /k" 145 self.__defaults["ConsoleCommandNoClose"] = "cmd.exe /k"
153 self.__defaults["ConsoleCommand"] = "cmd.exe /c" 146 self.__defaults["ConsoleCommand"] = "cmd.exe /c"
155 self.__defaults["ConsoleCommandNoClose"] = "xterm -hold -e" 148 self.__defaults["ConsoleCommandNoClose"] = "xterm -hold -e"
156 self.__defaults["ConsoleCommand"] = "xterm -e" 149 self.__defaults["ConsoleCommand"] = "xterm -e"
157 else: 150 else:
158 self.__defaults["ConsoleCommandNoClose"] = "konsole --noclose -e" 151 self.__defaults["ConsoleCommandNoClose"] = "konsole --noclose -e"
159 self.__defaults["ConsoleCommand"] = "konsole -e" 152 self.__defaults["ConsoleCommand"] = "konsole -e"
160 153
161 self.__translator = None 154 self.__translator = None
162 self.__loadTranslator() 155 self.__loadTranslator()
163 156
164 def __initialize(self): 157 def __initialize(self):
165 """ 158 """
166 Private slot to (re)initialize the plugin. 159 Private slot to (re)initialize the plugin.
167 """ 160 """
168 self.__object = None 161 self.__object = None
169 162
170 self.__mainMenu = None 163 self.__mainMenu = None
171 self.__mainAct = None 164 self.__mainAct = None
172 self.__separatorAct = None 165 self.__separatorAct = None
173 166
174 self.__ericProject = ericApp().getObject("Project") 167 self.__ericProject = ericApp().getObject("Project")
175 168
176 self.__supportedVariants = [] 169 self.__supportedVariants = []
177 170
178 def activate(self): 171 def activate(self):
179 """ 172 """
180 Public method to activate this plugin. 173 Public method to activate this plugin.
181 174
182 @return tuple of None and activation status 175 @return tuple of None and activation status
183 @rtype bool 176 @rtype bool
184 """ 177 """
185 global djangoPluginObject 178 global djangoPluginObject
186 djangoPluginObject = self 179 djangoPluginObject = self
187 180
188 usesDarkPalette = ericApp().usesDarkPalette() 181 usesDarkPalette = ericApp().usesDarkPalette()
189 iconSuffix = "dark" if usesDarkPalette else "light" 182 iconSuffix = "dark" if usesDarkPalette else "light"
190 183
191 self.__object = Project(self, iconSuffix, self.__ui) 184 self.__object = Project(self, iconSuffix, self.__ui)
192 self.__object.initActions() 185 self.__object.initActions()
193 ericApp().registerPluginObject("ProjectDjango", self.__object) 186 ericApp().registerPluginObject("ProjectDjango", self.__object)
194 187
195 self.__mainMenu = self.__object.initMenu() 188 self.__mainMenu = self.__object.initMenu()
196 189
197 self.__supportedVariants = self.__object.supportedPythonVariants() 190 self.__supportedVariants = self.__object.supportedPythonVariants()
198 191
199 if self.__supportedVariants: 192 if self.__supportedVariants:
200 self.__ericProject.registerProjectType( 193 self.__ericProject.registerProjectType(
201 "Django", self.tr("Django"), 194 "Django",
195 self.tr("Django"),
202 self.fileTypesCallback, 196 self.fileTypesCallback,
203 lexerAssociationCallback=self.lexerAssociationCallback, 197 lexerAssociationCallback=self.lexerAssociationCallback,
204 binaryTranslationsCallback=self.binaryTranslationsCallback, 198 binaryTranslationsCallback=self.binaryTranslationsCallback,
205 progLanguages=self.__supportedVariants[:]) 199 progLanguages=self.__supportedVariants[:],
206 200 )
201
207 from Project.ProjectBrowser import ( 202 from Project.ProjectBrowser import (
208 SourcesBrowserFlag, FormsBrowserFlag, TranslationsBrowserFlag, 203 SourcesBrowserFlag,
209 OthersBrowserFlag 204 FormsBrowserFlag,
210 ) 205 TranslationsBrowserFlag,
206 OthersBrowserFlag,
207 )
208
211 Preferences.setProjectBrowserFlagsDefault( 209 Preferences.setProjectBrowserFlagsDefault(
212 "Django", 210 "Django",
213 SourcesBrowserFlag | FormsBrowserFlag | 211 SourcesBrowserFlag
214 TranslationsBrowserFlag | OthersBrowserFlag, 212 | FormsBrowserFlag
215 ) 213 | TranslationsBrowserFlag
216 214 | OthersBrowserFlag,
215 )
216
217 if self.__ericProject.isOpen(): 217 if self.__ericProject.isOpen():
218 self.__projectOpened() 218 self.__projectOpened()
219 self.__object.projectOpenedHooks() 219 self.__object.projectOpenedHooks()
220 220
221 ericApp().getObject("Project").projectOpened.connect( 221 ericApp().getObject("Project").projectOpened.connect(self.__projectOpened)
222 self.__projectOpened) 222 ericApp().getObject("Project").projectClosed.connect(self.__projectClosed)
223 ericApp().getObject("Project").projectClosed.connect( 223 ericApp().getObject("Project").newProject.connect(self.__projectOpened)
224 self.__projectClosed) 224
225 ericApp().getObject("Project").projectOpenedHooks.connect(
226 self.__object.projectOpenedHooks
227 )
228 ericApp().getObject("Project").projectClosedHooks.connect(
229 self.__object.projectClosedHooks
230 )
231 ericApp().getObject("Project").newProjectHooks.connect(
232 self.__object.projectOpenedHooks
233 )
234
235 ericApp().getObject("Project").projectAboutToBeCreated.connect(
236 self.__object.startProjectOrApplication
237 )
225 ericApp().getObject("Project").newProject.connect( 238 ericApp().getObject("Project").newProject.connect(
226 self.__projectOpened) 239 self.__object.newProjectCreated
227 240 )
228 ericApp().getObject("Project").projectOpenedHooks.connect( 241
229 self.__object.projectOpenedHooks)
230 ericApp().getObject("Project").projectClosedHooks.connect(
231 self.__object.projectClosedHooks)
232 ericApp().getObject("Project").newProjectHooks.connect(
233 self.__object.projectOpenedHooks)
234
235 ericApp().getObject("Project").projectAboutToBeCreated.connect(
236 self.__object.startProjectOrApplication)
237 ericApp().getObject("Project").newProject.connect(
238 self.__object.newProjectCreated)
239
240 return None, True 242 return None, True
241 243
242 def deactivate(self): 244 def deactivate(self):
243 """ 245 """
244 Public method to deactivate this plugin. 246 Public method to deactivate this plugin.
245 """ 247 """
246 ericApp().unregisterPluginObject("ProjectDjango") 248 ericApp().unregisterPluginObject("ProjectDjango")
247 249
248 ericApp().getObject("Project").projectOpened.disconnect( 250 ericApp().getObject("Project").projectOpened.disconnect(self.__projectOpened)
249 self.__projectOpened) 251 ericApp().getObject("Project").projectClosed.disconnect(self.__projectClosed)
250 ericApp().getObject("Project").projectClosed.disconnect( 252 ericApp().getObject("Project").newProject.disconnect(self.__projectOpened)
251 self.__projectClosed) 253
254 ericApp().getObject("Project").projectOpenedHooks.disconnect(
255 self.__object.projectOpenedHooks
256 )
257 ericApp().getObject("Project").projectClosedHooks.disconnect(
258 self.__object.projectClosedHooks
259 )
260 ericApp().getObject("Project").newProjectHooks.disconnect(
261 self.__object.projectOpenedHooks
262 )
263
264 ericApp().getObject("Project").projectAboutToBeCreated.disconnect(
265 self.__object.startProjectOrApplication
266 )
252 ericApp().getObject("Project").newProject.disconnect( 267 ericApp().getObject("Project").newProject.disconnect(
253 self.__projectOpened) 268 self.__object.newProjectCreated
254 269 )
255 ericApp().getObject("Project").projectOpenedHooks.disconnect( 270
256 self.__object.projectOpenedHooks)
257 ericApp().getObject("Project").projectClosedHooks.disconnect(
258 self.__object.projectClosedHooks)
259 ericApp().getObject("Project").newProjectHooks.disconnect(
260 self.__object.projectOpenedHooks)
261
262 ericApp().getObject("Project").projectAboutToBeCreated.disconnect(
263 self.__object.startProjectOrApplication)
264 ericApp().getObject("Project").newProject.disconnect(
265 self.__object.newProjectCreated)
266
267 self.__ericProject.unregisterProjectType("Django") 271 self.__ericProject.unregisterProjectType("Django")
268 272
269 self.__object.projectClosedHooks() 273 self.__object.projectClosedHooks()
270 self.__projectClosed() 274 self.__projectClosed()
271 275
272 self.__initialize() 276 self.__initialize()
273 277
274 def __loadTranslator(self): 278 def __loadTranslator(self):
275 """ 279 """
276 Private method to load the translation file. 280 Private method to load the translation file.
277 """ 281 """
278 if self.__ui is not None: 282 if self.__ui is not None:
279 loc = self.__ui.getLocale() 283 loc = self.__ui.getLocale()
280 if loc and loc != "C": 284 if loc and loc != "C":
281 locale_dir = os.path.join( 285 locale_dir = os.path.join(
282 os.path.dirname(__file__), "ProjectDjango", "i18n") 286 os.path.dirname(__file__), "ProjectDjango", "i18n"
287 )
283 translation = "django_{0}".format(loc) 288 translation = "django_{0}".format(loc)
284 translator = QTranslator(None) 289 translator = QTranslator(None)
285 loaded = translator.load(translation, locale_dir) 290 loaded = translator.load(translation, locale_dir)
286 if loaded: 291 if loaded:
287 self.__translator = translator 292 self.__translator = translator
288 ericApp().installTranslator(self.__translator) 293 ericApp().installTranslator(self.__translator)
289 else: 294 else:
290 print("Warning: translation file '{0}' could not be" 295 print(
291 " loaded.".format(translation)) 296 "Warning: translation file '{0}' could not be"
297 " loaded.".format(translation)
298 )
292 print("Using default.") 299 print("Using default.")
293 300
294 def __projectOpened(self): 301 def __projectOpened(self):
295 """ 302 """
296 Private slot to handle the projectOpened signal. 303 Private slot to handle the projectOpened signal.
297 """ 304 """
298 if self.__ericProject.getProjectType() == "Django": 305 if self.__ericProject.getProjectType() == "Django":
299 projectToolsMenu = self.__ui.getMenu("project_tools") 306 projectToolsMenu = self.__ui.getMenu("project_tools")
300 insertBeforeAct = projectToolsMenu.actions()[0] 307 insertBeforeAct = projectToolsMenu.actions()[0]
301 self.__mainAct = projectToolsMenu.insertMenu( 308 self.__mainAct = projectToolsMenu.insertMenu(
302 insertBeforeAct, self.__mainMenu) 309 insertBeforeAct, self.__mainMenu
303 self.__separatorAct = projectToolsMenu.insertSeparator( 310 )
304 insertBeforeAct) 311 self.__separatorAct = projectToolsMenu.insertSeparator(insertBeforeAct)
305 312
306 def __projectClosed(self): 313 def __projectClosed(self):
307 """ 314 """
308 Private slot to handle the projectClosed signal. 315 Private slot to handle the projectClosed signal.
309 """ 316 """
310 if self.__mainAct is not None: 317 if self.__mainAct is not None:
312 projectToolsMenu.removeAction(self.__separatorAct) 319 projectToolsMenu.removeAction(self.__separatorAct)
313 projectToolsMenu.removeAction(self.__mainAct) 320 projectToolsMenu.removeAction(self.__mainAct)
314 self.__mainAct = None 321 self.__mainAct = None
315 self.__separatorAct = None 322 self.__separatorAct = None
316 self.__object.projectClosed() 323 self.__object.projectClosed()
317 324
318 def fileTypesCallback(self): 325 def fileTypesCallback(self):
319 """ 326 """
320 Public method get the filetype associations of the Django project type. 327 Public method get the filetype associations of the Django project type.
321 328
322 @return dictionary with file type associations 329 @return dictionary with file type associations
323 @rtype dict 330 @rtype dict
324 """ 331 """
325 fileTypes = ( 332 fileTypes = (
326 { 333 {
330 "*.pot": "TRANSLATIONS", 337 "*.pot": "TRANSLATIONS",
331 "*.po": "TRANSLATIONS", 338 "*.po": "TRANSLATIONS",
332 "*.mo": "TRANSLATIONS", 339 "*.mo": "TRANSLATIONS",
333 "*.py": "SOURCES", 340 "*.py": "SOURCES",
334 } 341 }
335 if self.__ericProject.getProjectType() == "Django" else 342 if self.__ericProject.getProjectType() == "Django"
336 {} 343 else {}
337 ) 344 )
338 return fileTypes 345 return fileTypes
339 346
340 def lexerAssociationCallback(self, filename): 347 def lexerAssociationCallback(self, filename):
341 """ 348 """
342 Public method to get the lexer association of the Django project type 349 Public method to get the lexer association of the Django project type
343 for a file. 350 for a file.
344 351
345 @param filename name of the file 352 @param filename name of the file
346 @type str 353 @type str
347 @return name of the lexer (Pygments lexers are prefixed with 354 @return name of the lexer (Pygments lexers are prefixed with
348 'Pygments|') 355 'Pygments|')
349 @rtype str 356 @rtype str
350 """ 357 """
351 for pattern, language in self.lexerAssociations.items(): 358 for pattern, language in self.lexerAssociations.items():
352 if fnmatch.fnmatch(filename, pattern): 359 if fnmatch.fnmatch(filename, pattern):
353 return language 360 return language
354 361
355 return "" 362 return ""
356 363
357 def binaryTranslationsCallback(self, filename): 364 def binaryTranslationsCallback(self, filename):
358 """ 365 """
359 Public method to determine the filename of a compiled translation file 366 Public method to determine the filename of a compiled translation file
360 given the translation source file. 367 given the translation source file.
361 368
362 @param filename name of the translation source file 369 @param filename name of the translation source file
363 @type str 370 @type str
364 @return name of the binary translation file 371 @return name of the binary translation file
365 @rtype str 372 @rtype str
366 """ 373 """
367 if filename.endswith(".po"): 374 if filename.endswith(".po"):
368 filename = filename.replace(".po", ".mo") 375 filename = filename.replace(".po", ".mo")
369 return filename 376 return filename
370 377
371 def getPreferences(self, key): 378 def getPreferences(self, key):
372 """ 379 """
373 Public method to retrieve the various settings. 380 Public method to retrieve the various settings.
374 381
375 @param key the key of the value to get 382 @param key the key of the value to get
376 @type str 383 @type str
377 @return value of the requested setting 384 @return value of the requested setting
378 @rtype Any 385 @rtype Any
379 """ 386 """
380 if key in ["RecentNumberApps", "RecentNumberTestData"]: 387 if key in ["RecentNumberApps", "RecentNumberTestData"]:
381 return int(Preferences.Prefs.settings.value( 388 return int(
382 self.PreferencesKey + "/" + key, self.__defaults[key])) 389 Preferences.Prefs.settings.value(
383 elif key in ["UseIPv6", "UseThreading", 390 self.PreferencesKey + "/" + key, self.__defaults[key]
384 "UseExternalBrowser", "CheckDeployMode", 391 )
385 "KeepTestDatabase", "FuzzyTranslations", ]: 392 )
386 return Preferences.toBool(Preferences.Prefs.settings.value( 393 elif key in [
387 self.PreferencesKey + "/" + key, self.__defaults[key])) 394 "UseIPv6",
395 "UseThreading",
396 "UseExternalBrowser",
397 "CheckDeployMode",
398 "KeepTestDatabase",
399 "FuzzyTranslations",
400 ]:
401 return Preferences.toBool(
402 Preferences.Prefs.settings.value(
403 self.PreferencesKey + "/" + key, self.__defaults[key]
404 )
405 )
388 else: 406 else:
389 return Preferences.Prefs.settings.value( 407 return Preferences.Prefs.settings.value(
390 self.PreferencesKey + "/" + key, self.__defaults[key]) 408 self.PreferencesKey + "/" + key, self.__defaults[key]
391 409 )
410
392 def setPreferences(self, key, value): 411 def setPreferences(self, key, value):
393 """ 412 """
394 Public method to store the various settings. 413 Public method to store the various settings.
395 414
396 @param key the key of the setting to be set 415 @param key the key of the setting to be set
397 @type str 416 @type str
398 @param value value to be set 417 @param value value to be set
399 @type Any 418 @type Any
400 """ 419 """
401 Preferences.Prefs.settings.setValue( 420 Preferences.Prefs.settings.setValue(self.PreferencesKey + "/" + key, value)
402 self.PreferencesKey + "/" + key, value) 421
403
404 if key in ["VirtualEnvironmentNamePy3"]: 422 if key in ["VirtualEnvironmentNamePy3"]:
405 self.__reregisterProjectType() 423 self.__reregisterProjectType()
406 elif key == "TranslationsEditor" and self.__object: 424 elif key == "TranslationsEditor" and self.__object:
407 self.__object.registerOpenHook() 425 self.__object.registerOpenHook()
408 426
409 def __reregisterProjectType(self): 427 def __reregisterProjectType(self):
410 """ 428 """
411 Private method to re-register the project type. 429 Private method to re-register the project type.
412 """ 430 """
413 supportedVariants = self.__object.supportedPythonVariants() 431 supportedVariants = self.__object.supportedPythonVariants()
414 if supportedVariants != self.__supportedVariants: 432 if supportedVariants != self.__supportedVariants:
415 # step 1: unregister 433 # step 1: unregister
416 self.__ericProject.unregisterProjectType("Django") 434 self.__ericProject.unregisterProjectType("Django")
417 435
418 # step 2: register again with new language settings 436 # step 2: register again with new language settings
419 self.__supportedVariants = supportedVariants 437 self.__supportedVariants = supportedVariants
420 if self.__supportedVariants: 438 if self.__supportedVariants:
421 self.__ericProject.registerProjectType( 439 self.__ericProject.registerProjectType(
422 "Django", self.tr("Django"), 440 "Django",
441 self.tr("Django"),
423 self.fileTypesCallback, 442 self.fileTypesCallback,
424 lexerAssociationCallback=self.lexerAssociationCallback, 443 lexerAssociationCallback=self.lexerAssociationCallback,
425 binaryTranslationsCallback=self.binaryTranslationsCallback, 444 binaryTranslationsCallback=self.binaryTranslationsCallback,
426 progLanguages=self.__supportedVariants[:]) 445 progLanguages=self.__supportedVariants[:],
427 446 )
447
428 def getMenu(self, name): 448 def getMenu(self, name):
429 """ 449 """
430 Public method to get a reference to the requested menu. 450 Public method to get a reference to the requested menu.
431 451
432 @param name name of the menu (string) 452 @param name name of the menu (string)
433 @return reference to the menu (QMenu) or None, if no 453 @return reference to the menu (QMenu) or None, if no
434 menu with the given name exists 454 menu with the given name exists
435 """ 455 """
436 if self.__object is not None: 456 if self.__object is not None:
437 return self.__object.getMenu(name) 457 return self.__object.getMenu(name)
438 else: 458 else:
439 return None 459 return None
440 460
441 def getMenuNames(self): 461 def getMenuNames(self):
442 """ 462 """
443 Public method to get the names of all menus. 463 Public method to get the names of all menus.
444 464
445 @return menu names (list of string) 465 @return menu names (list of string)
446 """ 466 """
447 if self.__object is not None: 467 if self.__object is not None:
448 return list(self.__menus.keys()) 468 return list(self.__menus.keys())
449 else: 469 else:
450 return [] 470 return []
451 471
472
452 # 473 #
453 # eflag: noqa = M801 474 # eflag: noqa = M801

eric ide

mercurial