Есть форма для ввода Main_Window
#coding:cp1251
import sys
from PyQt4 import QtGui, QtCore
class GridNetCgf(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.setGeometry(300,50,500,600)
spisok_us = QtGui.QAction(QtGui.QIcon('images/web.png'), u'Список', self)
self.connect(spisok_us, QtCore.SIGNAL('triggered()'),self.list_users)
spisok_us.setStatusTip(u'Просмотр всех пользователей')
menubar = self.menuBar()
users = menubar.addMenu(u'Пользователи')
users.addAction(spisok_us)
def list_users(self):
self.fr=QtGui.QWidget(self)
self.ipEdit = QtGui.QLineEdit(self.fr)
self.ipEdit.setGeometry(100,100,60,30)
self.btn3 = QtGui.QPushButton('Add',self.fr)
self.btn3.setGeometry(100,200,60,30)
self.textLinks = QtGui.QLabel(self.fr)
self.textLinks.setGeometry(100,300,200,30)
self.connect(self.btn3, QtCore.SIGNAL("clicked()"), self.myfunc)
self.fr.show()
self.setCentralWidget(self.fr)
def myfunc(self):
text = self.ipEdit.text()
self.textLinks.setText(text*4)
app = QtGui.QApplication(sys.argv)
qb = GridNetCgf()
qb.show()
sys.exit(app.exec_())
# -*- coding: cp1251 -*-
from PyQt4 import QtGui, QtCore
from Main_Window1 import GridNetCgf
import MySQLdb as mdb
import sys
try:
conn = mdb.connect('localhost', 'root', '', 'test');
cursor = conn.cursor()
conn.set_character_set('cp1251')
cursor.execute('SET NAMES cp1251')
cursor.execute('SET CHARACTER SET cp1251')
cursor.execute('SET character_set_connection=cp1251')
cursor.execute("INSERT INTO users(name) VALUES('Клиент1')")
conn.commit()
cursor.close()
conn.close()
except mdb.Error, e:
print "Error %d: %s" % (e.args[0],e.args[1])
sys.exit(1)
Спасибо.