python 2.7 - PySide: How to change the status bar text from another class? -


I am trying to design a GUI using PySide and let me make some positions and update the status bar. is intended. However, there is something wrong with my code. Can someone see me what I am doing wrong? Especially in the way I call method method under SampleTab1 class

  PySide Import from QtGui class MainWindow import sys (QtGui.QMainWindow):. Def __init __ (self): super (MainWindow, self). __init __ () # setup window self.resize (750, 550) self.myGUI () def myGUI (self): # tab widgets self.mytabs_widget = QtGui.QTabWidget () create self.mytabs_widget.addTab (SampleTab1 (self.mytabs_widget ), "Tab 1") # Create widget area area for tab widgets self.mylayout = QtGui.QHBoxLayout () self.mylayout.addWidget (self.mytabs_widget) #cadding self.mycontent_widget = QtGui.QWidget (create content area widget) ) Self.mycontent_widget.setContentsMargins (5, 5, 5, 0) self.mycontent_widget.setLayout (self.mylayout) # Central widgets self.setCentralWidget set (self.mycontent_widget) self.setWindowTitle ("tab example") # create a status Information about progress with time self.statu SText = QtGui.QLabel ("Ready") self.statusBar () addWidget (self.statusText, 1) Square SampleTab1 (QtGui.QWidget) :. Def __init __ (self, parent = none): Super (SampleTab1, self) .__ init __ (parent) label = QtGui.QLabel ('Sample tab 1', self) label.move (15, 10) self. show () try: Selfkprocess () def process (self): MainWindowkstatusTextksetText ( "processing") def main (): the barring app = QtGui.QApplication (Syskargv): app = QtGui.QApplication .instance () app.aboutToQuit.connect (app.deleteLater) window = MainWindow () window.show () Sys.exit (app.exec_ ()) if __name__ == '__main__': main ()  < / Pre> 

If you are a parent, You can acces the mainWindow from the Yum, add the following lines to your code: MainWindow tabWidget

set as the origin of
 (put brackets inside )> ... self .mytabs_widget = QtGu I.qtabwidget (self) ...  

using the main code parent () method:

  Use ... Def process (self): self. (Original). mother-father (). Status () Show Message ("Processing") ...  

Here self.parent () gives you a tab visit, so own (). Parent () gives you the main window

I have updated your post code:

  importing system import from PySide QtGui class MainWindow (QtGui.QMainWindow): def __init __ (self): Super (MainWindow, self) .__ init __ () # setup window self.resize (750, 550) self.myGUI () def MyGUI (self): # tab widget self.mytabs_widget = QtGui.QTabWidget ( themselves) make self.mytabs_widget.addTab (SampleTab1 (self.mytabs_widget), 1 "" tab) # tabs widget created self.mylayout = QtGui.QHBoxLayout () layout to its own zone. Create content area widget for mylayout.addWidget (self.mytabs_widget) # padding self.my content_widget = QtGui.QWidget () self.mycontent_widget.setContentsMargins (5, 5, 5, 0) self.mycontent_widget.setLayout (self.mylayout) # the widget self.setCentralWidget (self.mycontent_widget) self.setWindowTitle ( "tab set the example") # progress create a status bar with information self.statusText = QtGui.QLabel ( "Ready") self.statusBar () addWidget (self .statusText, 1) Class SampleTab1 (QtGui.QWidget) :. Def __init __ (self, parent = none): Super (SampleTab1, self) .__ init __ (parent) label = QtGui.QLabel ('Sample tab 1', self) label.move (15, 10) self. Show () self.process () def process (self):. Self.parent () Parents () Try: KstatusBar () ShowMessage ( "processing") def main (): The app = except QtGui.QApplication (sys.argv): app = QtGui.QApplication.instance () app.aboutToQuit.connect (app. DeleteLater) window = MainWindow () window.show () sys.exit (app.exec_ ()) if __name__ == '__main__': main ()  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -