Python PYQT Tabs outside app window [why] -


tabs added before app.exec_() called , act other tabs u met, though if adding after app.exec_() call makes new tab 'detach' main app window. pic below :)

why? how can make move inside window?

import threading import time import sys  pyqt5.qtwidgets import qapplication pyqt5.qtwidgets import qformlayout pyqt5.qtwidgets import qlineedit pyqt5.qtwidgets import qtabwidget pyqt5.qtwidgets import qtextedit pyqt5.qtwidgets import qwidget  class atry(threading.thread):     def __init__(self):         super().__init__()      def run(self):         time.sleep(1)         anothertextedit = qtextedit()         anotherlineedit = qlineedit()         anotherlayout = qformlayout()         anotherlayout.addrow(anothertextedit)         anotherlayout.addrow(anotherlineedit)         anothertab = qwidget()         anothertab.setlayout(anotherlayout)         md.addtab(anothertab, "outside")  app = qapplication(sys.argv) md = qtabwidget()  atextedit = qtextedit() alineedit = qlineedit() layout = qformlayout() layout.addrow(atextedit) layout.addrow(alineedit) thistab = qwidget() thistab.setlayout(layout) md.addtab(thistab, "inside")  = atry() a.start() md.show()  app.exec_() 

screen describing problem

it works qtimer or signals:

import sys import time  pyqt5.qtcore import qobject pyqt5.qtcore import qthread pyqt5.qtcore import pyqtsignal pyqt5.qtwidgets import qapplication pyqt5.qtwidgets import qformlayout pyqt5.qtwidgets import qlineedit pyqt5.qtwidgets import qtabwidget pyqt5.qtwidgets import qtextedit pyqt5.qtwidgets import qwidget   class atry(qthread):     def __init__(self, pointer):         super().__init__()         self.pointer = pointer      def run(self):         time.sleep(2)         self.pointer.emit()   def addthetab():     anothertextedit = qtextedit()     anotherlineedit = qlineedit()     anotherlayout = qformlayout()     anotherlayout.addrow(anotherlineedit)     anotherlayout.addrow(anothertextedit)     anothertab = qwidget()     anothertab.setlayout(anotherlayout)     md.addtab(anothertab, "whatever")   class myqobject(qobject):     trigger = pyqtsignal()      def __init__(self):         super().__init__()      def connect_and_get_trigger(self):         self.trigger.connect(addthetab)         return self.trigger      def getgfx(self):         app = qapplication(sys.argv)         md = qtabwidget()         md.show()         return app, md   obj = myqobject() app, md = obj.getgfx() addthetab() = atry(obj.connect_and_get_trigger()) a.start()  # timer = qtimer() # timer.timeout.connect(proba) # timer.start(3000)  app.exec_() 

Comments

Popular posts from this blog

serialization - Convert Any type in scala to Array[Byte] and back -

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -