Could anyone tel me that how can I link two widgets in PyQt4.
one more thing I want to know. I have created a tabbed view. How can I add the vcontents in a tabbed view?

Recommended Answers

All 2 Replies

Look at this post for learning PyQt,i like wxpython better as many her on daniweb.
http://www.daniweb.com/forums/thread191210.html
There are license problem with PyQt.

How can I add the vcontents in a tabbed view?

You can use Qtabwidget.
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qtabwidget.html

import os, sys 
from PyQt4 import QtGui, QtCore 

class MainWindow(QtGui.QWidget): 
    def __init__(self): 
        QtGui.QWidget.__init__(self) 
         
        self.setGeometry(0,0, 200,300) 
        self.setWindowTitle("my window")         
        self.resize(200,300) 
        self.setMinimumSize(200,300) 
        self.center()         
         
        tab_widget = QtGui.QTabWidget() 
        tab1 = QtGui.QWidget() 
        tab2 = QtGui.QWidget() 
         
        p1_vertical = QtGui.QVBoxLayout(tab1) 
        p2_vertical = QtGui.QVBoxLayout(tab2) 
         
        tab_widget.addTab(tab1, "Main") 
        tab_widget.addTab(tab2, "Description")        
        vbox = QtGui.QVBoxLayout()      
        vbox.addWidget(tab_widget)         
        self.setLayout(vbox)      
     
    def center(self): 
        screen = QtGui.QDesktopWidget().screenGeometry() 
        size = self.geometry() 
        self.move((screen.width()-size.width())/2, (screen.height()-size.height())/2)

app = QtGui.QApplication(sys.argv) 
frame = MainWindow() 
frame.show() 
sys.exit(app.exec_())

Look at this post for learning PyQt,i like wxpython better as many her on daniweb.
http://www.daniweb.com/forums/thread191210.html
There are license problem with PyQt.


You can use Qtabwidget.
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qtabwidget.html

import os, sys 
from PyQt4 import QtGui, QtCore 

class MainWindow(QtGui.QWidget): 
    def __init__(self): 
        QtGui.QWidget.__init__(self) 
         
        self.setGeometry(0,0, 200,300) 
        self.setWindowTitle("my window")         
        self.resize(200,300) 
        self.setMinimumSize(200,300) 
        self.center()         
         
        tab_widget = QtGui.QTabWidget() 
        tab1 = QtGui.QWidget() 
        tab2 = QtGui.QWidget() 
         
        p1_vertical = QtGui.QVBoxLayout(tab1) 
        p2_vertical = QtGui.QVBoxLayout(tab2) 
         
        tab_widget.addTab(tab1, "Main") 
        tab_widget.addTab(tab2, "Description")        
        vbox = QtGui.QVBoxLayout()      
        vbox.addWidget(tab_widget)         
        self.setLayout(vbox)      
     
    def center(self): 
        screen = QtGui.QDesktopWidget().screenGeometry() 
        size = self.geometry() 
        self.move((screen.width()-size.width())/2, (screen.height()-size.height())/2)

app = QtGui.QApplication(sys.argv) 
frame = MainWindow() 
frame.show() 
sys.exit(app.exec_())

Thanks a lot

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.