Re: MTG: Introductions to PyQt and DataClasses

2024-03-17 Thread dn via Python-list

On 18/03/24 10:02, Jim Schwartz wrote:

Actually, I have a sleep disorder that requires me to keep a constant sleep 
schedule. Thats why I asked.


At a weekend meeting, discussion swirled around topics such as the best 
way to learn/work, how much work we should attempt in one sitting, 
could/should I 'do more', and similar.


One of the valuable observations is that most of us would benefit by 
improving our sleep-schedule and ensuring we do sleep for sufficient 
time (probably longer than current habit).


--
Regards,
=dn

--
https://mail.python.org/mailman/listinfo/python-list


Re: MTG: Introductions to PyQt and DataClasses

2024-03-17 Thread Jim Schwartz via Python-list
Actually, I have a sleep disorder that requires me to keep a constant sleep 
schedule. Thats why I asked. 

Sent from my iPhone

> On Mar 17, 2024, at 3:36 PM, dn via Python-list  
> wrote:
> 
> On 17/03/24 23:40, Jim Schwartz wrote:
>> Will it be recorded?
> 
> Better than that (assumption) "coming soon" - please join-up or keep an eye 
> on PySprings' Meetup ANNs: https://www.meetup.com/pysprings/
> 
> 
>>>> On Mar 17, 2024, at 1:47 AM, dn via Python-list  
>>>> wrote:
>>> 
>>> The Auckland Branch of NZPUG meets this Wednesday, 20 March at 1830 NZDT 
>>> (0530 UTC, midnight-ish Tue/Wed in American time-zones), for a virtual 
>>> meeting.
>>> 
>>> Part 1: Learn the basics of PyQt with code examples.
>>> Hannan Khan is currently consulting as a Data Scientist for the (US) 
>>> National Oceanic and Atmospheric Administration. He holds a Bachelor's 
>>> degree in Neuroscience as well as a Masters in Computer Science. As a keen 
>>> member of the PySprings Users' Group (Colorado), his contribution is part 
>>> of a collaboration between our two PUGs.
>>> 
>>> Part 2: Why use Dataclasses?
>>> - will be the question asked, and answered, by yours truly. After surveying 
>>> a number of groups, it seems most of us know that Dataclasses are 
>>> available, but we don't use them - mostly because we haven't ascertained 
>>> their place in our tool-box. By the end of this session you will, and will 
>>> have good reason to use (or not) Dataclasses!
>>> 
>>> Everyone is welcome from every location and any time-zone. The NZPUG Code 
>>> of Conduct applies. JetBrains have kindly donated a door-prize. Our 
>>> BigBlueButton web-conferencing instance is best accessed using Chromium, 
>>> Brave, Vivaldi, Safari, etc, (rather than Firefox - for now). A head-set 
>>> will facilitate asking questions but text-chat will be available.
>>> 
>>> Please RSVP at https://www.meetup.com/nzpug-auckland/events/299764049/
>>> See you there!
>>> =dn, Branch Leader
>>> --
>>> https://mail.python.org/mailman/listinfo/python-list
> 
> --
> Regards,
> =dn
> 
> --
> https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: MTG: Introductions to PyQt and DataClasses

2024-03-17 Thread dn via Python-list

On 17/03/24 23:40, Jim Schwartz wrote:

Will it be recorded?


Better than that (assumption) "coming soon" - please join-up or keep an 
eye on PySprings' Meetup ANNs: https://www.meetup.com/pysprings/




On Mar 17, 2024, at 1:47 AM, dn via Python-list  wrote:

The Auckland Branch of NZPUG meets this Wednesday, 20 March at 1830 NZDT (0530 
UTC, midnight-ish Tue/Wed in American time-zones), for a virtual meeting.

Part 1: Learn the basics of PyQt with code examples.
Hannan Khan is currently consulting as a Data Scientist for the (US) National 
Oceanic and Atmospheric Administration. He holds a Bachelor's degree in 
Neuroscience as well as a Masters in Computer Science. As a keen member of the 
PySprings Users' Group (Colorado), his contribution is part of a collaboration 
between our two PUGs.

Part 2: Why use Dataclasses?
- will be the question asked, and answered, by yours truly. After surveying a 
number of groups, it seems most of us know that Dataclasses are available, but 
we don't use them - mostly because we haven't ascertained their place in our 
tool-box. By the end of this session you will, and will have good reason to use 
(or not) Dataclasses!

Everyone is welcome from every location and any time-zone. The NZPUG Code of 
Conduct applies. JetBrains have kindly donated a door-prize. Our BigBlueButton 
web-conferencing instance is best accessed using Chromium, Brave, Vivaldi, 
Safari, etc, (rather than Firefox - for now). A head-set will facilitate asking 
questions but text-chat will be available.

Please RSVP at https://www.meetup.com/nzpug-auckland/events/299764049/
See you there!
=dn, Branch Leader
--
https://mail.python.org/mailman/listinfo/python-list




--
Regards,
=dn

--
https://mail.python.org/mailman/listinfo/python-list


Re: MTG: Introductions to PyQt and DataClasses

2024-03-17 Thread Jim Schwartz via Python-list
Will it be recorded?  

Sent from my iPhone

> On Mar 17, 2024, at 1:47 AM, dn via Python-list  
> wrote:
> 
> The Auckland Branch of NZPUG meets this Wednesday, 20 March at 1830 NZDT 
> (0530 UTC, midnight-ish Tue/Wed in American time-zones), for a virtual 
> meeting.
> 
> Part 1: Learn the basics of PyQt with code examples.
> Hannan Khan is currently consulting as a Data Scientist for the (US) National 
> Oceanic and Atmospheric Administration. He holds a Bachelor's degree in 
> Neuroscience as well as a Masters in Computer Science. As a keen member of 
> the PySprings Users' Group (Colorado), his contribution is part of a 
> collaboration between our two PUGs.
> 
> Part 2: Why use Dataclasses?
> - will be the question asked, and answered, by yours truly. After surveying a 
> number of groups, it seems most of us know that Dataclasses are available, 
> but we don't use them - mostly because we haven't ascertained their place in 
> our tool-box. By the end of this session you will, and will have good reason 
> to use (or not) Dataclasses!
> 
> Everyone is welcome from every location and any time-zone. The NZPUG Code of 
> Conduct applies. JetBrains have kindly donated a door-prize. Our 
> BigBlueButton web-conferencing instance is best accessed using Chromium, 
> Brave, Vivaldi, Safari, etc, (rather than Firefox - for now). A head-set will 
> facilitate asking questions but text-chat will be available.
> 
> Please RSVP at https://www.meetup.com/nzpug-auckland/events/299764049/
> See you there!
> =dn, Branch Leader
> --
> https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


MTG: Introductions to PyQt and DataClasses

2024-03-17 Thread dn via Python-list
The Auckland Branch of NZPUG meets this Wednesday, 20 March at 1830 NZDT 
(0530 UTC, midnight-ish Tue/Wed in American time-zones), for a virtual 
meeting.


Part 1: Learn the basics of PyQt with code examples.
Hannan Khan is currently consulting as a Data Scientist for the (US) 
National Oceanic and Atmospheric Administration. He holds a Bachelor's 
degree in Neuroscience as well as a Masters in Computer Science. As a 
keen member of the PySprings Users' Group (Colorado), his contribution 
is part of a collaboration between our two PUGs.


Part 2: Why use Dataclasses?
- will be the question asked, and answered, by yours truly. After 
surveying a number of groups, it seems most of us know that Dataclasses 
are available, but we don't use them - mostly because we haven't 
ascertained their place in our tool-box. By the end of this session you 
will, and will have good reason to use (or not) Dataclasses!


Everyone is welcome from every location and any time-zone. The NZPUG 
Code of Conduct applies. JetBrains have kindly donated a door-prize. Our 
BigBlueButton web-conferencing instance is best accessed using Chromium, 
Brave, Vivaldi, Safari, etc, (rather than Firefox - for now). A head-set 
will facilitate asking questions but text-chat will be available.


Please RSVP at https://www.meetup.com/nzpug-auckland/events/299764049/
See you there!
=dn, Branch Leader
--
https://mail.python.org/mailman/listinfo/python-list


Re: Any PyQt developers here?

2022-10-29 Thread Michael Torrie
On 10/28/22 21:31, DFS wrote:
> I found one person that said they did it but their syntax didn't work. 
> But it doesn't throw an error either.
> 
> model.setData(model.index(tblRow, col), font, Qt.FontRole)

I wouldn't expect that to work but it's understandable why it didn't
throw an error.  setData() is used to edit the contents of the model at
the provided index. Remember a model can store anything. All this does
is replace whatever was at that index with a Font object instance.  I'm
puzzled why you keep trying to mess with the model when it's the view
that does the actual font setting.  Remember that a single model can be
used with more than one view at the same time, each view implementing
its own style. Thus a model has no information like fonts in it, nor
should it, other than perhaps HTML text markup that the view will render.

Did you consult the folk on the PyQt mailing list? Or even the main Qt
lists?  This isn't language-specific stuff you're asking about.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Any PyQt developers here?

2022-10-28 Thread DFS

On 10/27/2022 3:47 PM, Thomas Passin wrote:

On 10/27/2022 11:15 AM, DFS wrote:

On 10/25/2022 1:45 PM, Thomas Passin wrote:

On 10/25/2022 1:03 PM, DFS wrote:

Having problems with removeRow() on a QTableView object.


removeRow() isn't listed as being a method of a QTableView, not even 
an inherited method, so how are you calling removeRow() on it? (See 
https://doc.qt.io/qt-6/qtableview-members.html)


Since you helped me on the last one, maybe you could try to answer a 
couple more [probably simple] roadblocks I'm hitting.



I just wanna set the font to bold/not-bold when clicking on a row in 
QTableView.




With a QTableWidget I do it like this:

font = QFont()
font.setBold(True) or False
QTableWidget.item(row,col).setFont(font)



But the QTableView has data/view 'models' attached to it and that 
syntax doesn't work:



Tried:
font = QFont()
font.setBold(True) or False
model = QTableView.model()
model.setFont(model.index(row,col), font)

Throws AttributeError: 'QSqlTableModel' object has no attribute 'setFont'


This doesn't throw an error, but doesn't show bold:
model.setData(model.index(tblRow, col), font, Qt.FontRole)


Any ideas?


You definitely need to be setting the font in an item.  I'm not sure but 
I think that your QFont() doesn't have any properties, so it doesn't do 
anything.  I found this bit in a page - it's in C++ instead of Python 
but that doesn't really make a difference except for the exact syntax to 
use -



https://forum.qt.io/topic/70016/qlistview-item-font-stylesheet-not-working/4 



   QVariant v = ModelBaseClass::data(index,role);
   if( condition && role == Qt::FontRole )
   {
    QFont font = v.value();
     font.setBold( true );
    v = QVariant::fromValue( font );
   }

IOW, you have to get the font from the item, then set it to bold, which 
you would do with setFont().  Then you set that new font on the item. Of 
course you would have to unset bold on it later. See


https://doc.qt.io/qt-6/qtablewidgetitem.html#font

Instead of "item", you might need to operate on "row".  I didn't look 
into that.  Since a row probably doesn't have just one font (since it 
can have more than one item), you'd still have to get the font from some 
item in the row.


You might also be able to make the item bold using CSS, but I'm not sure.


Thanks


Internet searches are your friend for questions like this.  


Before I posted I spent a couple hours looking online, reading the docs, 
and trying different ways.


I found one person that said they did it but their syntax didn't work. 
But it doesn't throw an error either.


model.setData(model.index(tblRow, col), font, Qt.FontRole)

When I'm done with my app (nearly 2K LOC) I'm going to put a summary out 
there somewhere with a bunch of examples of easy ways to do things.  For 
one thing I wrote zero classes.  Not one.




I've never 
worked with a QTableView, so I had to start with some knowledge about 
some other parts of QT.  I found the first page searching for "qt set 
qtableview row font", and the second searching for "qtablewidgetitem".



I used TableWidgets in 2 apps and no problems.  In this app there's more 
data and more sorting, and one of the TableWidgets took a while to load 
35K rows (7 items per row).  So I tried a TableView.  Incredibly fast - 
4x the speed - but it doesn't have the bolding in place yet.  That could 
slow it down.


As you know, a TableView is tied to the underlying datasource (in my 
case via a QSqlTableModel), but it's much faster to show data than a 
TableWidget, because with the widget you have populate each cell with 
setItem().


The Widget is slower but easier to work with.  So it's a tradeoff.


And I think I found some bugs in the TableViews.  The Views have 
editStrategies() that control how data is updated (if the model supports 
editing), but they don't work the way the docs say they do.


In my app, when I click on a row a flag field is changed from N to Y 
onscreen (well, it's hidden but it's in the row).


model.setData(model.index(row,7), 'Y')


OnFieldChange  : all changes to the model will be applied immediately to 
the database.

model.setEditStrategy(QSqlTableModel.OnFieldChange)

Doesn't work right.  The screen is updated the first row you click on, 
but the db isn't updated until you reload the view.



OnRowChange: changes to a row will be applied when the user selects 
a different row.

model.setEditStrategy(QSqlTableModel.OnRowChange)

Doesn't work right.  The screen is updated the first row you click on, 
but the db isn't updated until you reload the view.



OnManualSubmit : all changes will be cached in the model until either 
submitAll() or revertAll() is called.

model.setEditStrategy(QSqlTableModel.OnManualSubmit)

This works the best: the screen changes on each row I click, but the db 
isn't updated even if I do submitAll() right after setData().  Have to 
reload the view for the changes to propagate to the 

Re: Any PyQt developers here?

2022-10-28 Thread Thomas Passin

On 10/28/2022 1:01 AM, Thomas Passin wrote:
{snip]

You might also be able to make the item bold using CSS, but I'm not sure.



Apparently so:

QTreeView::item:selected {
background-color: #1d3dec;
color: white;
}

See https://joekuan.wordpress.com/2015/10/02/styling-qt-qtreeview-with-css/.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Any PyQt developers here?

2022-10-27 Thread Thomas Passin

This looks like a useful tutorial -

https://doc.qt.io/qt-6/modelview.html

On 10/27/2022 3:47 PM, Thomas Passin wrote:

On 10/27/2022 11:15 AM, DFS wrote:

On 10/25/2022 1:45 PM, Thomas Passin wrote:

On 10/25/2022 1:03 PM, DFS wrote:

Having problems with removeRow() on a QTableView object.


removeRow() isn't listed as being a method of a QTableView, not even 
an inherited method, so how are you calling removeRow() on it? (See 
https://doc.qt.io/qt-6/qtableview-members.html)


Since you helped me on the last one, maybe you could try to answer a 
couple more [probably simple] roadblocks I'm hitting.



I just wanna set the font to bold/not-bold when clicking on a row in 
QTableView.




With a QTableWidget I do it like this:

font = QFont()
font.setBold(True) or False
QTableWidget.item(row,col).setFont(font)



But the QTableView has data/view 'models' attached to it and that 
syntax doesn't work:



Tried:
font = QFont()
font.setBold(True) or False
model = QTableView.model()
model.setFont(model.index(row,col), font)

Throws AttributeError: 'QSqlTableModel' object has no attribute 'setFont'


This doesn't throw an error, but doesn't show bold:
model.setData(model.index(tblRow, col), font, Qt.FontRole)


Any ideas?


You definitely need to be setting the font in an item.  I'm not sure but 
I think that your QFont() doesn't have any properties, so it doesn't do 
anything.  I found this bit in a page - it's in C++ instead of Python 
but that doesn't really make a difference except for the exact syntax to 
use -



https://forum.qt.io/topic/70016/qlistview-item-font-stylesheet-not-working/4

   QVariant v = ModelBaseClass::data(index,role);
   if( condition && role == Qt::FontRole )
   {
    QFont font = v.value();
     font.setBold( true );
    v = QVariant::fromValue( font );
   }

IOW, you have to get the font from the item, then set it to bold, which 
you would do with setFont().  Then you set that new font on the item. Of 
course you would have to unset bold on it later. See


https://doc.qt.io/qt-6/qtablewidgetitem.html#font

Instead of "item", you might need to operate on "row".  I didn't look 
into that.  Since a row probably doesn't have just one font (since it 
can have more than one item), you'd still have to get the font from some 
item in the row.


You might also be able to make the item bold using CSS, but I'm not sure.


Thanks


Internet searches are your friend for questions like this.  I've never 
worked with a QTableView, so I had to start with some knowledge about 
some other parts of QT.  I found the first page searching for "qt set 
qtableview row font", and the second searching for "qtablewidgetitem".




--
https://mail.python.org/mailman/listinfo/python-list


Re: Any PyQt developers here?

2022-10-27 Thread Thomas Passin

On 10/27/2022 11:15 AM, DFS wrote:

On 10/25/2022 1:45 PM, Thomas Passin wrote:

On 10/25/2022 1:03 PM, DFS wrote:

Having problems with removeRow() on a QTableView object.


removeRow() isn't listed as being a method of a QTableView, not even 
an inherited method, so how are you calling removeRow() on it? (See 
https://doc.qt.io/qt-6/qtableview-members.html)


Since you helped me on the last one, maybe you could try to answer a 
couple more [probably simple] roadblocks I'm hitting.



I just wanna set the font to bold/not-bold when clicking on a row in 
QTableView.




With a QTableWidget I do it like this:

font = QFont()
font.setBold(True) or False
QTableWidget.item(row,col).setFont(font)



But the QTableView has data/view 'models' attached to it and that syntax 
doesn't work:



Tried:
font = QFont()
font.setBold(True) or False
model = QTableView.model()
model.setFont(model.index(row,col), font)

Throws AttributeError: 'QSqlTableModel' object has no attribute 'setFont'


This doesn't throw an error, but doesn't show bold:
model.setData(model.index(tblRow, col), font, Qt.FontRole)


Any ideas?


You definitely need to be setting the font in an item.  I'm not sure but 
I think that your QFont() doesn't have any properties, so it doesn't do 
anything.  I found this bit in a page - it's in C++ instead of Python 
but that doesn't really make a difference except for the exact syntax to 
use -



https://forum.qt.io/topic/70016/qlistview-item-font-stylesheet-not-working/4

  QVariant v = ModelBaseClass::data(index,role);
  if( condition && role == Qt::FontRole )
  {
   QFont font = v.value();
font.setBold( true );
   v = QVariant::fromValue( font );
  }

IOW, you have to get the font from the item, then set it to bold, which 
you would do with setFont().  Then you set that new font on the item. Of 
course you would have to unset bold on it later. See


https://doc.qt.io/qt-6/qtablewidgetitem.html#font

Instead of "item", you might need to operate on "row".  I didn't look 
into that.  Since a row probably doesn't have just one font (since it 
can have more than one item), you'd still have to get the font from some 
item in the row.


You might also be able to make the item bold using CSS, but I'm not sure.


Thanks


Internet searches are your friend for questions like this.  I've never 
worked with a QTableView, so I had to start with some knowledge about 
some other parts of QT.  I found the first page searching for "qt set 
qtableview row font", and the second searching for "qtablewidgetitem".


--
https://mail.python.org/mailman/listinfo/python-list


Re: Any PyQt developers here?

2022-10-27 Thread DFS

On 10/25/2022 1:45 PM, Thomas Passin wrote:

On 10/25/2022 1:03 PM, DFS wrote:

Having problems with removeRow() on a QTableView object.


removeRow() isn't listed as being a method of a QTableView, not even an 
inherited method, so how are you calling removeRow() on it? (See 
https://doc.qt.io/qt-6/qtableview-members.html)


Since you helped me on the last one, maybe you could try to answer a 
couple more [probably simple] roadblocks I'm hitting.



I just wanna set the font to bold/not-bold when clicking on a row in 
QTableView.




With a QTableWidget I do it like this:

font = QFont()
font.setBold(True) or False
QTableWidget.item(row,col).setFont(font)



But the QTableView has data/view 'models' attached to it and that syntax 
doesn't work:



Tried:
font = QFont()
font.setBold(True) or False
model = QTableView.model()
model.setFont(model.index(row,col), font)

Throws AttributeError: 'QSqlTableModel' object has no attribute 'setFont'


This doesn't throw an error, but doesn't show bold:
model.setData(model.index(tblRow, col), font, Qt.FontRole)


Any ideas?

Thanks
--
https://mail.python.org/mailman/listinfo/python-list


Re: Any PyQt developers here?

2022-10-26 Thread DFS

On 10/25/2022 2:03 PM, Barry Scott wrote:

There is an active PyQt mailing list that has lots of helpful and knowledgeable 
people on it.

https://www.riverbankcomputing.com/mailman/listinfo/pyqt

Barry



Thanks.  I'll send some questions their way, I'm sure.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Any PyQt developers here?

2022-10-26 Thread DFS

On 10/25/2022 1:45 PM, Thomas Passin wrote:

On 10/25/2022 1:03 PM, DFS wrote:

Having problems with removeRow() on a QTableView object.


removeRow() isn't listed as being a method of a QTableView, not even an 
inherited method, so how are you calling removeRow() on it? (See 
https://doc.qt.io/qt-6/qtableview-members.html)



* I thought I was calling it the same way it's called with
  QTableWidgets:  tbl.removeRow()

  But looking at my code again I was using tbl.model().removeRow()


* Plus I found several others online with similar removeRow() issues
  with QTableViews.


* Plus the code didn't throw an error:

selected = tbl.selectionModel().selectedRows()
#reverse sort the selected items to delete from bottom up
selected = sorted(selected,reverse=True)
for i,val in enumerate(selected):
 tbl.model().removeRow(selected[i].row())


But... as you say, when looking at the docs, removeRow() isn't even one 
of the slots for QTableViews.  So duh!


I see the QTableView.hideRow(row) method, which does exactly what I need.

Thanks man!





After calling removeRow(), the screen isn't updating.  It's as if the 
model is read-only, but it's a QSqlTableModel() model, which is not 
read-only.


The underlying SQL is straightforward (one table) and all columns are 
editable.


None of the editStrategies are working either.

I tried everything I can think of, including changes to the 
EditTriggers, but no luck.  HELP!


FWIW, the same removeRow() code works fine with a QTableWidget.

---
object creation and data loading all works fine
---
#open db connection
qdb = QSqlDatabase.addDatabase("QSQLITE")
qdb.setDatabaseName(dbname)
qdb.open()

#prepare query and execute to return data
query = QSqlQuery()
query.prepare(cSQL)
query.exec_()

#set model type and query
model = QSqlTableModel()
model.setQuery(query)

#assign model to QTableView object
view = frm.tblPostsView
view.setModel(model)

#get all data
while(model.canFetchMore()): model.fetchMore()
datarows = model.rowCount()



---
iterate selected rows also works fine
SelectionMode is Extended.
identical code works for a QTableWidget
---
selected = tbl.selectionModel().selectedRows()
#reverse sort the selected items to delete from bottom up
selected = sorted(selected,reverse=True)
for i,val in enumerate(selected):
 tbl.model().removeRow(selected[i].row())





--
https://mail.python.org/mailman/listinfo/python-list


Re: Any PyQt developers here?

2022-10-25 Thread Barry Scott
There is an active PyQt mailing list that has lots of helpful and knowledgeable 
people on it.

https://www.riverbankcomputing.com/mailman/listinfo/pyqt

Barry


> On 25 Oct 2022, at 18:03, DFS  wrote:
> 
> Having problems with removeRow() on a QTableView object.
> 
> After calling removeRow(), the screen isn't updating.  It's as if the model 
> is read-only, but it's a QSqlTableModel() model, which is not read-only.
> 
> The underlying SQL is straightforward (one table) and all columns are 
> editable.
> 
> None of the editStrategies are working either.
> 
> I tried everything I can think of, including changes to the EditTriggers, but 
> no luck.  HELP!
> 
> FWIW, the same removeRow() code works fine with a QTableWidget.
> 
> ---
> object creation and data loading all works fine
> ---
> #open db connection
> qdb = QSqlDatabase.addDatabase("QSQLITE")
> qdb.setDatabaseName(dbname)
> qdb.open()
> 
> #prepare query and execute to return data
> query = QSqlQuery()
> query.prepare(cSQL)
> query.exec_()
> 
> #set model type and query
> model = QSqlTableModel()
> model.setQuery(query)
>   
> #assign model to QTableView object
> view = frm.tblPostsView
> view.setModel(model)
>   
> #get all data
> while(model.canFetchMore()): model.fetchMore()
> datarows = model.rowCount()
> 
> 
> 
> ---
> iterate selected rows also works fine
> SelectionMode is Extended.
> identical code works for a QTableWidget
> ---
> selected = tbl.selectionModel().selectedRows()
> #reverse sort the selected items to delete from bottom up
> selected = sorted(selected,reverse=True)
> for i,val in enumerate(selected):
>   tbl.model().removeRow(selected[i].row())
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Any PyQt developers here?

2022-10-25 Thread Thomas Passin

On 10/25/2022 1:03 PM, DFS wrote:

Having problems with removeRow() on a QTableView object.


removeRow() isn't listed as being a method of a QTableView, not even an 
inherited method, so how are you calling removeRow() on it? (See 
https://doc.qt.io/qt-6/qtableview-members.html)


After calling removeRow(), the screen isn't updating.  It's as if the 
model is read-only, but it's a QSqlTableModel() model, which is not 
read-only.


The underlying SQL is straightforward (one table) and all columns are 
editable.


None of the editStrategies are working either.

I tried everything I can think of, including changes to the 
EditTriggers, but no luck.  HELP!


FWIW, the same removeRow() code works fine with a QTableWidget.

---
object creation and data loading all works fine
---
#open db connection
qdb = QSqlDatabase.addDatabase("QSQLITE")
qdb.setDatabaseName(dbname)
qdb.open()

#prepare query and execute to return data
query = QSqlQuery()
query.prepare(cSQL)
query.exec_()

#set model type and query
model = QSqlTableModel()
model.setQuery(query)

#assign model to QTableView object
view = frm.tblPostsView
view.setModel(model)

#get all data
while(model.canFetchMore()): model.fetchMore()
datarows = model.rowCount()



---
iterate selected rows also works fine
SelectionMode is Extended.
identical code works for a QTableWidget
---
selected = tbl.selectionModel().selectedRows()
#reverse sort the selected items to delete from bottom up
selected = sorted(selected,reverse=True)
for i,val in enumerate(selected):
 tbl.model().removeRow(selected[i].row())



--
https://mail.python.org/mailman/listinfo/python-list


Any PyQt developers here?

2022-10-25 Thread DFS

Having problems with removeRow() on a QTableView object.

After calling removeRow(), the screen isn't updating.  It's as if the 
model is read-only, but it's a QSqlTableModel() model, which is not 
read-only.


The underlying SQL is straightforward (one table) and all columns are 
editable.


None of the editStrategies are working either.

I tried everything I can think of, including changes to the 
EditTriggers, but no luck.  HELP!


FWIW, the same removeRow() code works fine with a QTableWidget.

---
object creation and data loading all works fine
---
#open db connection
qdb = QSqlDatabase.addDatabase("QSQLITE")
qdb.setDatabaseName(dbname)
qdb.open()

#prepare query and execute to return data
query = QSqlQuery()
query.prepare(cSQL)
query.exec_()

#set model type and query
model = QSqlTableModel()
model.setQuery(query)

#assign model to QTableView object
view = frm.tblPostsView
view.setModel(model)

#get all data
while(model.canFetchMore()): model.fetchMore()
datarows = model.rowCount()



---
iterate selected rows also works fine
SelectionMode is Extended.
identical code works for a QTableWidget
---
selected = tbl.selectionModel().selectedRows()
#reverse sort the selected items to delete from bottom up
selected = sorted(selected,reverse=True)
for i,val in enumerate(selected):
tbl.model().removeRow(selected[i].row())

--
https://mail.python.org/mailman/listinfo/python-list


Which PyQt-compatible, performant graphing library should I use?

2019-09-07 Thread kangalioo654
Hi,

Currently I'm making a statistics tool for a game I'm playing with PyQt5. I'm 
not happy with my current graphing library though. In the beginning I've used 
matplotlib, which was way too laggy for my use case. Currently I have 
pyqtgraph, which is snappy, but is missing useful features.

The Python graphing library selection is overwhelming, which is why I'm asking 
here for a recommendation.

Things that I need the library to support:

* PyQt5 integration
* plot layout in a grid
* performant navigation
* scatter plots, simple and stacked bar charts

Things that I don't strictly *require*, but would be really useful:

* log scale support (specifically for y-axis)
* tooltip support, or alternatively click callback support
* plot legend
* datetime axes support (like in matplotlib)
* configurable colors, scatter spot sizes, bar widths, etc.

Here are some screenshots how my application currently looks like with 
pyqtgraph:
https://i.redd.it/rx423arbw5l31.png
https://i.redd.it/r68twvfmw5l31.png

I would be really grateful for some recommendations!
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue5978] cProfile and profile don't work with pygtk/pyqt and sys.exit(0)

2018-07-28 Thread Steve Dower


Change by Steve Dower :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5978] cProfile and profile don't work with pygtk/pyqt and sys.exit(0)

2018-07-28 Thread Steve Dower

Steve Dower  added the comment:


New changeset 0041d721a6f6b312ef762838d390fc4d64cf5e3a by Steve Dower (Andrés 
Delfino) in branch '3.6':
[3.6] bpo-5978: Document that profiling needs cmd/function to return (GH-8515)
https://github.com/python/cpython/commit/0041d721a6f6b312ef762838d390fc4d64cf5e3a


--
nosy: +steve.dower

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5978] cProfile and profile don't work with pygtk/pyqt and sys.exit(0)

2018-07-28 Thread miss-islington


miss-islington  added the comment:


New changeset c6801b48a1964d87a77f1303e0c6ddf31f54259b by Miss Islington (bot) 
in branch '3.7':
bpo-5978: Document that profiling needs cmd/function to return (GH-7938)
https://github.com/python/cpython/commit/c6801b48a1964d87a77f1303e0c6ddf31f54259b


--
nosy: +miss-islington

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5978] cProfile and profile don't work with pygtk/pyqt and sys.exit(0)

2018-07-28 Thread Andrés Delfino

Change by Andrés Delfino :


--
pull_requests: +8032

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5978] cProfile and profile don't work with pygtk/pyqt and sys.exit(0)

2018-07-28 Thread miss-islington


Change by miss-islington :


--
pull_requests: +8029

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5978] cProfile and profile don't work with pygtk/pyqt and sys.exit(0)

2018-07-28 Thread Christian Heimes

Christian Heimes  added the comment:


New changeset 937fb55d35373fd2701078251840b6be0465a6e1 by Christian Heimes 
(Andrés Delfino) in branch 'master':
bpo-5978: Document that profiling needs cmd/function to return (GH-7938)
https://github.com/python/cpython/commit/937fb55d35373fd2701078251840b6be0465a6e1


--
nosy: +christian.heimes

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5978] cProfile and profile don't work with pygtk/pyqt and sys.exit(0)

2018-06-26 Thread Andrés Delfino

Change by Andrés Delfino :


--
nosy: +adelfino
versions: +Python 2.7, Python 3.6, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5978] cProfile and profile don't work with pygtk/pyqt and sys.exit(0)

2018-06-26 Thread Andrés Delfino

Change by Andrés Delfino :


--
keywords: +patch
pull_requests: +7548
stage: needs patch -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Redundant features in python library, PyQt

2018-03-02 Thread Michael Torrie
On 03/02/2018 04:15 PM, jlada...@itu.edu wrote:
> Python's standard library has (to take three examples) threads,
> processes, and  datetime functions. Meanwhile, PyQt has QThread,
> QProcess, and QDateTime.
> 
> Does this redundancy exist for C++ programmers who are programming Qt
> directly, and who may lack a standard C++ library with these
> features?  Are the Python wrappers simply provided for completeness,
> or do these libraries truly function differently?  When writing a
> PyQt application, how does one choose between the standard library
> and the PyQt library
Yes, when using Qt in C++, you'll be using QThread, QProcess, QDateTime,
etc, even though there are equivalents in the C++ standard library. This
is largely because Qt was created long before the C++ standard library
had many of these things.  But it's also because Qt's versions are
tightly integrated with the Qt object and event machinery.  A QThread
sets up the necessary message queues, for example, whereas a STL thread
will not.

When programming in PyQt, you will also want to use the Qt versions of
primitives when they exist. The primary reason is that the Qt versions
integrate with the Qt event-handling machinery.  As Qt is a C++ library,
it's necessary to wrap each and every Qt class with a Python class.
Thus PyQt often really is just C++ with a Python dialect. In other words
often times you'll be using C++ idioms and C++ data structures even
though Python's idioms and versions would be cleaner and more flexible.
This is the price you pay for using a C++ library that's wrapped using
automated tools for use in Python.  So you'll find api calls that return
a QString, for example, when a python string would be preferred.  Or a
QArray when a list would be better.

This is not just a PyQt thing. Any time you have thin wrappers around C
or C++ libraries, the underlying language idioms are going to bleed
through a bit into Python.


-- 
https://mail.python.org/mailman/listinfo/python-list


Redundant features in python library, PyQt

2018-03-02 Thread jladasky
Python's standard library has (to take three examples) threads, processes, and  
datetime functions.  Meanwhile, PyQt has QThread, QProcess, and QDateTime.

Does this redundancy exist for C++ programmers who are programming Qt directly, 
and who may lack a standard C++ library with these features?  Are the Python 
wrappers simply provided for completeness, or do these libraries truly function 
differently?  When writing a PyQt application, how does one choose between the 
standard library and the PyQt library?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue5978] cProfile and profile don't work with pygtk/pyqt and sys.exit(0)

2018-02-11 Thread Cheryl Sabella

Change by Cheryl Sabella :


--
keywords: +easy
stage:  -> needs patch
type: behavior -> enhancement
versions: +Python 3.8 -Python 2.7, Python 3.1, Python 3.2

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: PyQt: Parenting a Widget

2017-09-26 Thread Thomas Jollans
On 2017-09-26 16:41, Veek M wrote:
> Thanks - i'm on debian stretch so python 2.7 is what I use.


https://packages.debian.org/stretch/python3
https://packages.debian.org/stretch/python3-pyqt4
https://packages.debian.org/stretch/python3-pyqt5


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyQt: Parenting a Widget

2017-09-26 Thread Chris Angelico
On Wed, Sep 27, 2017 at 12:41 AM, Veek M  wrote:
> Thanks - i'm on debian stretch so python 2.7 is what I use.

Debian Stretch ships with Python 3.5 too.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyQt: Parenting a Widget

2017-09-26 Thread Veek M
On Tuesday, September 26, 2017 at 2:23:22 PM UTC+5:30, Thomas Jollans wrote:
> On 2017-09-26 08:16, Veek M wrote:
> > On Tuesday, September 26, 2017 at 11:18:54 AM UTC+5:30, Veek M wrote:
> >> Summary: Could someone explain widget and dialog parenting - the text book 
> >> is not making sense.
> >> ##
> >> I'm trying to understand widget parenting, from the book: Rapid GUI 
> >> Programming, pg 118, and thereabouts - he says:
> >>
> >> A. All PyQt classes that derive from QObjectand this includes all the 
> >> widgets,
> >> since QWidget is a QObject subclasscan have a “parent”.
> >>
> >> B. PyQt automatically repar-
> >> ents the widgets that are laid out. So although we did not give our 
> >> widgets a
> >> parent of self (the Form instance),when we call setLayout() the layout 
> >> manager
> >> gives ownership of the widgets and of itself to the form,and takes 
> >> ownership of
> >> any nested layouts itself. This means that none of the widgets that are 
> >> laid out
> >> is a top-level window, and all of them have parents, which is what we 
> >> want. So
> >> when the form is deleted, all its child widgets and layouts will be 
> >> deleted with
> >> -
> >> 1. In A, does he mean, you are ALLOWED to set a parent on a widget ONLY 
> >> because its Base Class is QObject? 
> >>
> >> With DockWidgets, you have to explicitly parent them - why?
> >>
> >> 2. If I create two widgets and wdget.show() them, and app.exec_() - which 
> >> one becomes the main-window and which one is the memory leak? I have not 
> >> used a layout manager so, one widget with no parent auto-becomes the 
> >> main-window (as per B), which would result in a leak with the other?
> >>
> >> #!/usr/bin/python
> >>
> >> import sys, os, re
> >>
> >>
> >> from PyQt4.QtCore import *
> >> from PyQt4.QtGui import *
> >>
> >> app = QApplication(sys.argv)
> >>
> >> lbl = QLabel('Hello World')
> >> lbl.setWindowFlags(Qt.SplashScreen)
> >> lbl.show()
> >> txtBrw = QTextBrowser()
> >> txtBrw.show()
> >>
> >> QTimer.singleShot(3000, app.quit)
> >> app.exec_()
> >>
> >> 3. QObject --> QWidget --> QDialog --> Form --> Form_Layout_Manager --> 
> >> Nested_Layout_Manager
> >>
> >> B, says that the layout manager parents the widgets under it and makes 
> >> 'Form' the parent. If the Form Layout Manager is taking charge of the 
> >> Nested Layout Manager, who is the parent of the widgets under the Nested 
> >> Layout Mangaer? 
> >>
> >> 4. In the Chapter on 'Dialogs', I am trying to create a QMainWindow Style 
> >> application with one label as the central widget and one button to invoke 
> >> a dialog. It doesn't work and I get:
> >>
> >> QWidget::setLayout: Attempting to set QLayout "" on Parent "", which 
> >> already has a layout
> >>
> >> I tried this link and it made no sense:
> >> https://stackoverflow.com/questions/25450598/qlayout-attempting-to-add-qlayout-to-qwidget-which-already-has-a-layout
> >>
> >> How does parenting work in PyQt? What is autoparented, what needs to be 
> >> explicitly parented and who is scrwing whom? Additionally, why is my 
> >> button, hiding?
> >>
> >>
> >> #!/usr/bin/python
> >>
> >> import sys, os, re
> >>
> >>
> >> from PyQt4.QtCore import *
> >> from PyQt4.QtGui import *
> >>
> >> app = QApplication(sys.argv)
> >>
> >> class Dialog(QDialog):
> >> def __init__(self, parent = None):
> >> super(Dialog, self).__init__(parent)
> >> 
> >> self.lbl = QLabel('Width: ')
> >> self.spn = QSpinBox()
> >> self.spn.setRange(0, 100)
> >> self.lbl.setBuddy(self.spn)
> >> 
> >> self.chk = QCheckBox(' Edges')
> >>
> >> self.lbl_styl = QLabel('Style')
> >> self.lst = QComboBox()
> >> self.lst.addItems(['dashed', 'dotted', 'star'])
> >> self.lbl_styl.setBuddy(self.lst)
> >> 
> >> self.ok_btn = QPushButton('')
> >> self.cncl_btn = QPushButton('')
> >>
> >> self.

Re: PyQt: Parenting a Widget

2017-09-26 Thread Thomas Jollans
On 2017-09-26 08:16, Veek M wrote:
> On Tuesday, September 26, 2017 at 11:18:54 AM UTC+5:30, Veek M wrote:
>> Summary: Could someone explain widget and dialog parenting - the text book 
>> is not making sense.
>> ##
>> I'm trying to understand widget parenting, from the book: Rapid GUI 
>> Programming, pg 118, and thereabouts - he says:
>>
>> A. All PyQt classes that derive from QObjectand this includes all the 
>> widgets,
>> since QWidget is a QObject subclasscan have a “parent”.
>>
>> B. PyQt automatically repar-
>> ents the widgets that are laid out. So although we did not give our widgets a
>> parent of self (the Form instance),when we call setLayout() the layout 
>> manager
>> gives ownership of the widgets and of itself to the form,and takes ownership 
>> of
>> any nested layouts itself. This means that none of the widgets that are laid 
>> out
>> is a top-level window, and all of them have parents, which is what we want. 
>> So
>> when the form is deleted, all its child widgets and layouts will be deleted 
>> with
>> -
>> 1. In A, does he mean, you are ALLOWED to set a parent on a widget ONLY 
>> because its Base Class is QObject? 
>>
>> With DockWidgets, you have to explicitly parent them - why?
>>
>> 2. If I create two widgets and wdget.show() them, and app.exec_() - which 
>> one becomes the main-window and which one is the memory leak? I have not 
>> used a layout manager so, one widget with no parent auto-becomes the 
>> main-window (as per B), which would result in a leak with the other?
>>
>> #!/usr/bin/python
>>
>> import sys, os, re
>>
>>
>> from PyQt4.QtCore import *
>> from PyQt4.QtGui import *
>>
>> app = QApplication(sys.argv)
>>
>> lbl = QLabel('Hello World')
>> lbl.setWindowFlags(Qt.SplashScreen)
>> lbl.show()
>> txtBrw = QTextBrowser()
>> txtBrw.show()
>>
>> QTimer.singleShot(3000, app.quit)
>> app.exec_()
>>
>> 3. QObject --> QWidget --> QDialog --> Form --> Form_Layout_Manager --> 
>> Nested_Layout_Manager
>>
>> B, says that the layout manager parents the widgets under it and makes 
>> 'Form' the parent. If the Form Layout Manager is taking charge of the Nested 
>> Layout Manager, who is the parent of the widgets under the Nested Layout 
>> Mangaer? 
>>
>> 4. In the Chapter on 'Dialogs', I am trying to create a QMainWindow Style 
>> application with one label as the central widget and one button to invoke a 
>> dialog. It doesn't work and I get:
>>
>> QWidget::setLayout: Attempting to set QLayout "" on Parent "", which already 
>> has a layout
>>
>> I tried this link and it made no sense:
>> https://stackoverflow.com/questions/25450598/qlayout-attempting-to-add-qlayout-to-qwidget-which-already-has-a-layout
>>
>> How does parenting work in PyQt? What is autoparented, what needs to be 
>> explicitly parented and who is scrwing whom? Additionally, why is my button, 
>> hiding?
>>
>>
>> #!/usr/bin/python
>>
>> import sys, os, re
>>
>>
>> from PyQt4.QtCore import *
>> from PyQt4.QtGui import *
>>
>> app = QApplication(sys.argv)
>>
>> class Dialog(QDialog):
>> def __init__(self, parent = None):
>> super(Dialog, self).__init__(parent)
>> 
>> self.lbl = QLabel('Width: ')
>> self.spn = QSpinBox()
>> self.spn.setRange(0, 100)
>> self.lbl.setBuddy(self.spn)
>> 
>> self.chk = QCheckBox(' Edges')
>>
>> self.lbl_styl = QLabel('Style')
>> self.lst = QComboBox()
>> self.lst.addItems(['dashed', 'dotted', 'star'])
>> self.lbl_styl.setBuddy(self.lst)
>> 
>> self.ok_btn = QPushButton('')
>> self.cncl_btn = QPushButton('')
>>
>> self.layout([(self.lbl, 0, 0), (self.spn, 0, 1), (self.chk, 0, 2), 
>>  (self.lbl_styl, 1, 0), (self.lst, 1, 1), 
>>  (self.ok_btn, 2, 0), (self.cncl_btn, 2, 1)])
>>
>> def layout(self, wgts = []):
>> self.lyt = QGridLayout()
>> for wgt, row, col in wgts:
>> self.lyt.addWidget(wgt, row, col)
>> 
>> self.setLayout(self.lyt)
>> 
>>
>> class Parent(QMainWindow):
>> def __init__(self, parent = None):
>> super(Parent, self).__init__(parent)
>>  

Re: PyQt: Parenting a Widget

2017-09-26 Thread Veek M
On Tuesday, September 26, 2017 at 11:18:54 AM UTC+5:30, Veek M wrote:
> Summary: Could someone explain widget and dialog parenting - the text book is 
> not making sense.
> ##
> I'm trying to understand widget parenting, from the book: Rapid GUI 
> Programming, pg 118, and thereabouts - he says:
> 
> A. All PyQt classes that derive from QObjectand this includes all the widgets,
> since QWidget is a QObject subclasscan have a “parent”.
> 
> B. PyQt automatically repar-
> ents the widgets that are laid out. So although we did not give our widgets a
> parent of self (the Form instance),when we call setLayout() the layout manager
> gives ownership of the widgets and of itself to the form,and takes ownership 
> of
> any nested layouts itself. This means that none of the widgets that are laid 
> out
> is a top-level window, and all of them have parents, which is what we want. So
> when the form is deleted, all its child widgets and layouts will be deleted 
> with
> -
> 1. In A, does he mean, you are ALLOWED to set a parent on a widget ONLY 
> because its Base Class is QObject? 
> 
> With DockWidgets, you have to explicitly parent them - why?
> 
> 2. If I create two widgets and wdget.show() them, and app.exec_() - which one 
> becomes the main-window and which one is the memory leak? I have not used a 
> layout manager so, one widget with no parent auto-becomes the main-window (as 
> per B), which would result in a leak with the other?
> 
> #!/usr/bin/python
> 
> import sys, os, re
> 
> 
> from PyQt4.QtCore import *
> from PyQt4.QtGui import *
> 
> app = QApplication(sys.argv)
> 
> lbl = QLabel('Hello World')
> lbl.setWindowFlags(Qt.SplashScreen)
> lbl.show()
> txtBrw = QTextBrowser()
> txtBrw.show()
> 
> QTimer.singleShot(3000, app.quit)
> app.exec_()
> 
> 3. QObject --> QWidget --> QDialog --> Form --> Form_Layout_Manager --> 
> Nested_Layout_Manager
> 
> B, says that the layout manager parents the widgets under it and makes 'Form' 
> the parent. If the Form Layout Manager is taking charge of the Nested Layout 
> Manager, who is the parent of the widgets under the Nested Layout Mangaer? 
> 
> 4. In the Chapter on 'Dialogs', I am trying to create a QMainWindow Style 
> application with one label as the central widget and one button to invoke a 
> dialog. It doesn't work and I get:
> 
> QWidget::setLayout: Attempting to set QLayout "" on Parent "", which already 
> has a layout
> 
> I tried this link and it made no sense:
> https://stackoverflow.com/questions/25450598/qlayout-attempting-to-add-qlayout-to-qwidget-which-already-has-a-layout
> 
> How does parenting work in PyQt? What is autoparented, what needs to be 
> explicitly parented and who is scrwing whom? Additionally, why is my button, 
> hiding?
> 
> 
> #!/usr/bin/python
> 
> import sys, os, re
> 
> 
> from PyQt4.QtCore import *
> from PyQt4.QtGui import *
> 
> app = QApplication(sys.argv)
> 
> class Dialog(QDialog):
> def __init__(self, parent = None):
> super(Dialog, self).__init__(parent)
> 
> self.lbl = QLabel('Width: ')
> self.spn = QSpinBox()
> self.spn.setRange(0, 100)
> self.lbl.setBuddy(self.spn)
> 
> self.chk = QCheckBox(' Edges')
> 
> self.lbl_styl = QLabel('Style')
> self.lst = QComboBox()
> self.lst.addItems(['dashed', 'dotted', 'star'])
> self.lbl_styl.setBuddy(self.lst)
> 
> self.ok_btn = QPushButton('')
> self.cncl_btn = QPushButton('')
> 
> self.layout([(self.lbl, 0, 0), (self.spn, 0, 1), (self.chk, 0, 2), 
>  (self.lbl_styl, 1, 0), (self.lst, 1, 1), 
>  (self.ok_btn, 2, 0), (self.cncl_btn, 2, 1)])
> 
> def layout(self, wgts = []):
> self.lyt = QGridLayout()
> for wgt, row, col in wgts:
> self.lyt.addWidget(wgt, row, col)
> 
> self.setLayout(self.lyt)
> 
> 
> class Parent(QMainWindow):
> def __init__(self, parent = None):
> super(Parent, self).__init__(parent)
> 
> lbl = QLabel('HELLO WORLD')
> btn = QPushButton(' Dialog')
> lbl.setBuddy(btn)
> 
> lyt = QHBoxLayout()
> lyt.addWidget(lbl)
> lyt.addWidget(btn)
> 
> self.setLayout(lyt)
> self.connect(btn, SIGNAL('clicked()'), self.popup_dialog)
> 
> def popup_dialog(self):
> x = Dialog(self)
> if x.exec_():
> print(x.spn.value())
> 
> p = Parent()
>

Re: PyQt: viewport vs window - how do you translate co-ordinates?

2017-09-24 Thread Veek M
On Saturday, September 23, 2017 at 8:44:25 PM UTC+5:30, Michael Torrie wrote:
> On 09/23/2017 05:38 AM, Veek M wrote:
> > I didn't understand any of that - could someone expand on that para?
> > Is there a reading resource that explains the Viewport and translations? I 
> > am not a CS student so I did not study computer graphics.
> 
> I'm sure there are lots of things that might help. This is primarily
> about OpenGL but the principles may apply:
> https://www.cs.mtsu.edu/~jhankins/files/4250/notes/WinToView/WinToViewMap.html
> 
> Alternatively, you can think it through.  Imagine you're laying out a
> fence around your house. You could use global coordinates for
> everything, or you could just call the exact center of your yard 0,0 and
> measure everything from there, in whatever units you wish. That's the
> idea here. Rather than referring to pixels by their screen coordinates
> (which can change if it moves around the screen), you refer to them by
> an arbitrary coordinate system with it's own scaling relative to the
> screen region.  You could have a screen region that is 100 px by 100 px,
> and the you designate that the upper left corner of that region is
> -500,500 and the lower right corner is 500,-500. Or it could be
> something like -500,200 to 500,-200, which would make things stretched
> out in the x axis compared to the y axis.
> 
> > (sorry for using google groups but my knode is broken and pan is horrible 
> > on olvwm - my plan is to write myself a News client in PyQt :))
> 
> I don't think you need to know that much about graphics coordinate
> systems to get started with Qt. Most GUI layout stuff does not depend on
> pixels or coordinates.

I took a look at the: OpenGL SuperBible - 7e - it's heavy on doing, and not 
much theory; they have a section on Views. Also, read that link. The link has 
some mistakes I suspect..

Let's say we have a teacup-photograph and a table in a 3d-room. The photo has a 
local space - called Model Space or Object Space. The edges of the photo will 
form a coordinate system and using that i could make the teacup handle red.

If i take that photo and place it on top of that table - i get a World Space 
that contains both objects and the walls of the room form a coordinate system. 
(this is where that link is wrong)

Now let's say I want to display the room on a computer screen.

The entire computer screen forms a Screen coordinate system and will include 
the Dolphin file browser, maybe firefox, the kde toolbar)

However, I can't directly take a 3d room and stick it in my 2d screen so, I 
have to capture part of the room from a PERSPECTIVE - this is 2d because the 
camera film is 2d - so, this is a View Space/Clipping Window (link/url).

Now the View Space data that I captured has to be placed on the screen BUT not 
everywhere - this is the Interface Window (link/url).

However I may want to caption the room-image-displayed-on-screen so the 
Interface Window is further shrunk into a Viewport which represents 
pixels/points on the device/paper.

Transformation is a matrix associated with a space that will give you the 
desired pixels in the Viewport.

View Space is how this World Space looks when viewed
---

So how does the above fit into PyQt/book-description.

We have a Widget that is drawn in pixels/picas/whatever that has a 
physical-coordinate system associated with it (800x600 and will prolly fill the 
entire computer-screen). 

We have a window which is at (-60, -60) + 120 length - so you have a 
small rectangle in which to draw - equivalent to the ViewSpace however since 
this is 2d, it can also be equivalent to the Model/Object Space - with some 
random center (0,0) could be the teacup-handle.

The aspect ratio for widget is 1.
aspect ratio for window is 1

If the aspect ratios were the same there would be no problem - however since 
the aspect ratios are different, x-axis scaling is 120:800 and y-axis is 
120:600. We need to bear this in mind when we draw in our little window because 
what looks proportional/linear will be deformed when placed on screen/viewport.

So if we badly want a square window, we can create a square Screen/Viewport and 
loose some drawing area as a result of the viewport being squared from a 
rectangle.
--

Phew! anyway this is just my longwinded way but I think I got it. Thanks :)





-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyQt: viewport vs window - how do you translate co-ordinates?

2017-09-23 Thread Michael Torrie
On 09/23/2017 05:38 AM, Veek M wrote:
> I didn't understand any of that - could someone expand on that para?
> Is there a reading resource that explains the Viewport and translations? I am 
> not a CS student so I did not study computer graphics.

I'm sure there are lots of things that might help. This is primarily
about OpenGL but the principles may apply:
https://www.cs.mtsu.edu/~jhankins/files/4250/notes/WinToView/WinToViewMap.html

Alternatively, you can think it through.  Imagine you're laying out a
fence around your house. You could use global coordinates for
everything, or you could just call the exact center of your yard 0,0 and
measure everything from there, in whatever units you wish. That's the
idea here. Rather than referring to pixels by their screen coordinates
(which can change if it moves around the screen), you refer to them by
an arbitrary coordinate system with it's own scaling relative to the
screen region.  You could have a screen region that is 100 px by 100 px,
and the you designate that the upper left corner of that region is
-500,500 and the lower right corner is 500,-500. Or it could be
something like -500,200 to 500,-200, which would make things stretched
out in the x axis compared to the y axis.

> (sorry for using google groups but my knode is broken and pan is horrible on 
> olvwm - my plan is to write myself a News client in PyQt :))

I don't think you need to know that much about graphics coordinate
systems to get started with Qt. Most GUI layout stuff does not depend on
pixels or coordinates.

-- 
https://mail.python.org/mailman/listinfo/python-list


PyQt: viewport vs window - how do you translate co-ordinates?

2017-09-23 Thread Veek M
pg 329, Rapid GUI Programming

http://storage4.static.itmages.com/i/17/0923/h_1506165624_2588733_59fdfcd4cc.png

In PyQt terminology the physical coordinate system is called the “viewport”,
and confusingly, the logical coordinate system is called the “window”.

In Figure 11.4, we have a physical widget size of 800 × 600. By calling setWin-
dow(-60, -60, 120, 120) we can create a “window” with a top-left coordinate of
(-60, -60), a width of 120, a height of 120, and centered at point (0, 0). The
window’s coordinate system is a logical coordinate system that QPainter auto-
matically maps to the underlying physical device. After the setWindow() call,
all our painting takes place using the logical (window) coordinate system.
In this case, the widget is rectangular, but our window has the same width and
height. This means that the items we paint will be stretched out horizontally,
since coordinates in the y-axis will be scaled by QPainter in the ratio 120:600
(1:5), whereas those in the x-axis will be scaled in the ratio 120:800 (1:6 2
3
).



1. The physical (coordinate system) widget size is 800x600 = Viewport
2. Logical Coordinates = Window

When he does setWindow(-60, -60, 120, 120) he's moving along a diagonal from 
top-left to bottom-right. From that point he's then drawing a 120x120 rectangle.

A. So how does he get a (150,200) point and a -37.5 point??? 
B. Also, how is it stretched horizontally? If i use the inner 120x120 as a 
frame of reference and draw a circle - it'll still be a circle??? Just draw a 
square on a blackboard.. and then draw a circle in it..

I didn't understand any of that - could someone expand on that para?

C. Why does QPainter have to scale in a different ratio??
QPainter understands two coordinate systems - physical and logical and by 
default the two systems match each other.

Is there a reading resource that explains the Viewport and translations? I am 
not a CS student so I did not study computer graphics.


(sorry for using google groups but my knode is broken and pan is horrible on 
olvwm - my plan is to write myself a News client in PyQt :))
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue30801] shoutdown process error with python 3.4 and pyqt/PySide

2017-07-24 Thread Terry J. Reedy

Terry J. Reedy added the comment:

You must demonstrate that there is a problem with 3.6 or 3.7 and then write a 
patch that fixes the problem in those versions.

--
nosy: +terry.reedy

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30801] shoutdown process error with python 3.4 and pyqt/PySide

2017-07-11 Thread Larry Hastings

Larry Hastings added the comment:

Python 3.4 no longer accepts bug fixes; it is in "security fixes only" mode.  
Since this is not a security fix, it will not be accepted into Python 3.4.

If this bug affects other versions of Python, please file a new bug.  Although, 
unless you move *very* quickly, this fix won't be accepted into 3.5 either, as 
it's going to move into "security fixes only" mode later this month.

Finally, your submitted patch (PR 2413) does not apply to the 3.4 branch, it 
applies to master.  I have no opinion about whether or not this code should be 
accepted into master.  But the PR talks about fixing a bug in 3.4, which is 
wrong.

--
nosy: +larry
resolution:  -> wont fix
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30801] shoutdown process error with python 3.4 and pyqt/PySide

2017-06-29 Thread alberfontan1

Changes by alberfontan1 :


--
pull_requests: +2544

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30801] shoutdown process error with python 3.4 and pyqt/PySide

2017-06-29 Thread alberfontan1

New submission from alberfontan1:

For a package applicaction with pyqt/PySide, Python 3.4 on Windows, appers a 
window fatal error when shoutdown process manager of multiprocessing

--
components: Library (Lib)
messages: 297261
nosy: alberfontan1
priority: normal
severity: normal
status: open
title: shoutdown process error with python 3.4 and pyqt/PySide
type: crash
versions: Python 3.4

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30801>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: PyQt pass data from class

2016-11-16 Thread Michael Torrie
On 11/16/2016 12:47 AM, luca72 via Python-list wrote:
> Thanks for your reply
> 
> Is the latter, can you explain how i can do it.

Just add an argument to __init__() of the one class where you will pass
the instance of the other class to it. Then you can store it inside the
instance, and use it whenever needed.

class foo(object):
def __init__(self):
pass

def some_method(self):
print ("Hello from foo.some_method")

class bar(object):
def __init__(self, foo_instance):
self.foo_instance = foo_instance

def some_method(self):
foo.some_method()

a=foo()
b=bar(a)

Of course since you're dealing with PyQt your classes will involve some
other parameters to __init__ but you can still tack your parameter on there.

You may want to re-examine how you're building your classes, though.
There's likely a way you can structure things to eliminate this kind of
coupling, especially in the context of a GUI. Often times making your
own signal that can be externally connected to a method of the other
class is the way to go as this reduces the coupling between the classes.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyQt pass data from class

2016-11-15 Thread luca72 via Python-list
Thanks for your reply

Is the latter, can you explain how i can do it.

Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyQt pass data from class

2016-11-15 Thread Michael Torrie
On 11/15/2016 10:01 AM, luca72 via Python-list wrote:
> in wich way i can have access to the lineedit of class Form without event 
> from class Cornice

If I understand you, you are asking how to set the text without having
it emit a signal. Is that correct? Or are you asking how to access the
member of one class from a method in another class?

If it's the former, you can ask PyQt to suppress a callback for a while.
 Look up the blockSignals() method of QWidget.

If it's the latter, your best bet is to pass the object you want to
access into the other class somehow, perhaps as an argument to __init__().

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyQt pass data from class

2016-11-15 Thread Rob Gaddi
luca72 wrote:

> Hello i need to this
>
> class Form(QWidget, Ui_Form):
> """
> Class documentation goes here.
> """
> def __init__(self, parent=None):
> """
> Constructor
> 
> @param parent reference to the parent widget
> @type QWidget
> """
> super(Form, self).__init__(parent)
> self.setupUi(self)
> self.tabWidget.setCurrentIndex(0)
> combo = QComboBox()
> self.disegno = Cornice()
>
> class Cornice(QPainter):
> 
> def __init__(self, parent=None):
> 
> lista_dati = []
>
> in the class Form i have a lineEdit
>
> in the class Cornice i need to write something link
>
> self.lineEdit.setText('blabla') that is in the class Form
>
> in wich way i can have access to the lineedit of class Form without event 
> from class Cornice
>
> Many Thanks

Traditionally you'd have Cornice emit a Signal, which when you
__init__the Form you'd connect to the appropriate slot.  I don't recall
PyQt syntax, but in PySide it would look like

self.disengo.theSignal.connect(self.lineEdit.setText)


-- 
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.
-- 
https://mail.python.org/mailman/listinfo/python-list


PyQt pass data from class

2016-11-15 Thread luca72 via Python-list
Hello i need to this

class Form(QWidget, Ui_Form):
"""
Class documentation goes here.
"""
def __init__(self, parent=None):
"""
Constructor

@param parent reference to the parent widget
@type QWidget
"""
super(Form, self).__init__(parent)
self.setupUi(self)
self.tabWidget.setCurrentIndex(0)
combo = QComboBox()
self.disegno = Cornice()

class Cornice(QPainter):

def __init__(self, parent=None):

lista_dati = []

in the class Form i have a lineEdit

in the class Cornice i need to write something link

self.lineEdit.setText('blabla') that is in the class Form

in wich way i can have access to the lineedit of class Form without event from 
class Cornice

Many Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [PyQT] After MessageBox app quits...why?

2016-11-07 Thread Demosthenes Koptsis

i answered my own question.


On 11/07/2016 11:44 AM, Demosthenes Koptsis wrote:

because there is no window open and quits by default.

You have to do two things:

1) Make sure that your SystemTray class has parent a QWidget

w = QtGui.QWidget()
trayIcon = SystemTrayIcon(QtGui.QIcon("virtualdvd.png"), w)

2) set quit to false

app.setQuitOnLastWindowClosed(False)



Example



def main():
app = QtGui.QApplication(sys.argv)
app.setQuitOnLastWindowClosed(False)

w = QtGui.QWidget()
trayIcon = SystemTrayIcon(QtGui.QIcon("virtualdvd.png"), w)

trayIcon.show()
sys.exit(app.exec_())

if __name__ == '__main__':
main()

On 11/07/2016 10:49 AM, Anssi Saari wrote:

Demosthenes Koptsis <demosthen...@gmail.com> writes:


Hello, i have a PyQT systray app with a menu and two actions.

Action1 is Exit and action2 display a MessageBox with Hello World 
message.


When i click OK to MessageBox app quits...why?

http://pastebin.com/bVA49k1C

I haven't done anything with Qt in a while but apparently you need to
call QtGui.QApplication.setQuitOnLastWindowClosed(False) before
trayIcon.show().




--
https://mail.python.org/mailman/listinfo/python-list


Re: [PyQT] After MessageBox app quits...why?

2016-11-07 Thread Demosthenes Koptsis

because there is no window open and quits by default.

You have to do two things:

1) Make sure that your SystemTray class has parent a QWidget

w = QtGui.QWidget()
trayIcon = SystemTrayIcon(QtGui.QIcon("virtualdvd.png"), w)

2) set quit to false

app.setQuitOnLastWindowClosed(False)



Example



def main():
app = QtGui.QApplication(sys.argv)
app.setQuitOnLastWindowClosed(False)

w = QtGui.QWidget()
trayIcon = SystemTrayIcon(QtGui.QIcon("virtualdvd.png"), w)

trayIcon.show()
sys.exit(app.exec_())

if __name__ == '__main__':
main()

On 11/07/2016 10:49 AM, Anssi Saari wrote:

Demosthenes Koptsis <demosthen...@gmail.com> writes:


Hello, i have a PyQT systray app with a menu and two actions.

Action1 is Exit and action2 display a MessageBox with Hello World message.

When i click OK to MessageBox app quits...why?

http://pastebin.com/bVA49k1C

I haven't done anything with Qt in a while but apparently you need to
call QtGui.QApplication.setQuitOnLastWindowClosed(False) before
trayIcon.show().


--
https://mail.python.org/mailman/listinfo/python-list


Re: [PyQT] After MessageBox app quits...why?

2016-11-07 Thread Anssi Saari
Demosthenes Koptsis <demosthen...@gmail.com> writes:

> Hello, i have a PyQT systray app with a menu and two actions.
>
> Action1 is Exit and action2 display a MessageBox with Hello World message.
>
> When i click OK to MessageBox app quits...why?
>
> http://pastebin.com/bVA49k1C

I haven't done anything with Qt in a while but apparently you need to
call QtGui.QApplication.setQuitOnLastWindowClosed(False) before
trayIcon.show().
-- 
https://mail.python.org/mailman/listinfo/python-list


[PyQT] After MessageBox app quits...why?

2016-10-27 Thread Demosthenes Koptsis

Hello, i have a PyQT systray app with a menu and two actions.

Action1 is Exit and action2 display a MessageBox with Hello World message.

When i click OK to MessageBox app quits...why?

http://pastebin.com/bVA49k1C

--
https://mail.python.org/mailman/listinfo/python-list


Re: PyQT - Signals and Slots?

2016-10-10 Thread Michael Torrie
On 10/10/2016 07:32 AM, Veek M wrote:
> Whaaa...t?? Could someone explain what exactly is his grand design 
> besides being awfully circuitous? So he has some other Form thingy.. and 
> in that he sets up another mapping from ZeroSpinBox.atzero --> 
> ZeroSpinBox.announce  where's announce and atzero defined?

In your example code, "atzero" is implicitly defined as a signal in the
connect() call.  Under the hood in Qt, signals are all dispatched by
strings when you emit() the signal.  PyQt does allow you to define
signals in a more pythonic way using class variables:

class Foo(QWidget):
atzero = SIGNAL( signature )

The signature can be a list of python types, or strings describing the
C++ types.  This is where the C++ nature of Qt leaks into PyQt.  In C++
since the moc compiler takes C++ code and C++ type names and generates a
meta-class that defines signals in terms of strings (moc does basic
compile-time type checking), in Python we also have to provide
signatures in strings also if we need something more than core python
types (int, bool, etc).  This signature helps PyQt (well Qt really)
marshal the types properly when the signal's callback is called.

But yes the example is convoluted and circuitous.  I think it's just to
demonstrate how signals and slots work, though.  That's what the
comments make clear.  This isn't how you'd implement a real widget with
customized behavior.

In general I don't think widgets normally want to catch their own
signals.  There are other mechanisms for that.  Usually you subclass the
widget and then override the appropriate *Event() method. For example,
to do something special on value changes I believe you'd subclass
QSpinBox and override the changeEvent() method. Inside that you would
get your value, do your logic, and potentially emit a custom signal. And
of course calling the parent changeEvent() to propagate the event
through to the parent class.


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyQT - Signals and Slots?

2016-10-10 Thread Veek M
Mark Summerfield wrote:

> 
> The ZeroSpinBox is a tiny example designed to show how the signal/slot
> mechanism works. It is just a QSpinBox with the addition of
> remembering how many times (all the) ZeroSpinBox(es) have had a 0
> value.
> 
> Nowadays the connections would be made with a new improved syntax:
> 
> self.connect(self, SIGNAL("valueChanged(int)"), self.checkzero) # OLD
> self.valueChanged.connect(self.checkzero) # NEW
> # or
> self.valueChanged[int].connect(self.checkzero) # NEW
> 
> Similarly the emit:
> self.emit(SIGNAL("atzero"), self.zeros) # OLD
> self.atzero.emit(self.zeros) # NEW
> 
> What's happening inside ZeroSpinBox? Whenever its value is set to 0 it
> calls its own checkzero() method, and this in turn emits an atzero
> signal with the number of zeros so far. Why does it do this? Just to
> show the mechanism. It doesn't matter whether you connect a widget to
> itself (unusual but done here), or to another widget (the norm).
> 
> See the book's website https://www.qtrac.eu/pyqtbook.html
> for all the source code including some updated with the new syntax.
> (But the book is old, so even the Python 3.1 examples aren't as
> Pythonic as they would be written in Python 3.4+.)

ah - okay, so i was on the right track - thanks :) cool that you hang 
out here :) 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyQT - Signals and Slots?

2016-10-10 Thread Mark Summerfield

The ZeroSpinBox is a tiny example designed to show how the signal/slot
mechanism works. It is just a QSpinBox with the addition of remembering
how many times (all the) ZeroSpinBox(es) have had a 0 value.

Nowadays the connections would be made with a new improved syntax:

self.connect(self, SIGNAL("valueChanged(int)"), self.checkzero) # OLD
self.valueChanged.connect(self.checkzero) # NEW
# or
self.valueChanged[int].connect(self.checkzero) # NEW

Similarly the emit:
self.emit(SIGNAL("atzero"), self.zeros) # OLD
self.atzero.emit(self.zeros) # NEW

What's happening inside ZeroSpinBox? Whenever its value is set to 0 it
calls its own checkzero() method, and this in turn emits an atzero signal
with the number of zeros so far. Why does it do this? Just to show the
mechanism. It doesn't matter whether you connect a widget to itself
(unusual but done here), or to another widget (the norm).

See the book's website https://www.qtrac.eu/pyqtbook.html
for all the source code including some updated with the new syntax.
(But the book is old, so even the Python 3.1 examples aren't as Pythonic as 
they would be written in Python 3.4+.)
-- 
https://mail.python.org/mailman/listinfo/python-list


PyQT - Signals and Slots?

2016-10-10 Thread Veek M
I'm reading Rapid GUI Programming - Mark Summerfield with Python and QT 
pg 131. Basically the mechanism is an event table which maps a 'signal' 
to a 'function/slot' -correct?

  self.connect(dial, SIGNAL("valueChanged(int)"), spinbox.setValue)

Here, dial.valueChanged -> spinbox.setValue

 s.connect(w, SIGNAL("signalSignature"), functionName)
 s.connect(w, SIGNAL("signalSignature"), instance.methodName)
 s.connect(w, SIGNAL("signalSignature"), instance, 
SLOT("slotSignature"))

Here, w.signalSignature -> functionName
-> instance.methodName
-> instance.slotSignature

If signalSignature is a C++ implemented thingy then we got to pass type 
info as part of the mapping so "signalSignature(int, float, const char 
*). PyQT signals are any type and any number of args..


If the Slot-function is implemented in C++ it's better to use the SLOT() 
mechanism:
 self.connect(dial, SIGNAL("valueChanged(int)"), spinbox, 
SLOT("setValue(int)"))
Here, we are mapping dial.valueChanged(int) --> spinbox.setValue(int)


The part i found tricky was this:

class ZeroSpinBox(QSpinBox):
zeros = 0
def __init__(self, parent=None):
super(ZeroSpinBox, self).__init__(parent)
self.connect(self, SIGNAL("valueChanged(int)"), self.checkzero)

def checkzero(self):
if self.value() == 0:
self.zeros += 1
self.emit(SIGNAL("atzero"), self.zeros)

ZeroSpinBox.valueChanged -> ZeroSpinBox.checkzero? Why is he mapping 
back to himself? Shouldn't it be widget-to-widget?

Then he raises a signal 'atzero' with one arg - the lack of a atzero() 
implies it's a 'short-circuit' signal so self.zeroes is a python data 
type. And in the book he says:

###
Here is how we connect to the signal in the form’s __init__() method:
zerospinbox = ZeroSpinBox()
...
self.connect(zerospinbox, SIGNAL("atzero"), self.announce)
Again, we must not use parentheses because it is a short-circuit signal. 
And
for completeness, here is the slot it connects to in the form:
def announce(self, zeros):
print "ZeroSpinBox has been at zero %d times" % zeros
###

Whaaa...t?? Could someone explain what exactly is his grand design 
besides being awfully circuitous? So he has some other Form thingy.. and 
in that he sets up another mapping from ZeroSpinBox.atzero --> 
ZeroSpinBox.announce  where's announce and atzero defined?





-- 
https://mail.python.org/mailman/listinfo/python-list


ANN: PyQt v5.7 Released

2016-07-27 Thread Phil Thompson
PyQt v5.7 has been released. These are the Python bindings for the Qt 
application toolkit and runs on Linux, OS X, Windows, iOS and Android.

Also released for the first time under the GPL are PyQtChart, 
PyQtDataVisualization and PyQtPurchasing.

PyQtChart are the bindings for the Qt Charts library. This implements a set of 
classes for creating and manipulating 2D charts.

PyQtDataVisualization are the bindings for the Qt Data Visualization library. 
This implements a set of classes for representing data in 3D and allowing the 
user to interact with the view.

PyQtPurchasing are the bindings for the Qt Purchasing library. This implements 
a set of classes that allow applications to support in-app purchases from the 
Mac App Store on OS X, the App Store on iOS, and Google Play on Android.

Wheels are available from PyPI and include the relevent Qt libraries - nothing 
else needs to be installed.

Source packages and more information can be found at 
https://www.riverbankcomputing.com/.

Phil Thompson
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


ANN: PyQt v5.7 Released

2016-07-26 Thread Phil Thompson
PyQt v5.7 has been released. These are the Python bindings for the Qt 
application toolkit and runs on Linux, OS X, Windows, iOS and Android.

Also released for the first time under the GPL are PyQtChart, 
PyQtDataVisualization and PyQtPurchasing.

PyQtChart are the bindings for the Qt Charts library. This implements a set of 
classes for creating and manipulating 2D charts.

PyQtDataVisualization are the bindings for the Qt Data Visualization library. 
This implements a set of classes for representing data in 3D and allowing the 
user to interact with the view.

PyQtPurchasing are the bindings for the Qt Purchasing library. This implements 
a set of classes that allow applications to support in-app purchases from the 
Mac App Store on OS X, the App Store on iOS, and Google Play on Android.

Wheels are available from PyPI and include the relevent Qt libraries - nothing 
else needs to be installed.

Source packages and more information can be found at 
https://www.riverbankcomputing.com/.

Phil Thompson
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Getting back into PyQt and not loving it.

2016-07-02 Thread Sibylle Koczian

Am 27.06.2016 um 22:14 schrieb codewiz...@gmail.com:

On Sunday, June 26, 2016 at 5:45:18 PM UTC-4, Michael Torrie wrote:


Qt's a fantastic toolkit, and the most mature of any of them, and the
most portable, but man the bindings are not Pythonic at all.


Enaml feels pretty Pythonic to me:

https://github.com/nucleic/enaml


But:

Enaml is a Python framework and requires a supported Python runtime. 
Enaml currently supports Python 2.6 and Python 2.7. Python 3.x support 
may be added in the future, but is not currently a high priority item.


http://nucleic.github.io/enaml/docs/get_started/installation.html



--
https://mail.python.org/mailman/listinfo/python-list


Re: sample chatting apps in pyqt

2016-06-30 Thread Michael Torrie
On 06/30/2016 07:45 AM, tommy yama wrote:
> Hi all,
> 
> Let me post my question here
> Has anyone installed and run any of sample chat apps in pyqt?
> 
> Although I've tried to install and run sample scripts in pyqt once, the
> error said pyqt must be reinstalled.

If you paste the error message here, I'm sure someone can help you
figure out what is going on.

-- 
https://mail.python.org/mailman/listinfo/python-list


sample chatting apps in pyqt

2016-06-30 Thread tommy yama
Hi all,

Let me post my question here
Has anyone installed and run any of sample chat apps in pyqt?

Although I've tried to install and run sample scripts in pyqt once, the
error said pyqt must be reinstalled.

Appreciate for your suggestions.

Thanks.

Tomo
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Getting back into PyQt and not loving it.

2016-06-27 Thread Michael Torrie
On 06/27/2016 02:14 PM, codewiz...@gmail.com wrote:
> On Sunday, June 26, 2016 at 5:45:18 PM UTC-4, Michael Torrie wrote:
>>
>> Qt's a fantastic toolkit, and the most mature of any of them, and the
>> most portable, but man the bindings are not Pythonic at all.
> 
> Enaml feels pretty Pythonic to me:
> 
> https://github.com/nucleic/enaml

Cool. I'll check it out.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Getting back into PyQt and not loving it.

2016-06-27 Thread Ethan Furman

On 06/26/2016 07:12 PM, MRAB wrote:


Is it a problem with Tk itself or with the Python wrapper? Would it be
better if we made a more Pythonic version of Tkinter, e.g. making
Frame.title a property?


I would say it's the wrapper.

I appreciate all the work being done on tkinter lately, but it's still 
jarring trying to use the not-very-pythonic-at-all interface.


--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list


Re: Getting back into PyQt and not loving it.

2016-06-27 Thread codewizard
On Sunday, June 26, 2016 at 5:45:18 PM UTC-4, Michael Torrie wrote:
> 
> Qt's a fantastic toolkit, and the most mature of any of them, and the
> most portable, but man the bindings are not Pythonic at all.

Enaml feels pretty Pythonic to me:

https://github.com/nucleic/enaml
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Getting back into PyQt and not loving it.

2016-06-27 Thread llanitedave
On Sunday, June 26, 2016 at 11:16:01 PM UTC-7, John Ladasky wrote:
> On Sunday, June 26, 2016 at 7:41:17 PM UTC-7, Michael Torrie wrote:
> > If GTK+ had first-class support on Windows and Mac, including native
> > themes and seamless UI integration (file and print dialogs), I'd say
> > GTK+ would be the only game in town for Python programmers.
> > Unfortunately, unless you're only concerned with Linux, GTK+ is probably
> > not going to be your choice.
> 
> Although I work almost exclusively in Linux, I've been teaching Python for 
> several years as a sideline, and my students usually do not use Linux.  I 
> insist on teaching my students Python 3.  Unless they're professionals who 
> must work with legacy code (and, so far, none of them have been), I think I 
> would be doing them a disservice to teach them Python 2.
> 
> I started with WxPython, but WxPython/Phoenix has been very slow to migrate 
> to Python 3.  
> 
> Between the Py3 requirement and the need to work with all major OS's, I 
> decided to learn PyQt and not GTK+.  
> 
> In my current day job, I'm developing an application on a Linux box, but I'll 
> be handing it off to Windows users.  My choice of PyQt turned out to be the 
> right one in that situation as well.

I produced a couple of applications using wxPython 2.8 and Python 2.7, and I 
was happy with how they turned out, but since I moved to Python 3 I got tired 
of waiting for a Phoenix release that I felt comfortable with, so I've been 
learning PyQT lately. I do find that PyQt is more straightforward in many 
respects than wxPython, but the difference for me has always been how well 
organized and understandable the documentation is.  The PyQt examples seem very 
comprehensive, but the code is poorly commented and there are some quirks that 
are confusing me.   The original wxPython book was quite well put together and 
extremely helpful, and I miss having something like that for Qt.  I'm going 
through the eBook on PyQt4, but I'm not yet sure how well it will translate to 
PyQt5, which I'm trying to develop with.  I do think I'll stick with it, 
though.  Once I learn it I think it will serve me well.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Getting back into PyQt and not loving it.

2016-06-27 Thread Michael Torrie
On 06/27/2016 12:44 AM, Lawrence D’Oliveiro wrote:
> On Monday, June 27, 2016 at 6:16:01 PM UTC+12, John Ladasky wrote:
> 
>> Between the Py3 requirement and the need to work with all major OS's, I
>> decided to learn PyQt and not GTK+.  
> 
> GTK+ is available for Python 3.
>
> No doubt it will work on Windows as well, once Microsoft gets its Linux 
> compatibility layer debugged...

But that's not a solution for John's target audience.  Nor for most
users, honestly.  The Linux layer is targeted towards Azure developers
mainly, and not intended to be an application support layer.

GTK+ is working natively on Windows, and the Python bindings work on
Windows. However GTK+ does not have nearly as good integration with the
Windows desktop in terms of look and feel as other solutions like Qt and
wxWidgets.  Running the Linux version of GTK+ inside of Windows' Linux
layer would not solve that problem!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Getting back into PyQt and not loving it.

2016-06-27 Thread Mark Summerfield
On Monday, June 27, 2016 at 3:12:34 AM UTC+1, MRAB wrote:
[snip]
> > Not sure that wxPython is really any different in that respect, and Tkinter 
> > doesn't feel Pythonic to me, either -- considering how it's Tk at heart.  
> > So what's the alternative?  There really is no good Python-based GUI tool, 
> > and that's a shame.
> >
> Is it a problem with Tk itself or with the Python wrapper? Would it be 
> better if we made a more Pythonic version of Tkinter, e.g. making 
> Frame.title a property?

My main complaints about Tkinter are:

- Not very Pythonic.

- The event handling works very differently from other toolkits so it can be 
quite tricky to learn and get right.

- The bindings are incomplete (e.g., http://bugs.python.org/issue3405)

And for me there are show-stopping weaknesses.

- Show stopper #1: there is no nice way to create custom widgets. Compare with 
PySide, PyQt (& wxPython I believe) where you can inherit some "widget" base 
class and paint it however you like and do any event handling you like to get 
custom appearance and behaviour. Sure, you can do this with canvas as the base, 
but it seems like you have do do far more work in Tkinter than the other 
toolkits.

- Show stopper #2: there doesn't seem to be any way to create one line and 
multiline styled text editors (e.g., supporting bold, italic, underline, 
superscript, subscript, colour, font). The text widget can display all these 
(and more) but I haven't found any way to get it to be able to provide 
_editing_ of all these. (You can get it to do bold, italic, underline, and 
colour, but I certainly can't get these plus super- and sub-script and font 
support from Python. Nor is there any useful load/save in HTML or any other 
format.)

Hopefully people will point me to docs or examples to prove me wrong about 
these weaknesses:-)

Or better still, maybe the seemingly moribund PyGUI project could be revived or 
maybe someone will create bindings for libui or for IUP so that Python could 
have a lightweight GUI-only cross-platform library that had decent support for 
creating custom widgets in Python but left all non-GUI functionality to the 
rest of the Python ecosystem.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Getting back into PyQt and not loving it.

2016-06-27 Thread lorenzo . gatti
PyGTK is obsolete and stopped at Python 2.7, while PyGObject for Windows is 
several versions behind (currently 3.18 vs 3.21) and it doesn't support Python 
3.5. Game over for GTK+.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Getting back into PyQt and not loving it.

2016-06-27 Thread Lawrence D’Oliveiro
On Monday, June 27, 2016 at 6:16:01 PM UTC+12, John Ladasky wrote:

> Between the Py3 requirement and the need to work with all major OS's, I
> decided to learn PyQt and not GTK+.  

GTK+ is available for Python 3.

No doubt it will work on Windows as well, once Microsoft gets its Linux 
compatibility layer debugged...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Getting back into PyQt and not loving it.

2016-06-27 Thread John Ladasky
On Sunday, June 26, 2016 at 7:41:17 PM UTC-7, Michael Torrie wrote:
> If GTK+ had first-class support on Windows and Mac, including native
> themes and seamless UI integration (file and print dialogs), I'd say
> GTK+ would be the only game in town for Python programmers.
> Unfortunately, unless you're only concerned with Linux, GTK+ is probably
> not going to be your choice.

Although I work almost exclusively in Linux, I've been teaching Python for 
several years as a sideline, and my students usually do not use Linux.  I 
insist on teaching my students Python 3.  Unless they're professionals who must 
work with legacy code (and, so far, none of them have been), I think I would be 
doing them a disservice to teach them Python 2.

I started with WxPython, but WxPython/Phoenix has been very slow to migrate to 
Python 3.  

Between the Py3 requirement and the need to work with all major OS's, I decided 
to learn PyQt and not GTK+.  

In my current day job, I'm developing an application on a Linux box, but I'll 
be handing it off to Windows users.  My choice of PyQt turned out to be the 
right one in that situation as well.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Getting back into PyQt and not loving it.

2016-06-26 Thread Michael Torrie
On 06/26/2016 07:05 PM, llanitedave wrote:
> Not sure that wxPython is really any different in that respect, and
> Tkinter doesn't feel Pythonic to me, either -- considering how it's
> Tk at heart.  So what's the alternative?  There really is no good
> Python-based GUI tool, and that's a shame.

Guess I kind of ended my email early.

Actually GTK+ is pretty nice to work with in Python.  The bindings feel
quite good and it's hard to tell where stuff is written in python and
where it's written in C.  The integration between Python data types and
the glib backend stuff is pretty seamless. I can't recall ever wrapping
up stuff in a GObject structure, and Python idioms work rather well
including iteration.  Try it out; it's pretty slick.

GTK+'s downsides are that though it's available on Windows and Mac,
those versions don't get as much love and without some real work don't
integrate very well.  Also GTK+ development seems to focus more on Gnome
than on general application development.

If GTK+ had first-class support on Windows and Mac, including native
themes and seamless UI integration (file and print dialogs), I'd say
GTK+ would be the only game in town for Python programmers.
Unfortunately, unless you're only concerned with Linux, GTK+ is probably
not going to be your choice.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Getting back into PyQt and not loving it.

2016-06-26 Thread MRAB

On 2016-06-27 02:05, llanitedave wrote:

On Sunday, June 26, 2016 at 2:45:18 PM UTC-7, Michael Torrie wrote:

I'm starting to question the advice I gave not long ago to for new users
to consider the Qt toolkit with Python.

