Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #52819 > unrolled thread

Re: Using PyQT with QT Designer

Started byPhil Thompson <phil@riverbankcomputing.com>
First post2013-08-22 09:26 +0100
Last post2013-08-23 16:39 -0700
Articles 11 — 4 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Using PyQT with QT Designer Phil Thompson <phil@riverbankcomputing.com> - 2013-08-22 09:26 +0100
    Re: Using PyQT with QT Designer tausciam@gmail.com - 2013-08-22 18:08 -0700
      Re: Using PyQT with QT Designer Phil Thompson <phil@riverbankcomputing.com> - 2013-08-23 08:39 +0100
      Re: Using PyQT with QT Designer Michael Staggs <tausciam@gmail.com> - 2013-08-23 08:00 -0500
      Re: Using PyQT with QT Designer Phil Thompson <phil@riverbankcomputing.com> - 2013-08-23 18:17 +0100
      Re: Using PyQT with QT Designer Michael Staggs <tausciam@gmail.com> - 2013-08-23 12:30 -0500
      Re: Using PyQT with QT Designer Phil Thompson <phil@riverbankcomputing.com> - 2013-08-23 18:42 +0100
      Re: Using PyQT with QT Designer Michael Staggs <tausciam@gmail.com> - 2013-08-23 12:58 -0500
      Re: Using PyQT with QT Designer Michael Staggs <tausciam@gmail.com> - 2013-08-23 13:05 -0500
      Re: Using PyQT with QT Designer Dave Angel <davea@davea.name> - 2013-08-23 20:16 +0000
        Re: Using PyQT with QT Designer tausciam@gmail.com - 2013-08-23 16:39 -0700

#52819 — Re: Using PyQT with QT Designer

FromPhil Thompson <phil@riverbankcomputing.com>
Date2013-08-22 09:26 +0100
SubjectRe: Using PyQT with QT Designer
Message-ID<mailman.124.1377160367.19984.python-list@python.org>
On Wed, 21 Aug 2013 21:04:47 -0500, Michael Staggs <tausciam@gmail.com>
wrote:
> I'm learning Python and I have a problem. I've asked the question
> everywhere 
> and no one helps me, so I'm hoping someone here will. I am making a
> program 
> that shows album covers and you click on the album cover in the top
> window. In 
> the bottom window, the list of songs appear and you can click the
> individual 
> song to play it. It's going to be a media player for children. I'm
> thinking 
> I'll be able to use a dict and have the album as the key and the list of
> songs 
> as the value to accomplish this.
> 
> Right now, I'm just using my picture directory to try and get the basic
> layout 
> right. I designed a form in QT Designer: http://i.imgur.com/Wrp1zHW.png
> 
> Here is my gui file I got from running pyuic4 on the ui file:
> 
> 
> # -*- coding: utf-8 -*-
>  
> # Form implementation generated from reading ui file 'window.ui'
> #
> # Created by: PyQt4 UI code generator 4.9.6
> #
> # WARNING! All changes made in this file will be lost!
>  
> from PyQt4 import QtCore, QtGui
>  
> 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_MainWindow(object):
>     def setupUi(self, MainWindow):
>         MainWindow.setObjectName(_fromUtf8("MainWindow"))
>         MainWindow.resize(800, 600)
>         self.centralwidget = QtGui.QWidget(MainWindow)
>         self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
>         self.tableWidget = QtGui.QTableWidget(self.centralwidget)
>         self.tableWidget.setGeometry(QtCore.QRect(70, 20, 661, 381))
>         self.tableWidget.setObjectName(_fromUtf8("tableWidget"))
>         self.tableWidget.setColumnCount(0)
>         self.tableWidget.setRowCount(0)
>         self.listWidget = QtGui.QListWidget(self.centralwidget)
>         self.listWidget.setGeometry(QtCore.QRect(70, 400, 661, 181))
>         self.listWidget.setObjectName(_fromUtf8("listWidget"))
>         MainWindow.setCentralWidget(self.centralwidget)
>  
>         self.retranslateUi(MainWindow)
>         QtCore.QMetaObject.connectSlotsByName(MainWindow)
>  
>     def retranslateUi(self, MainWindow):
>         MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow",

