0

I have been trying to create GUI program for my laboratory colleagues.

I have some textboxes on my main window to show files directory that added by user.

I am new in PyQt5 and I want to add feature to my textboxes.

For example, textbox=QLineEdit().. textbox1=.. textbox2=..

So I want to choose textbox before I add file by clicking on the main window then directory of file will be written correct textbox.

I tried to make custom clickablelineedit but I did not succeed.

Is there another way to do it ?

King regards,

EDIT:

class Mutation_Finder():
    def __init__(self):
        ... (Main Window Code)
    def openFileNamesDialog(self, **kwargs):
        self.options = QFileDialog.Options()
        self.options |= QFileDialog.DontUseNativeDialog
        self.files, self._= QFileDialog.getOpenFileNames(self,"Dosya Ac","","All Files (*);;.abi,.fasta (*.abi,*fasta)", options=self.options)
    def toDoSomething():
        if textbox is clicked:
            for i in range(len(self.files):
                self.textbox.insert(self.files[i])
        if textbox1 is clicked:
            ...
        if textbox2 is clicked:
            ...

see the main window image

ggokturk
  • 15
  • 6
  • 1
    Can you give a code example to understand better your question? – Jacob Fuchs Jan 30 '19 at 08:32
  • I added some piece of code and image of my main window. – ggokturk Jan 30 '19 at 09:33
  • Seems to be a UI design issue. What if you have only one QTextEdit at the bottom and then a set of radio buttons with the options (Ref, Forward, Reverse) so the user can pick one and execute something? – cmaureir Jan 31 '19 at 10:15
  • I thought it before actually but I don't know whether user friendly or not thats why I have been trying to integrate radio button feature to QLineEdit but I will see. Thank you for your comment. – ggokturk Jan 31 '19 at 12:02

1 Answers1

0

SOLVED:

class cQLineEdit(QLineEdit):
    clicked=pyqtSignal()

    def __init__(self,*args, **kwargs):
        super().__init__(*args,**kwargs)

    def mousePressEvent(self,QMouseEvent):
        self.clicked.emit()

class MainClass(cQLineEdit)
    textbox=cQLineEdit(self)
    ....
    ....
    self.clicked.connect(...)

I solved it with this method but I have still problem with clicked event because when I click out of the QLineEdit I have Error:

self.clicked.emit() AttributeError: 'className' does not have a signal with the signature clicked()

like this and I don't have any idea how to deal with as well.

Apart from that, here is link that related with solution. Pyqt 5 how to make QLineEdit clickable

ggokturk
  • 15
  • 6