#!/usr/bin/env python # -*- coding: utf-8 -*- import sys import PyQt4.QtCore as QtCore import PyQt4.QtGui as QtGui class Frame_CheckBox_Edit(QtGui.QFrame): def __init__(self, parent = None): str3 = "first" # Работает self.first_label = QtGui.QLabel(str3) # Не работает eval('self.first_label = QtGui.QLabel(str3)') pass class MyWindow(QtGui.QWidget): def __init__(self, parent = None): QtGui.QWidget.__init__(self, parent) self.control_frame = Frame_CheckBox_Edit() app = QtGui.QApplication(sys.argv) window = MyWindow() window.show() sys.exit(app.exec_())
self.first_label = QtGui.QLabel(str3)
^
SyntaxError: invalid syntax