How to manipulate one python file in another python file

hi gyz! i’m new to python and i have a simple problem how can i call a python file and modify it in another python file this means that i have two .py files and i want to call file A in file B and manipulate file A in file B. can some 1 help

Hi @adeb can you give an example what you want to achive? There are some different ways to do this.

And please: Can you move this post to the Python category?

hey Didier
i have that login page first
snip1

and i want once it is an admin, goto snip2

and once it is a guest goto that page but remove that employee tab for guest and open it only for admin

Is that an Python webframework? Or did you wrote this by yourself? Do you have some code?

yes i have design it using pyqt4
but i do have the code

from PyQt4 import QtCore, QtGui
from registrn import Ui_registrn
import MySQLdb
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s

try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)

class Ui_borollelogin(object):

def ShowMessageBox(self,title,message):
    msgBox = QtGui.QMessageBox()
    msgBox.setIcon(QtGui.QMessageBox.Warning)
    msgBox.setWindowTitle(title)
    msgBox.setText(message)
    msgBox.setStandardButtons(QtGui.QMessageBox.Ok)
    msgBox.exec_()

def gotoreg(self):
    self.b = QtGui.QMainWindow()
    self.ui = Ui_registrn()
    self.ui.setupUi(self.b)
    self.b.show()
    borollelogin.hide()
    

    

def loginn(self):
    username = self.lineEdit1.text()
    password = self.lineEdit2.text()
    

    self.conn=MySQLdb.connect(host="localhost", user="root", passwd="", db="inv")
    dbcursor=self.conn.cursor()
    sql="select * from users where username=%s and password=%s"
    dbcursor.execute(sql,(username,password))
    datas=dbcursor.fetchall()
    if (len(datas) > 0):
        self.gotoreg()
    else:
        self.ShowMessageBox('WARNING','Invalid username or password')

def setupUi(self, borollelogin):
    borollelogin.setObjectName(_fromUtf8("borollelogin"))
    borollelogin.resize(479, 371)
    self.centralwidget = QtGui.QWidget(borollelogin)
    self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
    self.username = QtGui.QLabel(self.centralwidget)
    self.username.setGeometry(QtCore.QRect(90, 90, 71, 21))
    self.username.setObjectName(_fromUtf8("username"))
    self.password = QtGui.QLabel(self.centralwidget)
    self.password.setGeometry(QtCore.QRect(90, 140, 61, 20))
    self.password.setObjectName(_fromUtf8("password"))
    self.lineEdit1 = QtGui.QLineEdit(self.centralwidget)
    self.lineEdit1.setGeometry(QtCore.QRect(190, 90, 113, 20))
    self.lineEdit1.setObjectName(_fromUtf8("lineEdit1"))
    self.lineEdit2 = QtGui.QLineEdit(self.centralwidget)
    self.lineEdit2.setGeometry(QtCore.QRect(190, 140, 113, 20))
    self.lineEdit2.setEchoMode(QtGui.QLineEdit.Password)
    self.lineEdit2.setObjectName(_fromUtf8("lineEdit2"))
    self.pushButton1 = QtGui.QPushButton(self.centralwidget)
    self.pushButton1.setGeometry(QtCore.QRect(190, 250, 75, 23))
    self.pushButton1.setObjectName(_fromUtf8("pushButton1"))
    self.pstn = QtGui.QLabel(self.centralwidget)
    self.pstn.setGeometry(QtCore.QRect(90, 190, 61, 21))
    self.pstn.setObjectName(_fromUtf8("pstn"))
    self.comboBox1 = QtGui.QComboBox(self.centralwidget)
    self.comboBox1.setGeometry(QtCore.QRect(190, 190, 111, 22))
    self.comboBox1.setEditable(True)
    self.comboBox1.setObjectName(_fromUtf8("comboBox1"))
    self.comboBox1.addItems(['','admin','manager','nyirubwite'])
    borollelogin.setCentralWidget(self.centralwidget)

    self.pushButton1.clicked.connect(self.loginn)

    self.retranslateUi(borollelogin)
    QtCore.QMetaObject.connectSlotsByName(borollelogin)

def retranslateUi(self, borollelogin):
    borollelogin.setWindowTitle(_translate("borollelogin", "borollelogin", None))
    self.username.setText(_translate("borollelogin", "<html><head/><body><p><span style=\" font-weight:600;\">Username</span></p></body></html>", None))
    self.password.setText(_translate("borollelogin", "<html><head/><body><p><span style=\" font-weight:600;\">Password</span></p></body></html>", None))
    self.pushButton1.setText(_translate("borollelogin", "Login", None))
    self.pstn.setText(_translate("borollelogin", "<html><head/><body><p><span style=\" font-weight:600;\">Position</span></p></body></html>", None))

if name == “main”:
import sys
app = QtGui.QApplication(sys.argv)
borollelogin = QtGui.QMainWindow()
ui = Ui_borollelogin()
ui.setupUi(borollelogin)
borollelogin.show()
sys.exit(app.exec_())

Sorry then, I think I’m the wrong person to help you with. I don’t have any experience with pyqt4 nor databases. For me it looks like you have some database in the background. Maybe you can achieve what you want with different permissions for admins and users.

exactly that what i want to use
the permissions for admins and other users

So I think you have to go to the documentation of the framework you use and look up how to do it.

i can’t find it that why i was asking help

Hey @adeb, I’m sorry to say but your question is way outside the scope of this forum. What you want to do is a very advanced thing and I think you are most likely going to have to find the person who wrote this code and have them help you. Also, I think you may not be allowed to post this code to the forum as it looks like it’s private and proprietary. I’d suggest that you delete this post (or tell me to) and then go contact the original author and ask for help.