I just did a little project porting a simple graphical user interface
from GTK+ to Qt (PyQt4 for now as that's what I have installed).  For
the most part it worked out pretty well.  It's been a while since I used
PyQt or PySide, and I had forgotten what a horrid Python experience Qt
really is, at least in PyQt4.  Maybe the bindings for Qt5 are better...
I'll be working with them next as I convert my working code.

Qt's a fantastic toolkit, and the most mature of any of them, and the
most portable, but man the bindings are not Pythonic at all. PyQt does
not seem to hide the C++-isms at all from the programmer.  I am
constantly wrapping things up in Qt classes like QRect, QPoint, QSize,
etc, when really a python Tuple would have sufficed.  All the data
structures are wrapped in Qt C++ classes, so you end up writing what is
really idiomatic C++ code using Python syntax. Not the best way to code
Python!  Implementing signals in a class, too, reminds you strongly that
you're working with C++ as you have to construct their method signatures
using types that map back into C++.


Not sure that wxPython is really any different in that respect, and Tkinter 
doesn't feel Pythonic to me, either -- considering how it's Tk at heart.  So 
what's the alternative?  There really is no good Python-based GUI tool, and 
that's a shame.

Is it a problem with Tk itself or with the Python wrapper? Would it be 
better if we made a more Pythonic version of Tkinter, e.g. making 
Frame.title a property?


--
https://mail.python.org/mailman/listinfo/python-list


Re: Getting back into PyQt and not loving it.

2016-06-26 Thread Rustom Mody
On Monday, June 27, 2016 at 6:35:31 AM UTC+5:30, llanitedave wrote:
> So what's the alternative?  There really is no good Python-based GUI tool, 
> and that's a shame.

The last time Ranting Rick made a big rant about this (saying wxpython should 
replace tkinter in core CPython) everyone took note of the rant
And missed the fact of the sux-state of GUI-in-python

Yes this is one big bus that python missed
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Getting back into PyQt and not loving it.

2016-06-26 Thread llanitedave
On Sunday, June 26, 2016 at 2:45:18 PM UTC-7, Michael Torrie wrote:
> I'm starting to question the advice I gave not long ago to for new users
> to consider the Qt toolkit with Python.
> 
> I just did a little project porting a simple graphical user interface
> from GTK+ to Qt (PyQt4 for now as that's what I have installed).  For
> the most part it worked out pretty well.  It's been a while since I used
> PyQt or PySide, and I had forgotten what a horrid Python experience Qt
> really is, at least in PyQt4.  Maybe the bindings for Qt5 are better...
> I'll be working with them next as I convert my working code.
> 
> Qt's a fantastic toolkit, and the most mature of any of them, and the
> most portable, but man the bindings are not Pythonic at all. PyQt does
> not seem to hide the C++-isms at all from the programmer.  I am
> constantly wrapping things up in Qt classes like QRect, QPoint, QSize,
> etc, when really a python Tuple would have sufficed.  All the data
> structures are wrapped in Qt C++ classes, so you end up writing what is
> really idiomatic C++ code using Python syntax. Not the best way to code
> Python!  Implementing signals in a class, too, reminds you strongly that
> you're working with C++ as you have to construct their method signatures
> using types that map back into C++.

Not sure that wxPython is really any different in that respect, and Tkinter 
doesn't feel Pythonic to me, either -- considering how it's Tk at heart.  So 
what's the alternative?  There really is no good Python-based GUI tool, and 
that's a shame.
-- 
https://mail.python.org/mailman/listinfo/python-list


Getting back into PyQt and not loving it.

2016-06-26 Thread Michael Torrie
I'm starting to question the advice I gave not long ago to for new users
to consider the Qt toolkit with Python.

I just did a little project porting a simple graphical user interface
from GTK+ to Qt (PyQt4 for now as that's what I have installed).  For
the most part it worked out pretty well.  It's been a while since I used
PyQt or PySide, and I had forgotten what a horrid Python experience Qt
really is, at least in PyQt4.  Maybe the bindings for Qt5 are better...
I'll be working with them next as I convert my working code.

Qt's a fantastic toolkit, and the most mature of any of them, and the
most portable, but man the bindings are not Pythonic at all. PyQt does
not seem to hide the C++-isms at all from the programmer.  I am
constantly wrapping things up in Qt classes like QRect, QPoint, QSize,
etc, when really a python Tuple would have sufficed.  All the data
structures are wrapped in Qt C++ classes, so you end up writing what is
really idiomatic C++ code using Python syntax. Not the best way to code
Python!  Implementing signals in a class, too, reminds you strongly that
you're working with C++ as you have to construct their method signatures
using types that map back into C++.

-- 
https://mail.python.org/mailman/listinfo/python-list


How to remember last position and size (geometry) of PyQt application?

2015-11-23 Thread Santosh Kumar
Hello all fellow Python programmers!

I am using PyQt5 (5.5.1) with Python 3.4.0 (64-bit) on Windows 8.1
64-bit. I don't think this much data was needed. :P

I am having trouble restoring the position and size (geometry) of my
very simple PyQt app.

What I read online is that this is the default behavior and we need to
use QSettings to save and retrieve settings from Windows registry,
which is stored in
`\\HKEY_CURRENT_USER\Software\[CompanyName]\[AppName]\`.

Here are some of the links are read:
http://doc.qt.io/qt-5.5/restoring-geometry.html
http://doc.qt.io/qt-5.5/qwidget.html#saveGeometry
http://doc.qt.io/qt-5.5/qsettings.html#restoring-the-state-of-a-gui-application
and the last one:
https://ic3man5.wordpress.com/2013/01/26/save-qt-window-size-and-state-on-closeopen/

I could have followed those tutorials but those tutorials/docs were
written for C++ users.

C++ is not my glass of beer. Should I expect help from you guys? :)

Here is minimal working application:


import sys
from PyQt5.QtWidgets import QApplication, QWidget

class sViewer(QWidget):
"""Main class of sViewer"""
def __init__(self):
super(sViewer, self).__init__()
self.initUI()


def initUI(self):
self.show()

if __name__ == '__main__':
app = QApplication(sys.argv)
view = sViewer()
sys.exit(app.exec_())
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to remember last position and size (geometry) of PyQt application?

2015-11-23 Thread Santosh Kumar
This question was reasked and answered on StackOverflow:
http://stackoverflow.com/q/33869721/939986
-- 
https://mail.python.org/mailman/listinfo/python-list


PyQt v5.5 Released

2015-07-19 Thread Phil Thompson

PyQt5 v5.5 has been released and is available from
http://www.riverbankcomputing.com/software/pyqt/download5.

PyQt5 is a comprehensive set of bindings for v5 of The Qt Company's Qt
cross-platform application framework.  It supports Python v3, v2.7 and
v2.6.

The highlights of this release include support for Qt v5.5.0 including
the new QtLocation and QtNfc modules.

PyQt5 supports cross-compiling to iOS and Android.

Windows installers are provided which contain everything needed for 
PyQt5
development (including Qt, Qt Designer, QScintilla, and MySQL, 
PostgreSQL,

SQLite and ODBC drivers) except Python itself.  Installers are provided
for the 32 and 64 bit versions of Python v3.4.

PyQt5 is implemented as a set of 35 extension modules comprising more 
than

a 1,000 classes including support for:

- non-GUI infrastructure including event loops, threads, i18n, user and
  application settings, mapped files and shared memory

- GUI infrastructure including window system integration, event 
handling,

  2D graphics, basic imaging, fonts, OpenGL

- a comprehensive set of desktop widgets

- WebKit and Chromium based browsers

- WebSockets

- location and positioning services (including OpenStreetMap) using
  satellite, Wi-Fi or text file sources

- a client-side library for accessing Qt Cloud Services

- full integration with Quick2 and QML allowing new Quick items to be
  implemented in Python and created in QML

- event driven network programming

- multimedia including cameras, audio and radios

- Bluetooth

- NFC enabled devices

- sensors including accelerometers, altimeters, compasses, gyroscopes,
  magnetometers, and light, pressure, proximity, rotation and 
temperature

  sensors

- serial ports

- SQL

- printing

- DBus

- XPath, XQuery, XSLT and XML Schema validation

- a help system for creating and viewing searchable documentation

- unit testing of GUI applications.
--
https://mail.python.org/mailman/listinfo/python-list


PyQt v5.5 Released

2015-07-19 Thread Phil Thompson

PyQt5 v5.5 has been released and is available from
http://www.riverbankcomputing.com/software/pyqt/download5.

PyQt5 is a comprehensive set of bindings for v5 of The Qt Company's Qt
cross-platform application framework.  It supports Python v3, v2.7 and
v2.6.

The highlights of this release include support for Qt v5.5.0 including
the new QtLocation and QtNfc modules.

PyQt5 supports cross-compiling to iOS and Android.

Windows installers are provided which contain everything needed for 
PyQt5
development (including Qt, Qt Designer, QScintilla, and MySQL, 
PostgreSQL,

SQLite and ODBC drivers) except Python itself.  Installers are provided
for the 32 and 64 bit versions of Python v3.4.

PyQt5 is implemented as a set of 35 extension modules comprising more 
than

a 1,000 classes including support for:

- non-GUI infrastructure including event loops, threads, i18n, user and
  application settings, mapped files and shared memory

- GUI infrastructure including window system integration, event 
handling,

  2D graphics, basic imaging, fonts, OpenGL

- a comprehensive set of desktop widgets

- WebKit and Chromium based browsers

- WebSockets

- location and positioning services (including OpenStreetMap) using
  satellite, Wi-Fi or text file sources

- a client-side library for accessing Qt Cloud Services

- full integration with Quick2 and QML allowing new Quick items to be
  implemented in Python and created in QML

- event driven network programming

- multimedia including cameras, audio and radios

- Bluetooth

- NFC enabled devices

- sensors including accelerometers, altimeters, compasses, gyroscopes,
  magnetometers, and light, pressure, proximity, rotation and 
temperature

  sensors

- serial ports

- SQL

- printing

- DBus

- XPath, XQuery, XSLT and XML Schema validation

- a help system for creating and viewing searchable documentation

- unit testing of GUI applications.
--
https://mail.python.org/mailman/listinfo/python-announce-list

   Support the Python Software Foundation:
   http://www.python.org/psf/donations/


Re: [PyQt] win32api.LoadKeyboardLayout; any solutions for OSX?

2015-03-20 Thread Timothy W. Grove
-packages/objc/_lazyimport.py,
line 82, in __init__

if nm.startswith(pfx):

AttributeError: 'NoneType' object has no attribute 'startswith'

logout


[Process completed]



___
PyQt mailing list p...@riverbankcomputing.com
mailto:p...@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt




-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [PyQt] win32api.LoadKeyboardLayout; any solutions for OSX?

2015-03-19 Thread michael h
Did you see this:

https://bitbucket.org/ronaldoussoren/pyobjc/issue/95/attributeerror-in-some-cases-when-checking



On Thu, Mar 19, 2015 at 12:20 PM, Timothy W. Grove tim_gr...@sil.org
wrote:

  A personal reply to my question sent me to the following link:
 http://stackoverflow.com/questions/23729704/change-osx-keyboard-layoutinput-source-programmatically-via-terminal-or-appl.
 I seem to have found a solution that worked using PyObjC.

 I'm currently using Python 3.3 installed via macports, and I installed the
 appropriate ports for my setup (py33-pyobjc, py33-pyobjc-cocoa).

 For my import statement:

 from AppKit import NSTextInputContext

  To find the current keyboard being used:

 ic = NSTextInputContext.new()
 current_keyboard = ic.selectedKeyboardInputSource()

  To list the currently available keyboards:

 keyboards = ic.keyboardInputSources()

  To change the current keyboard (to 'Arabic', for example):

 ic.setValue_forKey_('com.apple.keylayout.Arabic',
 'selectedKeyboardInputSource')


 Now, that is the good news! This all worked great in my source code, but
 as an app bundle (created with cx_Freeze 4.3.2) it wouldn't run at all.
 I'll include the full error trace at the end of this email, but the
 problems seem to start with the import of AppKit and end with
 objc/_lazyimport.py.

 I'm not sure if this points to a 'bug' in objc or something else which
 I've left out of my setup routine, but if anyone has any ideas, I would be
 interested to hear from you.

 Best regards,
 Timothy Grove



 On 05/03/2015 14:51, Timothy W. Grove wrote:

 I was looking for a way to change keyboard layouts from within a Python 3
 / PyQt4 application. Win32api.LoadKeyboardLayout has come to my rescue on
 Windows, but is anyone aware of a cross-platform or OSX specific solution
 for Apple Mac? Thanks for any suggestions.

 Best regards,
 Tim


  Traceback (most recent call last):

   File
 /opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/cx_Freeze/initscripts/Console3.py,
 line 27, in module

 exec(code, m.__dict__)

   File soosl.py, line 6, in module

   File
 /opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/importlib/_bootstrap.py,
 line 1565, in _find_and_load

 return _find_and_load_unlocked(name, import_)

   File
 /opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/importlib/_bootstrap.py,
 line 1532, in _find_and_load_unlocked

 loader.load_module(name)

   File /Users/timothygrove/Documents/workspace/SooSL/mainwindow.py, line
 19, in module

   File
 /opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/importlib/_bootstrap.py,
 line 1565, in _find_and_load

 return _find_and_load_unlocked(name, import_)

   File
 /opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/importlib/_bootstrap.py,
 line 1532, in _find_and_load_unlocked

 loader.load_module(name)

   File
 /opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/AppKit/__init__.py,
 line 9, in module

 import Foundation

   File
 /opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/importlib/_bootstrap.py,
 line 1565, in _find_and_load

 return _find_and_load_unlocked(name, import_)

   File
 /opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/importlib/_bootstrap.py,
 line 1532, in _find_and_load_unlocked

 loader.load_module(name)

   File
 /opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/Foundation/__init__.py,
 line 9, in module

 import CoreFoundation

   File
 /opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/importlib/_bootstrap.py,
 line 1565, in _find_and_load

 return _find_and_load_unlocked(name, import_)

   File
 /opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/importlib/_bootstrap.py,
 line 1532, in _find_and_load_unlocked

 loader.load_module(name)

   File
 /opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/CoreFoundation/__init__.py,
 line 20, in module

 }, ())

   File
 /opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/objc/_lazyimport.py,
 line 82, in __init__

 if nm.startswith(pfx):

 AttributeError: 'NoneType' object has no attribute 'startswith'

 logout


   [Process completed]



 ___
 PyQt mailing listp...@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt

-- 
https://mail.python.org/mailman/listinfo/python-list


ANN: PyQt v5.4 Released

2014-12-27 Thread Phil Thompson

PyQt5 v5.4 has been released and is available from
http://www.riverbankcomputing.com/software/pyqt/download5.

PyQt5 is a comprehensive set of bindings for v5 of Digia's Qt
cross-platform application framework.  It supports Python v3, v2.7 and
v2.6.

The highlights of this release include support for Qt v5.4 including the
new QtWebChannel and QtWebEngineWidgets modules.  The QtXml module has 
also

been restored.

PyQt5 supports cross-compiling to iOS and Android.

Windows installers are provided which contain everything needed for 
PyQt5
development (including Qt, Qt Designer, QScintilla, and MySQL, 
PostgreSQL,

SQLite and ODBC drivers) except Python itself.  Installers are provided
for the 32 and 64 bit versions of Python v3.4.

PyQt5 is implemented as a set of 33 extension modules including support
for:

- non-GUI infrastructure including event loops, threads, i18n, user and
  application settings, mapped files and shared memory

- GUI infrastructure including window system integration, event 
handling,

  2D graphics, basic imaging, fonts, OpenGL

- a comprehensive set of desktop widgets

- WebKit and Chromium based browsers

- WebSockets

- a client-side library for accessing Qt Cloud Services

- full integration with Quick2 and QML allowing new Quick items to be
  implemented in Python and created in QML

- event driven network programming

- multimedia including cameras, audio and radios

- Bluetooth

- global positioning using satellite, Wi-Fi or text file sources

- sensors including accelerometers, altimeters, compasses, gyroscopes,
  magnetometers, and light, pressure, proximity, rotation and 
temperature

  sensors

- serial ports

- SQL

- printing

- DBus

- XPath, XQuery, XSLT and XML Schema validation

- a help system for creating and viewing searchable documentation

- unit testing of GUI applications.
--
https://mail.python.org/mailman/listinfo/python-announce-list

   Support the Python Software Foundation:
   http://www.python.org/psf/donations/


ANN: PyQt v5.4 Released

2014-12-26 Thread Phil Thompson

PyQt5 v5.4 has been released and is available from
http://www.riverbankcomputing.com/software/pyqt/download5.

PyQt5 is a comprehensive set of bindings for v5 of Digia's Qt
cross-platform application framework.  It supports Python v3, v2.7 and
v2.6.

The highlights of this release include support for Qt v5.4 including the
new QtWebChannel and QtWebEngineWidgets modules.  The QtXml module has 
also

been restored.

PyQt5 supports cross-compiling to iOS and Android.

Windows installers are provided which contain everything needed for 
PyQt5
development (including Qt, Qt Designer, QScintilla, and MySQL, 
PostgreSQL,

SQLite and ODBC drivers) except Python itself.  Installers are provided
for the 32 and 64 bit versions of Python v3.4.

PyQt5 is implemented as a set of 33 extension modules including support
for:

- non-GUI infrastructure including event loops, threads, i18n, user and
  application settings, mapped files and shared memory

- GUI infrastructure including window system integration, event 
handling,

  2D graphics, basic imaging, fonts, OpenGL

- a comprehensive set of desktop widgets

- WebKit and Chromium based browsers

- WebSockets

- a client-side library for accessing Qt Cloud Services

- full integration with Quick2 and QML allowing new Quick items to be
  implemented in Python and created in QML

- event driven network programming

- multimedia including cameras, audio and radios

- Bluetooth

- global positioning using satellite, Wi-Fi or text file sources

- sensors including accelerometers, altimeters, compasses, gyroscopes,
  magnetometers, and light, pressure, proximity, rotation and 
temperature

  sensors

- serial ports

- SQL

- printing

- DBus

- XPath, XQuery, XSLT and XML Schema validation

- a help system for creating and viewing searchable documentation

- unit testing of GUI applications.
--
https://mail.python.org/mailman/listinfo/python-list


Re: PyQt: user interface freezed when using concurrent.futures.ThreadPoolExecutor

2014-12-18 Thread Mark Summerfield
On Thursday, December 11, 2014 4:53:04 AM UTC, iMath wrote:
 I think the user interface shouldn't be freezed when using 
 concurrent.futures.ThreadPoolExecutor here,as it executes asynchronously ,
  but it doesn't meet my expectations,anyone can explain why ? any other 
 solutions here to not let user interface freezed?
 
 code is here
 http://stackoverflow.com/questions/27393533/user-interface-freezed-when-using-concurrent-futures-threadpoolexecutor

It looks to me that what you are doing is sharing a single core between your 
GUI and your processing. Threading isn't usually a good approach to Python 
concurrency that is CPU-bound.

Simply changing ThreadPoolExecutor to ProcessPoolExecutor will improve 
performance, but will still allow the UI to freeze.

The approach I use for concurrency in GUI applications is for the GUI to run in 
the main thread (the default, and there's no choice) and to create a manager 
thread that does almost no work. This means that the GUI thread gets almost all 
the processing on the core on which it runs. Whenever there is work to do it is 
passed to the manager thread which immediately gives it to someone else. The 
someone else is a process pool. This ensures that the GUI doesn't freeze even 
in the face of lots of processing (because the processing is done in one or 
more separate processes).

In my book Python in Practice, http://www.qtrac.eu/pipbook.html there's an 
example of how to do this in chapter 4. The example uses Tkinter but I use 
exactly the same approach in PyQt and PySide. This chapter also discusses many 
issues related to Python concurrency.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyQt: user interface freezed when using concurrent.futures.ThreadPoolExecutor

2014-12-18 Thread Michael Torrie
On 12/18/2014 04:16 AM, Mark Summerfield wrote:
 It looks to me that what you are doing is sharing a single core
 between your GUI and your processing. Threading isn't usually a good
 approach to Python concurrency that is CPU-bound.

Except that his code was not CPU-bound to begin with.  His real problem
is that his callback is starting *and* waiting for all the threads to do
their work without returning to the main loop, thus blocking the GUI.
As for the threads, they are I/O bound--he's simply trying to do
concurrent HTTP downloads.  So blocking in the GIL is not the issue
here.  In fact, in lieu of using proper asynchronous I/O, threading of
some kind is probably not a bad solution here, but he has to do it
within the Qt Framework, using signals to notify the GUI when a thread
is finished, or using a synchronization primitive such as a queue, as
recommended by your book in fact.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyQt: user interface freezed when using concurrent.futures.ThreadPoolExecutor

2014-12-12 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com:

 And I don't remember how Java did things, except that I struggled to
 find basic fundamental primitives like semaphores, and had to use
 synchronized functions/objects instead.

Java now has a diverse set of synchornization facilities, but the
builtin object synchronization produces excellent idioms and is usually
preferred (by me). Java also has rigorously defined its multithreaded
data model (the Happens-Before Relation).

Java's threads have two major problems:

 * The classic I/O forced you to dedicate a thread for each
   communication context (connection) because there was no multiplexing
   facility and because the sockets were blocking (and buffered IIRC).
   The thread proliferation caused serious scalability issues.
   Latter-day Java's NIO framework addresses this shortcoming to a great
   degree, but even that is a surprisingly tricky beast to program
   for -- it suffers from builtin race conditions.

 * There is no way to interrupt a thread -- except in Solaris! You can
   mark a thread for interruption and there is an associated exception
   but they are not guaranteed to be provided by JVM.

And then there's the inherent problems of thread programming:

 * Deadlocks.

 * Missing synchronization.

which in practice are just too hard for mortals. I've seen it. I've been
complicit.

Now, when it comes to Python, asyncio is its answer to Java's NIO. It
seeks to provide a cross-platform Way to Life, Universe and Everything.
A commendable objective. Unfortunately, I find the coroutine approach
artificial and unintuitive in practice. Select.epoll(EPOLLET) plus a
timer implementation easily beats it (as long as you can limit yourself
to linux).


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyQt: user interface freezed when using concurrent.futures.ThreadPoolExecutor

2014-12-11 Thread iMath
在 2014年12月11日星期四UTC+8下午1时25分41秒,Michael Torrie写道:
 On 12/10/2014 09:52 PM, iMath wrote:
  I think the user interface shouldn't be freezed when using
  concurrent.futures.ThreadPoolExecutor here,as it executes
  asynchronously , but it doesn't meet my expectations,anyone can
  explain why ? any other solutions here to not let user interface
  freezed?
  
  code is here 
  http://stackoverflow.com/questions/27393533/user-interface-freezed-when-using-concurrent-futures-threadpoolexecutor
 
 In most any GUI framework, regardless of your use of threads, your
 callbacks must return control to the main loop immediately (whether an
 on-click or an on-timer event), or the GUI *will* freeze.
 
 You are spawning threads to download the urls, then sitting there
 waiting for them to finish in the callback.  Of course the GUI will
 freeze; your callback is blocking it.  What you should be doing is
 spawning the threads to do the download, then have the threads (using a
 proper QThread mechanism or some other semaphore mechanism) raise a
 signal to indicate they are done, which you will then catch in the main
 loop as a normal callback.  And really when it comes to I/O and GUIs,
 asynchronous calls are always better than threads.  Not sure what Qt has
 in the way of asynchronous i/o calls, and I'm not familiar enough with
 the various async i/o frameworks in Python to speak to that, though I
 did use Python-Twisted once... very powerful once you get your head
 wrapped around it.
 
 Look through the list archives because in the last 3 or 4 weeks I and
 another Python user talked proper thread use with PyQt or PySide, with
 code examples.

when it comes to I/O and GUIs, asynchronous calls are always better than 
threads.

I cannot grasp your meaning here, IMO, asynchronous calls are done by using 
threads.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyQt: user interface freezed when using concurrent.futures.ThreadPoolExecutor

2014-12-11 Thread Michael Torrie
On 12/11/2014 08:20 PM, iMath wrote:
 在 2014年12月11日星期四UTC+8下午1时25分41秒,Michael Torrie写道:
 On 12/10/2014 09:52 PM, iMath wrote:
 when it comes to I/O and GUIs, asynchronous calls are always better than 
 threads.
 
 I cannot grasp your meaning here, IMO, asynchronous calls are done by using 
 threads.

Not in your code.  All your I/O calls are synchronous; they block until
they are finished.  But if you mean that calling synchronous calls while
in a thread has a similar effect to an asynchronous call, you are
correct.  But the way you're waiting for the threads to finish, you're
blocking your gui.

An asynchronous API lets you start long-running I/O calls and define a
function that is automatically called upon completion.  In other words
it's event-driven.  Qt may provide everything you need already in an
asynchronous form.  Check the docs. And use google.  Here's a link I
found from a google search that illustrates how to fetch a url in Qt
using an asynchronous method.  You could fire off as many of these as
you want, then just wait for signals.

http://qt-project.org/wiki/Download_Data_from_URL


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyQt: user interface freezed when using concurrent.futures.ThreadPoolExecutor

2014-12-11 Thread Marko Rauhamaa
Michael Torrie torr...@gmail.com:

 An asynchronous API lets you start long-running I/O calls and define a
 function that is automatically called upon completion. In other words
 it's event-driven. Qt may provide everything you need already in an
 asynchronous form.

GUI developers have been doing event-driven programming for decades.
That's an excellent preparation for network programming as well.
Unfortunately, the minds of a generation of programmers were
contaminated by the thread craze of the 1990's (Java and Windows NT).


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyQt: user interface freezed when using concurrent.futures.ThreadPoolExecutor

2014-12-11 Thread Chris Angelico
On Fri, Dec 12, 2014 at 6:18 PM, Marko Rauhamaa ma...@pacujo.net wrote:
 GUI developers have been doing event-driven programming for decades.
 That's an excellent preparation for network programming as well.
 Unfortunately, the minds of a generation of programmers were
 contaminated by the thread craze of the 1990's (Java and Windows NT).

Threads predate Java and NT, and with a much MUCH better
implementation, on OS/2. I don't consider my mind to have been
*contaminated* by the OS/2 threading model, which worked superbly.
Like all models, it has its limitations, but it's one worth getting
your head around IMO. Knowing when to use threads, when to use
processes, and when to keep everything in a single thread with some
kind of dispatch loop (and *which* dispatch loop) is a valuable skill.

But yes, the Windows threading model does have a number of annoying
flaws. And I don't remember how Java did things, except that I
struggled to find basic fundamental primitives like semaphores, and
had to use synchronized functions/objects instead.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


PyQt: user interface freezed when using concurrent.futures.ThreadPoolExecutor

2014-12-10 Thread iMath
I think the user interface shouldn't be freezed when using 
concurrent.futures.ThreadPoolExecutor here,as it executes asynchronously ,
 but it doesn't meet my expectations,anyone can explain why ? any other 
solutions here to not let user interface freezed?

code is here
http://stackoverflow.com/questions/27393533/user-interface-freezed-when-using-concurrent-futures-threadpoolexecutor
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyQt: user interface freezed when using concurrent.futures.ThreadPoolExecutor

2014-12-10 Thread Michael Torrie
On 12/10/2014 09:52 PM, iMath wrote:
 I think the user interface shouldn't be freezed when using
 concurrent.futures.ThreadPoolExecutor here,as it executes
 asynchronously , but it doesn't meet my expectations,anyone can
 explain why ? any other solutions here to not let user interface
 freezed?
 
 code is here 
 http://stackoverflow.com/questions/27393533/user-interface-freezed-when-using-concurrent-futures-threadpoolexecutor

In most any GUI framework, regardless of your use of threads, your
callbacks must return control to the main loop immediately (whether an
on-click or an on-timer event), or the GUI *will* freeze.

You are spawning threads to download the urls, then sitting there
waiting for them to finish in the callback.  Of course the GUI will
freeze; your callback is blocking it.  What you should be doing is
spawning the threads to do the download, then have the threads (using a
proper QThread mechanism or some other semaphore mechanism) raise a
signal to indicate they are done, which you will then catch in the main
loop as a normal callback.  And really when it comes to I/O and GUIs,
asynchronous calls are always better than threads.  Not sure what Qt has
in the way of asynchronous i/o calls, and I'm not familiar enough with
the various async i/o frameworks in Python to speak to that, though I
did use Python-Twisted once... very powerful once you get your head
wrapped around it.

Look through the list archives because in the last 3 or 4 weeks I and
another Python user talked proper thread use with PyQt or PySide, with
code examples.
-- 
https://mail.python.org/mailman/listinfo/python-list


pyqt darg and drop

2014-10-04 Thread Sachin Tiwari
Hi

I want to drag and drop push multiple push buttons but its working for only for 
last button. And I want to connect them by a wire.

Please help.

  import sys
from PyQt4 import QtGui, QtCore


class Button(QtGui.QPushButton):
def mouseMoveEvent(self, e):
if e.buttons() != QtCore.Qt.RightButton:
return

mimeData = QtCore.QMimeData()
mimeData.setText('%d,%d' % (e.x(), e.y()))

pixmap = QtGui.QPixmap.grabWidget(self)

painter = QtGui.QPainter(pixmap)
painter.setCompositionMode(painter.CompositionMode_DestinationIn)
painter.fillRect(pixmap.rect(), QtGui.QColor(0, 0, 0, 127))
painter.end()

drag = QtGui.QDrag(self)
drag.setMimeData(mimeData)
drag.setPixmap(pixmap)
drag.setHotSpot(e.pos())
if drag.exec_(QtCore.Qt.CopyAction  QtCore.Qt.MoveAction) == 
QtCore.Qt.MoveAction:
print 'moved'
else:
print 'copied'

def mousePressEvent(self, e):
QtGui.QPushButton.mousePressEvent(self, e)
if e.button() == QtCore.Qt.LeftButton:
print 'press'



class Example(QtGui.QWidget):
def __init__(self):
super(Example, self).__init__()
self.initUI()


def initUI(self):
self.setAcceptDrops(True)

button = Button('Button', self)
button1 = Button('Button1', self)
button.move(100, 65)
button1.move(200, 65)

self.buttons = [button]

self.setWindowTitle('Copy or Move')
self.setGeometry(300, 300, 280, 150)


def dragEnterEvent(self, e):
e.accept()


def dropEvent(self, e):
mime = e.mimeData().text()
x, y = map(int, mime.split(','))

if e.keyboardModifiers()  QtCore.Qt.ShiftModifier:
button = Button('Button', self)
button1 = Button('Button1', self)
button.move(e.pos()-QtCore.QPoint(x, y))
button1.move(e.pos()-QtCore.QPoint(x, y))
button.show()
button1.show()
self.buttons.append(button)
self.buttons.append(button1)
e.setDropAction(QtCore.Qt.CopyAction)
else:
e.source().move(e.pos()-QtCore.QPoint(x, y))
e.setDropAction(QtCore.Qt.MoveAction)
e.accept()


if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
ex = Example()
ex.show()
 

   
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pyqt darg and drop

2014-10-04 Thread Sachin Tiwari
On Saturday, October 4, 2014 3:35:33 PM UTC+5:30, Sachin Tiwari wrote:
 Hi
 
 
 
 I want to drag and drop push multiple push buttons but its working for only 
 for last button. And I want to connect them by a wire.
 
 
 
 Please help.
 
 
 
   import sys
 
 from PyQt4 import QtGui, QtCore
 
 
 
 
 
 class Button(QtGui.QPushButton):
 
 def mouseMoveEvent(self, e):
 
 if e.buttons() != QtCore.Qt.RightButton:
 
 return
 
 
 
 mimeData = QtCore.QMimeData()
 
 mimeData.setText('%d,%d' % (e.x(), e.y()))
 
 
 
 pixmap = QtGui.QPixmap.grabWidget(self)
 
 
 
 painter = QtGui.QPainter(pixmap)
 
 painter.setCompositionMode(painter.CompositionMode_DestinationIn)
 
 painter.fillRect(pixmap.rect(), QtGui.QColor(0, 0, 0, 127))
 
 painter.end()
 
 
 
 drag = QtGui.QDrag(self)
 
 drag.setMimeData(mimeData)
 
 drag.setPixmap(pixmap)
 
 drag.setHotSpot(e.pos())
 
 if drag.exec_(QtCore.Qt.CopyAction  QtCore.Qt.MoveAction) == 
 QtCore.Qt.MoveAction:
 
 print 'moved'
 
 else:
 
 print 'copied'
 
 
 
 def mousePressEvent(self, e):
 
 QtGui.QPushButton.mousePressEvent(self, e)
 
 if e.button() == QtCore.Qt.LeftButton:
 
 print 'press'
 
 
 
 
 
 
 
 class Example(QtGui.QWidget):
 
 def __init__(self):
 
 super(Example, self).__init__()
 
 self.initUI()
 
 
 
 
 
 def initUI(self):
 
 self.setAcceptDrops(True)
 
 
 
 button = Button('Button', self)
 
 button1 = Button('Button1', self)
 
 button.move(100, 65)
 
 button1.move(200, 65)
 
 
 
 self.buttons = [button]
 
 
 
 self.setWindowTitle('Copy or Move')
 
 self.setGeometry(300, 300, 280, 150)
 
 
 
 
 
 def dragEnterEvent(self, e):
 
 e.accept()
 
 
 
 
 
 def dropEvent(self, e):
 
 mime = e.mimeData().text()
 
 x, y = map(int, mime.split(','))
 
 
 
 if e.keyboardModifiers()  QtCore.Qt.ShiftModifier:
 
 button = Button('Button', self)
 
 button1 = Button('Button1', self)
 
 button.move(e.pos()-QtCore.QPoint(x, y))
 
 button1.move(e.pos()-QtCore.QPoint(x, y))
 
 button.show()
 
 button1.show()
 
 self.buttons.append(button)
 
 self.buttons.append(button1)
 
 e.setDropAction(QtCore.Qt.CopyAction)
 
 else:
 
 e.source().move(e.pos()-QtCore.QPoint(x, y))
 
 e.setDropAction(QtCore.Qt.MoveAction)
 
 e.accept()
 
 
 
 
 
 if __name__ == '__main__':
 
 app = QtGui.QApplication(sys.argv)
 
 ex = Example()
 
 ex.show()

Change this line,

 if drag.exec_(QtCore.Qt.CopyAction | QtCore.Qt.MoveAction) == 
QtCore.Qt.MoveAction: 
-- 
https://mail.python.org/mailman/listinfo/python-list


pyqt problem

2014-10-02 Thread sachin . tiwari50
Hi 
I am learning pyqt, can any one help me to make instances of pushbutton 
wherever cursor will be clicked on canvas,like a circuit simulator where  we 
add components on canvas just by left or right click.

Thanks  Regards,
Sachin
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pyqt problem

2014-10-02 Thread Mark Lawrence

On 02/10/2014 10:49, sachin.tiwar...@gmail.com wrote:

Hi
I am learning pyqt, can any one help me to make instances of pushbutton 
wherever cursor will be clicked on canvas,like a circuit simulator where  we 
add components on canvas just by left or right click.

Thanks  Regards,
Sachin



Please show us what you're tried so far and where it's going wrong, 
we're not here simply to write code for you.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list


Re: pyqt problem

2014-10-02 Thread Sachin Tiwari
On Thursday, October 2, 2014 3:19:22 PM UTC+5:30, Sachin Tiwari wrote:
 Hi 
 
 I am learning pyqt, can any one help me to make instances of pushbutton 
 wherever cursor will be clicked on canvas,like a circuit simulator where  we 
 add components on canvas just by left or right click.
 
 
 
 Thanks  Regards,
 
 Sachin

Hi

swch = QPushButton('', self)
swch.setToolTip('Switch ')
swch.setCheckable(True)
swch.setIcon(QIcon('sw.png'))
swch.setIconSize(QSize(40,40))
swch.move(05, 25)
swch.clicked.connect(self.switch)

The above code will make a push button on canvas, now what I want when I will 
click on this button it get ready to drop anywhere on canvas by left click,I 
mean if I click 10 times on canvas 10 push button will be there.
 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [PyQt] Automatic Crash Reporting

2014-09-26 Thread Detlev Offenbach
Hi,

I did this myself for the eric IDE. Depending upon your needs it is really 
simple. 
Just check the eric5.py main script. (http://eric-ide.python-projects.org)

Detlev

On Thursday 25 September 2014, 04:15:53 Timothy W. Grove wrote:
 Can anyone recommend a good automatic crash reporting module that would
 work nicely with a python3/pyqt4 application? Thanks.
 
 Tim
 ___
 PyQt mailing listp...@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt-- 
*Detlev Offenbach*
det...@die-offenbachs.de
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to add ftp put function in PyQT network ftp demo

2014-07-02 Thread 不坏阿峰
在 2014年7月1日星期二UTC+7下午5时27分59秒,不坏阿峰写道:
 I want to modify the pyqt network ftp demo to include an upload function, but 
 I am failing. Could someone can show me how to do this? I have tried to add 
 this code, but it does not work. 
 
 [Orignal 
 demo]https://github.com/Werkov/PyQt4/blob/master/examples/network/ftp/ftp.py
 
 
 
 at First, i add these code into demo. not work at all
 
 ##
 
 buttonBox.addButton(self.uploadButton,
 
 QtGui.QDialogButtonBox.ActionRole)
 
 self.uploadButton = QtGui.QPushButton(upload)
 
 self.uploadButton.clicked.connect(self.selectFile)
 
 
 
 def selectFile(self):
 
 self.filename =QtGui.QFileDialog.getOpenFileName()
 
 up_fname = re.sub(r.*/,,self.filename)
 
 upload_file = QtCore.QFile(self.filename)
 
 self.ftp.put(upload_file, up_fname)
 
 
 
 ##
 
 
 
 Second, i modify like this, i can upload small file successfully, but fail on 
 big size file, the app will crash.
 
 
 
 #
 
 def selectFile(self):
 
 self.filename =QtGui.QFileDialog.getOpenFileName()
 
 print self.filename
 
 up_fname = re.sub(r.*/,,self.filename)
 
 print up_fname
 
 
 
 
 
 upload_file = QtCore.QFile(self.filename)
 
 #print upload_file
 
 upload_file.open(QtCore.QIODevice.ReadOnly)
 
 ba = QtCore.QByteArray()
 
 ba.append(upload_file.readAll())
 
 
 
 #buffer = QtCore.QBuffer() do not how to use Buffer
 
 #buffer.open(QtCore.QIODevice.ReadWrite)
 
 #buffer.setData(ba)
 
 
 
 self.ftp.put(ba, up_fname)
 
 self.progressDialog.setLabelText(Uploading %s... % up_fname)
 
 self.uploadButton.setEnabled(False)
 
 self.progressDialog.exec_()
 
 self.uploadButton.setEnabled(True)
 
 self.ftp.list()
 
 
 
 

any one can give some suggestion?
-- 
https://mail.python.org/mailman/listinfo/python-list


How to add ftp put function in PyQT network ftp demo

2014-07-01 Thread 不坏阿峰
I want to modify the pyqt network ftp demo to include an upload function, but I 
am failing. Could someone can show me how to do this? I have tried to add this 
code, but it does not work. 
[Orignal 
demo]https://github.com/Werkov/PyQt4/blob/master/examples/network/ftp/ftp.py

at First, i add these code into demo. not work at all
##
buttonBox.addButton(self.uploadButton,
QtGui.QDialogButtonBox.ActionRole)
self.uploadButton = QtGui.QPushButton(upload)
self.uploadButton.clicked.connect(self.selectFile)

def selectFile(self):
self.filename =QtGui.QFileDialog.getOpenFileName()
up_fname = re.sub(r.*/,,self.filename)
upload_file = QtCore.QFile(self.filename)
self.ftp.put(upload_file, up_fname)

##

Second, i modify like this, i can upload small file successfully, but fail on 
big size file, the app will crash.

#
def selectFile(self):
self.filename =QtGui.QFileDialog.getOpenFileName()
print self.filename
up_fname = re.sub(r.*/,,self.filename)
print up_fname


upload_file = QtCore.QFile(self.filename)
#print upload_file
upload_file.open(QtCore.QIODevice.ReadOnly)
ba = QtCore.QByteArray()
ba.append(upload_file.readAll())

#buffer = QtCore.QBuffer() do not how to use Buffer
#buffer.open(QtCore.QIODevice.ReadWrite)
#buffer.setData(ba)

self.ftp.put(ba, up_fname)
self.progressDialog.setLabelText(Uploading %s... % up_fname)
self.uploadButton.setEnabled(False)
self.progressDialog.exec_()
self.uploadButton.setEnabled(True)
self.ftp.list()


-- 
https://mail.python.org/mailman/listinfo/python-list


ANN: PyQt v5.3 Released

2014-06-02 Thread Phil Thompson

PyQt5 v5.3 has been released and is available from
http://www.riverbankcomputing.com/software/pyqt/download5.

PyQt5 is a comprehensive set of bindings for v5 of Digia's Qt
cross-platform application framework.  It supports Python v3, v2.7 and
v2.6.

The highlights of this release include support for Qt v5.3 including the
new QtQuickWidgets and QtWebSockets modules.

PyQt5 supports cross-compiling to iOS and Android.

Windows installers are provided which contain everything needed for 
PyQt5
development (including Qt, Qt Designer, QScintilla, and MySQL, 
PostgreSQL,

SQLite and ODBC drivers) except Python itself.  Installers are provided
for the 32 and 64 bit versions of Python v3.4.

PyQt5 is implemented as a set of 29 extension modules including support
for:

- non-GUI infrastructure including event loops, threads, i18n, user and
  application settings, mapped files and shared memory

- GUI infrastructure including window system integration, event 
handling,

  2D graphics, basic imaging, fonts, OpenGL

- a comprehensive set of desktop widgets

- WebKit

- full integration with Quick2 and QML allowing new Quick items to be
  implemented in Python and created in QML

- event driven network programming

- multimedia including cameras, audio and radios

- Bluetooth

- global positioning using satellite, Wi-Fi or text file sources

- sensors including accelerometers, altimeters, compasses, gyroscopes,
  magnetometers, and light, pressure, proximity, rotation and 
temperature

  sensors

- serial ports

- SQL

- printing

- DBus

- XPath, XQuery, XSLT and XML Schema validation

- a help system for creating and viewing searchable documentation

- unit testing of GUI applications.
--
https://mail.python.org/mailman/listinfo/python-announce-list

   Support the Python Software Foundation:
   http://www.python.org/psf/donations/


ANN: PyQt v5.3 Released

2014-05-28 Thread Phil Thompson

PyQt5 v5.3 has been released and is available from
http://www.riverbankcomputing.com/software/pyqt/download5.

PyQt5 is a comprehensive set of bindings for v5 of Digia's Qt
cross-platform application framework.  It supports Python v3, v2.7 and
v2.6.

The highlights of this release include support for Qt v5.3 including the
new QtQuickWidgets and QtWebSockets modules.

PyQt5 supports cross-compiling to iOS and Android.

Windows installers are provided which contain everything needed for 
PyQt5
development (including Qt, Qt Designer, QScintilla, and MySQL, 
PostgreSQL,

SQLite and ODBC drivers) except Python itself.  Installers are provided
for the 32 and 64 bit versions of Python v3.4.

PyQt5 is implemented as a set of 29 extension modules including support
for:

- non-GUI infrastructure including event loops, threads, i18n, user and
  application settings, mapped files and shared memory

- GUI infrastructure including window system integration, event 
handling,

  2D graphics, basic imaging, fonts, OpenGL

- a comprehensive set of desktop widgets

- WebKit

- full integration with Quick2 and QML allowing new Quick items to be
  implemented in Python and created in QML

- event driven network programming

- multimedia including cameras, audio and radios

- Bluetooth

- global positioning using satellite, Wi-Fi or text file sources

- sensors including accelerometers, altimeters, compasses, gyroscopes,
  magnetometers, and light, pressure, proximity, rotation and 
temperature

  sensors

- serial ports

- SQL

- printing

- DBus

- XPath, XQuery, XSLT and XML Schema validation

- a help system for creating and viewing searchable documentation

- unit testing of GUI applications.

--
https://mail.python.org/mailman/listinfo/python-list


[issue5978] cProfile and profile don't work with pygtk/pyqt and sys.exit(0)

2014-02-03 Thread Mark Lawrence

Changes by Mark Lawrence breamore...@yahoo.co.uk:


--
nosy:  -BreamoreBoy

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5978
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   3   4   5   6   7   8   >