> None))
> 
> Now, according to websites I read, I should just have to add the
following
> to 
> my program to get it to use the form:
> 
> from window import Ui_MainWindow
> class MainWindow(QMainWindow, Ui_MainWindow):
>     def __init__(self, parent=None, **kwargs):
>         super(MainWindow, self).__init__(parent)
>         self.setupUi(self)
> 
> and here is my program:
> 
> from PyQt4.QtCore import *
> from PyQt4.QtGui import *
> from window import Ui_MainWindow
>      
> THUMBNAIL_SIZE = 128
> SPACING        = 10
> IMAGES_PER_ROW = 5
>          
> class TableWidget(QTableWidget):
>     def __init__(self, parent=None, **kwargs):
>         QTableWidget.__init__(self, parent, **kwargs)
>          
>         self.setIconSize(QSize(128,128))
>         self.setColumnCount(IMAGES_PER_ROW)
>         self.setGridStyle(Qt.NoPen)
>          
>         # Set the default column width and hide the header
>        
self.verticalHeader().setDefaultSectionSize(THUMBNAIL_SIZE+SPACING)
>         self.verticalHeader().hide()
>          
>         # Set the default row height and hide the header
>        
self.horizontalHeader().setDefaultSectionSize(THUMBNAIL_SIZE+SPACING)
>         self.horizontalHeader().hide()
>          
>         # Set the table width to show all images without horizontal
>         scrolling
>        
self.setMinimumWidth((THUMBNAIL_SIZE+SPACING)*IMAGES_PER_ROW+(SPACING*2))
>          
>     def addPicture(self, row, col, picturePath):
>         item=QTableWidgetItem()
>          
>         # Scale the image by either height or width and then 'crop' it
to
>         the
>         # desired size, this prevents distortion of the image.
>         p=QPixmap(picturePath)
>         if p.height()>p.width(): p=p.scaledToWidth(THUMBNAIL_SIZE)
>         else: p=p.scaledToHeight(THUMBNAIL_SIZE)
>         p=p.copy(0,0,THUMBNAIL_SIZE,THUMBNAIL_SIZE)
>         item.setIcon(QIcon(p))
>          
>         self.setItem(row,col,item)
>          
> class MainWindow(QMainWindow, Ui_MainWindow):
>     def __init__(self, parent=None, **kwargs):
>         super(MainWindow, self).__init__(parent)
>         self.setupUi(self)
>          
>         centralWidget=QWidget(self)
>         l=QVBoxLayout(centralWidget)
>          
>         self.tableWidget=TableWidget(self)
>         l.addWidget(self.tableWidget)
>          
>         self.setCentralWidget(centralWidget)
>          
>        
picturesPath=QDesktopServices.storageLocation(QDesktopServices.PicturesLocation)
>         pictureDir=QDir(picturesPath)
>         pictures=pictureDir.entryList(['*.jpg','*.png','*.gif'])
>          
>         rowCount=len(pictures)//IMAGES_PER_ROW
>         if len(pictures)%IMAGES_PER_ROW: rowCount+=1
>         self.tableWidget.setRowCount(rowCount)
>          
>         row=-1
>         for i,picture in enumerate(pictures):
>             col=i%IMAGES_PER_ROW
>             if not col: row+=1
>             self.tableWidget.addPicture(row, col, 
> pictureDir.absoluteFilePath(picture))      
>          
> if __name__=="__main__":
>     from sys import argv, exit
>          
>     a=QApplication(argv)
>     m=MainWindow()
>     m.show()
>     m.raise_()
>     exit(a.exec_())
> 
> But, it doesn't work. It ignores the form and the two windows go from
side
> to 
> side in the frame. When I add buttons, it adds them on TOP of those two 
> windows instead of beside them in the empty space....because there is no
> empty 
> space.
> 
> http://i.imgur.com/ZQfsMDa.png
> 
> Please tell me what I'm doing wrong.

It looks like you aren't using a layout to arrange your widgets.
Explicitly specifying geometries is a bad idea.

Phil

[toc] | [next] | [standalone]


#52854

Fromtausciam@gmail.com
Date2013-08-22 18:08 -0700
Message-ID<8f9d0148-fda3-4139-ab45-a8be6da8320f@googlegroups.com>
In reply to#52819
On Thursday, August 22, 2013 3:26:17 AM UTC-5, Phil Thompson wrote:

> It looks like you aren't using a layout to arrange your widgets.
> 
> Explicitly specifying geometries is a bad idea.
> 
> 
> 
> Phil

Thanks.QT Designer uses set geometry and I'm totally lost as how to implement it. I've tried using a layout on the central widget. I've tried specifically referencing the Ui_MainWindow in the window.py ui file...

This is what I tried:

from PyQt4.QtCore import *
from PyQt4.QtGui import *
from window import Ui_MainWindow
     
THUMBNAIL_SIZE = 128
SPACING        = 10
IMAGES_PER_ROW = 4

class MainWindow(QMainWindow, Ui_MainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()

#        self.setWindowTitle("Image Gallery")
        
        centralWidget=QWidget(self)
        l=QVBoxLayout(centralWidget)
        
        self.tableWidget=TableWidget(self)
        l.addWidget(self.tableWidget)
        
        self.listWidget=ListWidget(self)
        l.addWidget(self.listWidget)
        
        Ui_MainWindow.pushButton = QPushButton(self)
        l.addWidget(Ui_MainWindow.pushButton)
        
        self.pushButton_2 = QPushButton(self)
        l.addWidget(self.pushButton_2)
        
        self.pushButton_3 = QPushButton(self)
        l.addWidget(self.pushButton_3)
     
        self.setCentralWidget(centralWidget)
     
        picturesPath=QDesktopServices.storageLocation(QDesktopServices.PicturesLocation)
        pictureDir=QDir(picturesPath)
        pictures=pictureDir.entryList(['*.jpg','*.png','*.gif'])
     
        rowCount=len(pictures)//IMAGES_PER_ROW
        if len(pictures)%IMAGES_PER_ROW: rowCount+=1
        self.tableWidget.setRowCount(rowCount)
     
        row=-1
        for i,picture in enumerate(pictures):
            col=i%IMAGES_PER_ROW
            if not col: row+=1
            self.tableWidget.addPicture(row, col, pictureDir.absoluteFilePath(picture))    

class ListWidget(QListWidget):
    def __init__(self, parent=MainWindow, **kwargs):
        QListWidget.__init__(self, parent, **kwargs)
        
        self.setGeometry(QRect(70, 400, 661, 181))
        
class TableWidget(QTableWidget):
    def __init__(self, parent=MainWindow, **kwargs):
        QTableWidget.__init__(self, parent, **kwargs)
     
        self.setIconSize(QSize(128,128))
        self.setColumnCount(IMAGES_PER_ROW)
        self.setGridStyle(Qt.NoPen)

        # Set the default column width and hide the header
        self.verticalHeader().setDefaultSectionSize(THUMBNAIL_SIZE+SPACING)
        self.verticalHeader().hide()
     
        # Set the default row height and hide the header
        self.horizontalHeader().setDefaultSectionSize(THUMBNAIL_SIZE+SPACING)
        self.horizontalHeader().hide()
     
        # Set the table width to show all images without horizontal scrolling
        self.setMinimumWidth((THUMBNAIL_SIZE+SPACING)*IMAGES_PER_ROW+(SPACING*2))
     
    def addPicture(self, row, col, picturePath):
        item=QTableWidgetItem()
     
        # Scale the image by either height or width and then 'crop' it to the
        # desired size, this prevents distortion of the image.
        p=QPixmap(picturePath)
        if p.height()>p.width(): p=p.scaledToWidth(THUMBNAIL_SIZE)
        else: p=p.scaledToHeight(THUMBNAIL_SIZE)
        p=p.copy(0,0,THUMBNAIL_SIZE,THUMBNAIL_SIZE)
        item.setIcon(QIcon(p))
     
        self.setItem(row,col,item)
        
     
if __name__=="__main__":
    from sys import argv, exit
     
    a=QApplication(argv)
    m=MainWindow()
    m.show()
    m.raise_()
    exit(a.exec_())

and I'm getting this (not even starting at 800x600): http://i.imgur.com/Xg4Qnzl.png

instead of this as it was designed in QT Designer: http://i.imgur.com/ULRolq8.png

Here is the ui file window.py that I got by running pyuic4 on window.ui:

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'window.ui'
#
# Created by: PyQt4 UI code generator 4.9.6
#
# WARNING! All changes made in this file will be lost!

from PyQt4 import QtCore, QtGui

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_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        MainWindow.resize(800, 600)
        MainWindow.setAnimated(False)
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        self.tableWidget = QtGui.QTableWidget(self.centralwidget)
        self.tableWidget.setGeometry(QtCore.QRect(70, 20, 661, 381))
        self.tableWidget.setObjectName(_fromUtf8("tableWidget"))
        self.tableWidget.setColumnCount(0)
        self.tableWidget.setRowCount(0)
        self.listWidget = QtGui.QListWidget(self.centralwidget)
        self.listWidget.setGeometry(QtCore.QRect(70, 400, 661, 181))
        self.listWidget.setObjectName(_fromUtf8("listWidget"))
        self.pushButton = QtGui.QPushButton(self.centralwidget)
        self.pushButton.setGeometry(QtCore.QRect(0, 150, 71, 81))
        self.pushButton.setText(_fromUtf8(""))
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(_fromUtf8("pics/eye.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.pushButton.setIcon(icon)
        self.pushButton.setIconSize(QtCore.QSize(64, 64))
        self.pushButton.setObjectName(_fromUtf8("pushButton"))
        self.pushButton_2 = QtGui.QPushButton(self.centralwidget)
        self.pushButton_2.setGeometry(QtCore.QRect(0, 230, 71, 81))
        self.pushButton_2.setText(_fromUtf8(""))
        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap(_fromUtf8("pics/ear.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.pushButton_2.setIcon(icon1)
        self.pushButton_2.setIconSize(QtCore.QSize(64, 64))
        self.pushButton_2.setObjectName(_fromUtf8("pushButton_2"))
        self.pushButton_3 = QtGui.QPushButton(self.centralwidget)
        self.pushButton_3.setGeometry(QtCore.QRect(730, 20, 61, 61))
        self.pushButton_3.setText(_fromUtf8(""))
        icon2 = QtGui.QIcon()
        icon2.addPixmap(QtGui.QPixmap(_fromUtf8("pics/exit.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.pushButton_3.setIcon(icon2)
        self.pushButton_3.setIconSize(QtCore.QSize(48, 48))
        self.pushButton_3.setObjectName(_fromUtf8("pushButton_3"))
        MainWindow.setCentralWidget(self.centralwidget)

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

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))




[toc] | [prev] | [next] | [standalone]


#52869

FromPhil Thompson <phil@riverbankcomputing.com>
Date2013-08-23 08:39 +0100
Message-ID<mailman.153.1377243588.19984.python-list@python.org>
In reply to#52854
On Thu, 22 Aug 2013 18:08:14 -0700 (PDT), tausciam@gmail.com wrote:
> On Thursday, August 22, 2013 3:26:17 AM UTC-5, Phil Thompson wrote:
> 
>> It looks like you aren't using a layout to arrange your widgets.
>> 
>> Explicitly specifying geometries is a bad idea.
>> 
>> 
>> 
>> Phil
> 
> Thanks.QT Designer uses set geometry

...only because you have told it to...

> and I'm totally lost as how to
> implement it. I've tried using a layout on the central widget. I've
tried
> specifically referencing the Ui_MainWindow in the window.py ui file...

You need to read up on how to use layouts in Designer. The generated .py
file will then do what you want automatically.

Phil

[toc] | [prev] | [next] | [standalone]


#52886

FromMichael Staggs <tausciam@gmail.com>
Date2013-08-23 08:00 -0500
Message-ID<mailman.164.1377262831.19984.python-list@python.org>
In reply to#52854

[Multipart message — attachments visible in raw view] — view raw

I tried that this morning and it destroyed my form. So, right now, that's
probably not what I'm looking for.

But, if you look at that picture, the app isn't resized to 800x600 like it
says in the ui file. The pixmaps aren't on the buttons like I set them up
in the ui file. It's not using the ui file at all. So, what's the point of
making a QT Designer file at all if it doesn't use it?

I'm guessing it CAN use it and there is just something I'm missing.

You may be right and I may not want to set the geometry in qt designer down
the road. But, right now I do and not only is it not getting that from the
ui file....it's not getting anything at all...even though I added all the
lines I thought I needed to.

If I decide to actually change the gui later, I'd like to be able to use QT
Designer to do so...design a layout and not really have to change my
program. As it stands, it's totally ignoring my ui file and I have to redo
all the work in the program. In which case, there's no point to using qt
designer at all.

I know I have to be missing something though.... there has to be a way to
use the work qt designer did.

Thanks
On Aug 23, 2013 2:39 AM, "Phil Thompson" <phil@riverbankcomputing.com>
wrote:

> On Thu, 22 Aug 2013 18:08:14 -0700 (PDT), tausciam@gmail.com wrote:
> > On Thursday, August 22, 2013 3:26:17 AM UTC-5, Phil Thompson wrote:
> >
> >> It looks like you aren't using a layout to arrange your widgets.
> >>
> >> Explicitly specifying geometries is a bad idea.
> >>
> >>
> >>
> >> Phil
> >
> > Thanks.QT Designer uses set geometry
>
> ...only because you have told it to...
>
> > and I'm totally lost as how to
> > implement it. I've tried using a layout on the central widget. I've
> tried
> > specifically referencing the Ui_MainWindow in the window.py ui file...
>
> You need to read up on how to use layouts in Designer. The generated .py
> file will then do what you want automatically.
>
> Phil
>

[toc] | [prev] | [next] | [standalone]


#52904

FromPhil Thompson <phil@riverbankcomputing.com>
Date2013-08-23 18:17 +0100
Message-ID<mailman.174.1377278254.19984.python-list@python.org>
In reply to#52854
On Fri, 23 Aug 2013 08:00:29 -0500, Michael Staggs <tausciam@gmail.com>
wrote:
> I tried that this morning and it destroyed my form. So, right now,
that's
> probably not what I'm looking for.
> 
> But, if you look at that picture, the app isn't resized to 800x600 like
it
> says in the ui file. The pixmaps aren't on the buttons like I set them
up
> in the ui file. It's not using the ui file at all. So, what's the point
of
> making a QT Designer file at all if it doesn't use it?

pyuic4 uses it to generate the corresponding Python code. Any time you
change the .ui file with Designer you have to run pyuic4 again. You should
not modify the Python code that pyuic4 generates.

> I'm guessing it CAN use it and there is just something I'm missing.
> 
> You may be right and I may not want to set the geometry in qt designer
down
> the road. But, right now I do and not only is it not getting that from
the
> ui file....it's not getting anything at all...even though I added all
the
> lines I thought I needed to.
> 
> If I decide to actually change the gui later, I'd like to be able to use
QT
> Designer to do so...design a layout and not really have to change my
> program. As it stands, it's totally ignoring my ui file and I have to
redo
> all the work in the program. In which case, there's no point to using qt
> designer at all.
> 
> I know I have to be missing something though.... there has to be a way
to
> use the work qt designer did.

I strongly suggest you do some more reading about using Designer.

Phil

[toc] | [prev] | [next] | [standalone]


#52905

FromMichael Staggs <tausciam@gmail.com>
Date2013-08-23 12:30 -0500
Message-ID<mailman.176.1377279049.19984.python-list@python.org>
In reply to#52854

[Multipart message — attachments visible in raw view] — view raw

Right. I know that if I redesign it I have to run pyuic4 again and that I
shouldn't change that file...let qt designer do its job.

But, that's exactly what I'm having the problem with...incorporating the
file pyuic4 gave me... and why I posted here.

If you can point me towards something I need to read then by all means...
I'd be grateful. But, all the little tutorials I've found told me to do it
this way and obviously my program has no access to it....it's not resizing
the window or doing anything the ui file states. So, I do know I'm doing
something wrong and doing something the little tutorials didn't account
for. So, I'm asking here.

Again, I'm just learning. I took the codecademy python course and started
trying to learn to build a media player...and haven't figured out how to
build the gui yet. If you or anyone else can point me to something that
would explain what I'm doing wrong, I'll read it from front to back. If
it's too advanced it will lose me....but I would like to learn to do this.
On Aug 23, 2013 12:17 PM, "Phil Thompson" <phil@riverbankcomputing.com>
wrote:

> On Fri, 23 Aug 2013 08:00:29 -0500, Michael Staggs <tausciam@gmail.com>
> wrote:
> > I tried that this morning and it destroyed my form. So, right now,
> that's
> > probably not what I'm looking for.
> >
> > But, if you look at that picture, the app isn't resized to 800x600 like
> it
> > says in the ui file. The pixmaps aren't on the buttons like I set them
> up
> > in the ui file. It's not using the ui file at all. So, what's the point
> of
> > making a QT Designer file at all if it doesn't use it?
>
> pyuic4 uses it to generate the corresponding Python code. Any time you
> change the .ui file with Designer you have to run pyuic4 again. You should
> not modify the Python code that pyuic4 generates.
>
> > I'm guessing it CAN use it and there is just something I'm missing.
> >
> > You may be right and I may not want to set the geometry in qt designer
> down
> > the road. But, right now I do and not only is it not getting that from
> the
> > ui file....it's not getting anything at all...even though I added all
> the
> > lines I thought I needed to.
> >
> > If I decide to actually change the gui later, I'd like to be able to use
> QT
> > Designer to do so...design a layout and not really have to change my
> > program. As it stands, it's totally ignoring my ui file and I have to
> redo
> > all the work in the program. In which case, there's no point to using qt
> > designer at all.
> >
> > I know I have to be missing something though.... there has to be a way
> to
> > use the work qt designer did.
>
> I strongly suggest you do some more reading about using Designer.
>
> Phil
>

[toc] | [prev] | [next] | [standalone]


#52906

FromPhil Thompson <phil@riverbankcomputing.com>
Date2013-08-23 18:42 +0100
Message-ID<mailman.177.1377279752.19984.python-list@python.org>
In reply to#52854
On Fri, 23 Aug 2013 12:30:41 -0500, Michael Staggs <tausciam@gmail.com>
wrote:
> Right. I know that if I redesign it I have to run pyuic4 again and that
I
> shouldn't change that file...let qt designer do its job.
> 
> But, that's exactly what I'm having the problem with...incorporating the
> file pyuic4 gave me... and why I posted here.
> 
> If you can point me towards something I need to read then by all
means...
> I'd be grateful. But, all the little tutorials I've found told me to do
it
> this way and obviously my program has no access to it....it's not
resizing
> the window or doing anything the ui file states. So, I do know I'm doing
> something wrong and doing something the little tutorials didn't account
> for. So, I'm asking here.
> 
> Again, I'm just learning. I took the codecademy python course and
started
> trying to learn to build a media player...and haven't figured out how to
> build the gui yet. If you or anyone else can point me to something that
> would explain what I'm doing wrong, I'll read it from front to back. If
> it's too advanced it will lose me....but I would like to learn to do
this.

http://qt-project.org/doc/qt-4.8/designer-manual.html

Designer has a preview option that creates your UI on the fly. The first
step would be to get it working as far as you can with that before you try
generating any Python code.

Phil

[toc] | [prev] | [next] | [standalone]


#52907

FromMichael Staggs <tausciam@gmail.com>
Date2013-08-23 12:58 -0500
Message-ID<mailman.179.1377280686.19984.python-list@python.org>
In reply to#52854

[Multipart message — attachments visible in raw view] — view raw

Thanks for the manual. I will look into it but all the examples are
probably c++. Ive tried zetcode and some of the other tutorials.

That's the problem though. It is exactly how I want it in designer. It's
perfect as it is in designer when I preview it. Here is a screenshot of the
preview: http://i.imgur.com/ULRolq8.png

The problem isn't that I can't design it in QT Designer. It is designed
just like I want it. The problem is, when I try to follow zetcode and other
tutorials about how to import and use my form as designed by qt designer
and run through pyuic4.... it doesn't seem to even notice my ui file...and
certainly isnt acting on it.

I posted my code above where I was trying anything just to get it to use
that ui I designed in qt designer.....so far to no avail
---------- Forwarded message ----------
From: "Michael Staggs" <tausciam@gmail.com>
Date: Aug 23, 2013 12:54 PM
Subject: Re: Using PyQT with QT Designer
To: "Phil Thompson" <phil@riverbankcomputing.com>
Cc:

Thanks for the manual. I will look into it but all the examples are
probably c++. Ive tried zetcode and some of the other tutorials.

That's the problem though. It is exactly how I want it in designer. It's
perfect as it is in designer when I preview it. Here is a screenshot of the
preview: http://i.imgur.com/ULRolq8.png

The problem isn't that I can't design it in QT Designer. It is designed
just like I want it. The problem is, when I try to follow zetcode and other
tutorials about how to import and use my form as designed by qt designer
and run through pyuic4.... it doesn't seem to even notice my ui file...and
certainly isnt acting on it.

I posted my code above where I was trying anything just to get it to use
that ui I designed in qt designer.....so far to no avail
On Aug 23, 2013 12:42 PM, "Phil Thompson" <phil@riverbankcomputing.com>
wrote:

> On Fri, 23 Aug 2013 12:30:41 -0500, Michael Staggs <tausciam@gmail.com>
> wrote:
> > Right. I know that if I redesign it I have to run pyuic4 again and that
> I
> > shouldn't change that file...let qt designer do its job.
> >
> > But, that's exactly what I'm having the problem with...incorporating the
> > file pyuic4 gave me... and why I posted here.
> >
> > If you can point me towards something I need to read then by all
> means...
> > I'd be grateful. But, all the little tutorials I've found told me to do
> it
> > this way and obviously my program has no access to it....it's not
> resizing
> > the window or doing anything the ui file states. So, I do know I'm doing
> > something wrong and doing something the little tutorials didn't account
> > for. So, I'm asking here.
> >
> > Again, I'm just learning. I took the codecademy python course and
> started
> > trying to learn to build a media player...and haven't figured out how to
> > build the gui yet. If you or anyone else can point me to something that
> > would explain what I'm doing wrong, I'll read it from front to back. If
> > it's too advanced it will lose me....but I would like to learn to do
> this.
>
> http://qt-project.org/doc/qt-4.8/designer-manual.html
>
> Designer has a preview option that creates your UI on the fly. The first
> step would be to get it working as far as you can with that before you try
> generating any Python code.
>
> Phil
>

[toc] | [prev] | [next] | [standalone]


#52908

FromMichael Staggs <tausciam@gmail.com>
Date2013-08-23 13:05 -0500
Message-ID<mailman.180.1377281128.19984.python-list@python.org>
In reply to#52854

[Multipart message — attachments visible in raw view] — view raw

Again though....I'm finished with QT Designer. I have the finished product
I want exactly like I want it. But, as ive shown in the screenshots, I'm
doing exactly what ive seen in zetcode and other tutorials but It doesn't
seem to incorporate and act upon that ui file. The first thing you notice
is that it doesn't resize the main window to 800x600...which is one of the
first lines in the ui file.

I know whatever I'm doing wrong has to be a 1 or 2 line solution...just
something I should change a little....but I dont know what that is
On Aug 23, 2013 12:42 PM, "Phil Thompson" <phil@riverbankcomputing.com>
wrote:

> On Fri, 23 Aug 2013 12:30:41 -0500, Michael Staggs <tausciam@gmail.com>
> wrote:
> > Right. I know that if I redesign it I have to run pyuic4 again and that
> I
> > shouldn't change that file...let qt designer do its job.
> >
> > But, that's exactly what I'm having the problem with...incorporating the
> > file pyuic4 gave me... and why I posted here.
> >
> > If you can point me towards something I need to read then by all
> means...
> > I'd be grateful. But, all the little tutorials I've found told me to do
> it
> > this way and obviously my program has no access to it....it's not
> resizing
> > the window or doing anything the ui file states. So, I do know I'm doing
> > something wrong and doing something the little tutorials didn't account
> > for. So, I'm asking here.
> >
> > Again, I'm just learning. I took the codecademy python course and
> started
> > trying to learn to build a media player...and haven't figured out how to
> > build the gui yet. If you or anyone else can point me to something that
> > would explain what I'm doing wrong, I'll read it from front to back. If
> > it's too advanced it will lose me....but I would like to learn to do
> this.
>
> http://qt-project.org/doc/qt-4.8/designer-manual.html
>
> Designer has a preview option that creates your UI on the fly. The first
> step would be to get it working as far as you can with that before you try
> generating any Python code.
>
> Phil
>

[toc] | [prev] | [next] | [standalone]


#52911

FromDave Angel <davea@davea.name>
Date2013-08-23 20:16 +0000
Message-ID<mailman.182.1377289040.19984.python-list@python.org>
In reply to#52854
Michael Staggs wrote:


>
> That's the problem though. It is exactly how I want it in designer. It's
> perfect as it is in designer when I preview it. Here is a screenshot of the
> preview: http://i.imgur.com/ULRolq8.png
>
> The problem isn't that I can't design it in QT Designer. It is designed
> just like I want it. The problem is, when I try to follow zetcode and other
> tutorials about how to import and use my form as designed by qt designer
> and run through pyuic4.... it doesn't seem to even notice my ui file...and
> certainly isnt acting on it.
>

I don't know PyQT, so I've kept quiet so far...

You don't say what the name of the generated file is, but perhaps since
the source file was window.ui, the generated one is window.py

My guess is that when you do the

from window import Ui_MainWindow

it is finding some OTHER window.py file.

Have you tried simply adding an illegal line to the generated file, to
force the compiler to fail the import?  Once you're sure that it is
importing this particular file, you can remove such a line.

Could be that you have some other window.py file  (or window.pyc, or
whatever) and that it's finding that one.  Or it's finding some older
version of this one.



-- 
DaveA

[toc] | [prev] | [next] | [standalone]


#52915

Fromtausciam@gmail.com
Date2013-08-23 16:39 -0700
Message-ID<8fd16ce2-c620-45ae-ad6e-403dda99d050@googlegroups.com>
In reply to#52911
Thank you. I just deleted all of them, reran pyuic4 on window.ui and regenerated window.py just to make sure. Unfortunately, I get the same problem.

I've got the GUI perfectly designed just like I want it in window.py... just can't figure out how to use it in my program.

On Friday, August 23, 2013 3:16:59 PM UTC-5, Dave Angel wrote:
> Michael Staggs wrote:
> 
> 
> 
> 
> 
> >
> 
> > That's the problem though. It is exactly how I want it in designer. It's
> 
> > perfect as it is in designer when I preview it. Here is a screenshot of the
> 
> > preview: http://i.imgur.com/ULRolq8.png
> 
> >
> 
> > The problem isn't that I can't design it in QT Designer. It is designed
> 
> > just like I want it. The problem is, when I try to follow zetcode and other
> 
> > tutorials about how to import and use my form as designed by qt designer
> 
> > and run through pyuic4.... it doesn't seem to even notice my ui file...and
> 
> > certainly isnt acting on it.
> 
> >
> 
> 
> 
> I don't know PyQT, so I've kept quiet so far...
> 
> 
> 
> You don't say what the name of the generated file is, but perhaps since
> 
> the source file was window.ui, the generated one is window.py
> 
> 
> 
> My guess is that when you do the
> 
> 
> 
> from window import Ui_MainWindow
> 
> 
> 
> it is finding some OTHER window.py file.
> 
> 
> 
> Have you tried simply adding an illegal line to the generated file, to
> 
> force the compiler to fail the import?  Once you're sure that it is
> 
> importing this particular file, you can remove such a line.
> 
> 
> 
> Could be that you have some other window.py file  (or window.pyc, or
> 
> whatever) and that it's finding that one.  Or it's finding some older
> 
> version of this one.
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> DaveA

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web